void CHARACTER::SaveAffect() { TPacketGDAddAffect p; itertype(m_list_pkAffect) it = m_list_pkAffect.begin(); while (it != m_list_pkAffect.end()) { CAffect * pkAff = *it++; if (IS_NO_SAVE_AFFECT(pkAff->dwType)) continue; sys_log(1, "AFFECT_SAVE: %u %u %d %d", pkAff->dwType, pkAff->bApplyOn, pkAff->lApplyValue, pkAff->lDuration); p.dwPID = GetPlayerID(); p.elem.dwType = pkAff->dwType; p.elem.bApplyOn = pkAff->bApplyOn; p.elem.lApplyValue = pkAff->lApplyValue; p.elem.dwFlag = pkAff->dwFlag; p.elem.lDuration = pkAff->lDuration; p.elem.lSPCost = pkAff->lSPCost; db_clientdesc->DBPacket(HEADER_GD_ADD_AFFECT, 0, &p, sizeof(p)); } }
TargetInfo * CTargetManager::GetTargetInfo(DWORD dwPID, int iType, int iArg1) { itertype(m_map_kListEvent) it = m_map_kListEvent.find(dwPID); if (it == m_map_kListEvent.end()) return NULL; std::list<LPEVENT>::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { LPEVENT pkEvent = *(it2++); TargetInfo * info = dynamic_cast<TargetInfo*>(pkEvent->info); if ( info == NULL ) { sys_err( "CTargetManager::GetTargetInfo> <Factor> Null pointer" ); continue; } if (!IS_SET(info->iType, iType)) continue; if (info->iArg1 != iArg1) continue; return info; } return NULL; }
LPEVENT CTargetManager::GetTargetEvent(DWORD dwPID, DWORD dwQuestIndex, const char * c_pszTargetName) { itertype(m_map_kListEvent) it = m_map_kListEvent.find(dwPID); if (it == m_map_kListEvent.end()) return NULL; std::list<LPEVENT>::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { LPEVENT pkEvent = *(it2++); TargetInfo * info = dynamic_cast<TargetInfo*>(pkEvent->info); if ( info == NULL ) { sys_err( "CTargetManager::GetTargetEvent> <Factor> Null pointer" ); continue; } if (info->dwQuestIndex != dwQuestIndex) continue; if (strcmp(info->szTargetName, c_pszTargetName)) continue; return pkEvent; } return NULL; }
void CWarMapManager::OnShutdown() { itertype(m_mapWarMap) it = m_mapWarMap.begin(); while (it != m_mapWarMap.end()) (it++)->second->Draw(); }
int CGuildManager::GetRanking(DWORD dwGID) { itertype(map_kLadderPointRankingByGID) it = map_kLadderPointRankingByGID.find(dwGID); if (it == map_kLadderPointRankingByGID.end()) return GUILD_RANK_MAX_NUM; return MINMAX(0, it->second, GUILD_RANK_MAX_NUM); }
std::string * CConfig::Search(const char* key) { itertype(m_valueMap) i = m_valueMap.find(key); if (i == m_valueMap.end()) return NULL; else return (&i->second); }
CWarMap * CWarMapManager::Find(long lMapIndex) { itertype(m_mapWarMap) it = m_mapWarMap.find(lMapIndex); if (it == m_mapWarMap.end()) return NULL; return it->second; }
void CHARACTER::RefreshAffect() { itertype(m_list_pkAffect) it = m_list_pkAffect.begin(); while (it != m_list_pkAffect.end()) { CAffect * pkAff = *it++; ComputeAffect(pkAff, true); } }
TGuild & CGuildManager::TouchGuild(DWORD GID) { itertype(m_map_kGuild) it = m_map_kGuild.find(GID); if (it != m_map_kGuild.end()) return it->second; TGuild info; m_map_kGuild.insert(std::map<DWORD, TGuild>::value_type(GID, info)); return m_map_kGuild[GID]; }
TWarMapInfo * CWarMapManager::GetWarMapInfo(long lMapIndex) { if (lMapIndex >= 10000) lMapIndex /= 10000; itertype(m_map_kWarMapInfo) it = m_map_kWarMapInfo.find(lMapIndex); if (m_map_kWarMapInfo.end() == it) return NULL; return it->second; }
int CMonarch::GetCandidacyIndex(DWORD pid) { itertype(m_vec_MonarchCandidacy) it = m_vec_MonarchCandidacy.begin(); for (int n = 0; it != m_vec_MonarchCandidacy.end(); ++it, ++n) { if (it->pid == pid) return n; } return -1; }
static PyObject* bond_iterator_create(NodeData* _in) { BondIterator *result = PyObject_New(BondIterator, itertype()); if(result == NULL) return NULL; result->parent = _in; Py_INCREF(result->parent); new(&result->i_first) std::vector<EdgeData*>::iterator(_in->bonds.begin()); new(&result->i_end) std::vector<EdgeData*>::iterator(_in->bonds.end()); result->is_first = true; result->N = _in->bonds.size(); return (PyObject*) result; }
void CTargetManager::Logout(DWORD dwPID) { itertype(m_map_kListEvent) it = m_map_kListEvent.find(dwPID); if (it == m_map_kListEvent.end()) return; std::list<LPEVENT>::iterator it2 = it->second.begin(); while (it2 != it->second.end()) event_cancel(&(*(it2++))); m_map_kListEvent.erase(it); }
//////////////////////////////////////////////////////////////////// // Affect CAffect * CHARACTER::FindAffect(DWORD dwType, BYTE bApply) const { itertype(m_list_pkAffect) it = m_list_pkAffect.begin(); while (it != m_list_pkAffect.end()) { CAffect * pkAffect = *it++; if (pkAffect->dwType == dwType && (bApply == APPLY_NONE || bApply == pkAffect->bApplyOn)) return pkAffect; } return NULL; }
void AuctionManager::Boot(CPeer* peer) { peer->EncodeWORD(sizeof(TPlayerItem)); peer->EncodeWORD(auction_item_cache_map.size()); itertype(auction_item_cache_map) auction_item_cache_map_it = auction_item_cache_map.begin(); while (auction_item_cache_map_it != auction_item_cache_map.end()) peer->Encode((auction_item_cache_map_it++)->second->Get(), sizeof(TPlayerItem)); Auction.Boot(peer); Sale.Boot(peer); Wish.Boot(peer); MyBid.Boot(peer); }
bool COXEventManager::GiveItemToAttender(DWORD dwItemVnum, BYTE count) { itertype(m_map_attender) iter = m_map_attender.begin(); for (; iter != m_map_attender.end(); ++iter) { LPCHARACTER pkChar = CHARACTER_MANAGER::instance().FindByPID(iter->second); if (pkChar) { pkChar->AutoGiveItem(dwItemVnum, count); LogManager::instance().ItemLog(pkChar->GetPlayerID(), 0, count, dwItemVnum, "OXEVENT_REWARD", "", pkChar->GetDesc()->GetHostName(), dwItemVnum); } } return true; }
bool COXEventManager::CheckIpAddress(LPCHARACTER ch) { for (itertype(m_map_attender) it = m_map_attender.begin(); it != m_map_attender.end(); ++it) { LPCHARACTER tch = CHARACTER_MANAGER::Instance().FindByPID(it->second); if (!tch || !tch->GetDesc()) continue; if (!strcmp(ch->GetDesc()->GetHostName(), tch->GetDesc()->GetHostName()) && ch->GetMapIndex() == tch->GetMapIndex()) { LogManager::Instance().HackLog("MULTI_IP_OX", ch); ch->GoHome(); return false; } } return true; }
bool CMonarch::DelCandidacy(const char * name) { itertype(m_vec_MonarchCandidacy) it = m_vec_MonarchCandidacy.begin(); for (; it != m_vec_MonarchCandidacy.end(); ++it) { if (0 == strncmp(it->name, name, sizeof(it->name))) { char szQuery[256]; snprintf(szQuery, sizeof(szQuery), "DELETE FROM monarch_candidacy WHERE pid=%d ", it->pid); CDBManager::instance().AsyncQuery(szQuery); m_vec_MonarchCandidacy.erase (it); return true; } } return false; }
void CTargetManager::DeleteTarget(DWORD dwPID, DWORD dwQuestIndex, const char * c_pszTargetName) { itertype(m_map_kListEvent) it = m_map_kListEvent.find(dwPID); if (it == m_map_kListEvent.end()) return; std::list<LPEVENT>::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { LPEVENT pkEvent = *it2; TargetInfo * info = dynamic_cast<TargetInfo*>(pkEvent->info); if ( info == NULL ) { sys_err( "CTargetManager::DeleteTarget> <Factor> Null pointer" ); ++it2; continue; } if (dwQuestIndex == info->dwQuestIndex) { if (!c_pszTargetName || !strcmp(info->szTargetName, c_pszTargetName)) { if (info->bSendToClient) { // <Factor> Removed pkChr //SendTargetDeletePacket(info->pkChr->GetDesc(), info->iID); LPCHARACTER pkChr = CHARACTER_MANAGER::instance().FindByPID(info->dwPID); if (pkChr != NULL) { SendTargetDeletePacket(pkChr->GetDesc(), info->iID); } } event_cancel(&pkEvent); it2 = it->second.erase(it2); continue; } } it2++; } }
void CHARACTER::ClearAffect(bool bSave) { TAffectFlag afOld = m_afAffectFlag; WORD wMovSpd = GetPoint(POINT_MOV_SPEED); WORD wAttSpd = GetPoint(POINT_ATT_SPEED); itertype(m_list_pkAffect) it = m_list_pkAffect.begin(); while (it != m_list_pkAffect.end()) { CAffect * pkAff = *it; if (bSave) { if ( IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || IS_NO_SAVE_AFFECT(pkAff->dwType) ) { ++it; continue; } if (IsPC()) { SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn); } } ComputeAffect(pkAff, false); it = m_list_pkAffect.erase(it); CAffect::Release(pkAff); } if (afOld != m_afAffectFlag || wMovSpd != GetPoint(POINT_MOV_SPEED) || wAttSpd != GetPoint(POINT_ATT_SPEED)) UpdatePacket(); CheckMaximumPoints(); if (m_list_pkAffect.empty()) event_cancel(&m_pkAffectEvent); }
int CParty::GetMemberMaxLevel() { int bMax = 0; itertype(m_memberMap) it = m_memberMap.begin(); while (it!=m_memberMap.end()) { if (!it->second.bLevel) { ++it; continue; } if (!bMax) bMax = it->second.bLevel; else if (it->second.bLevel) bMax = MAX(bMax, it->second.bLevel); ++it; } return bMax; }
int CParty::GetMemberMinLevel() { int bMin = PLAYER_MAX_LEVEL_CONST; itertype(m_memberMap) it = m_memberMap.begin(); while (it!=m_memberMap.end()) { if (!it->second.bLevel) { ++it; continue; } if (!bMin) bMin = it->second.bLevel; else if (it->second.bLevel) bMin = MIN(bMin, it->second.bLevel); ++it; } return bMin; }
bool CWarMapManager::GetStartPosition(long lMapIndex, BYTE bIdx, PIXEL_POSITION & pos) { assert(bIdx < 3); TWarMapInfo * pi = GetWarMapInfo(lMapIndex); if (!pi) { sys_log(0, "GetStartPosition FAILED [%d] WarMapInfoSize(%d)", lMapIndex, m_map_kWarMapInfo.size()); itertype(m_map_kWarMapInfo) it; for (it = m_map_kWarMapInfo.begin(); it != m_map_kWarMapInfo.end(); ++it) { PIXEL_POSITION& cur=it->second->posStart[bIdx]; sys_log(0, "WarMap[%d]=Pos(%d, %d)", it->first, cur.x, cur.y); } return false; } pos = pi->posStart[bIdx]; return true; }
void CMonarch::ElectMonarch() { int size = GetVecMonarchCandidacy().size(); int * s = new int[size]; itertype(m_map_MonarchElection) it = m_map_MonarchElection.begin(); int idx = 0; for (; it != m_map_MonarchElection.end(); ++it) { if ((idx = GetCandidacyIndex(it->second->pid)) < 0) continue; ++s[idx]; if (g_test_server) sys_log (0, "[MONARCH_VOTE] pid(%d) come to vote candidacy pid(%d)", it->second->pid, m_vec_MonarchCandidacy[idx].pid); } delete [] s; }
CWarMap::~CWarMap() { event_cancel(&m_pkBeginEvent); event_cancel(&m_pkEndEvent); event_cancel(&m_pkTimeoutEvent); event_cancel(&m_pkResetFlagEvent); sys_log(0, "WarMap::~WarMap : map index %d", GetMapIndex()); itertype(m_set_pkChr) it = m_set_pkChr.begin(); while (it != m_set_pkChr.end()) { LPCHARACTER ch = *(it++); if (ch->GetDesc()) { sys_log(0, "WarMap::~WarMap : disconnecting %s", ch->GetName()); DESC_MANAGER::instance().DestroyDesc(ch->GetDesc()); } } m_set_pkChr.clear(); }
bool ITEM_MANAGER::ReadDropItemGroup(const char * c_pszFileName) { CTextFileLoader loader; if (!loader.Load(c_pszFileName)) return false; std::string stName; for (DWORD i = 0; i < loader.GetChildNodeCount(); ++i) { loader.SetChildNode(i); loader.GetCurrentNodeName(&stName); int iVnum; int iMobVnum; if (!loader.GetTokenInteger("vnum", &iVnum)) { sys_err("ReadDropItemGroup : Syntax error %s : no vnum, node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } if (!loader.GetTokenInteger("mob", &iMobVnum)) { sys_err("ReadDropItemGroup : Syntax error %s : no mob vnum, node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } sys_log(0,"DROP_ITEM_GROUP %s %d", stName.c_str(), iMobVnum); TTokenVector * pTok; itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find(iMobVnum); CDropItemGroup* pkGroup; if (it == m_map_pkDropItemGroup.end()) pkGroup = M2_NEW CDropItemGroup(iVnum, iMobVnum, stName); else pkGroup = it->second; for (int k = 1; k < 256; ++k) { char buf[4]; snprintf(buf, sizeof(buf), "%d", k); if (loader.GetTokenVector(buf, &pTok)) { std::string& name = pTok->at(0); DWORD dwVnum = 0; if (!GetVnumByOriginalName(name.c_str(), dwVnum)) { str_to_number(dwVnum, name.c_str()); if (!ITEM_MANAGER::instance().GetTable(dwVnum)) { sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str()); if (it == m_map_pkDropItemGroup.end()) M2_DELETE(pkGroup); return false; } } float fPercent = atof(pTok->at(1).c_str()); DWORD dwPct = (DWORD)(10000.0f * fPercent); int iCount = 1; if (pTok->size() > 2) str_to_number(iCount, pTok->at(2).c_str()); if (iCount < 1) { sys_err("ReadDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str()); if (it == m_map_pkDropItemGroup.end()) M2_DELETE(pkGroup); return false; } sys_log(0," %s %d %d", name.c_str(), dwPct, iCount); pkGroup->AddItem(dwVnum, dwPct, iCount); continue; } break; } if (it == m_map_pkDropItemGroup.end()) m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup)); loader.SetParentNode(); } return true; }
void CItem::ModifyPoints(bool bAdd) { int accessoryGrade; // ¹«±â¿Í °©¿Ê¸¸ ¼ÒÄÏÀ» Àû¿ë½ÃŲ´Ù. if (false == IsAccessoryForSocket()) { if (m_pProto->bType == ITEM_WEAPON || m_pProto->bType == ITEM_ARMOR) { // ¼ÒÄÏÀÌ ¼Ó¼º°È¿¡ »ç¿ëµÇ´Â °æ¿ì Àû¿ëÇÏÁö ¾Ê´Â´Ù (ARMOR_WRIST ARMOR_NECK ARMOR_EAR) for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i) { DWORD dwVnum; if ((dwVnum = GetSocket(i)) <= 2) continue; TItemTable * p = ITEM_MANAGER::instance().GetTable(dwVnum); if (!p) { sys_err("cannot find table by vnum %u", dwVnum); continue; } if (ITEM_METIN == p->bType) { //m_pOwner->ApplyPoint(p->alValues[0], bAdd ? p->alValues[1] : -p->alValues[1]); for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { if (p->aApplies[i].bType == APPLY_NONE) continue; if (p->aApplies[i].bType == APPLY_SKILL) m_pOwner->ApplyPoint(p->aApplies[i].bType, bAdd ? p->aApplies[i].lValue : p->aApplies[i].lValue ^ 0x00800000); else m_pOwner->ApplyPoint(p->aApplies[i].bType, bAdd ? p->aApplies[i].lValue : -p->aApplies[i].lValue); } } } } accessoryGrade = 0; } else { accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM); } for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { if (m_pProto->aApplies[i].bType == APPLY_NONE) continue; long value = m_pProto->aApplies[i].lValue; if (m_pProto->aApplies[i].bType == APPLY_SKILL) { m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : value ^ 0x00800000); } else { if (0 != accessoryGrade) value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100); m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value); } } // Ãʽ´ÞÀÇ ¹ÝÁö, ÇÒ·ÎÀ© »çÅÁ, ÇູÀÇ ¹ÝÁö, ¿µ¿øÇÑ »ç¶ûÀÇ Ææ´øÆ®ÀÇ °æ¿ì // ±âÁ¸ÀÇ Çϵå ÄÚµùÀ¸·Î °Á¦·Î ¼Ó¼ºÀ» ºÎ¿©ÇßÁö¸¸, // ±× ºÎºÐÀ» Á¦°ÅÇÏ°í special item group Å×ÀÌºí¿¡¼ ¼Ó¼ºÀ» ºÎ¿©Çϵµ·Ï º¯°æÇÏ¿´´Ù. // ÇÏÁö¸¸ Çϵå ÄÚµùµÇ¾îÀÖÀ» ¶§ »ý¼ºµÈ ¾ÆÀÌÅÛÀÌ ³²¾ÆÀÖÀ» ¼öµµ ÀÖ¾î¼ Æ¯¼öó¸® Çسõ´Â´Ù. // ÀÌ ¾ÆÀÌÅÛµéÀÇ °æ¿ì, ¹Ø¿¡ ITEM_UNIQUEÀÏ ¶§ÀÇ Ã³¸®·Î ¼Ó¼ºÀÌ ºÎ¿©µÇ±â ¶§¹®¿¡, // ¾ÆÀÌÅÛ¿¡ ¹ÚÇôÀÖ´Â attribute´Â Àû¿ëÇÏÁö ¾Ê°í ³Ñ¾î°£´Ù. if (true == CItemVnumHelper::IsRamadanMoonRing(GetVnum()) || true == CItemVnumHelper::IsHalloweenCandy(GetVnum()) || true == CItemVnumHelper::IsHappinessRing(GetVnum()) || true == CItemVnumHelper::IsLovePendant(GetVnum())) { // Do not anything. } else { for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i) { if (GetAttributeType(i)) { const TPlayerItemAttribute& ia = GetAttribute(i); if (ia.bType == APPLY_SKILL) m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : ia.sValue ^ 0x00800000); else m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : -ia.sValue); } } } switch (m_pProto->bType) { case ITEM_PICK: case ITEM_ROD: { if (bAdd) { if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON) m_pOwner->SetPart(PART_WEAPON, GetVnum()); } else { if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON) m_pOwner->SetPart(PART_WEAPON, m_pOwner->GetOriginalPart(PART_WEAPON)); } } break; case ITEM_WEAPON: { if (bAdd) { if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON) m_pOwner->SetPart(PART_WEAPON, GetVnum()); } else { if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON) m_pOwner->SetPart(PART_WEAPON, m_pOwner->GetOriginalPart(PART_WEAPON)); } } break; case ITEM_ARMOR: { // ÄÚ½ºÃõ body¸¦ ÀÔ°íÀÖ´Ù¸é armor´Â ¹þ´ø ÀÔ´ø »ó°ü ¾øÀÌ ºñÁÖ¾ó¿¡ ¿µÇâÀ» ÁÖ¸é ¾È µÊ. if (0 != m_pOwner->GetWear(WEAR_COSTUME_BODY)) break; if (GetSubType() == ARMOR_BODY || GetSubType() == ARMOR_HEAD || GetSubType() == ARMOR_FOOTS || GetSubType() == ARMOR_SHIELD) { if (bAdd) { if (GetProto()->bSubType == ARMOR_BODY) m_pOwner->SetPart(PART_MAIN, GetVnum()); } else { if (GetProto()->bSubType == ARMOR_BODY) m_pOwner->SetPart(PART_MAIN, m_pOwner->GetOriginalPart(PART_MAIN)); } } } break; // ÄÚ½ºÃõ ¾ÆÀÌÅÛ ÀÔ¾úÀ» ¶§ ij¸¯ÅÍ parts Á¤º¸ ¼¼ÆÃ. ±âÁ¸ ½ºÅ¸ÀÏ´ë·Î Ãß°¡ÇÔ.. case ITEM_COSTUME: { DWORD toSetValue = this->GetVnum(); EParts toSetPart = PART_MAX_NUM; // °©¿Ê ÄÚ½ºÃõ if (GetSubType() == COSTUME_BODY) { toSetPart = PART_MAIN; if (false == bAdd) { // ÄÚ½ºÃõ °©¿ÊÀ» ¹þ¾úÀ» ¶§ ¿ø·¡ °©¿ÊÀ» ÀÔ°í ÀÖ¾ú´Ù¸é ±× °©¿ÊÀ¸·Î look ¼¼ÆÃ, ÀÔÁö ¾Ê¾Ò´Ù¸é default look const CItem* pArmor = m_pOwner->GetWear(WEAR_BODY); toSetValue = (NULL != pArmor) ? pArmor->GetVnum() : m_pOwner->GetOriginalPart(PART_MAIN); } } // Çì¾î ÄÚ½ºÃõ else if (GetSubType() == COSTUME_HAIR) { toSetPart = PART_HAIR; // ÄÚ½ºÃõ Çì¾î´Â shape°ªÀ» item protoÀÇ value3¿¡ ¼¼ÆÃÇϵµ·Ï ÇÔ. Ưº°ÇÑ ÀÌÀ¯´Â ¾ø°í ±âÁ¸ °©¿Ê(ARMOR_BODY)ÀÇ shape°ªÀÌ ÇÁ·ÎÅäÀÇ value3¿¡ ÀÖ¾î¼ Çì¾îµµ °°ÀÌ value3À¸·Î ÇÔ. // [NOTE] °©¿ÊÀº ¾ÆÀÌÅÛ vnumÀ» º¸³»°í Çì¾î´Â shape(value3)°ªÀ» º¸³»´Â ÀÌÀ¯´Â.. ±âÁ¸ ½Ã½ºÅÛÀÌ ±×·¸°Ô µÇ¾îÀÖÀ½... toSetValue = (true == bAdd) ? this->GetValue(3) : 0; } if (PART_MAX_NUM != toSetPart) { m_pOwner->SetPart((BYTE)toSetPart, toSetValue); m_pOwner->UpdatePacket(); } } break; case ITEM_UNIQUE: { if (0 != GetSIGVnum()) { const CSpecialItemGroup* pItemGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(GetSIGVnum()); if (NULL == pItemGroup) break; DWORD dwAttrVnum = pItemGroup->GetAttrVnum(GetVnum()); const CSpecialAttrGroup* pAttrGroup = ITEM_MANAGER::instance().GetSpecialAttrGroup(dwAttrVnum); if (NULL == pAttrGroup) break; for (itertype (pAttrGroup->m_vecAttrs) it = pAttrGroup->m_vecAttrs.begin(); it != pAttrGroup->m_vecAttrs.end(); it++) { m_pOwner->ApplyPoint(it->apply_type, bAdd ? it->apply_value : -it->apply_value); } } } break; } }
int CHARACTER::ProcessAffect() { bool bDiff = false; CAffect *pkAff = NULL; // // 프리미엄 처리 // for (int i = 0; i <= PREMIUM_MAX_NUM; ++i) { int aff_idx = i + AFFECT_PREMIUM_START; pkAff = FindAffect(aff_idx); if (!pkAff) continue; int remain = GetPremiumRemainSeconds(i); if (remain < 0) { RemoveAffect(aff_idx); bDiff = true; } else pkAff->lDuration = remain + 1; } ////////// HAIR_AFFECT pkAff = FindAffect(AFFECT_HAIR); if (pkAff) { // IF HAIR_LIMIT_TIME() < CURRENT_TIME() if ( this->GetQuestFlag("hair.limit_time") < get_global_time()) { // SET HAIR NORMAL this->SetPart(PART_HAIR, 0); // REMOVE HAIR AFFECT RemoveAffect(AFFECT_HAIR); } else { // INCREASE AFFECT DURATION ++(pkAff->lDuration); } } ////////// HAIR_AFFECT // CHorseNameManager::instance().Validate(this); TAffectFlag afOld = m_afAffectFlag; long lMovSpd = GetPoint(POINT_MOV_SPEED); long lAttSpd = GetPoint(POINT_ATT_SPEED); itertype(m_list_pkAffect) it; it = m_list_pkAffect.begin(); while (it != m_list_pkAffect.end()) { pkAff = *it; bool bEnd = false; if (pkAff->dwType >= GUILD_SKILL_START && pkAff->dwType <= GUILD_SKILL_END) { if (!GetGuild() || !GetGuild()->UnderAnyWar()) bEnd = true; } if (pkAff->lSPCost > 0) { if (GetSP() < pkAff->lSPCost) bEnd = true; else PointChange(POINT_SP, -pkAff->lSPCost); } // AFFECT_DURATION_BUG_FIX // 무한 효과 아이템도 시간을 줄인다. // 시간을 매우 크게 잡기 때문에 상관 없을 것이라 생각됨. if ( --pkAff->lDuration <= 0 ) { bEnd = true; } // END_AFFECT_DURATION_BUG_FIX if (bEnd) { it = m_list_pkAffect.erase(it); ComputeAffect(pkAff, false); bDiff = true; if (IsPC()) { SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn); } CAffect::Release(pkAff); continue; } ++it; } if (bDiff) { if (afOld != m_afAffectFlag || lMovSpd != GetPoint(POINT_MOV_SPEED) || lAttSpd != GetPoint(POINT_ATT_SPEED)) { UpdatePacket(); } CheckMaximumPoints(); } if (m_list_pkAffect.empty()) return true; return false; }
/** * @version 05/06/08 Bang2ni - __get_guildid_byname 스크립트 함수 등록 */ bool CQuestManager::InitializeLua() { #if LUA_V == 503 L = lua_open(); luaopen_base(L); luaopen_table(L); luaopen_string(L); luaopen_math(L); //TEMP luaopen_io(L); luaopen_debug(L); #elif LUA_V == 523 L = luaL_newstate(); luaL_openlibs(L); //luaopen_debug(L); #else #error "lua version not found" #endif RegisterAffectFunctionTable(); RegisterBuildingFunctionTable(); RegisterDungeonFunctionTable(); RegisterGameFunctionTable(); RegisterGuildFunctionTable(); RegisterHorseFunctionTable(); #ifdef __PET_SYSTEM__ RegisterPetFunctionTable(); #endif RegisterITEMFunctionTable(); RegisterMarriageFunctionTable(); RegisterNPCFunctionTable(); RegisterPartyFunctionTable(); RegisterPCFunctionTable(); RegisterQuestFunctionTable(); RegisterTargetFunctionTable(); RegisterArenaFunctionTable(); RegisterForkedFunctionTable(); RegisterMonarchFunctionTable(); RegisterOXEventFunctionTable(); RegisterMgmtFunctionTable(); RegisterBattleArenaFunctionTable(); RegisterDanceEventFunctionTable(); RegisterDragonLairFunctionTable(); RegisterSpeedServerFunctionTable(); RegisterDragonSoulFunctionTable(); { luaL_reg member_functions[] = { { "chat", member_chat }, { "set_ready", member_set_ready }, { "clear_ready", member_clear_ready }, { NULL, NULL } }; AddLuaFunctionTable("member", member_functions); } { luaL_reg highscore_functions[] = { { "register", highscore_register }, { "show", highscore_show }, { NULL, NULL } }; AddLuaFunctionTable("highscore", highscore_functions); } { luaL_reg mob_functions[] = { { "spawn", mob_spawn }, { "spawn_group", mob_spawn_group }, { NULL, NULL } }; AddLuaFunctionTable("mob", mob_functions); } // // global namespace functions // RegisterGlobalFunctionTable(L); // LUA_INIT_ERROR_MESSAGE { char settingsFileName[256]; snprintf(settingsFileName, sizeof(settingsFileName), "%s/settings.lua", LocaleService_GetBasePath().c_str()); int settingsLoadingResult = lua_dofile(L, settingsFileName); sys_log(0, "LoadSettings(%s), returns %d", settingsFileName, settingsLoadingResult); if (settingsLoadingResult != 0) { sys_err("LOAD_SETTINS_FAILURE(%s)", settingsFileName); return false; } } { char questlibFileName[256]; snprintf(questlibFileName, sizeof(questlibFileName), "%s/questlib.lua", LocaleService_GetQuestPath().c_str()); int questlibLoadingResult = lua_dofile(L, questlibFileName); sys_log(0, "LoadQuestlib(%s), returns %d", questlibFileName, questlibLoadingResult); if (questlibLoadingResult != 0) { sys_err("LOAD_QUESTLIB_FAILURE(%s)", questlibFileName); return false; } } if (LC_IsEurope()) { char translateFileName[256]; snprintf(translateFileName, sizeof(translateFileName), "%s/translate.lua", LocaleService_GetBasePath().c_str()); int translateLoadingResult = lua_dofile(L, translateFileName); sys_log(0, "LoadTranslate(%s), returns %d", translateFileName, translateLoadingResult); if (translateLoadingResult != 0) { sys_err("LOAD_TRANSLATE_ERROR(%s)", translateFileName); return false; } } { char questLocaleFileName[256]; if (LC_IsEurope()) { snprintf(questLocaleFileName, sizeof(questLocaleFileName), "%s/locale.lua", g_stQuestDir.c_str()); } else { snprintf(questLocaleFileName, sizeof(questLocaleFileName), "%s/locale_%s.lua", g_stQuestDir.c_str(), g_stLocale.c_str()); } int questLocaleLoadingResult = lua_dofile(L, questLocaleFileName); sys_log(0, "LoadQuestLocale(%s), returns %d", questLocaleFileName, questLocaleLoadingResult); if (questLocaleLoadingResult != 0) { sys_err("LoadQuestLocale(%s) FAILURE", questLocaleFileName); return false; } } // END_OF_LUA_INIT_ERROR_MESSAGE for (itertype(g_setQuestObjectDir) it = g_setQuestObjectDir.begin(); it != g_setQuestObjectDir.end(); ++it) { const string& stQuestObjectDir = *it; char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/state/", stQuestObjectDir.c_str()); DIR * pdir = opendir(buf); int iQuestIdx = 0; if (pdir) { dirent * pde; while ((pde = readdir(pdir))) { if (pde->d_name[0] == '.') continue; snprintf(buf + 11, sizeof(buf) - 11, "%s", pde->d_name); RegisterQuest(pde->d_name, ++iQuestIdx); int ret = lua_dofile(L, (stQuestObjectDir + "/state/" + pde->d_name).c_str()); sys_log(0, "QUEST: loading %s, returns %d", (stQuestObjectDir + "/state/" + pde->d_name).c_str(), ret); BuildStateIndexToName(pde->d_name); } closedir(pdir); } } #if LUA_V == 503 lua_setgcthreshold(L, 0); #endif lua_newtable(L); lua_setglobal(L, "__codecache"); return true; }
bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName) { CTextFileLoader loader; if (!loader.Load(c_pszFileName)) return false; for (DWORD i = 0; i < loader.GetChildNodeCount(); ++i) { std::string stName(""); loader.GetCurrentNodeName(&stName); if (strncmp (stName.c_str(), "kr_", 3) == 0) { if (LC_IsYMIR()) { stName.assign(stName, 3, stName.size() - 3); } else { continue; } } loader.SetChildNode(i); int iMobVnum = 0; int iKillDrop = 0; int iLevelLimit = 0; std::string strType(""); if (!loader.GetTokenString("type", &strType)) { sys_err("ReadMonsterDropItemGroup : Syntax error %s : no type (kill|drop), node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } if (!loader.GetTokenInteger("mob", &iMobVnum)) { sys_err("ReadMonsterDropItemGroup : Syntax error %s : no mob vnum, node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } if (strType == "kill") { if (!loader.GetTokenInteger("kill_drop", &iKillDrop)) { sys_err("ReadMonsterDropItemGroup : Syntax error %s : no kill drop count, node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } } else { iKillDrop = 1; } if ( strType == "limit" ) { if ( !loader.GetTokenInteger("level_limit", &iLevelLimit) ) { sys_err("ReadmonsterDropItemGroup : Syntax error %s : no level_limit, node %s", c_pszFileName, stName.c_str()); loader.SetParentNode(); return false; } } else { iLevelLimit = 0; } sys_log(0,"MOB_ITEM_GROUP %s [%s] %d %d", stName.c_str(), strType.c_str(), iMobVnum, iKillDrop); if (iKillDrop == 0) { loader.SetParentNode(); continue; } TTokenVector* pTok = NULL; if (strType == "kill") { CMobItemGroup * pkGroup = M2_NEW CMobItemGroup(iMobVnum, iKillDrop, stName); for (int k = 1; k < 256; ++k) { char buf[4]; snprintf(buf, sizeof(buf), "%d", k); if (loader.GetTokenVector(buf, &pTok)) { //sys_log(1, " %s %s", pTok->at(0).c_str(), pTok->at(1).c_str()); std::string& name = pTok->at(0); DWORD dwVnum = 0; if (!GetVnumByOriginalName(name.c_str(), dwVnum)) { str_to_number(dwVnum, name.c_str()); if (!ITEM_MANAGER::instance().GetTable(dwVnum)) { sys_err("ReadMonsterDropItemGroup : there is no item %s : node %s : vnum %d", name.c_str(), stName.c_str(), dwVnum); return false; } } int iCount = 0; str_to_number(iCount, pTok->at(1).c_str()); if (iCount<1) { sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s : vnum %d, count %d", name.c_str(), stName.c_str(), dwVnum, iCount); return false; } int iPartPct = 0; str_to_number(iPartPct, pTok->at(2).c_str()); if (iPartPct == 0) { sys_err("ReadMonsterDropItemGroup : there is no drop percent for item %s : node %s : vnum %d, count %d, pct %d", name.c_str(), stName.c_str(), iPartPct); return false; } int iRarePct = 0; str_to_number(iRarePct, pTok->at(3).c_str()); iRarePct = MINMAX(0, iRarePct, 100); sys_log(0," %s count %d rare %d", name.c_str(), iCount, iRarePct); pkGroup->AddItem(dwVnum, iCount, iPartPct, iRarePct); continue; } break; } m_map_pkMobItemGroup.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup)); } else if (strType == "drop") { CDropItemGroup* pkGroup; bool bNew = true; itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find (iMobVnum); if (it == m_map_pkDropItemGroup.end()) { pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName); } else { bNew = false; CDropItemGroup* pkGroup = it->second; } for (int k = 1; k < 256; ++k) { char buf[4]; snprintf(buf, sizeof(buf), "%d", k); if (loader.GetTokenVector(buf, &pTok)) { std::string& name = pTok->at(0); DWORD dwVnum = 0; if (!GetVnumByOriginalName(name.c_str(), dwVnum)) { str_to_number(dwVnum, name.c_str()); if (!ITEM_MANAGER::instance().GetTable(dwVnum)) { sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str()); M2_DELETE(pkGroup); return false; } } int iCount = 0; str_to_number(iCount, pTok->at(1).c_str()); if (iCount < 1) { sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str()); M2_DELETE(pkGroup); return false; } float fPercent = atof(pTok->at(2).c_str()); DWORD dwPct = (DWORD)(10000.0f * fPercent); sys_log(0," name %s pct %d count %d", name.c_str(), dwPct, iCount); pkGroup->AddItem(dwVnum, dwPct, iCount); continue; } break; } if (bNew) m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup)); } else if ( strType == "limit" ) { CLevelItemGroup* pkLevelItemGroup = M2_NEW CLevelItemGroup(iLevelLimit); for ( int k=1; k < 256; k++ ) { char buf[4]; snprintf(buf, sizeof(buf), "%d", k); if ( loader.GetTokenVector(buf, &pTok) ) { std::string& name = pTok->at(0); DWORD dwItemVnum = 0; if (false == GetVnumByOriginalName(name.c_str(), dwItemVnum)) { str_to_number(dwItemVnum, name.c_str()); if ( !ITEM_MANAGER::instance().GetTable(dwItemVnum) ) { M2_DELETE(pkLevelItemGroup); return false; } } int iCount = 0; str_to_number(iCount, pTok->at(1).c_str()); if (iCount < 1) { M2_DELETE(pkLevelItemGroup); return false; } float fPct = atof(pTok->at(2).c_str()); DWORD dwPct = (DWORD)(10000.0f * fPct); pkLevelItemGroup->AddItem(dwItemVnum, dwPct, iCount); continue; } break; } m_map_pkLevelItemGroup.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup)); } else if (strType == "thiefgloves") { CBuyerThiefGlovesItemGroup* pkGroup = M2_NEW CBuyerThiefGlovesItemGroup(0, iMobVnum, stName); for (int k = 1; k < 256; ++k) { char buf[4]; snprintf(buf, sizeof(buf), "%d", k); if (loader.GetTokenVector(buf, &pTok)) { std::string& name = pTok->at(0); DWORD dwVnum = 0; if (!GetVnumByOriginalName(name.c_str(), dwVnum)) { str_to_number(dwVnum, name.c_str()); if (!ITEM_MANAGER::instance().GetTable(dwVnum)) { sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str()); M2_DELETE(pkGroup); return false; } } int iCount = 0; str_to_number(iCount, pTok->at(1).c_str()); if (iCount < 1) { sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str()); M2_DELETE(pkGroup); return false; } float fPercent = atof(pTok->at(2).c_str()); DWORD dwPct = (DWORD)(10000.0f * fPercent); sys_log(0," name %s pct %d count %d", name.c_str(), dwPct, iCount); pkGroup->AddItem(dwVnum, dwPct, iCount); continue; } break; } m_map_pkGloveItemGroup.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup)); } else { sys_err("ReadMonsterDropItemGroup : Syntax error %s : invalid type %s (kill|drop), node %s", c_pszFileName, strType.c_str(), stName.c_str()); loader.SetParentNode(); return false; } loader.SetParentNode(); } return true; }