conditioneverytime.cpp

来自「dk1游戏的原代码文件,完整.编译系统redhat7.3,mysql 3.23 」· C++ 代码 · 共 79 行

CPP
79
字号
////////////////////////////////////////////////////////////////////////////////// Filename    : ConditionEveryTime.cpp// Written By  : // Description :////////////////////////////////////////////////////////////////////////////////#include "ConditionEveryTime.h"////////////////////////////////////////////////////////////////////////////////// is satisfied?////////////////////////////////////////////////////////////////////////////////bool ConditionEveryTime::isSatisfied (Creature * pCreature1 , Creature * pCreature2, void* pParam) const 	throw () { 	Timeval currentTime;	getCurrentTime(currentTime);	bool expired = pCreature1 != NULL && pCreature2 == NULL && currentTime > m_NextTurn;	////////////////////////////////////////////////////////////////////////////////	// 矫埃捞 檬苞登菌栏搁, 促澜 角青矫埃阑 m_Turn 捞饶肺 犁汲沥茄促.	////////////////////////////////////////////////////////////////////////////////	if (expired)	{		Timeval delay;		delay.tv_sec = m_Turn / 10;		delay.tv_usec = (m_Turn % 10) * 100000;		m_NextTurn = m_NextTurn + delay;	}	return expired;}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void ConditionEveryTime::read (PropertyBuffer & propertyBuffer) 	throw (Error){	try	{		// read turn		m_Turn = propertyBuffer.getPropertyInt("Turn");	}	catch (NoSuchElementException & nsee)	{		throw Error(nsee.toString());	}	// set next turn (current time + m_Turn)	Timeval delay;	delay.tv_sec = m_Turn / 10;			delay.tv_usec = (m_Turn % 10) * 100000;	getCurrentTime(m_NextTurn);	m_NextTurn = m_NextTurn + delay;}////////////////////////////////////////////////////////////////////////////////	// get debug string////////////////////////////////////////////////////////////////////////////////string ConditionEveryTime::toString () const 	throw () { 	__BEGIN_TRY	StringStream msg;	msg << "ConditionEveryTime("			<< "Turn:"      << (int)m_Turn			<< ",NextTurn:" << (int)m_NextTurn.tv_sec 			<< "."          << (int)m_NextTurn.tv_usec			<< ")"; 	return msg.toString();	__END_CATCH}

⌨️ 快捷键说明

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