void CIOCPSocket2::SendCompressingPacket(const char *pData, int len) { // Data's too short to bother with compression... if (len < 500) { Send((char *)pData, len); return; } if (len <= 0 || len >= 49152) { TRACE("### SendCompressingPacket Error : len = %d ### \n", len); return; } CCompressMng comp; int send_index = 0; char send_buff[49152]; comp.PreCompressWork(pData, len); comp.Compress(); SetByte(send_buff, WIZ_COMPRESS_PACKET, send_index); SetDWORD(send_buff, comp.m_nOutputBufferCurPos, send_index); SetDWORD(send_buff, comp.m_nOrgDataLength, send_index); SetDWORD(send_buff, comp.m_dwCrc, send_index); SetString(send_buff, comp.m_pOutputBuffer, comp.m_nOutputBufferCurPos, send_index); Send(send_buff, send_index); }
void CUser::GetUserInfo(char *buff, int & buff_index) { CKnights* pKnights = NULL; SetKOString(buff, m_pUserData->m_id, buff_index, 1); SetByte(buff, m_pUserData->m_bNation, buff_index); SetByte(buff, m_pUserData->m_bCity, buff_index); // probably isn't this, but it'll at least serve as filler if it's not SetShort(buff, m_pUserData->m_bKnights, buff_index); SetByte(buff, m_pUserData->m_bFame, buff_index); pKnights = m_pMain->m_KnightsArray.GetData(m_pUserData->m_bKnights); if (pKnights == NULL || m_pUserData->m_bKnights <= 0) { SetShort(buff, 0, buff_index ); SetByte(buff, 0, buff_index ); SetByte(buff, 0, buff_index ); } else { SetKOString(buff, pKnights->m_strName, buff_index); SetByte(buff, pKnights->m_byGrade, buff_index); // knights grade SetByte(buff, pKnights->m_byRanking, buff_index); // knights grade } SetByte(buff, m_pUserData->m_bLevel, buff_index); SetByte(buff, m_pUserData->m_bRace, buff_index); SetShort(buff, m_pUserData->m_sClass, buff_index); SetShort(buff, (WORD)(m_pUserData->m_curx*10), buff_index); SetShort(buff, (WORD)(m_pUserData->m_curz*10), buff_index); SetShort(buff, (WORD)(m_pUserData->m_cury*10), buff_index); SetByte(buff, m_pUserData->m_bFace, buff_index); SetDWORD(buff, m_pUserData->m_nHair, buff_index); SetByte(buff, m_bResHpType, buff_index); SetDWORD(buff, m_bAbnormalType, buff_index); SetByte(buff, m_bNeedParty, buff_index); SetByte(buff, m_pUserData->m_bAuthority, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[BREAST].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[BREAST].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[LEG].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[LEG].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[HEAD].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[HEAD].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[GLOVE].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[GLOVE].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[FOOT].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[FOOT].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[SHOULDER].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[SHOULDER].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[RIGHTHAND].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[RIGHTHAND].sDuration, buff_index); SetDWORD(buff, m_pUserData->m_sItemArray[LEFTHAND].nNum, buff_index); SetShort(buff, m_pUserData->m_sItemArray[LEFTHAND].sDuration, buff_index); }
void CUser::NpcEvent(char *pBuf) { if( m_pMain->m_bPointCheckFlag == FALSE) return; int index = 0, send_index = 0, nid = 0, i=0, temp_index = 0; char send_buf[2048]; memset( send_buf, NULL, 2048); CNpc* pNpc = NULL; nid = GetShort( pBuf, index ); pNpc = m_pMain->m_arNpcArray.GetData(nid); if( !pNpc ) return; switch( pNpc->m_tNpcType ) { case NPC_MERCHANT: SetByte( send_buf, WIZ_TRADE_NPC, send_index ); SetDWORD( send_buf, pNpc->m_iSellingGroup, send_index ); Send( send_buf, send_index ); break; case NPC_TINKER: SetByte( send_buf, WIZ_REPAIR_NPC, send_index ); SetDWORD( send_buf, pNpc->m_iSellingGroup, send_index ); Send( send_buf, send_index ); break; case NPC_CAPTAIN: SetByte( send_buf, WIZ_CLASS_CHANGE, send_index ); SetByte( send_buf, CLASS_CHANGE_REQ, send_index ); Send( send_buf, send_index ); break; case NPC_OFFICER: SetShort( send_buf, 0, send_index ); // default 0 page m_pMain->m_KnightsManager.AllKnightsList( this, send_buf ); break; case NPC_WAREHOUSE: SetByte( send_buf, WIZ_WAREHOUSE, send_index ); SetByte( send_buf, WAREHOUSE_REQ, send_index ); Send( send_buf, send_index ); break; case NPC_WARP: break; case NPC_CLERIC: case NPC_COUPON: case NPC_MONK_KARUS: case NPC_MONK_ELMORAD: SetShort( send_buf, nid, send_index ); ClientEvent( send_buf ); break; } }
BOOL CUser::RobItem(int itemid, short count) { int send_index = 0, i = 0; char send_buff[256]; BYTE type = 1; _ITEM_TABLE* pTable = NULL; // This checks if such an item exists. pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) return FALSE; for ( i = SLOT_MAX ; i < SLOT_MAX + HAVE_MAX * type ; i++ ) { if( m_pUserData->m_sItemArray[i].nNum == itemid ) { if (!pTable->m_bCountable) { // Remove item from inventory (Non-countable items) m_pUserData->m_sItemArray[i].nNum = 0; m_pUserData->m_sItemArray[i].sCount = 0; m_pUserData->m_sItemArray[i].sDuration = 0; goto success_return; } else { // Remove the number of items from the inventory (Countable Items) if (m_pUserData->m_sItemArray[i].sCount >= count) { m_pUserData->m_sItemArray[i].sCount -= count ; if (m_pUserData->m_sItemArray[i].sCount == 0) { m_pUserData->m_sItemArray[i].nNum = 0 ; m_pUserData->m_sItemArray[i].sCount = 0; m_pUserData->m_sItemArray[i].sDuration = 0; } goto success_return; } else { return FALSE; } } } } return FALSE; success_return: SendItemWeight(); // Change weight first :) SetByte( send_buff, WIZ_ITEM_COUNT_CHANGE, send_index ); SetShort( send_buff, 0x01, send_index ); // The number of for-loops SetByte( send_buff, 0x01, send_index ); SetByte( send_buff, i - SLOT_MAX, send_index ); SetDWORD( send_buff, itemid, send_index ); // The ID of item. SetDWORD( send_buff, m_pUserData->m_sItemArray[i].sCount, send_index ); Send( send_buff, send_index ); return TRUE; }
void CUser::ItemRepair(char *pBuf) { int index = 0, send_index = 0, money = 0, quantity = 0; int itemid = 0, pos = 0, slot = -1, durability = 0; char send_buff[128]; memset( send_buff, 0x00, 128 ); _ITEM_TABLE* pTable = NULL; pos = GetByte( pBuf, index ); slot = GetByte( pBuf, index ); itemid = GetDWORD( pBuf, index ); if( pos == 1 ) { // SLOT if( slot >= SLOT_MAX ) goto fail_return; if( m_pUserData->m_sItemArray[slot].nNum != itemid ) goto fail_return; } else if ( pos == 2 ) { // INVEN if( slot >= HAVE_MAX ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+slot].nNum != itemid ) goto fail_return; } pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) goto fail_return; durability = pTable->m_sDuration; if( durability == 1 ) goto fail_return; if( pos == 1 ) quantity = pTable->m_sDuration - m_pUserData->m_sItemArray[slot].sDuration; else if( pos == 2 ) quantity = pTable->m_sDuration - m_pUserData->m_sItemArray[SLOT_MAX+slot].sDuration; money = (int)( ((pTable->m_iBuyPrice-10)/10000.0f) + pow(pTable->m_iBuyPrice, 0.75)) * quantity / (double)durability; if( money > m_pUserData->m_iGold ) goto fail_return; m_pUserData->m_iGold -= money; if( pos == 1 ) m_pUserData->m_sItemArray[slot].sDuration = durability; else if( pos == 2 ) m_pUserData->m_sItemArray[SLOT_MAX+slot].sDuration = durability; SetByte( send_buff, WIZ_ITEM_REPAIR, send_index ); SetByte( send_buff, 0x01, send_index ); SetDWORD( send_buff, m_pUserData->m_iGold, send_index ); Send( send_buff, send_index ); return; fail_return: SetByte( send_buff, WIZ_ITEM_REPAIR, send_index ); SetByte( send_buff, 0x00, send_index ); SetDWORD( send_buff, m_pUserData->m_iGold, send_index ); Send( send_buff, send_index ); }
void CUser::SendAttackSuccess(int tuid, BYTE result, short sDamage, int nHP, short sAttack_type) { int send_index = 0; int sid = -1, tid = -1; BYTE type, bResult; char buff[256]; memset( buff, 0x00, 256 ); float rx=0.0f, ry=0.0f, rz=0.0f; type = 0x01; bResult = result; sid = m_iUserId+USER_BAND; tid = tuid; SetByte( buff, AG_ATTACK_RESULT, send_index ); SetByte( buff, type, send_index ); SetByte( buff, bResult, send_index ); SetShort( buff, sid, send_index ); SetShort( buff, tid, send_index ); SetShort( buff, sDamage, send_index ); SetDWORD( buff, nHP, send_index ); SetByte( buff, (BYTE)sAttack_type, send_index ); //TRACE("User - SendAttackSuccess() : [sid=%d, tid=%d, result=%d], damage=%d, hp = %d\n", sid, tid, bResult, sDamage, sHP); SendAll(buff, send_index); // thread 에서 send }
void CAISocket::RecvUserExp(char* pBuf) { int index = 0; int nid = 0; short sExp = 0; short sLoyalty = 0; nid = GetShort(pBuf,index); sExp = GetShort(pBuf,index); sLoyalty = GetShort(pBuf,index); CUser* pUser = m_pMain->GetUserPtr(nid); if(pUser == NULL) return; if(sExp < 0 || sLoyalty < 0) { TRACE("#### AISocket - RecvUserExp : exp=%d, loyalty=%d,, 잘못된 경험치가 온다,, 수정해!!\n", sExp, sLoyalty); return; } pUser->m_pUserData->m_iLoyalty += sLoyalty; pUser->ExpChange(sExp); if( sLoyalty > 0 ) { char send_buff[128]; int send_index = 0; SetByte( send_buff, WIZ_LOYALTY_CHANGE, send_index ); SetDWORD( send_buff, pUser->m_pUserData->m_iLoyalty, send_index ); pUser->Send( send_buff, send_index ); } }
void CAISocket::RecvNpcMoveResult(char *pBuf) { // sungyong tw char send_buff[256]; int index = 0, send_index = 0; BYTE flag; // 01(INFO_MODIFY) : NPC 정보 변경 // 02(INFO_DELETE) : NPC 정보 삭제 short nid; // NPC index float fPosX; // X Position float fPosZ; // Z Position float fPosY; // Y Position float fSecForMetor; // Sec당 metor flag = GetByte(pBuf,index); nid = GetShort(pBuf,index); fPosX = Getfloat(pBuf, index); fPosZ = Getfloat(pBuf, index); fPosY = Getfloat(pBuf, index); fSecForMetor = Getfloat(pBuf, index); CNpc* pNpc = m_pMain->m_arNpcArray.GetData( nid ); if(!pNpc) return; if( pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP <= 0 ) { // Npc 상태 동기화 불량,, 재요청.. SetByte( send_buff, AG_NPC_HP_REQ, send_index); SetShort( send_buff, nid, send_index ); SetDWORD( send_buff, pNpc->m_iHP, send_index ); Send( send_buff, send_index ); } // ~sungyong tw pNpc->MoveResult(fPosX, fPosY, fPosZ, fSecForMetor); }
void CNpc::GetNpcInfo(char *buff, int & send_index) { SetShort(buff, m_sPid, send_index ); SetByte(buff, m_tNpcType, send_index ); SetDWORD(buff, m_iSellingGroup, send_index ); SetShort(buff, m_sSize, send_index ); SetDWORD(buff, m_iWeapon_1, send_index ); SetDWORD(buff, m_iWeapon_2, send_index ); SetKOString(buff, m_strName, send_index); SetByte(buff, m_byGroup, send_index ); SetByte(buff, m_byLevel, send_index ); SetShort(buff, (WORD)m_fCurX*10, send_index ); SetShort(buff, (WORD)m_fCurZ*10, send_index ); SetShort(buff, (short)m_fCurY*10, send_index ); SetDWORD(buff, (int)m_byGateOpen, send_index ); SetByte(buff, m_byObjectType, send_index ); }
void CUser::SendHP() { if(m_bLive == USER_DEAD) return; // HP 변동량을 게임서버로... int send_index = 0; char buff[256]; memset( buff, 0x00, 256 ); SetByte(buff, AG_USER_SET_HP, send_index ); SetShort(buff, m_iUserId, send_index ); SetDWORD(buff, m_sHP, send_index ); SendAll(buff, send_index); }
void CUser::SendNpcSay(EXEC *pExec) { int i, send_index = 0; char send_buf[128]; memset(send_buf, NULL, 128); if( !pExec ) return; SetByte( send_buf, WIZ_NPC_SAY, send_index ); for( i=0; i<MAX_MESSAGE_EVENT; i++) { SetDWORD( send_buf, pExec->m_ExecInt[i], send_index ); } Send( send_buf, send_index ); }
// Presumably received item data back from Aujard. void CUser::RecvStoreClose(char *pData) { char send_buff[2048]; int index = 0, send_index = 0; BYTE result = GetByte(pData, index); // If it was succesful, i.e. it loaded data, give it to us if (result) { short count = GetShort(pData, index); for (int i = 0; i < count; i++) { int nItemID = GetDWORD(pData, index); short sCount = GetShort(pData, index); // reuse the GiveItem() method for giving them the item, just don't send that particular packet. GiveItem(nItemID, sCount, false); } } SetByte(send_buff, WIZ_SHOPPING_MALL, send_index); SetByte(send_buff, STORE_CLOSE, send_index); // not sure if this limit's correct for (int i = 0; i < HAVE_MAX + SLOT_MAX + COSP_MAX + MBAG_MAX; i++) { SetDWORD(send_buff, m_pUserData->m_sItemArray[i].nNum, send_index); SetShort(send_buff, m_pUserData->m_sItemArray[i].sDuration, send_index); SetShort(send_buff, m_pUserData->m_sItemArray[i].sCount, send_index); SetByte(send_buff, 0, send_index); // item type flag (e.g. rented) SetShort(send_buff, 0, send_index); // remaining time SetDWORD(send_buff, 0, send_index); // unknown SetDWORD(send_buff, 0, send_index); // expiration date } Send(send_buff, send_index); }
void CUser::SelectMsg(EXEC *pExec) { int i, chat, send_index = 0; char send_buf[128]; memset(send_buf, NULL, 128); if( !pExec ) return; SetByte( send_buf, WIZ_SELECT_MSG, send_index ); SetShort( send_buf, m_sEventNid, send_index ); SetDWORD( send_buf, pExec->m_ExecInt[1], send_index ); chat = 2; for( i = 0 ; i < MAX_MESSAGE_EVENT ; i++ ) { SetDWORD( send_buf, pExec->m_ExecInt[chat], send_index ); chat += 2; } Send( send_buf, send_index ); for (int j = 0 ; j < MAX_MESSAGE_EVENT ; j++) { m_iSelMsgEvent[j] = pExec->m_ExecInt[(2 * j) + 3]; } }
void CMagicProcess::ExecuteType3(int magicid, int tid, int data1, int data2, int data3, int moral, int dexpoint, int righthand_damage ) // Applied when a magical attack, healing, and mana restoration is done. { int damage = 0, result = 1, send_index=0, attack_type = 0; char send_buff[256]; _MAGIC_TYPE3* pType = NULL; CNpc* pNpc = NULL ; // Pointer initialization! _MAGIC_TABLE* pMagic = NULL; pMagic = g_pMain->m_MagictableArray.GetData( magicid ); // Get main magic table. if( !pMagic ) return; if(tid == -1) { // 지역 공격 result = AreaAttack(3, magicid, moral, data1, data2, data3, dexpoint, righthand_damage); //if(result == 0) goto packet_send; //else return; } pNpc = g_pMain->m_arNpc.GetData(tid-NPC_BAND); if(pNpc == NULL || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) { result = 0; goto packet_send; } pType = g_pMain->m_Magictype3Array.GetData( magicid ); // Get magic skill table type 3. if( !pType ) return; // if (pType->sFirstDamage < 0) { if ((pType->sFirstDamage < 0) && (pType->bDirectType == 1) && (magicid < 400000)) { damage = GetMagicDamage(tid, pType->sFirstDamage, pType->bAttribute, dexpoint, righthand_damage) ; } else { damage = pType->sFirstDamage ; } //TRACE("magictype3 ,, magicid=%d, damage=%d\n", magicid, damage); if (pType->bDuration == 0) { // Non-Durational Spells. if (pType->bDirectType == 1) { // Health Point related ! //damage = pType->sFirstDamage; // Reduce target health point // if(damage >= 0) { if(damage > 0) { result = pNpc->SetHMagicDamage(damage); } else { damage = abs(damage); if(pType->bAttribute == 3) attack_type = 3; // 기절시키는 마법이라면..... else attack_type = magicid; if(pNpc->SetDamage(attack_type, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND) == FALSE) { // Npc가 죽은 경우,, pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(tid, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP, MAGIC_ATTACK); } else { // 공격 결과 전송 m_pSrcUser->SendAttackSuccess(tid, ATTACK_SUCCESS, damage, pNpc->m_iHP, MAGIC_ATTACK); } } } else if ( pType->bDirectType == 2 || pType->bDirectType == 3 ) // Magic or Skill Point related ! pNpc->MSpChange(pType->bDirectType, pType->sFirstDamage); // Change the SP or the MP of the target. else if( pType->bDirectType == 4 ) // Armor Durability related. pNpc->ItemWoreOut( DEFENCE, pType->sFirstDamage); // Reduce Slot Item Durability } else if (pType->bDuration != 0) { // Durational Spells! Remember, durational spells only involve HPs. if(damage >= 0) { } else { damage = abs(damage); if(pType->bAttribute == 3) attack_type = 3; // 기절시키는 마법이라면..... else attack_type = magicid; if(pNpc->SetDamage(attack_type, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND) == FALSE) { // Npc가 죽은 경우,, pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(tid, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); } else { // 공격 결과 전송 m_pSrcUser->SendAttackSuccess(tid, ATTACK_SUCCESS, damage, pNpc->m_iHP); } } damage = GetMagicDamage(tid, pType->sTimeDamage, pType->bAttribute, dexpoint, righthand_damage); // The duration magic routine. for(int i=0; i<MAX_MAGIC_TYPE3; i++) { if(pNpc->m_MagicType3[i].sHPAttackUserID == -1 && pNpc->m_MagicType3[i].byHPDuration == 0) { pNpc->m_MagicType3[i].sHPAttackUserID = m_pSrcUser->m_iUserId; pNpc->m_MagicType3[i].fStartTime = TimeGet(); pNpc->m_MagicType3[i].byHPDuration = pType->bDuration; pNpc->m_MagicType3[i].byHPInterval = 2; pNpc->m_MagicType3[i].sHPAmount = damage / (pType->bDuration / 2); break; } } } packet_send: //if ( pMagic->bType[1] == 0 || pMagic->bType[1] == 3 ) { SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcUser->m_iUserId, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, moral, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); g_pMain->Send( send_buff, send_index ); } }
void WriteConfig(void) { HKEY myKey; DWORD myDisp; DWORD temp; RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\GPU\\DFXVideo",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); temp=iResX; RegSetValueEx(myKey,"ResX",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iResY; RegSetValueEx(myKey,"ResY",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iRefreshRate; RegSetValueEx(myKey,"RefreshRate",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iWinSize; RegSetValueEx(myKey,"WinSize",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iWindowMode; RegSetValueEx(myKey,"WindowMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iColDepth; RegSetValueEx(myKey,"ColDepth",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=UseFrameLimit; RegSetValueEx(myKey,"UseFrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=UseFrameSkip; RegSetValueEx(myKey,"UseFrameSkip",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=dwCfgFixes; RegSetValueEx(myKey,"CfgFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iUseFixes; RegSetValueEx(myKey,"UseFixes",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iUseScanLines; RegSetValueEx(myKey,"UseScanLines",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iShowFPS; RegSetValueEx(myKey,"ShowFPS",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iUseNoStretchBlt; RegSetValueEx(myKey,"UseNoStrechBlt",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iUseDither; RegSetValueEx(myKey,"UseDither",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iFrameLimit; RegSetValueEx(myKey,"FrameLimit",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iUseGammaVal; RegSetValueEx(myKey,"UseGamma",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=(DWORD)fFrameRate; RegSetValueEx(myKey,"FrameRate",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=*((DWORD *)&fFrameRate); RegSetValueEx(myKey,"FrameRateFloat",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=bVsync; RegSetValueEx(myKey,"WaitVSYNC",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=bTransparent; RegSetValueEx(myKey,"Transparent",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iSysMemory; RegSetValueEx(myKey,"UseSysMemory",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iStopSaver; RegSetValueEx(myKey,"StopSaver",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); temp=iDebugMode; RegSetValueEx(myKey,"DebugMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); RegSetValueEx(myKey,"GPUKeys",0,REG_BINARY,(LPBYTE)szGPUKeys,11); RegSetValueEx(myKey,"DeviceName",0,REG_BINARY,(LPBYTE)szDevName,128); RegSetValueEx(myKey,"GuiDev",0,REG_BINARY,(LPBYTE)&guiDev,sizeof(GUID)); // // Recording options // if(RECORD_COMPRESSION1.cbState>sizeof(RECORD_COMPRESSION_STATE1) || RECORD_COMPRESSION1.lpState!=RECORD_COMPRESSION_STATE1) { memset(&RECORD_COMPRESSION1,0,sizeof(RECORD_COMPRESSION1)); memset(&RECORD_COMPRESSION_STATE1,0,sizeof(RECORD_COMPRESSION_STATE1)); RECORD_COMPRESSION1.cbSize = sizeof(RECORD_COMPRESSION1); RECORD_COMPRESSION1.lpState = RECORD_COMPRESSION_STATE1; } if(RECORD_COMPRESSION2.cbState>sizeof(RECORD_COMPRESSION_STATE2) || RECORD_COMPRESSION2.lpState!=RECORD_COMPRESSION_STATE2) { memset(&RECORD_COMPRESSION2,0,sizeof(RECORD_COMPRESSION2)); memset(&RECORD_COMPRESSION_STATE2,0,sizeof(RECORD_COMPRESSION_STATE2)); RECORD_COMPRESSION2.cbSize = sizeof(RECORD_COMPRESSION2); RECORD_COMPRESSION2.lpState = RECORD_COMPRESSION_STATE2; } #define SetDWORD(xa,xb) RegSetValueEx(myKey,xa,0,REG_DWORD,(LPBYTE)&xb,sizeof(xb)); #define SetBINARY(xa,xb) RegSetValueEx(myKey,xa,0,REG_BINARY,(LPBYTE)&xb,sizeof(xb)); SetDWORD("RecordingMode", RECORD_RECORDING_MODE); SetDWORD("RecordingVideoSize", RECORD_VIDEO_SIZE); SetDWORD("RecordingWidth", RECORD_RECORDING_WIDTH); SetDWORD("RecordingHeight", RECORD_RECORDING_HEIGHT); SetDWORD("RecordingFrameRateScale", RECORD_FRAME_RATE_SCALE); SetDWORD("RecordingCompressionMode", RECORD_COMPRESSION_MODE); SetBINARY("RecordingCompression1", RECORD_COMPRESSION1); SetBINARY("RecordingCompressionState1", RECORD_COMPRESSION_STATE1); SetBINARY("RecordingCompression2", RECORD_COMPRESSION2); SetBINARY("RecordingCompressionState2", RECORD_COMPRESSION_STATE2); // // // RegCloseKey(myKey); }
// NPC shops void CUser::ItemTrade(char *pBuf) { int index = 0, send_index = 0, itemid = 0, money = 0, count = 0, group = 0, npcid = 0; _ITEM_TABLE* pTable = NULL; char send_buf[128]; CNpc* pNpc = NULL; memset( send_buf, NULL, 128); BYTE type, pos, destpos, result; if (isDead()) { TRACE("### ItemTrade Fail : name=%s(%d), m_bResHpType=%d, hp=%d, x=%d, z=%d ###\n", m_pUserData->m_id, m_Sid, m_bResHpType, m_pUserData->m_sHp, (int)m_pUserData->m_curx, (int)m_pUserData->m_curz); result = 0x01; goto fail_return; } type = GetByte( pBuf, index ); if( type == 0x01 ) {// item buy group = GetDWORD( pBuf, index ); npcid = GetShort( pBuf, index ); } itemid = GetDWORD( pBuf, index ); pos = GetByte( pBuf, index ); if( type == 0x03 ) // item move only destpos = GetByte( pBuf, index ); else count = GetShort( pBuf, index ); if (itemid >= ITEM_NO_TRADE) goto fail_return; if( type == 0x03 ) { // item inven to inven move if( pos >= HAVE_MAX || destpos >= HAVE_MAX ) { SetByte( send_buf, WIZ_ITEM_TRADE, send_index ); SetByte( send_buf, 0x04, send_index ); Send( send_buf, send_index ); return; } if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum ) { SetByte( send_buf, WIZ_ITEM_TRADE, send_index ); SetByte( send_buf, 0x04, send_index ); Send( send_buf, send_index ); return; } short duration = m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration; short itemcount = m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = duration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = itemcount; SetByte( send_buf, WIZ_ITEM_TRADE, send_index ); SetByte( send_buf, 0x03, send_index ); Send( send_buf, send_index ); return; } if( m_sExchangeUser != -1 ) goto fail_return; pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) { result = 0x01; goto fail_return; } if( pos >= HAVE_MAX ) { result = 0x02; goto fail_return; } if( count <= 0 || count > MAX_ITEM_COUNT) { result = 0x02; goto fail_return; } if( type == 0x01 ) { // buy sequence if( m_pMain->m_bPointCheckFlag == FALSE) { result = 0x01; goto fail_return; } pNpc = m_pMain->m_arNpcArray.GetData(npcid); if( !pNpc ) { result = 0x01; goto fail_return; } if( pNpc->m_iSellingGroup != group ) { result = 0x01; goto fail_return; } if( m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum != 0 ) { if( m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum == itemid ) { if( !pTable->m_bCountable || count <= 0 ) { result = 0x02; goto fail_return; } if( pTable->m_bCountable && (count+m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount) > MAX_ITEM_COUNT ) { result = 0x04; goto fail_return; } } else { result = 0x02; goto fail_return; } } if( m_pUserData->m_iGold < (pTable->m_iBuyPrice*count) ) { result = 0x03; goto fail_return; } // if (pTable->m_bCountable) { // Check weight of countable item. if (((pTable->m_sWeight * count) + m_sItemWeight) > m_sMaxWeight) { result = 0x04; goto fail_return; } } else { // Check weight of non-countable item. if ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight) { result = 0x04; goto fail_return; } } // m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration = pTable->m_sDuration; if( pTable->m_bCountable && count > 0 ) { // count ?????? ??? ?????? m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount += count; m_pUserData->m_iGold -= (pTable->m_iBuyPrice * count); } else { m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = 1; m_pUserData->m_iGold -= pTable->m_iBuyPrice; m_pUserData->m_sItemArray[SLOT_MAX+pos].nSerialNum = m_pMain->GenerateItemSerial(); } SendItemWeight(); ItemLogToAgent( m_pUserData->m_id, pNpc->m_strName, ITEM_MERCHANT_BUY, m_pUserData->m_sItemArray[SLOT_MAX+pos].nSerialNum, itemid, count, pTable->m_sDuration ); } else { // sell sequence if( m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum != itemid ) { result = 0x02; goto fail_return; } if( m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount < count ) { result = 0x03; goto fail_return; } int durability = m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration; if( pTable->m_bCountable && count > 0 ) { m_pUserData->m_iGold += (pTable->m_iSellPrice * count); m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount -= count; if( m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount <= 0 ) { m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum = 0; m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration = 0; m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = 0; } } else { m_pUserData->m_iGold += pTable->m_iSellPrice; m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum = 0; m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration = 0; m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = 0; } SendItemWeight(); ItemLogToAgent( m_pUserData->m_id, "MERCHANT SELL", ITEM_MERCHANT_SELL, 0, itemid, count, durability ); } SetByte( send_buf, WIZ_ITEM_TRADE, send_index ); SetByte( send_buf, 0x01, send_index ); SetDWORD( send_buf, m_pUserData->m_iGold, send_index ); Send( send_buf, send_index ); return; fail_return: send_index = 0; SetByte( send_buf, WIZ_ITEM_TRADE, send_index ); SetByte( send_buf, 0x00, send_index ); SetByte( send_buf, result, send_index ); Send( send_buf, send_index ); }
void CUser::WarehouseProcess(char *pBuf) { int index = 0, send_index = 0, itemid = 0, srcpos = -1, destpos = -1, page = -1, reference_pos = -1; DWORD count = 0; char send_buff[2048]; memset( send_buff, 0x00, 2048 ); _ITEM_TABLE* pTable = NULL; BYTE command = 0; command = GetByte( pBuf, index ); // â?? ??j?... if (isDead()) { TRACE("### WarehouseProcess Fail : name=%s(%d), m_bResHpType=%d, hp=%d, x=%d, z=%d ###\n", m_pUserData->m_id, m_Sid, m_bResHpType, m_pUserData->m_sHp, (int)m_pUserData->m_curx, (int)m_pUserData->m_curz); return; } if( m_sExchangeUser != -1 ) goto fail_return; if( command == WAREHOUSE_OPEN ) { SetByte( send_buff, WIZ_WAREHOUSE, send_index ); SetByte( send_buff, WAREHOUSE_OPEN, send_index ); SetDWORD( send_buff, m_pUserData->m_iBank, send_index ); for(int i=0; i<WAREHOUSE_MAX; i++ ) { SetDWORD( send_buff, m_pUserData->m_sWarehouseArray[i].nNum, send_index ); SetShort( send_buff, m_pUserData->m_sWarehouseArray[i].sDuration, send_index ); SetShort( send_buff, m_pUserData->m_sWarehouseArray[i].sCount, send_index ); } SendCompressingPacket( send_buff, send_index ); return; } itemid = GetDWORD( pBuf, index ); page = GetByte( pBuf, index ); srcpos = GetByte( pBuf, index ); destpos = GetByte( pBuf, index ); pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) goto fail_return; reference_pos = 24 * page; switch( command ) { case WAREHOUSE_INPUT: count = GetDWORD( pBuf, index ); if( itemid == ITEM_GOLD ) { if( m_pUserData->m_iBank+count > 2100000000 ) goto fail_return; if( m_pUserData->m_iGold-count < 0 ) goto fail_return; m_pUserData->m_iBank += count; m_pUserData->m_iGold -= count; break; } if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != itemid ) goto fail_return; if( reference_pos+destpos > WAREHOUSE_MAX ) goto fail_return; if( m_pUserData->m_sWarehouseArray[reference_pos+destpos].nNum && !pTable->m_bCountable ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount < count ) goto fail_return; m_pUserData->m_sWarehouseArray[reference_pos+destpos].nNum = itemid; m_pUserData->m_sWarehouseArray[reference_pos+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sWarehouseArray[reference_pos+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( pTable->m_bCountable == 0 && m_pUserData->m_sWarehouseArray[reference_pos+destpos].nSerialNum == 0 ) m_pUserData->m_sWarehouseArray[reference_pos+destpos].nSerialNum = m_pMain->GenerateItemSerial(); if( pTable->m_bCountable ) { m_pUserData->m_sWarehouseArray[reference_pos+destpos].sCount += count; } else { m_pUserData->m_sWarehouseArray[reference_pos+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; } if( !pTable->m_bCountable ) { m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = 0; } else { m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount -= count; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount <= 0 ) { m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = 0; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = 0; } } SendItemWeight(); ItemLogToAgent( m_pUserData->m_Accountid, m_pUserData->m_id, ITEM_WAREHOUSE_PUT, 0, itemid, count, m_pUserData->m_sWarehouseArray[reference_pos+destpos].sDuration ); break; case WAREHOUSE_OUTPUT: count = GetDWORD( pBuf, index ); if( itemid == ITEM_GOLD ) { if( m_pUserData->m_iGold+count > 2100000000 ) goto fail_return; if( m_pUserData->m_iBank-count < 0 ) goto fail_return; m_pUserData->m_iGold += count; m_pUserData->m_iBank -= count; break; } // if (pTable->m_bCountable) { // Check weight of countable item. if (((pTable->m_sWeight * count) + m_sItemWeight) > m_sMaxWeight) { goto fail_return; } } else { // Check weight of non-countable item. if ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight) { goto fail_return; } } // if( reference_pos+srcpos > WAREHOUSE_MAX ) goto fail_return; if( m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nNum != itemid ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum && !pTable->m_bCountable ) goto fail_return; if( m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount < count ) goto fail_return; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nSerialNum; if( pTable->m_bCountable ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount += count; else { if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount; } if( !pTable->m_bCountable ) { m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nNum = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sDuration = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nSerialNum = 0; } else { m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount -= count; if( m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount <= 0 ) { m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nNum = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sDuration = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nSerialNum = 0; } } SendItemWeight(); ItemLogToAgent( m_pUserData->m_id, m_pUserData->m_Accountid, ITEM_WAREHOUSE_GET, 0, itemid, count, m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration ); //TRACE("WARE OUTPUT : %s %s %d %d %d %d %d", m_pUserData->m_id, m_pUserData->m_Accountid, ITEM_WAREHOUSE_GET, 0, itemid, count, m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration ); break; case WAREHOUSE_MOVE: if( reference_pos+srcpos > WAREHOUSE_MAX ) goto fail_return; if( m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nNum != itemid ) goto fail_return; if( m_pUserData->m_sWarehouseArray[reference_pos+destpos].nNum ) goto fail_return; m_pUserData->m_sWarehouseArray[reference_pos+destpos].nNum = itemid; m_pUserData->m_sWarehouseArray[reference_pos+destpos].sDuration = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sDuration; m_pUserData->m_sWarehouseArray[reference_pos+destpos].sCount = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount; m_pUserData->m_sWarehouseArray[reference_pos+destpos].nSerialNum = m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nSerialNum; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nNum = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sDuration = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].sCount = 0; m_pUserData->m_sWarehouseArray[reference_pos+srcpos].nSerialNum = 0; break; case WAREHOUSE_INVENMOVE: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; short itemcount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = duration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = itemcount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = serial; } break; } m_pUserData->m_bWarehouse = 1; SetByte( send_buff, WIZ_WAREHOUSE, send_index ); SetByte( send_buff, command, send_index ); SetByte( send_buff, 0x01, send_index ); Send( send_buff, send_index ); return; fail_return: SetByte( send_buff, WIZ_WAREHOUSE, send_index ); SetByte( send_buff, command, send_index ); SetByte( send_buff, 0x00, send_index ); Send( send_buff, send_index ); }
void CUser::ClassChange(char *pBuf) { int index = 0, classcode = 0, send_index = 0, type=0, sub_type = 0, money = 0, old_money=0; char send_buff[128]; memset( send_buff, NULL, 128 ); BOOL bSuccess = FALSE; type = GetByte( pBuf, index ); if (type == CLASS_CHANGE_REQ) { ClassChangeReq(); return; } else if (type == ALL_POINT_CHANGE) { AllPointChange(); return; } else if (type == ALL_SKILLPT_CHANGE) { AllSkillPointChange(); return; } else if (type == CHANGE_MONEY_REQ) { sub_type = GetByte( pBuf, index ); money = pow(( m_pUserData->m_bLevel * 2 ), 3.4); money = ( money / 100 )*100; if( m_pUserData->m_bLevel < 30) money = money * 0.4; else if( m_pUserData->m_bLevel >= 30 && m_pUserData->m_bLevel < 60 ) money = money * 1; else if( m_pUserData->m_bLevel >= 60 && m_pUserData->m_bLevel <= 90 ) money = money * 1.5; if( sub_type == 1 ) { if( m_pMain->m_sDiscount == 1 && m_pMain->m_byOldVictory == m_pUserData->m_bNation ) { old_money = money; money = money * 0.5; //TRACE("^^ ClassChange - point Discount ,, money=%d->%d\n", old_money, money); } if( m_pMain->m_sDiscount == 2 ) { old_money = money; money = money * 0.5; } SetByte( send_buff, WIZ_CLASS_CHANGE, send_index ); SetByte( send_buff, CHANGE_MONEY_REQ, send_index ); SetDWORD( send_buff, money, send_index ); Send( send_buff, send_index ); } else if( sub_type == 2 ) { money = money * 1.5; if( m_pMain->m_sDiscount == 1 && m_pMain->m_byOldVictory == m_pUserData->m_bNation ) { old_money = money; money = money * 0.5; //TRACE("^^ ClassChange - skillpoint Discount ,, money=%d->%d\n", old_money, money); } if( m_pMain->m_sDiscount == 2 ) { old_money = money; money = money * 0.5; } SetByte( send_buff, WIZ_CLASS_CHANGE, send_index ); SetByte( send_buff, CHANGE_MONEY_REQ, send_index ); SetDWORD( send_buff, money, send_index ); Send( send_buff, send_index ); } return; } classcode = GetByte( pBuf, index ); switch( m_pUserData->m_sClass ) { case KARUWARRRIOR: if( classcode == BERSERKER || classcode == GUARDIAN ) bSuccess = TRUE; break; case KARUROGUE: if( classcode == HUNTER || classcode == PENETRATOR ) bSuccess = TRUE; break; case KARUWIZARD: if( classcode == SORSERER || classcode == NECROMANCER ) bSuccess = TRUE; break; case KARUPRIEST: if( classcode == SHAMAN || classcode == DARKPRIEST ) bSuccess = TRUE; break; case ELMORWARRRIOR: if( classcode == BLADE || classcode == PROTECTOR ) bSuccess = TRUE; break; case ELMOROGUE: if( classcode == RANGER || classcode == ASSASSIN ) bSuccess = TRUE; break; case ELMOWIZARD: if( classcode == MAGE || classcode == ENCHANTER ) bSuccess = TRUE; break; case ELMOPRIEST: if( classcode == CLERIC || classcode == DRUID ) bSuccess = TRUE; break; } memset( send_buff, NULL, 128 ); send_index = 0; if( !bSuccess ) { SetByte( send_buff, WIZ_CLASS_CHANGE, send_index ); SetByte( send_buff, CLASS_CHANGE_RESULT, send_index ); SetByte( send_buff, 0x00, send_index ); Send( send_buff, send_index ); } else { m_pUserData->m_sClass = classcode; if( m_sPartyIndex != -1 ) { SetByte( send_buff, WIZ_PARTY, send_index ); SetByte( send_buff, PARTY_CLASSCHANGE, send_index ); SetShort( send_buff, m_Sid, send_index ); SetShort( send_buff, m_pUserData->m_sClass, send_index ); m_pMain->Send_PartyMember(m_sPartyIndex, send_buff, send_index); } } }
void CUser::Dead(int tid, int nDamage) { if(m_bLive == USER_DEAD) return; // 이 부분에서 update를 해야 함,, 게임서버에서,, 처리하도록,,, m_sHP = 0; m_bLive = USER_DEAD; InitNpcAttack(); // region에서 삭제... MAP* pMap = GetMap(); if(pMap == NULL) { TRACE("#### CUser-Dead() Fail : [nid=%d, name=%s], pMap == NULL #####\n", m_iUserId, m_strUserID); return; } // map에 region에서 나의 정보 삭제.. if(m_sRegionX < 0 || m_sRegionZ < 0 || m_sRegionX > pMap->GetXRegionMax() || m_sRegionZ > pMap->GetZRegionMax()) { TRACE("#### CUser-Dead() Fail : [nid=%d, name=%s], x1=%d, z1=%d #####\n", m_iUserId, m_strUserID, m_sRegionX, m_sRegionZ); return; } //pMap->m_ppRegion[m_sRegionX][m_sRegionZ].DeleteUser(m_iUserId); pMap->RegionUserRemove(m_sRegionX, m_sRegionZ, m_iUserId); //TRACE("*** User Dead()-> User(%s, %d)를 Region에 삭제,, region_x=%d, y=%d\n", m_strUserID, m_iUserId, m_sRegionX, m_sRegionZ); m_sRegionX = -1; m_sRegionZ = -1; int send_index = 0; int sid = -1, targid = -1; BYTE type, result; char buff[256]; memset( buff, 0x00, 256 ); wsprintf(buff, "*** User Dead = %d, %s ***", m_iUserId, m_strUserID); TimeTrace(buff); //TRACE("*** User Dead = %d, %s ********\n", m_iUserId, m_strUserID); memset( buff, 0x00, 256 ); float rx=0.0f, ry=0.0f, rz=0.0f; type = 0x02; result = ATTACK_TARGET_DEAD; sid = tid; targid = m_iUserId+USER_BAND; SetByte( buff, AG_ATTACK_RESULT, send_index ); SetByte( buff, type, send_index ); SetByte( buff, result, send_index ); SetShort( buff, sid, send_index ); SetShort( buff, targid, send_index ); SetShort( buff, nDamage, send_index ); SetDWORD( buff, m_sHP, send_index ); //SetShort( buff, m_sMaxHP, send_index ); //TRACE("Npc - SendAttackSuccess()-User Dead : [sid=%d, tid=%d, result=%d], damage=%d, hp = %d\n", sid, targid, result, nDamage, m_sHP); if(tid > 0) SendAll(buff, send_index); // thread 에서 send /* SetByte(buff, AG_DEAD, send_index ); SetShort(buff, m_iUserId, send_index ); Setfloat(buff, m_curx, send_index); Setfloat(buff, m_curz, send_index); SendAll(buff, send_index); // thread 에서 send */ }
_MAGIC_TABLE* CNpcMagicProcess::IsAvailable(int magicid, int tid, BYTE type ) { CUser* pUser = NULL; CNpc* pNpc = NULL; _MAGIC_TABLE* pTable = NULL; int modulator = 0, Class = 0, send_index = 0, moral = 0; char send_buff[128]; if( !m_pSrcNpc ) return FALSE; pTable = g_pMain->m_MagictableArray.GetData( magicid ); // Get main magic table. if( !pTable ) goto fail_return; if( tid >= 0 && tid < MAX_USER ) // Compare morals between source and target character. { pUser = g_pMain->GetUserPtr(tid); if( !pUser || pUser->m_bLive == USER_DEAD ) goto fail_return; moral = pUser->m_bNation; } else if( tid >= NPC_BAND ) // Compare morals between source and target NPC. { pNpc = g_pMain->m_arNpc.GetData(tid - NPC_BAND); if( !pNpc || pNpc->m_NpcState == NPC_DEAD ) goto fail_return; moral = pNpc->m_byGroup; } else if ( tid == -1) { // Party Moral check routine. if (pTable->bMoral == MORAL_AREA_ENEMY) { if( m_pSrcNpc->m_byGroup == 0) { // Switch morals. 작업할것 : 몬스터는 국가라는 개념이 없기 때문에.. 나중에 NPC가 이 마법을 사용하면 문제가 됨 moral = 2 ; } else { moral = 1 ; } } else { moral = m_pSrcNpc->m_byGroup; } } else moral = m_pSrcNpc->m_byGroup ; switch( pTable->bMoral ) { // tid >= 0 case only case MORAL_SELF: if( tid != (m_pSrcNpc->m_sNid+NPC_BAND) ) goto fail_return; break; case MORAL_FRIEND_WITHME: if( m_pSrcNpc->m_byGroup != moral ) goto fail_return; break; case MORAL_FRIEND_EXCEPTME: if( m_pSrcNpc->m_byGroup != moral ) goto fail_return; if( tid == (m_pSrcNpc->m_sNid+NPC_BAND) ) goto fail_return; break; case MORAL_PARTY: case MORAL_PARTY_ALL: break; case MORAL_NPC: if( !pNpc ) goto fail_return; if( pNpc->m_byGroup != moral ) goto fail_return; break; case MORAL_ENEMY: if( m_pSrcNpc->m_byGroup == moral ) goto fail_return; break; } /* if( type == MAGIC_CASTING ) // Just ordinary spell casting. { //if( m_bMagicState == CASTING ) goto fail_return; //if( pTable->bCastTime == 0 ) goto fail_return; m_bMagicState = CASTING; } else if( m_bMagicState == NONE /*&& pTable->bCastTime != 0*/ //) goto fail_return; if( type == MAGIC_EFFECTING ) // Make sure you subtract MPs (SPs) after you use spell (skill). { // MP만 달다록 처리한당.. Npc는 SP가 없음.. //if( pTable->sMsp > m_pSrcNpc->m_sMP ) // goto fail_return; //m_pSrcNpc->MSpChange(2, -(pTable->sMsp) ); //m_bMagicState = NONE; } return pTable; // Magic was successful! fail_return: // In case the magic failed. send_index = 0; SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_FAIL, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcNpc->m_sNid+NPC_BAND, send_index ); SetShort( send_buff, tid, send_index ); if( type == MAGIC_CASTING ) SetShort( send_buff, -100, send_index ); else SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); /* if( m_bMagicState == CASTING ) g_pMain->Send_Region( send_buff, send_index, m_pSrcUser->m_pUserData->m_bZone, m_pSrcUser->m_RegionX, m_pSrcUser->m_RegionZ ); else m_pSrcUser->Send( send_buff, send_index ); */ m_pSrcNpc->SendAll(send_buff, send_index); m_bMagicState = NONE; return NULL; // Magic was a failure! }
void CNpcMagicProcess::ExecuteType3(int magicid, int tid, int data1, int data2, int data3, int moral ) // Applied when a magical attack, healing, and mana restoration is done. { int damage = 0, result = 1, send_index=0, attack_type = 0; char send_buff[256]; _MAGIC_TYPE3* pType = NULL; CNpc* pNpc = NULL ; // Pointer initialization! int dexpoint = 0; _MAGIC_TABLE* pMagic = NULL; pMagic = g_pMain->m_MagictableArray.GetData( magicid ); // Get main magic table. if( !pMagic ) return; if(tid == -1) { // 지역 공격,, 몬스터의 지역공격은 게임서버에서 처리한다.. 유저들을 상대로.. goto packet_send; } pNpc = g_pMain->m_arNpc.GetData(tid-NPC_BAND); if(pNpc == NULL || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) { result = 0; goto packet_send; } pType = g_pMain->m_Magictype3Array.GetData( magicid ); // Get magic skill table type 3. if( !pType ) return; damage = GetMagicDamage(tid, pType->sFirstDamage, pType->bAttribute, dexpoint); // if(damage == 0) damage = -1; //TRACE("magictype3 ,, magicid=%d, damage=%d\n", magicid, damage); if (pType->bDuration == 0) { // Non-Durational Spells. if (pType->bDirectType == 1) { // Health Point related ! if(damage > 0) { result = pNpc->SetHMagicDamage(damage); } else { damage = abs(damage); /* if(pType->bAttribute == 3) attack_type = 3; // 기절시키는 마법이라면..... else attack_type = magicid; if(pNpc->SetDamage(attack_type, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND) == FALSE) { // Npc가 죽은 경우,, pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(tid, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP, MAGIC_ATTACK); } else { // 공격 결과 전송 m_pSrcUser->SendAttackSuccess(tid, ATTACK_SUCCESS, damage, pNpc->m_iHP, MAGIC_ATTACK); } */ } } } else if (pType->bDuration != 0) { // Durational Spells! Remember, durational spells only involve HPs. } packet_send: //if ( pMagic->bType[1] == 0 || pMagic->bType[1] == 3 ) { SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcNpc->m_sNid+NPC_BAND, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, moral, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); m_pSrcNpc->SendAll(send_buff, send_index); } }
BYTE CMagicProcess::ExecuteType2(int magicid, int tid, int data1, int data2, int data3) { int damage = 0, send_index = 0, result = 1 ; // Variable initialization. result == 1 : success, 0 : fail char send_buff[128]; damage = m_pSrcUser->GetDamage(tid, magicid); // Get damage points of enemy. // if(damage <= 0) damage = 1; //TRACE("magictype2 ,, magicid=%d, damage=%d\n", magicid, damage); if (damage > 0){ CNpc* pNpc = NULL ; // Pointer initialization! pNpc = g_pMain->m_arNpc.GetData(tid-NPC_BAND); if(pNpc == NULL || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) { result = 0; goto packet_send; } if(pNpc->SetDamage(magicid, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND) == FALSE) { SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcUser->m_iUserId, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); if (damage == 0) { SetShort( send_buff, -104, send_index ); } else { SetShort( send_buff, 0, send_index ); } g_pMain->Send( send_buff, send_index ); // Npc가 죽은 경우,, pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(tid, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); //m_pSrcUser->SendAttackSuccess(tid, ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); return result; } else { // 공격 결과 전송 m_pSrcUser->SendAttackSuccess(tid, ATTACK_SUCCESS, damage, pNpc->m_iHP); } } // else // result = 0; packet_send: SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcUser->m_iUserId, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); if (damage == 0) { SetShort( send_buff, -104, send_index ); } else { SetShort( send_buff, 0, send_index ); } g_pMain->Send( send_buff, send_index ); return result; }
void CUser::MarketBBSRegister(char *pBuf) { CUser* pUser = NULL; // Basic Initializations. int index = 0, send_index = 0; BYTE result = 0; BYTE sub_result = 1; char send_buff[256]; memset( send_buff, NULL, 256 ); short title_len = 0; short message_len = 0; BYTE buysell_index = 0; int i = 0, j = 0; int page_index = 0; buysell_index = GetByte(pBuf, index); // Buy or sell? if (buysell_index == MARKET_BBS_BUY) { if (m_pUserData->m_iGold < BUY_POST_PRICE) { sub_result = 2; goto fail_return; } } else if (buysell_index == MARKET_BBS_SELL) { if (m_pUserData->m_iGold < SELL_POST_PRICE) { sub_result = 2; goto fail_return; } } for (i = 0 ; i < MAX_BBS_POST ; i++) { if (buysell_index == MARKET_BBS_BUY) { // Buy if (m_pMain->m_sBuyID[i] == -1) { m_pMain->m_sBuyID[i] = m_Sid; title_len = GetShort(pBuf, index); GetString(m_pMain->m_strBuyTitle[i], pBuf, title_len, index); message_len = GetShort(pBuf, index); GetString(m_pMain->m_strBuyMessage[i], pBuf, message_len, index); m_pMain->m_iBuyPrice[i] = GetDWORD(pBuf, index); m_pMain->m_fBuyStartTime[i] = TimeGet(); result = 1; break; } } else if (buysell_index == MARKET_BBS_SELL) { // Sell if (m_pMain->m_sSellID[i] == -1) { m_pMain->m_sSellID[i] = m_Sid; title_len = GetShort(pBuf, index); GetString(m_pMain->m_strSellTitle[i], pBuf, title_len, index); message_len = GetShort(pBuf, index); GetString(m_pMain->m_strSellMessage[i], pBuf, message_len, index); m_pMain->m_iSellPrice[i] = GetDWORD(pBuf, index); m_pMain->m_fSellStartTime[i] = TimeGet(); result = 1; break; } } else goto fail_return; // Error } if (result == 0) goto fail_return; // No spaces available SetByte( send_buff, WIZ_GOLD_CHANGE, send_index ); // Money removal packet... SetByte( send_buff, 0x02, send_index ); if (buysell_index == MARKET_BBS_BUY) { m_pUserData->m_iGold -= BUY_POST_PRICE; SetDWORD( send_buff, BUY_POST_PRICE, send_index ); } else if (buysell_index == MARKET_BBS_SELL) { m_pUserData->m_iGold -= SELL_POST_PRICE; SetDWORD( send_buff, SELL_POST_PRICE, send_index ); } SetDWORD( send_buff, m_pUserData->m_iGold, send_index ); Send( send_buff, send_index ); page_index = i / MAX_BBS_PAGE; send_index = 0; memset( send_buff, NULL, 256 ); SetByte(send_buff, buysell_index, send_index); SetShort(send_buff, page_index, send_index); MarketBBSReport(send_buff, MARKET_BBS_REGISTER); return; fail_return: send_index = 0; memset( send_buff, NULL, 256 ); SetByte(send_buff, WIZ_MARKET_BBS, send_index); SetByte(send_buff, MARKET_BBS_REGISTER, send_index); SetByte(send_buff, buysell_index, send_index); SetByte(send_buff, result, send_index); SetByte(send_buff, sub_result, send_index); Send(send_buff, send_index); return; }
void CUser::MarketBBSReport(char *pBuf, BYTE type) { CUser* pUser = NULL; // Basic Initializations. int index = 0, send_index = 0; BYTE result = 0; BYTE sub_result = 1; short bbs_len = 0; char send_buff[8192]; memset(send_buff, NULL, 8192); short page_index = 0; BYTE buysell_index = 0; short start_counter = 0; short valid_counter = 0 ; int i = 0, j = 0; short BBS_Counter = 0; short title_length = 0; short message_length = 0; buysell_index = GetByte(pBuf, index); // Buy or sell? page_index = GetShort(pBuf, index); // Which message should I delete? start_counter = page_index * MAX_BBS_PAGE; if (type == MARKET_BBS_OPEN) { start_counter = 0; page_index = 0; } if ( start_counter < 0 ) goto fail_return; if ( start_counter > MAX_BBS_POST ) goto fail_return; result = 1; SetByte(send_buff, WIZ_MARKET_BBS, send_index); SetByte(send_buff, type, send_index); SetByte(send_buff, buysell_index, send_index); SetByte(send_buff, result, send_index); for (i = 0 ; i < MAX_BBS_POST ; i++) { if (buysell_index == MARKET_BBS_BUY) { if (m_pMain->m_sBuyID[i] == -1) continue; pUser = m_pMain->GetUserPtr(m_pMain->m_sBuyID[i]); if (pUser == NULL) { MarketBBSBuyDelete(i); continue ; } BBS_Counter++; // Increment number of total messages. if (i < start_counter) continue; // Range check codes. if (valid_counter >= MAX_BBS_PAGE) continue; SetShort(send_buff, m_pMain->m_sBuyID[i], send_index); SetShort(send_buff, strlen(pUser->m_pUserData->m_id), send_index); SetString(send_buff, pUser->m_pUserData->m_id, strlen(pUser->m_pUserData->m_id), send_index); title_length = strlen(m_pMain->m_strBuyTitle[i]); if (title_length > MAX_BBS_TITLE) { title_length = MAX_BBS_TITLE; } SetShort(send_buff, title_length, send_index); SetString(send_buff, m_pMain->m_strBuyTitle[i], title_length, send_index); // SetShort(send_buff, strlen(m_pMain->m_strBuyTitle[i]), send_index); // SetString(send_buff, m_pMain->m_strBuyTitle[i], strlen(m_pMain->m_strBuyTitle[i]), send_index); message_length = strlen(m_pMain->m_strBuyMessage[i]); if (message_length > MAX_BBS_MESSAGE) { message_length = MAX_BBS_MESSAGE ; } SetShort(send_buff, message_length, send_index); SetString(send_buff, m_pMain->m_strBuyMessage[i], message_length, send_index); // SetShort(send_buff, strlen(m_pMain->m_strBuyMessage[i]), send_index); // SetString(send_buff, m_pMain->m_strBuyMessage[i], strlen(m_pMain->m_strBuyMessage[i]), send_index); SetDWORD(send_buff, m_pMain->m_iBuyPrice[i], send_index); SetShort(send_buff, i, send_index); valid_counter++; } else if (buysell_index == MARKET_BBS_SELL) { if (m_pMain->m_sSellID[i] == -1) continue; pUser = m_pMain->GetUserPtr(m_pMain->m_sSellID[i]); if (pUser == NULL) { MarketBBSSellDelete(i); continue ; } BBS_Counter++; if (i < start_counter) continue; // Range check codes. if (valid_counter >= MAX_BBS_PAGE) continue; SetShort(send_buff, m_pMain->m_sSellID[i], send_index); SetShort(send_buff, strlen(pUser->m_pUserData->m_id), send_index); SetString(send_buff, pUser->m_pUserData->m_id, strlen(pUser->m_pUserData->m_id), send_index); title_length = strlen(m_pMain->m_strSellTitle[i]); if (title_length > MAX_BBS_TITLE) { title_length = MAX_BBS_TITLE; } SetShort(send_buff, title_length, send_index); SetString(send_buff, m_pMain->m_strSellTitle[i], title_length, send_index); // SetShort(send_buff, strlen(m_pMain->m_strSellTitle[i]), send_index); // SetString(send_buff, m_pMain->m_strSellTitle[i], strlen(m_pMain->m_strSellTitle[i]), send_index); message_length = strlen(m_pMain->m_strSellMessage[i]); if (message_length > MAX_BBS_MESSAGE) { message_length = MAX_BBS_MESSAGE ; } SetShort(send_buff, message_length, send_index); SetString(send_buff, m_pMain->m_strSellMessage[i], message_length, send_index); // SetShort(send_buff, strlen(m_pMain->m_strSellMessage[i]), send_index); // SetString(send_buff, m_pMain->m_strSellMessage[i], strlen(m_pMain->m_strSellMessage[i]), send_index); SetDWORD(send_buff, m_pMain->m_iSellPrice[i], send_index); SetShort(send_buff, i, send_index); valid_counter++; // Increment number of messages on the requested page } } // if (valid_counter == 0 && page_index > 0) { goto fail_return1; } // if (valid_counter < MAX_BBS_PAGE) { // You still need to fill up slots. for (j = valid_counter ; j < MAX_BBS_PAGE ; j++) { SetShort(send_buff, -1, send_index); SetShort(send_buff, 0, send_index); SetString(send_buff, NULL, 0, send_index); SetShort(send_buff, 0, send_index); SetString(send_buff, NULL, 0, send_index); SetShort(send_buff, 0, send_index); SetString(send_buff, NULL, 0, send_index); SetDWORD(send_buff, 0, send_index); SetShort(send_buff, -1, send_index); valid_counter++; } } SetShort(send_buff, page_index, send_index); SetShort(send_buff, BBS_Counter, send_index); Send(send_buff, send_index); return; fail_return: send_index = 0; memset(send_buff, NULL, 8192); SetByte(send_buff, WIZ_MARKET_BBS, send_index); SetByte(send_buff, MARKET_BBS_REPORT, send_index); SetByte(send_buff, buysell_index, send_index); SetByte(send_buff, result, send_index); SetByte(send_buff, sub_result, send_index); Send(send_buff, send_index); return; fail_return1: send_index = 0; memset(send_buff, NULL, 8192); SetShort(send_buff, buysell_index, send_index); SetShort(send_buff, page_index - 1, send_index); MarketBBSReport(send_buff, type); return; }
void CUser::MarketBBSRemotePurchase(char *pBuf) { CUser* pUser = NULL; int send_index = 0; BYTE buysell_index = 0; short message_index = -1; BYTE result = 0; BYTE sub_result = 1; short tid = -1 ; int index = 0; char send_buff[256]; memset(send_buff, NULL, 256); int i = 0; buysell_index = GetByte(pBuf, index); // Buy or sell? message_index = GetShort(pBuf, index); // Which message should I retrieve? if (buysell_index != MARKET_BBS_BUY && buysell_index != MARKET_BBS_SELL) goto fail_return; if (buysell_index == MARKET_BBS_BUY) { if (m_pMain->m_sBuyID[message_index] == -1) { sub_result = 3; goto fail_return; } pUser = m_pMain->GetUserPtr(m_pMain->m_sBuyID[message_index]); if (pUser == NULL) { // Something wrong with the target ID. sub_result = 1; goto fail_return; } } else if (buysell_index == MARKET_BBS_SELL) { if (m_pMain->m_sSellID[message_index] == -1) { sub_result = 3; goto fail_return; } pUser = m_pMain->GetUserPtr(m_pMain->m_sSellID[message_index]); if (pUser == NULL) { // Something wrong with the target ID. sub_result = 1; goto fail_return; } } if ( m_pUserData->m_iGold >= REMOTE_PURCHASE_PRICE) { // Check if user has gold. m_pUserData->m_iGold -= REMOTE_PURCHASE_PRICE; SetByte( send_buff, WIZ_GOLD_CHANGE, send_index ); SetByte( send_buff, 0x02, send_index ); SetDWORD( send_buff, REMOTE_PURCHASE_PRICE, send_index ); SetDWORD( send_buff, m_pUserData->m_iGold, send_index ); Send( send_buff, send_index ); result = 1; } else { // User does not have gold. sub_result = 2; } fail_return: memset(send_buff, NULL, 256); send_index = 0; SetByte(send_buff, WIZ_MARKET_BBS, send_index); SetByte(send_buff, MARKET_BBS_REMOTE_PURCHASE, send_index); SetByte(send_buff, buysell_index, send_index); SetByte(send_buff, result, send_index); if (result == 0) { // Only on errors!!! SetByte(send_buff, sub_result, send_index); } Send(send_buff, send_index); }
void CMagicProcess::ExecuteType4(int magicid, int sid, int tid, int data1, int data2, int data3, int moral ) { int damage = 0, send_index = 0, result = 1; // Variable initialization. result == 1 : success, 0 : fail char send_buff[128]; _MAGIC_TYPE4* pType = NULL; CNpc* pNpc = NULL ; // Pointer initialization! if(tid == -1) { // 지역 공격 result = AreaAttack(4, magicid, moral, data1, data2, data3, 0, 0); if(result == 0) goto fail_return; else return; } pNpc = g_pMain->m_arNpc.GetData(tid-NPC_BAND); if(pNpc == NULL || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) { result = 0; goto fail_return; } pType = g_pMain->m_Magictype4Array.GetData( magicid ); // Get magic skill table type 4. if( !pType ) return; //TRACE("magictype4 ,, magicid=%d\n", magicid); switch (pType->bBuffType) { // Depending on which buff-type it is..... case 1 : // HP 올리기.. break; case 2 : // 방어력 올리기.. break; case 4 : // 공격력 올리기.. break; case 5 : // 공격 속도 올리기.. break; case 6 : // 이동 속도 올리기.. // if (pNpc->m_MagicType4[pType->bBuffType-1].sDurationTime > 0) { // result = 0 ; // goto fail_return ; // } // else { pNpc->m_MagicType4[pType->bBuffType-1].byAmount = pType->bSpeed; pNpc->m_MagicType4[pType->bBuffType-1].sDurationTime = pType->sDuration; pNpc->m_MagicType4[pType->bBuffType-1].fStartTime = TimeGet(); pNpc->m_fSpeed_1 = (float)(pNpc->m_fOldSpeed_1 * ((double)pType->bSpeed / 100)); pNpc->m_fSpeed_2 = (float)(pNpc->m_fOldSpeed_2 * ((double)pType->bSpeed / 100)); //TRACE("executeType4 ,, speed1=%.2f, %.2f,, type=%d, cur=%.2f, %.2f\n", pNpc->m_fOldSpeed_1, pNpc->m_fOldSpeed_2, pType->bSpeed, pNpc->m_fSpeed_1, pNpc->m_fSpeed_2); // } break; case 7 : // 능력치 올리기... break; case 8 : // 저항력 올리기... break; case 9 : // 공격 성공율 및 회피 성공율 올리기.. break; default : result = 0 ; goto fail_return; } SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, sid, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); g_pMain->Send( send_buff, send_index ); return; fail_return: SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_FAIL, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, sid, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); g_pMain->Send( send_buff, send_index ); }
void CUser::MarketBBSTimeCheck() { CUser* pUser = NULL; // Basic Initializations. int send_index = 0; char send_buff[256]; memset(send_buff, NULL, 256); float currenttime = 0.0f; int price = 0; currenttime = TimeGet(); for (int i = 0 ; i < MAX_BBS_POST ; i++) { if (m_pMain->m_sBuyID[i] != -1) { // BUY!!! pUser = m_pMain->GetUserPtr(m_pMain->m_sBuyID[i]); if (pUser == NULL) { MarketBBSBuyDelete(i); continue; } if (m_pMain->m_fBuyStartTime[i] + BBS_CHECK_TIME < currenttime) { if (pUser->m_pUserData->m_iGold >= BUY_POST_PRICE) { pUser->m_pUserData->m_iGold -= BUY_POST_PRICE ; m_pMain->m_fBuyStartTime[i] = TimeGet(); memset(send_buff, NULL, 256); send_index = 0; SetByte( send_buff, WIZ_GOLD_CHANGE, send_index ); // Now the target SetByte( send_buff, 0x02, send_index ); SetDWORD( send_buff, BUY_POST_PRICE, send_index ); SetDWORD( send_buff, pUser->m_pUserData->m_iGold, send_index ); pUser->Send( send_buff, send_index ); } else { MarketBBSBuyDelete(i); } } } if (m_pMain->m_sSellID[i] != -1) { // SELL!!! pUser = m_pMain->GetUserPtr(m_pMain->m_sSellID[i]); if (pUser == NULL) { MarketBBSSellDelete(i); continue; } if (m_pMain->m_fSellStartTime[i] + BBS_CHECK_TIME < currenttime) { if (pUser->m_pUserData->m_iGold >= SELL_POST_PRICE) { pUser->m_pUserData->m_iGold -= SELL_POST_PRICE ; m_pMain->m_fSellStartTime[i] = TimeGet(); memset(send_buff, NULL, 256); send_index = 0; SetByte( send_buff, WIZ_GOLD_CHANGE, send_index ); // Now the target SetByte( send_buff, 0x02, send_index ); SetDWORD( send_buff, SELL_POST_PRICE, send_index ); SetDWORD( send_buff, pUser->m_pUserData->m_iGold, send_index ); pUser->Send( send_buff, send_index ); } else { MarketBBSSellDelete(i); } } } } }
void CMagicProcess::AreaAttackDamage(int magictype, int rx, int rz, int magicid, int moral, int data1, int data2, int data3, int dexpoint, int righthand_damage) { MAP* pMap = m_pSrcUser->GetMap(); if (pMap == NULL) return; // 자신의 region에 있는 UserArray을 먼저 검색하여,, 가까운 거리에 유저가 있는지를 판단.. if(rx < 0 || rz < 0 || rx > pMap->GetXRegionMax() || rz > pMap->GetZRegionMax()) { TRACE("#### CMagicProcess-AreaAttackDamage() Fail : [nid=%d, name=%s], nRX=%d, nRZ=%d #####\n", m_pSrcUser->m_iUserId, m_pSrcUser->m_strUserID, rx, rz); return; } _MAGIC_TYPE3* pType3 = NULL; _MAGIC_TYPE4* pType4 = NULL; _MAGIC_TABLE* pMagic = NULL; int damage = 0, tid = 0, target_damage = 0, attribute = 0; float fRadius = 0; pMagic = g_pMain->m_MagictableArray.GetData( magicid ); // Get main magic table. if( !pMagic ) { TRACE("#### CMagicProcess-AreaAttackDamage Fail : magic maintable error ,, magicid=%d\n", magicid); return; } if(magictype == 3) { pType3 = g_pMain->m_Magictype3Array.GetData( magicid ); // Get magic skill table type 3. if( !pType3 ) { TRACE("#### CMagicProcess-AreaAttackDamage Fail : magic table3 error ,, magicid=%d\n", magicid); return; } target_damage = pType3->sFirstDamage; attribute = pType3->bAttribute; fRadius = (float)pType3->bRadius; } else if(magictype == 4) { pType4 = g_pMain->m_Magictype4Array.GetData( magicid ); // Get magic skill table type 3. if( !pType4 ) { TRACE("#### CMagicProcess-AreaAttackDamage Fail : magic table4 error ,, magicid=%d\n", magicid); return; } fRadius = (float)pType4->bRadius; } if( fRadius <= 0 ) { TRACE("#### CMagicProcess-AreaAttackDamage Fail : magicid=%d, radius = %d\n", magicid, fRadius); return; } __Vector3 vStart, vEnd; CNpc* pNpc = NULL ; // Pointer initialization! float fDis = 0.0f; vStart.Set((float)data1, (float)0, (float)data3); char send_buff[256]; int send_index=0, result = 1, count = 0, total_mon = 0, attack_type=0;; int* pNpcIDList = NULL; EnterCriticalSection( &g_region_critical ); CRegion *pRegion = &pMap->m_ppRegion[rx][rz]; total_mon = pRegion->m_RegionNpcArray.GetSize(); pNpcIDList = new int[total_mon]; foreach_stlmap (itr, pRegion->m_RegionNpcArray) pNpcIDList[count++] = *itr->second; LeaveCriticalSection(&g_region_critical); for(int i = 0 ; i < total_mon; i++ ) { int nid = pNpcIDList[i]; if( nid < NPC_BAND ) continue; pNpc = (CNpc*)g_pMain->m_arNpc.GetData(nid - NPC_BAND); if( pNpc != NULL && pNpc->m_NpcState != NPC_DEAD) { if( m_pSrcUser->m_bNation == pNpc->m_byGroup ) continue; vEnd.Set(pNpc->m_fCurX, pNpc->m_fCurY, pNpc->m_fCurZ); fDis = pNpc->GetDistance(vStart, vEnd); if(fDis <= fRadius) { // NPC가 반경안에 있을 경우... if(magictype == 3) { // 타잎 3일 경우... damage = GetMagicDamage(pNpc->m_sNid+NPC_BAND, target_damage, attribute, dexpoint, righthand_damage); TRACE("Area magictype3 ,, magicid=%d, damage=%d\n", magicid, damage); if(damage >= 0) { result = pNpc->SetHMagicDamage(damage); } else { damage = abs(damage); if(pType3->bAttribute == 3) attack_type = 3; // 기절시키는 마법이라면..... else attack_type = magicid; if(pNpc->SetDamage(attack_type, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND) == FALSE) { // Npc가 죽은 경우,, pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(pNpc->m_sNid+NPC_BAND, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); } else { m_pSrcUser->SendAttackSuccess(pNpc->m_sNid+NPC_BAND, ATTACK_SUCCESS, damage, pNpc->m_iHP); } } send_index = 0; // 패킷 전송..... //if ( pMagic->bType[1] == 0 || pMagic->bType[1] == 3 ) { SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcUser->m_iUserId, send_index ); SetShort( send_buff, pNpc->m_sNid+NPC_BAND, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, moral, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); g_pMain->Send( send_buff, send_index ); } } else if(magictype == 4) { // 타잎 4일 경우... send_index = 0; result = 1; switch (pType4->bBuffType) { // Depending on which buff-type it is..... case 1 : // HP 올리기.. break; case 2 : // 방어력 올리기.. break; case 4 : // 공격력 올리기.. break; case 5 : // 공격 속도 올리기.. break; case 6 : // 이동 속도 올리기.. //if (pNpc->m_MagicType4[pType4->bBuffType-1].sDurationTime > 0) { // result = 0 ; //} //else { pNpc->m_MagicType4[pType4->bBuffType-1].byAmount = pType4->bSpeed; pNpc->m_MagicType4[pType4->bBuffType-1].sDurationTime = pType4->sDuration; pNpc->m_MagicType4[pType4->bBuffType-1].fStartTime = TimeGet(); pNpc->m_fSpeed_1 = (float)(pNpc->m_fOldSpeed_1 * ((double)pType4->bSpeed / 100)); pNpc->m_fSpeed_2 = (float)(pNpc->m_fOldSpeed_2 * ((double)pType4->bSpeed / 100)); //} break; case 7 : // 능력치 올리기... break; case 8 : // 저항력 올리기... break; case 9 : // 공격 성공율 및 회피 성공율 올리기.. break; default : result = 0 ; break; } TRACE("Area magictype4 ,, magicid=%d\n", magicid); SetByte( send_buff, AG_MAGIC_ATTACK_RESULT, send_index ); SetByte( send_buff, MAGIC_EFFECTING, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, m_pSrcUser->m_iUserId, send_index ); SetShort( send_buff, pNpc->m_sNid+NPC_BAND, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, result, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); SetShort( send_buff, 0, send_index ); g_pMain->Send( send_buff, send_index ); } } } } if(pNpcIDList) { delete [] pNpcIDList; pNpcIDList = NULL; } }
BOOL CUser::GiveItem(int itemid, short count, bool send_packet /*= true*/) { int pos = 255; int send_index = 0 ; char send_buff[128]; _ITEM_TABLE* pTable = NULL; // This checks if such an item exists. pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) return FALSE; pos = GetEmptySlot( itemid, pTable->m_bCountable ); if( pos != 0xFF ) { // Common Item if( pos >= HAVE_MAX ) return FALSE; if( m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum != 0 ) { if( pTable->m_bCountable != 1) return FALSE; else if( m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum != itemid ) return FALSE; } /* if (pTable->m_bCountable) { // Check weight of countable item. if (((pTable->m_sWeight * count) + m_sItemWeight) > m_sMaxWeight) { return FALSE; } } else { // Check weight of non-countable item. if ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight) { return FALSE; } } */ m_pUserData->m_sItemArray[SLOT_MAX+pos].nNum = itemid; // Add item to inventory. if( pTable->m_bCountable) { // Apply number of items to a countable item. m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount += count; if( m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount > MAX_ITEM_COUNT ) { m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = MAX_ITEM_COUNT; } } else { // Just add uncountable item to inventory. m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount = 1; } m_pUserData->m_sItemArray[SLOT_MAX+pos].sDuration = pTable->m_sDuration; // Apply duration to item. } else { return FALSE; // No empty slots. } SendItemWeight(); // Change weight first -- do this regardless. if (send_packet) { SetByte( send_buff, WIZ_ITEM_COUNT_CHANGE, send_index ); SetShort( send_buff, 0x01, send_index ); // The number of for-loops SetByte( send_buff, 0x01, send_index ); SetByte( send_buff, pos, send_index ); SetDWORD( send_buff, itemid, send_index ); // The ID of item. SetDWORD( send_buff, m_pUserData->m_sItemArray[SLOT_MAX+pos].sCount, send_index ); Send( send_buff, send_index ); } return TRUE; }
void CUser::NewCharToAgent(char *pBuf) { int index = 0, idlen = 0, send_index = 0, retvalue = 0; int charindex = 0, race = 0, Class = 0, hair = 0, face = 0, str = 0, sta = 0, dex = 0, intel = 0, cha = 0; char charid[MAX_ID_SIZE+1]; memset( charid, NULL, MAX_ID_SIZE+1 ); char send_buff[256]; memset( send_buff, NULL, 256); BYTE result; int sum = 0; _CLASS_COEFFICIENT* p_TableCoefficient = NULL; charindex = GetByte( pBuf, index ); if (!GetKOString(pBuf, charid, index, MAX_ID_SIZE)) { result = 0x05; goto fail_return; } race = GetByte( pBuf, index ); Class = GetShort( pBuf, index ); face = GetByte( pBuf, index ); hair = GetDWORD( pBuf, index ); str = GetByte( pBuf, index ); sta = GetByte( pBuf, index ); dex = GetByte( pBuf, index ); intel = GetByte( pBuf, index ); cha = GetByte( pBuf, index ); if( charindex > 4 || charindex < 0 ) { result = 0x01; goto fail_return; } if( !IsValidName( charid ) ) { result = 0x05; goto fail_return; } p_TableCoefficient = m_pMain->m_CoefficientArray.GetData( Class ); if( !p_TableCoefficient ) { result = 0x02; goto fail_return; } sum = str + sta + dex + intel + cha; if( sum > 300 ) { result = 0x02; goto fail_return; } if (str < 50 || sta < 50 || dex < 50 || intel < 50 || cha < 50) { result = 0x11; goto fail_return; } SetByte( send_buff, WIZ_NEW_CHAR, send_index ); SetShort( send_buff, m_Sid, send_index ); SetKOString( send_buff, m_strAccountID, send_index ); SetByte( send_buff, charindex, send_index ); SetKOString(send_buff, charid, send_index); SetByte( send_buff, race, send_index ); SetShort( send_buff, Class, send_index ); SetByte( send_buff, face, send_index ); SetDWORD( send_buff, hair, send_index ); SetByte( send_buff, str, send_index ); SetByte( send_buff, sta, send_index ); SetByte( send_buff, dex, send_index ); SetByte( send_buff, intel, send_index ); SetByte( send_buff, cha, send_index ); retvalue = m_pMain->m_LoggerSendQueue.PutData( send_buff, send_index ); if (retvalue < SMQ_FULL) return; DEBUG_LOG("NewChar Send Fail : %d", retvalue); fail_return: send_index = 0; SetByte( send_buff, WIZ_NEW_CHAR, send_index ); SetByte( send_buff, result, send_index ); Send( send_buff, send_index ); }