⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directive.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////////////////// Filename    : Directive.cpp// Written By  : 辫己刮// Description : // MonsterAI俊辑 青悼阑 搬沥窍绰 Directive客 DirectiveSet阑// 备泅秦初篮 颇老捞促.////////////////////////////////////////////////////////////////////////#include "Directive.h"#include "StringStream.h"#include "DB.h"#include "Assert.h"#include <string.h>#include <stdio.h>#include "skill/Skill.h"// 惑荐甸...#define MODE_CONDITION   0#define MODE_ACTION      1// 傈开 函荐DirectiveSetManager* g_pDirectiveSetManager = NULL;////////////////////////////////////////////////////////////////////////// class Directive member methods////////////////////////////////////////////////////////////////////////Directive::Directive()	throw(){	__BEGIN_TRY	m_Action    = 0;	m_Parameter = 0;	m_Ratio     = 0;	m_Weight    = 0;	__END_CATCH}Directive::~Directive()	throw(){	__BEGIN_TRY	m_Conditions.clear();	__END_CATCH}void Directive::addCondition(int condition) 	throw(){	__BEGIN_TRY	// 鞍篮 牧叼记捞 乐瘤 臼篮瘤 八荤茄促.	list<int>::iterator itr = m_Conditions.begin();	for (; itr != m_Conditions.end(); itr++)	{		if (condition == *itr) return;	}	m_Conditions.push_back(condition);	__END_CATCH}string Directive::toString()	throw(){	__BEGIN_TRY	StringStream msg;	// header	msg << "Directive(";	// condition output	msg	<< "Condition : ";	list<int>::const_iterator itr = m_Conditions.begin();	for (; itr != m_Conditions.end(); itr++)		msg << DirectiveCondition2String[*itr] << ",";	msg << " ";	// action output	msg << "Action : " << DirectiveAction2String[m_Action] << " ";	// parameter output	if (m_Parameter != 0)		msg << "Parameter : " << SkillTypes2String[m_Parameter] << " ";	// ratio output	if (m_Ratio != 0)		msg << "Ratio : " << m_Ratio;	// tail 	msg << ")";	return msg.toString();	__END_CATCH}////////////////////////////////////////////////////////////////////////// class DirectiveSet member methods////////////////////////////////////////////////////////////////////////DirectiveSet::DirectiveSet()	throw(){	__BEGIN_TRY	__END_CATCH}DirectiveSet::~DirectiveSet()	throw(){	__BEGIN_TRY	// 府胶飘甫 八祸窍搁辑 Directive 按眉甫 昏力茄促.	list<Directive*>::iterator itr = m_Directives.begin();	for (; itr != m_Directives.end(); itr++)	{		Directive* pDirective = *itr;		SAFE_DELETE(pDirective);	}	m_Directives.clear();	__END_CATCH}void DirectiveSet::clear()	throw(){	__BEGIN_TRY	// 府胶飘甫 八祸窍搁辑 Directive 按眉甫 昏力茄促.	list<Directive*>::iterator itr = m_Directives.begin();	for (; itr != m_Directives.end(); itr++)	{		Directive* pDirective = *itr;		SAFE_DELETE(pDirective);	}	m_Directives.clear();	__END_CATCH}bool DirectiveSet::hasCondition( int condition ) const{	list<Directive*>::const_iterator itr = m_Directives.begin();	list<Directive*>::const_iterator endItr = m_Directives.end();	for (; itr != endItr; ++itr)	{		if ( (*itr)->hasCondition(condition) ) return true;	}	return false;}void DirectiveSet::addDirective(Directive* pDirective)	throw(){	__BEGIN_TRY	m_Directives.push_back(pDirective);		__END_CATCH}void DirectiveSet::addDeadDirective(Directive* pDirective)	throw(){	__BEGIN_TRY	m_DeadDirectives.push_back(pDirective);		__END_CATCH}////////////////////////////////////////////////////////////////////////// 积己磊////////////////////////////////////////////////////////////////////////DirectiveSetManager::DirectiveSetManager()	throw(){	__BEGIN_TRY	m_nSetCount = 0;	m_ppSet     = NULL;	__END_CATCH}////////////////////////////////////////////////////////////////////////// 家戈磊////////////////////////////////////////////////////////////////////////DirectiveSetManager::~DirectiveSetManager()	throw(){	__BEGIN_TRY	if (m_ppSet)	{		for (uint i=0; i<m_nSetCount; i++)		{			SAFE_DELETE(m_ppSet[i]);		}		SAFE_DELETE_ARRAY(m_ppSet);	// 捞霸 阂妨龙 老篮 绝摆瘤父.. -_-; by sigi	}	__END_CATCH}////////////////////////////////////////////////////////////////////////// init()// 按眉甫 檬扁拳茄促. 檬扁拳绰 ObjectManager俊辑...////////////////////////////////////////////////////////////////////////void DirectiveSetManager::init()	throw(){	__BEGIN_TRY	load();	__END_CATCH}////////////////////////////////////////////////////////////////////////// load()// DB俊辑 葛电 DirectiveSet阑 肺靛茄促. // MonsterAI 按眉甸篮 肺靛等 DirectiveSet俊 措茄 器牢磐父阑 啊瘤霸 等促.////////////////////////////////////////////////////////////////////////void DirectiveSetManager::load()	throw(){	__BEGIN_TRY	Statement* pStmt   = NULL;	Result*    pResult = NULL;	BEGIN_DB	{		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		// 悸狼 箭磊甫 佬绢柯促.		pResult = pStmt->executeQuery("SELECT MAX(ID) FROM DirectiveSet");		if (pResult->getRowCount() == 0) throw ("DirectiveSetManager::load() : 抛捞喉俊 绝嚼聪促.");		pResult->next();		m_nSetCount = pResult->getInt(1)+1;		// 佬绢甸牢 箭磊父怒 皋葛府甫 且寸窍绊...		if (m_ppSet==NULL)		{			m_ppSet = new (DirectiveSet*)[m_nSetCount];			Assert(m_ppSet != NULL);			for (uint i=0; i<m_nSetCount; i++)			{				m_ppSet[i] = NULL;			}		}		// 阿阿狼 directive甫 佬绢甸牢促.		pResult = pStmt->executeQuery("SELECT ID, Name, Content, DeadContent FROM DirectiveSet");		while (pResult->next())		{			uint   index    = pResult->getInt(1);			string name     = pResult->getString(2);			string text     = pResult->getString(3);			string deadtext = pResult->getString(4);			printf("ID[%d] Directive Loading Begin >> ", index);			////////////////			///filelog("Directive.txt", "===============================================");			//filelog("Directive.txt", "Name:%s", name.c_str());			////////////////			createDirectiveSet(index, name, text, deadtext);			printf("Loading End\n");		}		SAFE_DELETE(pStmt);	}	END_DB(pStmt)	__END_CATCH}////////////////////////////////////////////////////////////////////////// getDirectiveSet()// 瘤沥等 鸥涝狼 DirectiveSet狼 器牢磐甫 府畔茄促.////////////////////////////////////////////////////////////////////////DirectiveSet* DirectiveSetManager::getDirectiveSet(uint index)	throw(){	__BEGIN_TRY	if (index >= m_nSetCount)	{		cerr << "DirectiveSetManager::getDirectiveSet() : Out of bounds, value = [" << index << "]" << endl;		throw("DirectiveSetManager::getDirectiveSet() : Out of bounds!");	}	return m_ppSet[index];	__END_CATCH}////////////////////////////////////////////////////////////////////////// createDirectiveSet()// 巩磊凯阑 颇教秦辑 瘤沥等 牢郸胶狼 磊府俊促 DirectiveSet阑 积己.////////////////////////////////////////////////////////////////////////void DirectiveSetManager::createDirectiveSet(uint index, const string& name, const string& text, const string& deadtext)	throw(){	__BEGIN_TRY	if (index >= m_nSetCount)	{		cerr << "DirectiveSetManager::createDirectiveSet() : Out of bounds!" << endl;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -