CSCommon: MMatchItem.h 소스 파일

MAIET

MMatchItem.h

00001 #ifndef _MMATCHITEM_H
00002 #define _MMATCHITEM_H
00003 
00004 #include "winsock2.h"
00005 #include "MXml.h"
00006 #include "MUID.h"
00007 #include "MSync.h"
00008 #include "MBaseItem.h"
00009 #include <map>
00010 #include <list>
00011 #include <vector>
00012 #include <algorithm>
00013 using namespace std;
00014 
00015 class MZFileSystem;
00016 
00017 
00018 
00019 
00020 
00022 enum MMatchItemType
00023 {
00024     MMIT_MELEE = 0,
00025     MMIT_RANGE,
00026     MMIT_EQUIPMENT,
00027     MMIT_CUSTOM,
00028     MMIT_END
00029 };
00030 
00032 enum MMatchItemSlotType
00033 {
00034     MMIST_NONE = 0,
00035     MMIST_MELEE,
00036     MMIST_RANGE,
00037     MMIST_CUSTOM,
00038     MMIST_HEAD,
00039     MMIST_CHEST,
00040     MMIST_HANDS,
00041     MMIST_LEGS,
00042     MMIST_FEET,
00043     MMIST_FINGER,
00044     MMIST_EXTRA,
00045     MMIST_END
00046 };
00047 
00049 enum MMatchCharItemParts
00050 {
00051     MMCIP_HEAD      = 0,
00052     MMCIP_CHEST     = 1,
00053     MMCIP_HANDS     = 2,
00054     MMCIP_LEGS      = 3,
00055     MMCIP_FEET      = 4,
00056     MMCIP_FINGERL   = 5,
00057     MMCIP_FINGERR   = 6,
00058     MMCIP_MELEE     = 7,
00059     MMCIP_PRIMARY   = 8,
00060     MMCIP_SECONDARY = 9,
00061     MMCIP_CUSTOM1   = 10,
00062     MMCIP_CUSTOM2   = 11,
00063     MMCIP_END
00064 };
00065 
00066 // 커스텀 아이템 타입
00067 enum MMatchCustomItemType
00068 {
00069     MMCIT_MED_KIT               = 0,
00070     MMCIT_REPAIR_KIT            = 1,
00071     MMCIT_DYNAMITE              = 2,
00072     MMCIT_REMOTE_CHARGE         = 3,
00073     MMCIT_DEMOLITION_TOOLS      = 4,
00074     MMCIT_FLASH_BANG            = 5,
00075     MMCIT_FRAGMENTATION         = 6,
00076     MMCIT_SMOKE_GRENADE         = 7,
00077     MMCIT_TEARGAS_GRENADE       = 8,
00078     
00079     MMCIT_ENCHANT_FIRE          = 9,            // 인챈트 아이템 - fire
00080     MMCIT_ENCHANT_COLD          = 10,           // 인챈트 아이템 - cold
00081     MMCIT_ENCHANT_LIGHTNING     = 11,           // 인챈트 아이템 - lightning
00082     MMCIT_ENCHANT_POISON        = 12,           // 인챈트 아이템 - poison
00083 
00084 //  MMCIT_FOOD                  = 13,
00085 
00086     MMCIT_END
00087 };
00088 
00089 enum MMatchMeleeItemType
00090 {
00091     MIT_DAGGER          = 0,
00092     MIT_DUAL_DAGGER     = 1,
00093     MIT_KATANA          = 2,
00094     MIT_GREAT_SWORD     = 3,
00095     MIT_DOUBLE_KATANA   = 4,
00096 
00097     MIT_END
00098 };
00099 
00100 enum MMatchRangeItemType
00101 {
00102     RIT_PISTOL          = 0,
00103     RIT_PISTOLx2        = 1,
00104     RIT_REVOLVER        = 2,
00105     RIT_REVOLVERx2      = 3,
00106     RIT_SMG             = 4,
00107     RIT_SMGx2           = 5,
00108     RIT_SHOTGUN         = 6,
00109     RIT_SAWED_SHOTGUN   = 7,
00110     RIT_RIFLE           = 8,
00111     RIT_MACHINEGUN      = 9,
00112     RIT_ROCKET          = 10,
00113     RIT_SNIFER          = 11,
00114 
00115     RIT_END
00116 };
00117 
00118 // Melee, Range, Custom을 합친 무기 타입 .. 한손 양손의 구분은 없다..
00119 enum MMatchWeaponType
00120 {
00121     MWT_NONE    = 0,
00122     // melee
00123     MWT_DAGGER,
00124     MWT_DUAL_DAGGER,
00125     MWT_KATANA,
00126     MWT_GREAT_SWORD,
00127     MWT_DOUBLE_KATANA,
00128 
00129     // range
00130     MWT_PISTOL,
00131     MWT_PISTOLx2,
00132     MWT_REVOLVER,
00133     MWT_REVOLVERx2,
00134     MWT_SMG,
00135     MWT_SMGx2,
00136     MWT_SHOTGUN,
00137     MWT_SAWED_SHOTGUN,
00138     MWT_RIFLE,
00139     MWT_MACHINEGUN,
00140     MWT_ROCKET,
00141     MWT_SNIFER,
00142 
00143     // custom
00144     MWT_MED_KIT,
00145     MWT_REPAIR_KIT,
00146     MWT_FLASH_BANG,
00147     MWT_FRAGMENTATION,
00148     MWT_SMOKE_GRENADE,
00149 //  MWT_FOOD,
00150 
00151     // custom - enchant
00152     MWT_ENCHANT_FIRE,           
00153     MWT_ENCHANT_COLD,
00154     MWT_ENCHANT_LIGHTNING,
00155     MWT_ENCHANT_POISON,
00156 
00157     MWT_END
00158 };
00159 
00160 struct MMatchItemEffectDesc
00161 {
00162     unsigned long int   m_nID;
00163     char                m_szName[128];
00164     int                 m_nArea;
00165     unsigned long int   m_nTime;
00166     int                 m_nModHP;
00167     int                 m_nModAP;
00168     int                 m_nModMaxWT;
00169     int                 m_nModSF;
00170     int                 m_nModFR;
00171     int                 m_nModCR;
00172     int                 m_nModPR;
00173     int                 m_nModLR;
00174     int                 m_nResAP;
00175     int                 m_nResFR;
00176     int                 m_nResCR;
00177     int                 m_nResPR;
00178     int                 m_nResLR;
00179     int                 m_nStun;
00180     int                 m_nKnockBack;
00181     int                 m_nSmoke;
00182     int                 m_nFlash;
00183     int                 m_nTear;
00184     int                 m_nFlame;
00185 };
00186 
00187 struct MMatchItemDesc
00188 {
00189     unsigned long int   m_nID;
00190     char                m_szName[128];
00191     int                 m_nTotalPoint;
00192     MMatchItemType      m_nType;
00193     int                 m_nResSex;
00194     int                 m_nResLevel;
00195     MMatchItemSlotType  m_nSlot;
00196     MMatchWeaponType    m_nWeaponType;
00197     int                 m_nWeight;
00198     int                 m_nBountyPrice;
00199     bool                m_bIsCashItem;
00200     int                 m_nDamage;
00201     int                 m_nDelay;
00202     MMatchItemEffectDesc* m_pEffect;
00203     int                 m_nControllability;
00204     int                 m_nMagazine;
00205     int                 m_nMaxBullet;
00206     int                 m_nReloadTime;
00207     bool                m_bSlugOutput;
00208     int                 m_nGadgetID;
00209     int                 m_nHP;
00210     int                 m_nAP;
00211     int                 m_nMaxWT;
00212     int                 m_nSF;
00213     int                 m_nFR;
00214     int                 m_nCR;
00215     int                 m_nPR;
00216     int                 m_nLR;
00217     int                 m_nLimitSpeed;
00218     int                 m_nLimitJump;
00219     int                 m_nLimitTumble;
00220     int                 m_nLimitWall;
00221     int                 m_nRange;       // melee무기 공격범위
00222     int                 m_nEffectLevel;
00223     char                m_szDesc[8192]; // 설명
00224 
00225     unsigned long int   m_nColor;
00226     char                m_szMeshName[128];
00227     int                 m_nImageID;
00228     int                 m_nBulletImageID;
00229     int                 m_nMagazineImageID;
00230     char                m_szReloadSndName[256];
00231     char                m_szFireSndName[256];
00232     char                m_szDryfireSndName[256];
00233     MMatchItemDesc();
00234     int GetBountyValue() { return (m_nBountyPrice / 4); }
00235     bool IsCashItem()   { if ((m_nID>=500000) || (m_bIsCashItem)) return true; return false; }
00236     bool IsEnchantItem() { if (m_nWeaponType>=MWT_ENCHANT_FIRE && m_nWeaponType<=MWT_ENCHANT_POISON) return true; return false; }
00237 };
00238 
00239 // 슬롯과 파츠가 적합한지 체크
00240 bool IsSuitableItemSlot(MMatchItemSlotType nSlotType, MMatchCharItemParts nParts);
00241 MMatchCharItemParts GetSuitableItemParts(MMatchItemSlotType nSlotType);
00242 MMatchItemSlotType  GetSuitableItemSlot(MMatchCharItemParts nParts);
00243 bool IsWeaponItemSlotType(MMatchItemSlotType nSlotType);
00244 bool IsWeaponCharItemParts(MMatchCharItemParts nParts);
00245 
00246 char* GetItemSlotTypeStr(MMatchItemSlotType nSlotType);
00247 char* GetCharItemPartsStr(MMatchCharItemParts nParts);
00248 
00249 // 무기타입 알아내기
00250 MMatchWeaponType GetWeaponType(MMatchMeleeItemType nMeleeItemType);
00251 MMatchWeaponType GetWeaponType(MMatchRangeItemType nRangeItemType);
00252 MMatchWeaponType GetWeaponType(MMatchCustomItemType nCustomItemType);
00253 
00254 // 인챈트아이템인지 확인
00255 bool IsEnchantItem(MMatchItemDesc* pItemDesc);
00256 
00257 
00258 class MMatchItemEffectDescMgr : public map<int, MMatchItemEffectDesc*>
00259 {
00260 protected:
00261     void ParseEffect(MXmlElement& element);
00262 public:
00263     MMatchItemEffectDescMgr();
00264     virtual ~MMatchItemEffectDescMgr();
00265     bool ReadXml(const char* szFileName);
00266     bool ReadXml(MZFileSystem* pFileSystem, const char* szFileName);
00267     void Clear();
00268     MMatchItemEffectDesc* GetEffectDesc(int nID);
00269     static MMatchItemEffectDescMgr* GetInstance();
00270 };
00271 
00272 
00273 inline MMatchItemEffectDescMgr* MGetMatchItemEffectDescMgr() { return MMatchItemEffectDescMgr::GetInstance(); }
00274 
00275 class MMatchItemDescMgr : public map<int, MMatchItemDesc*>
00276 {
00277 protected:
00278     void ParseItemFast(MXmlElement& element);
00279 public:
00280     MMatchItemDescMgr();
00281     virtual ~MMatchItemDescMgr();
00282     bool ReadXml(const char* szFileName);
00283     bool ReadXml(MZFileSystem* pFileSystem, const char* szFileName);
00284     void Clear();
00285     MMatchItemDesc* GetItemDesc(unsigned long int nID);
00286     static MMatchItemDescMgr* GetInstance();
00287 };
00288 inline MMatchItemDescMgr* MGetMatchItemDescMgr() { return MMatchItemDescMgr::GetInstance(); }
00289 
00290 
00291 
00292 class MMatchItem : public MBaseItem
00293 {
00294 private:
00295 protected:
00296     MUID                m_uidItem;          
00297     unsigned long int   m_nCIID;                    
00298     MMatchItemDesc*     m_pDesc;                    
00299     bool                m_bEquiped;                 
00300     unsigned long int   m_nRentItemRegTime;         
00301 protected:
00302     void SetDesc(MMatchItemDesc* pDesc) { m_pDesc = pDesc; }
00303 public:
00304     MMatchItem();
00305     virtual ~MMatchItem();
00306     bool Create(MUID& uid, MMatchItemDesc* pDesc, int nCount = 1);
00307     void Destroy();
00308 
00309     MUID GetUID() { return m_uidItem; }
00310 
00311 
00312     bool IsEmpty() { return (((m_pDesc == NULL) || (m_nCount <= 0)) ? true : false); }
00313     void SetCIID(unsigned long int nCIID) { m_nCIID = nCIID; }
00314     unsigned long int GetCIID() { return m_nCIID; }
00315     MMatchItemDesc* GetDesc() { return m_pDesc; }
00316     unsigned long int GetDescID() { if (m_pDesc) return m_pDesc->m_nID; else return 0; }
00317     void SetCount(int n) { m_nCount = n; }
00318     int GetCount() { return m_nCount; }
00319     void Inc(int n=1) { m_nCount += n; }
00320     void Dec(int n=1) { m_nCount -= n; if (m_nCount < 0) m_nCount = 0; }
00321     void SetEquiped(bool bIsEquiped) { m_bEquiped = bIsEquiped; }
00322     bool IsEquiped() { return m_bEquiped; }
00323     unsigned long int GetRentItemRegTime()  { return m_nRentItemRegTime; }
00324     void SetRentItemRegTime(unsigned long int nTime){ m_nRentItemRegTime = nTime; }
00325 
00326     MMatchItemType GetItemType();
00327 };
00328 
00329 class MMatchItemMap;
00330 
00332 class MMatchEquipedItem
00333 {
00334 protected:
00335     MMatchItem*     m_pParts[MMCIP_END];
00336 public:
00337     MMatchEquipedItem() { memset(m_pParts, 0, sizeof(m_pParts)); }
00338     virtual ~MMatchEquipedItem() { }
00339 public:
00340     bool SetItem(MMatchCharItemParts parts, MMatchItem* pMatchItem);
00341     MMatchItem* GetItem(MMatchCharItemParts parts) { return m_pParts[parts]; }
00342     void Remove(MMatchCharItemParts parts);
00343     bool IsEmpty(MMatchCharItemParts parts) { if (m_pParts[parts] != NULL) return false; return true; }
00344     void GetTotalWeight(int* poutWeight, int* poutMaxWeight);
00345     bool IsEquipedItem(MMatchItem* pCheckItem, MMatchCharItemParts& outParts); // 해당 아이템이 장비중인지 체크
00346     void Clear();
00347 };
00348 
00350 class MMatchItemMap : public map<MUID, MMatchItem*>
00351 {
00352 private:
00353 protected:
00354     static MUID             m_uidGenerate;
00355     static MCriticalSection m_csUIDGenerateLock;
00356     bool                    m_bDoneDbAccess;        // 디비에서 정보를 가져왔었는지 여부
00357 
00360     bool                    m_bHasRentItem;         
00361 public:
00362     MMatchItemMap();
00363     virtual ~MMatchItemMap();
00364     bool IsEmpty() { return empty(); }
00365     int GetCount() { return (int)size(); }
00366     virtual bool CreateItem(MUID& uid, int nCIID, int nItemDescID, 
00367                             bool bRentItem=false, int nRentMinutePeriodRemainder=RENT_MINUTE_PERIOD_UNLIMITED, int nCount = 1);
00368     bool RemoveItem(MUID& uidItem);
00369     virtual void Clear();
00370     MMatchItem* GetItem(MUID& uidItem);
00371     bool IsDoneDbAccess() { return m_bDoneDbAccess; }
00372     void SetDbAccess() { m_bDoneDbAccess = true; }
00373     bool HasRentItem() { return m_bHasRentItem; }
00374 public:
00375     static MUID UseUID() {
00376         m_csUIDGenerateLock.Lock();
00377             m_uidGenerate.Increase();   
00378         m_csUIDGenerateLock.Unlock();
00379         return m_uidGenerate;
00380     }
00381 };
00382 
00383 
00384 // effect
00385 #define MECTOK_EFFECT       "EFFECT"
00386 #define MECTOK_ID           "id"
00387 #define MECTOK_NAME         "name"
00388 #define MECTOK_AREA         "area"
00389 #define MECTOK_TIME         "time"
00390 #define MECTOK_MOD_HP       "mod_hp"
00391 #define MECTOK_MOD_AP       "mod_ap"
00392 #define MECTOK_MOD_MAXWT    "mod_maxwt"
00393 #define MECTOK_MOD_SF       "mod_sf"
00394 #define MECTOK_MOD_FR       "mod_fr"
00395 #define MECTOK_MOD_CR       "mod_cr"
00396 #define MECTOK_MOD_PR       "mod_pr"
00397 #define MECTOK_MOD_LR       "mod_lr"
00398 #define MECTOK_RES_AP       "res_ap"
00399 #define MECTOK_RES_FR       "res_fr"
00400 #define MECTOK_RES_CR       "res_cr"
00401 #define MECTOK_RES_PR       "res_pr"
00402 #define MECTOK_RES_LR       "res_lr"
00403 #define MECTOK_STUN         "stun"
00404 #define MECTOK_KNOCKBACK    "knockback"
00405 #define MECTOK_SMOKE        "smoke"
00406 #define MECTOK_FLASH        "flash"
00407 #define MECTOK_TEAR         "tear"
00408 #define MECTOK_FLAME        "flame"
00409 
00410 
00411 // item
00412 #define MICTOK_ITEM         "ITEM"
00413 #define MICTOK_ID           "id"
00414 #define MICTOK_NAME         "name"
00415 #define MICTOK_TOTALPOINT   "totalpoint"
00416 #define MICTOK_TYPE         "type"
00417 #define MICTOK_RES_SEX      "res_sex"
00418 #define MICTOK_RES_LEVEL    "res_level"
00419 #define MICTOK_SLOT         "slot"
00420 #define MICTOK_WEAPON       "weapon"
00421 #define MICTOK_EFFECT_LEVEL "effect_level"
00422 #define MICTOK_WEIGHT       "weight"
00423 #define MICTOK_BOUNTY_PRICE "bt_price"
00424 #define MICTOK_ISCASHITEM   "iscashitem"
00425 #define MICTOK_DAMAGE       "damage"
00426 #define MICTOK_DELAY        "delay"
00427 #define MICTOK_EFFECT_ID    "effect_id"
00428 #define MICTOK_CONTROLLABILITY  "ctrl_ability"
00429 #define MICTOK_MAGAZINE     "magazine"
00430 #define MICTOK_MAXBULLET    "maxbullet"
00431 #define MICTOK_RELOADTIME   "reloadtime"
00432 #define MICTOK_SLUGOUTPUT   "slut_output"
00433 #define MICTOK_GADGET_ID    "gadget_id"
00434 #define MICTOK_HP           "hp"
00435 #define MICTOK_AP           "ap"
00436 #define MICTOK_MAXWT        "maxwt"
00437 #define MICTOK_SF           "sf"
00438 #define MICTOK_FR           "fr"
00439 #define MICTOK_CR           "cr"
00440 #define MICTOK_PR           "pr"
00441 #define MICTOK_LR           "lr"
00442 #define MICTOK_LIMITSPEED   "limitspeed"
00443 #define MICTOK_LIMITJUMP    "limitjump"
00444 #define MICTOK_LIMITTUMBLE  "limittumble"
00445 #define MICTOK_LIMITWALL    "limitwall"
00446 #define MICTOK_RANGE        "range"
00447 
00448 #define MICTOK_COLOR        "color"
00449 #define MICTOK_DESC         "desc"
00450 
00451 #define MICTOK_MESH_NAME            "mesh_name"
00452 #define MICTOK_IMAGE_ID             "image_id"
00453 #define MICTOK_BULLET_IMAGE_ID      "bullet_image_id"
00454 #define MICTOK_MAGAZINE_IMAGE_ID    "magazine_image_id"
00455 
00456 #define MICTOK_SOUND_RELOAD         "snd_reload"
00457 #define MICTOK_SOUND_FIRE           "snd_fire"
00458 #define MICTOK_SOUND_DRYFIRE        "snd_dryfire"
00459 
00460 
00461 #endif
00462 
00463 /*
00464 == XML 기술 설명 ==
00465 + zitem.xml 설명
00466 
00467 + 태그이름 : ITEM
00468 + attribute 설명
00469 id : 아이템 아이디(int)
00470 name : 아이템 이름(string[128])
00471 mesh_name : 메쉬 이름(str[256]) , weapon.xml의 name항목의 이름
00472 totalpoint : 종합 점수(int)
00473 type : 종류(melee, range, equip, custom)
00474 res_sex : 성별 제한사항(m, f, a)
00475 res_level : 레벨 제한사항(int) , 제한이 없을경우 0으로 세팅하도록 한다.
00476 slot : 슬롯(none, melee, range, head, chest, hands, legs, feet, finger, custom)
00477 weapon : 무기타입(none, dagger, katana, pistol, smg, shotgun, rifle, machinegun, 
00478                   rocket, snifer, medkit, flashbang, frag, smoke, 
00479                   enchant_fire, enchant_cold, enchant_lightning, enchant_poison)
00480 weight : 무게(int)
00481 bt_price : 판매가(int)
00482 iscashitem : 캐쉬아이템인지 여부(true, false)
00483 damage : 데미지(int)
00484 delay : 딜레이(int)
00485 effect_id : 이펙트 아이디(int) , effect.xml의 항목과 연동되는 ID
00486 ctrl_ability : 제어성(int)
00487 magazine : 장탄수(int)
00488 reloadtime : 장전시간(int)
00489 slug_output : 탄피적출(true, false)
00490 gadget_id : 옵션 아이디(int)
00491 hp : hp 캐릭터 수정치(int)
00492 ap : ap 캐릭터 수정치(int)
00493 maxwt : max wt 캐릭터 수정치(int)
00494 sf : sf 캐릭터 수정치(int)
00495 fr : fr 캐릭터 수정치(int)
00496 cr : cr 캐릭터 수정치(int)
00497 pr : pr 캐릭터 수정치(int)
00498 lr : lr 캐릭터 수정치(int)
00499 desc : 설명(string[65535])
00500 color : 색깔(color)
00501 image_id : ui에서 보이는 image 아이디(int) , 지금은 쓰이지 않음
00502 bullet_image_id : ui에서 보이는 bullet 이미지 아이디(int) , 지금은 쓰이지 않음
00503 magazine_image_id : ui에서 보이는 magazine 이미지 아이디(int) , 지금은 쓰이지 않음
00504 snd_reload : reload때 나오는 사운드 이름(str[128])
00505 snd_fire : fire때 나오는 사운드 이름(str[128])
00506 snd_dryfire : dryfire 때 나오는 사운드 이름(str[128])
00507 range : melee 공격의 범위(int)
00508 
00509 
00510 + effect.xml 설명
00511 
00512 - 태그이름 : EFFECT
00513 + attribute 설명
00514 id : 이펙트 아이디(int)
00515 name : 이펙트 이름(string[128])
00516 area : 이펙트 영역(int)
00517 time : 이펙트 시간(msec)
00518 mod_hp : hp 수정치 
00519 mod_ap : ap 수정치
00520 mod_maxwt : max wt 수정치
00521 mod_sf : sf 수정치
00522 mod_fr : fr 수정치
00523 mod_cr : cr 수정치
00524 mod_pr : pr 수정치
00525 mod_lr : lr 수정치
00526 res_ap : ap 저항판정
00527 res_fr : fr 저항판정
00528 res_cr : cr 저항판정
00529 res_pr : pr 저항판정
00530 res_lr : lr 저항판정
00531 stun : stun 수정치
00532 knockback : knockback 수정치
00533 smoke : smoke 수정치
00534 flash : flash 수정치
00535 tear : tear 수정치
00536 flame : frame 수정치
00537 
00538 
00539  */


MAIET entertainment