#include "stdafx.h" #include "ItemManager.h" #include "./util/Tokenizer.h" #include "UIManager.h" #include "./client/GameResourceManager.h" //#include "CoolTimeManager.h" #include "ItemDefine.h" #include "./client/ResourceManager.h" bool cItemManager::LoadAbility( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item ability" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = str.ToInt(); assert( index > 0 ); /// »ç¿ëÈ¿°ú¼³¸í if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long discription = (long)str.ToInt(); /// ¹æ¾î±¸ÀçÁú if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short defenseType = (short)str.ToInt(); /// ¹üÀ§¹æ½Ä if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short rangeType = (short)str.ToInt(); /// È¿°úÀû¿ëŸ°Ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short targetType = (short)str.ToInt(); /// »ç¿ë°Å¸® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short useRange = (short)str.ToInt(); /// ¹°¸® ¹æ¾î·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short physicDefense = (short)str.ToInt(); /// ¸¶¹ý ¹æ¾î·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short magicDefense = (short)str.ToInt(); /// »çÁ¤°Å¸® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short attackRange = (short)str.ToInt(); /// °ø°Ý ¼Óµµ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short attackSpeed = (short)str.ToInt(); /// ÄðŸÀÓ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long coolTime = (long)str.ToInt(); /// ±×·ì ÄðŸÀÓ ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int groupTime = (unsigned int)str.ToInt(); /// ¹°¸®:ÃÖ¼Ò°ø°Ý·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short physicMinAttack = (short)str.ToInt(); /// ¹°¸®:ÃÖ´ë°ø°Ý·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short physicMaxAttack = (short)str.ToInt(); /// ¸¶¹ý:ÃÖ¼Ò°ø°Ý·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short magicMinAttack = (short)str.ToInt(); /// ¸¶¹ý:ÃÖ´ë°ø°Ý·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short magicMaxAttack = (short)str.ToInt(); /// Èú ȸº¹·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short healValue = (short)str.ToInt(); /// ¿É¼Ç °ª sAblityOption opt[5]; for( int i = 0; i < 5; ++i ) { if( tokenizer.GetNext( &str ) == false ) { goto ERR; } opt[i].mOptType = (short)str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } opt[i].mOptValue = (short)str.ToInt(); } /// ½ºÅ³È¿°ú if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long InfluenceIndex = (long)str.ToInt(); /// ¹ßµ¿È¿°ú if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long activeIndex = (long)str.ToInt(); /// ¾ÆÀÌÅÛ ´É·ÂÀ» »ý¼º cItemAbility* p = new cItemAbility; p->mDescription = discription; p->mDefenseType = defenseType; p->mRangeType = rangeType; p->mTargetType = targetType; p->mUseRange = useRange; p->mPhysicDefense = physicDefense; p->mMagicDefense = magicDefense; p->mAttackRange = attackRange; p->mAttackSpeed = attackSpeed; p->mCoolTime = coolTime; p->mGroupNum = groupTime; p->mPhysicMinAttack = physicMinAttack; p->mPhysicMaxAttack = physicMaxAttack; p->mMagicMinAttack = magicMinAttack; p->mMagicMaxAttack = magicMaxAttack; p->mHealValue = healValue; p->mInfluenceIndex = InfluenceIndex; p->mActiveInfluenceIndex = activeIndex; for( int i = 0; i < 5; ++i ) { p->mOption[i] = opt[i]; } if( mAbilityMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item ability, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadLimit( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item limit" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = str.ToInt(); assert( index > 0 ); /// ij¸¯ÅÍ:Á¾Á· if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char charRace = (char)str.ToInt(); /// ij¸¯ÅÍ:¼ºº° if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char charGender = (char)str.ToInt(); /// Á÷¾÷1 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long job1 = (long)str.ToInt(); /// Á÷¾÷2 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long job2 = (long)str.ToInt(); /// ij¸¯ÅÍ:·¹º§ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char charLevel = (char)str.ToInt(); /// ij¸¯ÅÍ:ÃÖ´ë·¹º§ if( tokenizer.GetNext( &str ) == false ) return false; char charMaxLevel = (char)str.ToInt(); /// ÀüÀå »ç¿ëÁ¦ÇÑ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char usePVPOnly = (char)str.ToInt(); /// ¼¼·Â if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char forcetype = (char)str.ToInt(); /// º¸Á¶Á÷¾÷ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long makeSkill = (long)str.ToInt(); /// º¸Á¶Á÷¾÷ °æÇèÄ¡ if( tokenizer.GetNext( &str ) == false ) return false; unsigned long makeSkillExp = (unsigned long)str.ToInt(); /// ¾ÆÀÌÅÛ Á¦ÇÑÀ» »ý¼º cItemLimit* p = new cItemLimit; p->mCharRace = charRace; p->mCharGender = charGender; p->mCharJob1 = job1; p->mCharJob2 = job2; p->mCharLevel = charLevel; p->mCharMaxLevel = charMaxLevel; p->mUsePVPOnly = usePVPOnly; p->mForceType = forcetype; p->mMakeSkill = makeSkill; p->mMakeSkillExp = makeSkillExp; if( mLimitMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item limit, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadCard( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load tarot define" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); assert( index >= 0 ); /// ÆÇ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char episode = (char)str.ToInt(); /// Ä«µå³Ñ¹ö if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int cardnum = (unsigned int)str.ToInt(); /// Èñ±Íµµ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char rarelevel = (char)str.ToInt(); /// Ä«µåŸÀÔ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char cardtype = (char)str.ToInt(); /// ÀåÂøÀ§Ä¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char wearPos = (char)str.ToInt(); /// Ä«µåÀ̹ÌÁö À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int imageIndex = (unsigned int)str.ToInt(); /// µ¥ÀÌÅÍ ¼¼ÆÃ cItemCard* p = new cItemCard; p->mEpisode = episode; p->mCardNumber = cardnum; p->mRareLevel = rarelevel; p->mCardType = cardtype; p->mWearPos = wearPos; p->mImageIndex = imageIndex; if( mCardMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert card define, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadTarot( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load tarot define" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); assert( index >= 0 ); /// À̹ÌÁö À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int imageIndex = (unsigned int)str.ToInt(); assert( imageIndex >= 0 ); /// °íÀ¯ ¹øÈ£ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char number = (char)str.ToInt(); /// Ä«µå ·¹º§ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char level = (char)str.ToInt(); /// Á¤¹æÇâ¼öÄ¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short strvalue = (short)str.ToInt(); /// ¿ª¹æÇâ¼öÄ¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short invvalue = (short)str.ToInt(); /// ¼Ó¼º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char prop = (char)str.ToInt(); /// ¿¡ÇǼҵå(ÆÇ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char episode = (char)str.ToInt(); /// Á¤¹æÇâ ÇØ¼® À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long strdescIdx = (unsigned long)str.ToInt(); assert( strdescIdx >= 0 ); /// ¿ª¹æÇâ ÇØ¼® À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long invdescIdx = (unsigned long)str.ToInt(); assert( invdescIdx >= 0 ); /// µ¥ÀÌÅÍ ¼¼ÆÃ cItemTarot* p = new cItemTarot; p->mImageIndex = imageIndex; p->mNumber = number; p->mLevel = level; p->mStraightValue = strvalue; p->mInverseValue = invvalue; p->mProperty = prop; p->mEpisode = episode; p->mStraightIdx = strdescIdx; p->mInverseIdx = invdescIdx; if( mTarotMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert tarot define, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadSpread( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load spread define" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { long index = 0; cItemSpread* p = new cItemSpread; for( int i = 0; i < 10; ++i ) { /// ½ºÇÁ·¹µå À妽º if( tokenizer.GetNext( &str ) == false ) { assert( 0 && "spread must 10 list" );; { goto ERR; } } index = (long)str.ToInt(); assert( index >= 0 ); /// À̹ÌÁö À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int imageIdx = (int)str.ToInt(); /// ÁÂÇ¥ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long axisIndex = (long)str.ToInt(); assert( axisIndex >= 0 ); /// x ÁÂÇ¥ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int x = (unsigned int)str.ToInt(); /// y ÁÂÇ¥ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int y = (unsigned int)str.ToInt(); /// ¹æÇâ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int dir = (int)str.ToInt(); /// °è»ê½Ä if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int calc = 0; if( !str.CompareNoCase("*") ) { calc = 1; } else if( !str.CompareNoCase("/") ) { calc = 2; } else if( !str.CompareNoCase("+") ) { calc = 3; } /// °è»ê¼öÄ¡ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int value = (int)str.ToInt(); /// µ¥ÀÌÅÍ »ðÀÔ p->mParam[i].mImageIndex = imageIdx; p->mParam[i].mX = x; p->mParam[i].mY = y; p->mParam[i].mDir = dir; p->mParam[i].mCalc = calc; p->mParam[i].mValue = value; if( axisIndex < 1 || axisIndex > 10 ) { assert( 0 && "error axis index" ); { goto ERR; } } } if( mSpreadMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert spread define, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } /// ºÐÇØ °ü·Ã µ¥ÀÌÅÍ ·Îµù bool cItemManager::LoadDisjoint( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item disjoint" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); assert( index > 0 ); /// ºñ¿ë if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long price = (long)str.ToInt(); /// ¾ÆÀÌÅÛ1 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx1 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ1 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count1 = (int)str.ToInt(); /// ¾ÆÀÌÅÛ2 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx2 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ2 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count2 = (int)str.ToInt(); /// ¾ÆÀÌÅÛ3 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx3 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ3 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count3 = (int)str.ToInt(); /// ¾ÆÀÌÅÛ4 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx4 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ4 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count4 = (int)str.ToInt(); /// ¾ÆÀÌÅÛ5 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx5 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ5 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count5 = (int)str.ToInt(); /// ¾ÆÀÌÅÛ6 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long itemIdx6 = (long)str.ToInt(); /// ¾ÆÀÌÅÛ6 ¼ö·® if( tokenizer.GetNext( &str ) == false ) { goto ERR; } int count6 = (int)str.ToInt(); /// sItemDisjoint* p = new sItemDisjoint; p->mPrice = price; p->mDisjoint[0].itemIndex = itemIdx1; p->mDisjoint[0].count = count1; p->mDisjoint[1].itemIndex = itemIdx2; p->mDisjoint[1].count = count2; p->mDisjoint[2].itemIndex = itemIdx3; p->mDisjoint[2].count = count3; p->mDisjoint[3].itemIndex = itemIdx4; p->mDisjoint[3].count = count4; p->mDisjoint[4].itemIndex = itemIdx5; p->mDisjoint[4].count = count5; p->mDisjoint[5].itemIndex = itemIdx6; p->mDisjoint[5].count = count6; if( mDisjointMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item disjoint, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadEnhanced( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item enhanced" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// index ±¸ºÐÀÚ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } if( str.CompareNoCase("Index") != 0 ) { goto ERR; } /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); cEnhancedOptionArr* pEnhancedOption = new cEnhancedOptionArr; while( tokenizer.GetNext( &str ) ) { if( str.CompareNoCase("End") == 0 ) break; sItemEnhanced* p = new sItemEnhanced; p->mEnhancedType = (unsigned char)str.ToInt(); /// Áõ°¡°ª for( unsigned int i = 0; i < MAX_ITEM_ENHANCED; ++i ) { if( tokenizer.GetNext( &str ) == false ) { goto ERR; } p->mValue[i] = (short)str.ToInt(); } pEnhancedOption->PushBack( p ); } /// if( mEnhancedMap.Insert( index, pEnhancedOption ) == false ) { assert( 0 && "failed to insert item enhanced, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } /// Ä«µå ½½·Ô ·Îµù bool cItemManager::LoadCardSlot( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load card slot" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); /// ½½·Ô ŸÀÔ1 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short type1 = (short)str.ToInt(); /// ½½·Ô ŸÀÔ2 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short type2 = (short)str.ToInt(); /// ½½·Ô ŸÀÔ3 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short type3 = (short)str.ToInt(); /// ½½·Ô ŸÀÔ4 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short type4 = (short)str.ToInt(); /// ½½·Ô ŸÀÔ5 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short type5 = (short)str.ToInt(); /// µ¥ÀÌÅÍ »ðÀÔ sItemPutCardSlot* p = new sItemPutCardSlot; p->mSlotType[0] = type1; p->mSlotType[1] = type2; p->mSlotType[2] = type3; p->mSlotType[3] = type4; p->mSlotType[4] = type5; /// if( mPutCardSlotMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item putcard, maybe already exist" ); { goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadDefine( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item define" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); assert( index > 0 ); /// À̸§ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// À̸§ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int nameIndex = (unsigned int)str.ToInt(); /// ÅøÆÁ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int tipIndex = (unsigned int)str.ToInt(); /// Á¾·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned char type = (unsigned char)str.ToInt(); /// ¼¼ºÎ Á¾·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned char subType = (unsigned char)str.ToInt(); /// °Ë»ö ´ëºÐ·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int highType = (unsigned int)str.ToInt(); /// °Ë»ö Áߺзù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int middleType = (unsigned int)str.ToInt(); /// °Ë»ö ¼ÒºÐ·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int lowType = (unsigned int)str.ToInt(); /// ¹«°Ô if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short weight = (short)str.ToInt(); /// °ãħ°¹¼ö if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short capacity = (short)str.ToInt(); /// ÆÇ¸Å¹æ¹ý if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long sellType = (unsigned long)str.ToInt(); /// ÆÇ¸Å°¡°Ý if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long sellPrice = (unsigned long)str.ToInt(); /// ±¸ÀÔ¹æ¹ý if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long buyType = (unsigned long)str.ToInt(); /// ±¸ÀÔ°¡°Ý if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long buyPrice = (unsigned long)str.ToInt(); /// ÃÖ´ë ÃâÇö°³¼ö if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long presentNum = (unsigned long)str.ToInt(); /// º¸À¯ °¡´É°¹¼ö if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int maxHaveInven = (unsigned int)str.ToInt(); // ±â°£Á¦ ¼³Á¤ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } // »ç¿ë±âÇÑ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } // ÀÎÁõ¿©ºÎ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// »ç¿ëÀÚ°Å·¡ ¿©ºÎ(0°Å·¡°¡´É/1°Å·¡ºÒ°¡) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char exchange = (char)str.ToInt(); /// ´É·Â À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long abilityIndex = (long)str.ToInt(); /// Á¦ÇÑ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long limitIndex = (long)str.ToInt(); /// Ä«µå À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } //long cardIndex = (long)str.ToInt(); /// Ÿ·Î À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long tarotIndex = (long)str.ToInt(); /// ½ºÇÁ·¹µå À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long spreadIndex = (long)str.ToInt(); /// ºÐÇØ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long disjointIndex = (long)str.ToInt(); /// Ä«µå½½·Ô À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long cardSlotIndex = (long)str.ToInt(); /// °­È­È®·ü À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } //long enhanceRateIndex = (long)str.ToInt(); (long)str.ToInt(); /// °­È­ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long enhanceIndex = (long)str.ToInt(); /// üÀÎÁö À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// ȣĪ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long titleIndex = (long)str.ToInt(); /// ¼¼Æ® À妽º if( tokenizer.GetNext( &str) == false ) { goto ERR; } long setIndex = (long)str.ToInt(); /// ¾ÆÀÌÄÜ À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int iconIndex = (unsigned int)str.ToInt(); /// ¸ðµ¨ À妽º0 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int fileIndex0 = (unsigned int)str.ToInt(); /// ¸ðµ¨ À妽º1 if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int fileIndex1 = (unsigned int)str.ToInt(); /// Åõ±¸ Âø¿ë½Ã ±Í Ç¥½Ã¿©ºÎ (0:±ÍÇ¥½Ã, 1:±ÍÇ¥½Ã ¾ÈÇÔ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char hideEar = (char)str.ToInt(); /// ¾ÆÀÌÅÛ ÅøÆÁÄ÷¯ ( ·¹¾îµµ°ü·Ã ) if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned short tooltipColor = (unsigned short)str.ToInt(); // ȨÆäÀÌÁö °ø°³¿©ºÎ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } /// ¾ÆÀÌÅÛ Á¤ÀǸ¦ »ý¼º cItemDefine* p = new cItemDefine; //p->mName = GetItemName( nameIndex ); //p->mDescription = ( tipIndex > 0 ) ? GAMERESOURCEMAN->GetItemToolTipText( tipIndex ) : 0; p->mType = type; p->mSubType = subType; p->mHighType = highType; p->mMiddleType = middleType; p->mLowType = lowType; p->mWeight = weight; p->mCapacity = capacity; p->mSellType = sellType; p->mSellPrice = sellPrice; p->mBuyType = buyType; p->mBuyPrice = buyPrice; p->mPresentNum = presentNum; p->mMaxHaveInven = maxHaveInven; p->mExchange = exchange; p->mTitleIndex = titleIndex; p->mSetIndex = setIndex; // p->mAbility = GetItemAbility( abilityIndex ); p->mLimit = GetItemLimit( limitIndex ); // //p->mCard = GetItemCard( cardIndex ); // p->mTarot = GetItemTarot( tarotIndex ); // p->mSpread = GetItemSpread( spreadIndex ); // p->mDisjoint = GetItemDisjoint( disjointIndex ); // p->mEnhanceArr = GetItemEnhanced( enhanceIndex ); // p->mPutCardSlot = GetItemPutCardSlot( cardSlotIndex ); p->mIconParam = UIMAN->GetIconParam( iconIndex ); p->mFileNames0 = GetItemFileNames( fileIndex0 ); p->mFileNames1 = GetItemFileNames( fileIndex1 ); p->mHideEar = hideEar; p->mTooltipColor = tooltipColor; if( p->mIconParam == 0 ) { assert( 0 && "failed to find icon param" ); { goto ERR; } } if( p->mLimit == 0 ) { assert( 0 && "failed to find item limit" ); { goto ERR; } } /// ÀåÂø ŸÀÔÀ» ¼³Á¤ if( type == ITEM_WEAPON ) { switch( subType ) { /// ÇÑ¼Õ°Ë case ITEM_WEAPON_SWORD: p->mEquipType = ITEM_EQUIP_ONE_HAND; if( p->mFileNames0 == 0 ) { assert( 0 && "failed to find left item file name" ); { goto ERR; } } break; /// ¾ç¼Õ°Ë, ´Ü°Ë, ÃÑ, ÁöÆÎÀÌ, À̵µ·ù case ITEM_WEAPON_BLADE: case ITEM_WEAPON_GUN: case ITEM_WEAPON_STAFF: p->mEquipType = ITEM_EQUIP_TWO_HANDS; if( p->mFileNames0 == 0 ) { assert( 0 && "failed to find left item file name" ); { goto ERR; } } break; case ITEM_WEAPON_DUAL: case ITEM_WEAPON_CUTTER: p->mEquipType = ITEM_EQUIP_TWO_HANDS; if( p->mFileNames0 == 0 ) { assert( 0 && "failed to find left item file name" ); { goto ERR; } } if( p->mFileNames1 == 0 ) { assert( 0 && "failed to find right item file name" ); { goto ERR; } } break; /// ¹æÆÐ case ITEM_WEAPON_SHIELD: p->mEquipType = ITEM_EQUIP_SHIELD; break; } } /// Ç÷¢°ªÀ» ¼³Á¤ switch( type ) { case ITEM_WEAPON: switch( subType ) { case ITEM_WEAPON_SWORD: p->mFlag = ITEM_FLAG_SWORD; break; case ITEM_WEAPON_BLADE: p->mFlag = ITEM_FLAG_BLADE; break; case ITEM_WEAPON_DUAL: p->mFlag = ITEM_FLAG_DUAL; break; case ITEM_WEAPON_CUTTER: p->mFlag = ITEM_FLAG_CUTTER; break; case ITEM_WEAPON_GUN: p->mFlag = ITEM_FLAG_GUN; break; case ITEM_WEAPON_STAFF: p->mFlag = ITEM_FLAG_STAFF; break; case ITEM_WEAPON_SHIELD: p->mFlag = ITEM_FLAG_SHIELD; break; default: { assert( 0 && "invalid item weapon subtype" ); goto ERR; } } break; case ITEM_WEAR: switch( subType ) { case ITEM_WEAR_HEAD: p->mFlag = ITEM_FLAG_HEAD; break; case ITEM_WEAR_UPPER: p->mFlag = ITEM_FLAG_UPPER; break; case ITEM_WEAR_LOWER: p->mFlag = ITEM_FLAG_LOWER; break; case ITEM_WEAR_HANDS: p->mFlag = ITEM_FLAG_HANDS; break; case ITEM_WEAR_FEET: p->mFlag = ITEM_FLAG_FEET; break; case ITEM_WEAR_ONEPIECE: p->mFlag = ITEM_FLAG_ONEPIECE; break; case ITEM_WEAR_COS_ONEPIECE: p->mFlag = ITEM_FLAG_COSTUME_UPPER; break; case ITEM_WEAR_COS_HEAD: p->mFlag = ITEM_FLAG_COSTUME_HEAD; break; case ITEM_WEAR_COS_UPPER: p->mFlag = ITEM_FLAG_COSTUME_UPPER; break; case ITEM_WEAR_COS_LOWER: p->mFlag = ITEM_FLAG_COSTUME_LOWER; break; case ITEM_WEAR_COS_HANDS: p->mFlag = ITEM_FLAG_COSTUME_HANDS; break; case ITEM_WEAR_COS_FEET: p->mFlag = ITEM_FLAG_COSTUME_FEET; break; default: { assert( 0 && "invalid item wear subtype" ); goto ERR; } } break; case ITEM_ACCESSORY: switch( subType ) { case ITEM_ACCESSORY_EARRING: p->mFlag = ITEM_FLAG_EARRING; break; case ITEM_ACCESSORY_NECKLACE: p->mFlag = ITEM_FLAG_NECKLACE; break; case ITEM_ACCESSORY_BROOCH: p->mFlag = ITEM_FLAG_BROOCH; break; case ITEM_ACCESSORY_BRACELET: p->mFlag = ITEM_FLAG_BRACELET; break; case ITEM_ACCESSORY_RING: p->mFlag = ITEM_FLAG_RING; break; case ITEM_ACCESSORY_COS_FACE: p->mFlag = ITEM_FLAG_COSTUME_FACE; break; case ITEM_ACCESSORY_COS_BACK: p->mFlag = ITEM_FLAG_COSTUME_BACK; break; default: { assert( 0 && "invalid item accessory subtype" ); goto ERR; } } break; case ITEM_CARD: /// ij¸¯ÅÍ ÀåÂø Ä«µå p->mFlag = ( subType == ITEM_CARD_EQUIP_C ) ? ITEM_FLAG_EQUIPCARD : ITEM_FLAG_UNKNOWN; break; default: p->mFlag = ITEM_FLAG_UNKNOWN; break; } /// Ä«µåÀåÂø °¡´É ½½·Ô Ä«¿îÆ® ¼¼±â sItemPutCardSlot* slot = p->mPutCardSlot; if( slot ) { for( int i = 0; i < MAX_CARD_SLOT; ++i ) { /// ÀåÂø°¡´ÉÇÑ ½½·Ô ¼¼±â if( slot->mSlotType[i] > 0 ) p->mPutSlotCount++; } } if( mDefineMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item define, maybe already exist" ); { goto ERR; } } /// ¼¼Æ® Á¤º¸ »ðÀÔ if( p->mSetIndex != 0 ) { cItemSetInfo* setInfo = (cItemSetInfo*)mSetInfoMap.GetAt( p->mSetIndex ); if( setInfo ) { setInfo->AddItem( index ); } else { assert(0); goto ERR; } } } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadItemSet( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item set info" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) { goto ERR; } long index = (long)str.ToInt(); assert( index > 0 ); /// °¹¼ö if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int count = (unsigned int)str.ToInt(); /// ¼¼Æ® À̸§ if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned int nameIdx = (unsigned int)str.ToInt(); /// ¿É¼Ç if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short optType1 = (short)str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short optValue1 = (short)str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short optType2 = (short)str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short optValue2 = (short)str.ToInt(); if( tokenizer.GetNext( &str ) == false ) { goto ERR; } unsigned long actIdx = str.ToInt(); cItemSetInfo* setInfo = (cItemSetInfo*)mSetInfoMap.GetAt(index); if( setInfo == 0 ) { setInfo = new cItemSetInfo; if( setInfo == 0 || mSetInfoMap.Insert( index, setInfo ) == false ) { assert(0); continue; } } /// À̸§Á¤º¸ setInfo->mSetNameIdx = nameIdx; /// °¹¼öº° ¿É¼ÇÁ¤º¸ sSetAblityOption* opt = new sSetAblityOption; opt->mOptType[0] = optType1; opt->mOptValue[0] = optValue1; opt->mOptType[1] = optType2; opt->mOptValue[1] = optValue2; opt->mActIdx = actIdx; /// optÁ¤º¸ ¼ÂÆÃ setInfo->AddOption( count, opt ); } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } bool cItemManager::LoadFileName( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item file name" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } unsigned int iend = eRACE_MAX * eGENDER_MAX; cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), " \t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// À妽º if( tokenizer.GetNext( &str ) == false ) return false; long index = str.ToInt(); assert( index > 0 ); iend = eRACE_MAX * eGENDER_MAX; /// ¾ÆÀÌÅÛ ÆÄÀÏ À̸§ ¹è¿­À» »ý¼º cString* p = new cString[iend]; for( unsigned int i = 0; i < iend; ++i ) { if( tokenizer.GetNext( &(p[i]) ) == false ) { delete [] p; cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); return false; } else { // ij¸¯ÅÍ ¾ÆÀÌÅÛ À̹ÌÁö ·Îµù ·çƾ Ãß°¡ [12/14/2009 Jo_Client] if( ::_strcmpi( p[i].Cstr(), "None" ) != 0 ) { cString path; path.Format( "./Data/Character/%s", p[i].Cstr() ); if( RESOURCEMAN->LoadNIF( path, false ) == false ) { assert(0); cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to load nif", MB_OK | MB_ICONERROR ); } } } } if( mFileNamesMap.Insert( index, p ) == false ) { assert( 0 && "failed to insert item file names, maybe already exist" ); cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); return false; } } return true; } /// ÆÇ¸Å´ëÇà ½Ã½ºÅÛ Ä«Å×°í¸® Á¤º¸ bool cItemManager::LoadDealCategoryTable( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load item file name" ); cString msg; msg.Format("[%s]", pathName.Cstr() ); MessageBoxA( NULL, msg.Cstr(), "fail to open file", MB_OK | MB_ICONERROR ); return false; } cTokenizer tokenizer( loader.GetBufferPtr(), loader.GetSize(), "\t\r\n", pathName.Cstr() ); cString str; while( tokenizer.IsEnd() == false ) { /// ´ëºÐ·ù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } char highKey = (char)str.ToInt(); /// Áߺзù if( tokenizer.GetNext( &str ) == false ) { goto ERR; } short midKey = (short)str.ToInt(); sDealCategory* data = new sDealCategory; data->mHighKey = highKey; data->mMiddleKey = midKey; cDealArr* middleArr = (cDealArr*)mDealCategoryMap.GetAt( highKey ); if( middleArr == 0 ) { middleArr = new cDealArr; if( mDealCategoryMap.Insert( highKey, middleArr ) == false ) { assert(0); delete data; continue; } mDealHighArr.PushBack( highKey ); } middleArr->PushBack( data ); } return true; ERR: cString msg; msg.Format("[%s] [Line:%d]", pathName.Cstr(), tokenizer.mLine ); MessageBoxA( NULL, msg.Cstr(), "fail to parser", MB_OK | MB_ICONERROR ); assert(0); return false; } /// void cItemManager::LoadCoolData() { cAbilityMap::cIterator i = mAbilityMap.Begin(); cAbilityMap::cIterator end = mAbilityMap.End(); for( ; i != end; ++i ) { cItemAbility* p = (cItemAbility*)(i->mSecond); if( !p ) { assert(0); continue; } /// ÄðŸÀÓ µ¥ÀÌÅÍ ¼¼ÆÃ if( p->mCoolTime > 0 ) { unsigned long itemIndex = (unsigned long)(i->mFirst); // COOLMAN->LoadData( itemIndex, p->mGroupNum, p->mCoolTime ); } } }