📄 masterlairinfomanager.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : MasterLairInfoManager.cpp// Written By : reiot// Description ://////////////////////////////////////////////////////////////////////////////#include "MasterLairInfoManager.h"#include "MonsterInfo.h"#include "ZoneInfo.h"#include "ZoneInfoManager.h"#include "DB.h"#include "Assert.h"//////////////////////////////////////////////////////////////////////////////// constructor//////////////////////////////////////////////////////////////////////////////MasterLairInfo::MasterLairInfo(){ m_ZoneID = 0; m_MasterMonsterType = 0; m_MasterNotReadyMonsterType = 0; m_MasterRemainNotReady = false; m_MasterX = 0; m_MasterY = 0; m_MasterDir = 0; m_MaxPassPlayer = 0; //m_MaxSummonMonster = 0; m_SummonX = 0; m_SummonY = 0; m_FirstRegenDelay = 0; m_RegenDelay = 0; m_StartDelay = 0; m_EndDelay = 0; m_KickOutDelay = 0; m_KickZoneID = 0; m_KickZoneX = 0; m_KickZoneY = 0; m_LairAttackTick = 0; m_LairAttackMinNumber = 0; m_LairAttackMaxNumber = 0;}MasterLairInfo::~MasterLairInfo(){}// a bc// "hihihi", "dsfsdfsd sdfds, sfd", "anfdsf"void MasterLairInfo::setSayText(vector<string>& sayWords, const string& text) throw(){ sayWords.clear(); if (text.empty()) return; uint a=0, b=0, c=0; while (c < text.size()) { a = text.find_first_of('\"', c); b = text.find_first_of('\"', a+1); c = text.find_first_of(',', b+1); if (a==string::npos || b==string::npos) break; string words = text.substr(a+1, b-a-1); sayWords.push_back( words );// cout << "SayWord: " << words.c_str() << endl; }}void MasterLairInfo::setMasterSummonSay(const string& text) throw(){ setSayText(m_MasterSummonSay, text);}void MasterLairInfo::setMasterDeadSlayerSay(const string& text) throw(){ setSayText(m_MasterDeadSlayerSay, text);}void MasterLairInfo::setMasterDeadVampireSay(const string& text) throw(){ setSayText(m_MasterDeadVampireSay, text);}void MasterLairInfo::setMasterNotDeadSay(const string& text) throw(){ setSayText(m_MasterNotDeadSay, text);}const string& MasterLairInfo::getRandomMasterSummonSay() const throw(){ static string stringNULL = ""; if (m_MasterSummonSay.empty()) return stringNULL; return m_MasterSummonSay[rand()%m_MasterSummonSay.size()];}const string& MasterLairInfo::getRandomMasterDeadSlayerSay() const throw(){ static string stringNULL = ""; if (m_MasterDeadSlayerSay.empty()) return stringNULL; return m_MasterDeadSlayerSay[rand()%m_MasterDeadSlayerSay.size()];}const string& MasterLairInfo::getRandomMasterDeadVampireSay() const throw(){ static string stringNULL = ""; if (m_MasterDeadVampireSay.empty()) return stringNULL; return m_MasterDeadVampireSay[rand()%m_MasterDeadVampireSay.size()];}const string& MasterLairInfo::getRandomMasterNotDeadSay() const throw(){ static string stringNULL = ""; if (m_MasterNotDeadSay.empty()) return stringNULL; return m_MasterNotDeadSay[rand()%m_MasterNotDeadSay.size()];}stringMasterLairInfo::toString() const throw(){ __BEGIN_TRY StringStream msg; msg << "MasterLairInfo(" << "ZoneID:" << (int)m_ZoneID << ",MasterNotReadyMonsterType:" << (int)m_MasterNotReadyMonsterType << ",MasterMonsterType:" << (int)m_MasterMonsterType << ",MasterRemainNotReady:" << (int)m_MasterRemainNotReady << ",MasterX:" << (int)m_MasterX << ",MasterY:" << (int)m_MasterY << ",MasterDir:" << (int)m_MasterDir << ",MaxPassPlayer:" << (int)m_MaxPassPlayer //<< ",MaxSummonMonster:" << (int)m_MaxSummonMonster << ",SummonX:" << (int)m_SummonX << ",SummonY:" << (int)m_SummonY << ",FirstRegenDelay:" << (int)m_FirstRegenDelay << ",RegenDelay:" << (int)m_RegenDelay << ",StartDelay:" << (int)m_StartDelay << ",EndDelay:" << (int)m_EndDelay << ",KickOutDelay:" << (int)m_KickOutDelay << ",KickZoneID:" << (int)m_KickZoneID << ",KickZoneX:" << (int)m_KickZoneX << ",KickZoneY:" << (int)m_KickZoneY << ",LairAttackTick:" << (int)m_LairAttackTick << ",LairAttackMinNumber:" << (int)m_LairAttackMinNumber << ",LairAttackMaxNumber:" << (int)m_LairAttackMaxNumber << ")"; return msg.toString(); __END_CATCH}//////////////////////////////////////////////////////////////////////////////// constructor//////////////////////////////////////////////////////////////////////////////MasterLairInfoManager::MasterLairInfoManager () throw (){ __BEGIN_TRY __END_CATCH}//////////////////////////////////////////////////////////////////////////////// destructor//////////////////////////////////////////////////////////////////////////////MasterLairInfoManager::~MasterLairInfoManager () throw (){ __BEGIN_TRY hash_map< ZoneID_t , MasterLairInfo *>::iterator itr = m_MasterLairInfos.begin(); for (; itr != m_MasterLairInfos.end(); itr++) { MasterLairInfo* pInfo = itr->second; SAFE_DELETE(pInfo); } // 秦浆甘救俊 乐绰 葛电 pair 甸阑 昏力茄促. m_MasterLairInfos.clear(); __END_CATCH} //////////////////////////////////////////////////////////////////////////////// initialize zone info manager//////////////////////////////////////////////////////////////////////////////void MasterLairInfoManager::init () throw (Error){ __BEGIN_TRY // init == load load(); __END_CATCH} //void testMaxMemory();//////////////////////////////////////////////////////////////////////////////// load from database//////////////////////////////////////////////////////////////////////////////void MasterLairInfoManager::load () throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; BEGIN_DB { // create statement pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); Result* pResult = pStmt->executeQuery( "SELECT ZoneID, MasterNotReadyMonsterType, MasterMonsterType, MasterRemainNotReady, MasterX, MasterY, MasterDir, MaxPassPlayer, SummonX, SummonY, FirstRegenDelay, RegenDelay, StartDelay, EndDelay, KickOutDelay, KickZoneID, KickZoneX, KickZoneY, LairAttackTick, LairAttackMinNumber, LairAttackMaxNumber, MasterSummonSay, MasterDeadSlayerSay, MasterDeadVampireSay, MasterNotDeadSay FROM MasterLairInfo"); while (pResult->next()) { uint i = 0; ZoneID_t zoneID = pResult->getInt(++i); ZoneInfo* pZoneInfo = g_pZoneInfoManager->getZoneInfo( zoneID ); Assert( pZoneInfo!=NULL ); pZoneInfo->setMasterLair(); MasterLairInfo* pMasterLairInfo = new MasterLairInfo(); //cout << "new OK" << endl; pMasterLairInfo->setZoneID( zoneID ); pMasterLairInfo->setMasterNotReadyMonsterType( pResult->getInt(++i) ); pMasterLairInfo->setMasterMonsterType( pResult->getInt(++i) ); pMasterLairInfo->setMasterRemainNotReady( pResult->getInt(++i)!=0 ); pMasterLairInfo->setMasterX( pResult->getInt(++i) ); pMasterLairInfo->setMasterY( pResult->getInt(++i) ); pMasterLairInfo->setMasterDir( pResult->getInt(++i) ); pMasterLairInfo->setMaxPassPlayer( pResult->getInt(++i) ); //pMasterLairInfo->setMaxSummonMonster( pResult->getInt(++i) ); pMasterLairInfo->setSummonX( pResult->getInt(++i) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -