merge
commit
e6e1d2e3fe
@ -0,0 +1,15 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
@ -1,2 +1,17 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdpch.h"
|
||||
|
@ -1,24 +0,0 @@
|
||||
/** This file declare a pure nel module library */
|
||||
|
||||
|
||||
#include "nel/net/module_manager.h"
|
||||
#include "nel/net/module.h"
|
||||
#include "nel/net/module_builder_parts.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLNET;
|
||||
|
||||
extern void as_forceLink();
|
||||
extern void aes_forceLink();
|
||||
extern void aesclient_forceLink();
|
||||
|
||||
void admin_modules_forceLink()
|
||||
{
|
||||
as_forceLink();
|
||||
aes_forceLink();
|
||||
aesclient_forceLink();
|
||||
}
|
||||
|
||||
//NLMISC_DECL_PURE_LIB(CNelModuleLibrary);
|
||||
|
@ -1,485 +0,0 @@
|
||||
/** \file actor_manager.cpp
|
||||
*
|
||||
* the actor manager for AgS_Test
|
||||
*
|
||||
* $Id: actor_manager.cpp,v 1.34 2004/06/14 12:34:17 brigand Exp $
|
||||
* $Log: actor_manager.cpp,v $
|
||||
* Revision 1.34 2004/06/14 12:34:17 brigand
|
||||
* CHANGED : updated to new PDS people enum
|
||||
*
|
||||
* Revision 1.33 2004/03/01 19:18:37 lecroart
|
||||
* REMOVED: bad headers
|
||||
*
|
||||
* Revision 1.32 2004/01/13 18:47:07 cado
|
||||
* ADDED: Mirror tests
|
||||
*
|
||||
* Revision 1.31 2003/10/21 08:48:19 legros
|
||||
* ADDED: multi target commands
|
||||
*
|
||||
* Revision 1.30 2003/10/02 16:13:15 legros
|
||||
* no message
|
||||
*
|
||||
* Revision 1.29 2003/10/01 14:29:32 legros
|
||||
* no message
|
||||
*
|
||||
* Revision 1.28 2003/09/30 16:03:15 legros
|
||||
* CHANGED: ags test is now up to date...
|
||||
*
|
||||
* Revision 1.27 2003/07/16 15:51:19 cado
|
||||
* CHANGED: First-pass to re-adapt to mirror system V1.4
|
||||
*
|
||||
* Revision 1.26 2003/07/16 14:34:06 boucher
|
||||
* no message
|
||||
*
|
||||
* Revision 1.25 2003/02/26 10:24:19 cado
|
||||
* CHANGED: changed all properties to new mirror, no more old mirror
|
||||
*
|
||||
* Revision 1.24 2003/02/24 10:44:44 cado
|
||||
* ADDED: Adapted for new mirror system
|
||||
*
|
||||
* Revision 1.23 2003/01/28 20:36:51 miller
|
||||
* Changed header comments from 'Nel Network Services' to Ryzom
|
||||
*
|
||||
* Revision 1.22 2002/11/29 10:17:50 portier
|
||||
* #ADDED: ia_player.id
|
||||
*
|
||||
* Revision 1.21.2.1 2003/01/03 18:18:02 cado
|
||||
* ADDED: Integration with new mirror system
|
||||
*
|
||||
* Revision 1.21 2002/11/15 16:22:42 fleury
|
||||
* CHANGED : the OPS has been replaced by the EGS
|
||||
*
|
||||
* Revision 1.20 2002/08/30 08:47:34 miller
|
||||
* another quick test (non destructive)
|
||||
*
|
||||
* Revision 1.19 2002/08/30 08:46:09 miller
|
||||
* quick test (non destructive)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Nel
|
||||
//#include "nel/net/service.h"
|
||||
|
||||
|
||||
// Local headers
|
||||
#include "position_generator.h"
|
||||
#include "actor_manager.h"
|
||||
#include "sheets.h"
|
||||
#include <nel/net/unified_network.h>
|
||||
#include "game_share/people.h"
|
||||
#include "game_share/synchronised_message.h"
|
||||
|
||||
#include "nel/misc/variable.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace NLNET;
|
||||
using namespace std;
|
||||
|
||||
|
||||
namespace AGS_TEST
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Some global variables
|
||||
extern uint32 GlobalActorCount;
|
||||
extern uint32 GlobalActorUpdates;
|
||||
extern uint32 GlobalActorMoves;
|
||||
|
||||
CEntityId LastActorId;
|
||||
|
||||
NLMISC_DYNVARIABLE(string, LastActorId, "Last created actor")
|
||||
{
|
||||
if (get)
|
||||
*pointer = LastActorId.toString();
|
||||
else
|
||||
LastActorId.fromString((*pointer).c_str());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Some function prototypes
|
||||
|
||||
static void cbServiceUp( const string& serviceName, uint16 serviceId, void * );
|
||||
static void cbServiceDown( const string& serviceName, uint16 serviceId, void * );
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// static data for CActorManager
|
||||
|
||||
std::vector<CActor*> CActorManager::_actors;
|
||||
std::vector<CActorGroup*> CActorManager::_actorGroups;
|
||||
int CActorManager::_nextActorID=0;
|
||||
std::set<uint> CActorManager::_visionHandlingServices;
|
||||
CActorGroup *CActorManager::_defaultActorGroup;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// basic functionality for CActorManager singleton
|
||||
|
||||
void CActorManager::init()
|
||||
{
|
||||
static bool first_time=true;
|
||||
|
||||
if (first_time)
|
||||
{
|
||||
// Init callback for service up / down
|
||||
CUnifiedNetwork::getInstance()->setServiceUpCallback ("*", cbServiceUp, NULL);
|
||||
CUnifiedNetwork::getInstance()->setServiceDownCallback("*", cbServiceDown, NULL);
|
||||
first_time=false;
|
||||
}
|
||||
else
|
||||
release();
|
||||
|
||||
_nextActorID=0;
|
||||
/*
|
||||
CPositionGenerator::setPattern(std::string("grid"));
|
||||
CPositionGenerator::setPosition(17981,-33200);
|
||||
CPositionGenerator::setSpacing(2000);
|
||||
*/
|
||||
_defaultActorGroup = newActorGroup("defaultGroup");
|
||||
}
|
||||
|
||||
void CActorManager::update()
|
||||
{
|
||||
set< pair<sint32, sint32> > iaZones;
|
||||
|
||||
std::vector<CActorGroup*>::iterator itg;
|
||||
for (itg=_actorGroups.begin(); itg!=_actorGroups.end(); ++itg)
|
||||
(*itg)->update();
|
||||
|
||||
|
||||
// iterate through all known actors, calling their update
|
||||
uint16 positionChangeCount=0;
|
||||
uint16 updateCount=0;
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
bool updated= (*it)->update();
|
||||
if (updated)
|
||||
updateCount++;
|
||||
/*
|
||||
if ((*it)->positionChanged())
|
||||
positionChangeCount++;
|
||||
|
||||
sint32 zx = (*it)->getX()/160000;
|
||||
sint32 zy = -(*it)->getY()/160000;
|
||||
|
||||
iaZones.insert(make_pair<sint32,sint32>(zx, zy));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// for all entities, request vision zones
|
||||
/*CMessage msg("AGENT_VISON");
|
||||
sint64 fakeId = 0;
|
||||
msg.serial(fakeId);
|
||||
sint32 pos = msg.getPos();
|
||||
set< pair<sint32, sint32> >::iterator itz;
|
||||
for (itz=iaZones.begin(); itz!=iaZones.end(); ++itz)
|
||||
{
|
||||
sint32 x = (*itz).first,
|
||||
y = (*itz).second;
|
||||
msg.serial(x);
|
||||
msg.serial(y);
|
||||
}
|
||||
if (msg.getPos() > pos)
|
||||
CUnifiedNetwork::getInstance()->send("GPMS", msg);*/
|
||||
/*
|
||||
// build the position changed message and send it to GPMS
|
||||
if (positionChangeCount>0)
|
||||
{
|
||||
NLNET::CMessage gpmPosMsg("UPDATE_ENTITIES_POSITIONS");
|
||||
gpmPosMsg.serial(positionChangeCount);
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
(*it)->addPositionChangesToMessage(gpmPosMsg);
|
||||
|
||||
sendMessageViaMirror( "GPMS", gpmPosMsg );
|
||||
}
|
||||
*/
|
||||
GlobalActorUpdates=updateCount;
|
||||
//GlobalActorMoves=positionChangeCount;
|
||||
}
|
||||
|
||||
void CActorManager::release()
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
(*it)->removeFromOtherServices();
|
||||
}
|
||||
_actors.clear();
|
||||
}
|
||||
|
||||
// Callback called at service connexion
|
||||
static void cbServiceUp( const string& serviceName, uint16 serviceId, void * )
|
||||
{
|
||||
/*if (serviceName==std::string("EGS"))
|
||||
CActorManager::reconnectEGS((uint8)serviceId);
|
||||
|
||||
if (serviceName==std::string("IOS"))
|
||||
CActorManager::reconnectIOS((uint8)serviceId);
|
||||
|
||||
if (serviceName==std::string("GPMS"))
|
||||
CActorManager::reconnectGPMS((uint8)serviceId);*/
|
||||
|
||||
/*CMessage reqVision("ASK_VISION_ZONE");
|
||||
CUnifiedNetwork::getInstance()->send(serviceId, reqVision);*/
|
||||
}
|
||||
|
||||
//
|
||||
static void cbServiceDown( const string& serviceName, uint16 serviceId, void * )
|
||||
{
|
||||
CActorManager::removeVisionService(serviceId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// methods for dealing with tardy connection of a key service
|
||||
/*void CActorManager::reconnectEGS(uint8 serviceId)
|
||||
{
|
||||
}
|
||||
|
||||
void CActorManager::reconnectIOS(uint8 serviceId)
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
(*it)->addToIOS(serviceId);
|
||||
}
|
||||
}
|
||||
|
||||
void CActorManager::reconnectGPMS(uint8 serviceId)
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
(*it)->addToGPMS(serviceId);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// CActorManager methods for creating and killing actors
|
||||
|
||||
// method for adding a new actor to the scene
|
||||
CActor *CActorManager::newActor(const std::string &type, const std::string &name)
|
||||
{
|
||||
LastActorId = CEntityId::Unknown;
|
||||
|
||||
if (getActor(name)!=NULL)
|
||||
{
|
||||
nlinfo("Actor already exists: %s",name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSheetId sheetId(type);
|
||||
const CSheets::CSheet *sheet=CSheets::lookup(sheetId);
|
||||
if (!sheet)
|
||||
{
|
||||
nlwarning("ERROR: Can't find static type data for '%s'(%d) for entity %s", type.c_str(), sheetId.asInt(), name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create a new actor record and COPY it into the actor vector
|
||||
|
||||
// EGSPD::CPeople::TPeople p_type = EGSPD::CPeople::fromString( type );
|
||||
bool success = false;
|
||||
CActor *aNewActor;
|
||||
if ( sheet->isNpc /*EGSPD::CPeople::isPlayableRace( p_type )*/ )
|
||||
aNewActor = new CActor(type,name,CEntityId(RYZOMID::npc,_nextActorID++),success);
|
||||
else
|
||||
aNewActor = new CActor(type,name,CEntityId(RYZOMID::creature,_nextActorID++),success);
|
||||
|
||||
if ( ! success )
|
||||
{
|
||||
if (aNewActor)
|
||||
delete aNewActor;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LastActorId = aNewActor->_id;
|
||||
|
||||
int x,y;
|
||||
CPositionGenerator::next(x,y);
|
||||
aNewActor->setPos(x, y, 0);
|
||||
aNewActor->setAngle(0);
|
||||
_actors.push_back(aNewActor);
|
||||
|
||||
// get hold of a pointer of the copy of the actor in the actor vector
|
||||
CActor *theActor=getActor(name);
|
||||
|
||||
// add the actor to the GPMS, the IOS, etc
|
||||
if (theActor!=0)
|
||||
theActor->addToOtherServices();
|
||||
/*
|
||||
CMessage msgMode("SET_MODE");
|
||||
TDataSetRow index = CMirrors::DataSet->getDataSetRow(theActor->_id);
|
||||
msgMode.serial(index);
|
||||
MBEHAV::TMode mode(MBEHAV::NORMAL, x, y);
|
||||
msgMode.serial(mode);
|
||||
sendMessageViaMirror("EGS", msgMode);
|
||||
*/
|
||||
CMirrors::initSheet( aNewActor->getSid(), sheetId ); // initialize out the sheet
|
||||
// Let the position & angle & tick be sent ("UPDATE_ENTITIES_POSITIONS") in update
|
||||
//aNewActor->initMode();
|
||||
|
||||
MBEHAV::TMode mode(MBEHAV::NORMAL, x, y);
|
||||
theActor->_mode = mode.RawModeAndParam;
|
||||
|
||||
aNewActor->display();
|
||||
theActor->setGroup(_defaultActorGroup);
|
||||
|
||||
GlobalActorCount++;
|
||||
return theActor;
|
||||
}
|
||||
|
||||
// method for retrievng a pointer to a named actor
|
||||
// returns NULL if the actor doesn't exist
|
||||
CActor *CActorManager::getActor(const std::string &name)
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName()==name)
|
||||
return (*it);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// method for retrievng a pointer to given actor
|
||||
CActor *CActorManager::getActor(unsigned index)
|
||||
{
|
||||
if (index>=_actors.size())
|
||||
return NULL;
|
||||
else
|
||||
return (_actors[index]);
|
||||
}
|
||||
|
||||
// method for retrievng a pointer to given actor
|
||||
CActor *CActorManager::getActor(const NLMISC::CEntityId &id)
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
if ((*it)->getSid()==id)
|
||||
return (*it);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CActorManager::killActor(const std::string &name)
|
||||
{
|
||||
std::vector<CActor*>::iterator it;
|
||||
for (it=_actors.begin(); it!=_actors.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName()==name)
|
||||
{
|
||||
// remove from net refferences
|
||||
(*it)->removeFromOtherServices();
|
||||
|
||||
// remove from vision xrefs
|
||||
std::vector<CActor*>::iterator it2;
|
||||
for (it2=_actors.begin(); it2!=_actors.end(); ++it2)
|
||||
{
|
||||
(*it2)->removeRefs(*it);
|
||||
}
|
||||
|
||||
for (int i=_actorGroups.size();i--;)
|
||||
_actorGroups[i]->removeActor(*it);
|
||||
|
||||
// remove from container
|
||||
delete *it;
|
||||
_actors.erase(it);
|
||||
GlobalActorCount--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// basic functionality for actor group management
|
||||
|
||||
// method for adding a new actorGroup to the scene
|
||||
CActorGroup *CActorManager::newActorGroup(const std::string &name)
|
||||
{
|
||||
if (!getActorGroup(name))
|
||||
{
|
||||
// create a new actorGroup record and COPY it into the actorGroup vector
|
||||
CActorGroup *aNewActorGroup = new CActorGroup(name);
|
||||
_actorGroups.push_back(aNewActorGroup);
|
||||
aNewActorGroup->display();
|
||||
}
|
||||
|
||||
// get hold of a pointer of the copy of the actorGroup in the actorGroup vector
|
||||
return getActorGroup(name);
|
||||
}
|
||||
|
||||
// method for retrievng a pointer to a named actorGroup
|
||||
// returns NULL if the actorGroup doesn't exist
|
||||
CActorGroup *CActorManager::getActorGroup(const std::string &name)
|
||||
{
|
||||
std::vector<CActorGroup*>::iterator it;
|
||||
for (it=_actorGroups.begin(); it!=_actorGroups.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName()==name)
|
||||
return (*it);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// method for retrievng a pointer to given actorGroup
|
||||
CActorGroup *CActorManager::getActorGroup(unsigned index)
|
||||
{
|
||||
if (index>=_actorGroups.size())
|
||||
return NULL;
|
||||
else
|
||||
return (_actorGroups[index]);
|
||||
}
|
||||
|
||||
void CActorManager::removeActorGroup(const std::string &name)
|
||||
{
|
||||
std::vector<CActorGroup*>::iterator it;
|
||||
for (it=_actorGroups.begin(); it!=_actorGroups.end(); ++it)
|
||||
{
|
||||
if ((*it)->getName()==name)
|
||||
{
|
||||
// remove all actors from this group into default group
|
||||
uint i;
|
||||
for (i=0; i<(*it)->actorCount(); ++i)
|
||||
(*(*it))[i]->setGroup(_defaultActorGroup);
|
||||
|
||||
// remove from container
|
||||
delete (*it);
|
||||
_actorGroups.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void CActorManager::setActorsToGroup(const std::string &sourceActorGroup, const std::string &destActorGroup)
|
||||
{
|
||||
CActorGroup *srcGroup = getActorGroup(sourceActorGroup);
|
||||
if (srcGroup == NULL)
|
||||
{
|
||||
nlwarning("source actor group '%s' is unknown, abort setActorsToGroup(%s, %s)", sourceActorGroup.c_str(), sourceActorGroup.c_str(), destActorGroup.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
CActorGroup *destGroup = getActorGroup(destActorGroup);
|
||||
if (destGroup == NULL)
|
||||
{
|
||||
nlwarning("destination actor group '%s' is unknown, abort setActorsToGroup(%s, %s)", destActorGroup.c_str(), sourceActorGroup.c_str(), destActorGroup.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
uint i;
|
||||
for (i=0; i<srcGroup->actorCount(); ++i)
|
||||
(*srcGroup)[i]->setGroup(destGroup);
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace AGS_TEST
|
@ -1,61 +0,0 @@
|
||||
/** \file actor_manager.cpp
|
||||
*
|
||||
* the actor manager for AgS_Test
|
||||
*
|
||||
* $Id: ags_timer.cpp,v 1.3 2004/03/01 19:18:37 lecroart Exp $
|
||||
* $Log: ags_timer.cpp,v $
|
||||
* Revision 1.3 2004/03/01 19:18:37 lecroart
|
||||
* REMOVED: bad headers
|
||||
*
|
||||
* Revision 1.2 2003/01/28 20:36:51 miller
|
||||
* Changed header comments from 'Nel Network Services' to Ryzom
|
||||
*
|
||||
* Revision 1.1 2002/11/28 14:57:17 portier
|
||||
* #ADDED: ia_player.id
|
||||
*
|
||||
* Revision 1.21 2002/11/15 16:22:42 fleury
|
||||
* CHANGED : the OPS has been replaced by the EGS
|
||||
*
|
||||
* Revision 1.20 2002/08/30 08:47:34 miller
|
||||
* another quick test (non destructive)
|
||||
*
|
||||
* Revision 1.19 2002/08/30 08:46:09 miller
|
||||
* quick test (non destructive)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ags_timer.h"
|
||||
#include "game_share/tick_event_handler.h"
|
||||
|
||||
namespace AGS_TEST
|
||||
{
|
||||
CAGSTimer::CAGSTimer(uint32 dt /*= 0*/)
|
||||
{
|
||||
_dt = dt;
|
||||
}
|
||||
|
||||
void CAGSTimer::set(uint32 dt)
|
||||
{
|
||||
_start = (uint32)CTickEventHandler::getGameCycle();
|
||||
_dt = dt;
|
||||
}
|
||||
|
||||
void CAGSTimer::add(uint32 dt)
|
||||
{
|
||||
_start = (uint32)CTickEventHandler::getGameCycle();
|
||||
_dt += dt;
|
||||
}
|
||||
|
||||
bool CAGSTimer::test()
|
||||
{
|
||||
uint32 curent = (uint32) CTickEventHandler::getGameCycle();
|
||||
|
||||
uint32 elapsed = curent - _start;
|
||||
|
||||
return ( elapsed >= _dt );
|
||||
}
|
||||
|
||||
}
|
@ -1,359 +0,0 @@
|
||||
/** \file ai_profile_fauna.h
|
||||
*
|
||||
* $Id: ai_profile_fauna.h,v 1.8 2005/08/09 12:38:24 vuarand Exp $
|
||||
*
|
||||
* This file defines the classes:
|
||||
* - CPlanteIdleFaunaProfile
|
||||
* - CStaticPlanteIdleFaunaProfile
|
||||
* - CAIFaunaActivityBaseSpawnProfile
|
||||
* - CWanderFaunaProfile
|
||||
* - CStaticWanderFaunaProfile
|
||||
* - CGrazeFaunaProfile
|
||||
* - CStaticGrazeFaunaProfile
|
||||
* - CRestFaunaProfile
|
||||
* - CStaticRestFaunaProfile
|
||||
* - CStaticFightFaunaProfile
|
||||
* - CCorpseFaunaProfileFactory
|
||||
* - CEatCorpseFaunaProfile
|
||||
* - CStaticEatCorpseFaunaProfile
|
||||
* - CCuriosityFaunaProfile
|
||||
* - CStaticCuriosityFaunaProfile
|
||||
*/
|
||||
|
||||
#ifndef AI_PROFILE_FAUNA_H
|
||||
#define AI_PROFILE_FAUNA_H
|
||||
|
||||
#include "profile.h" // for CAIBaseProfile
|
||||
#include "path_behaviors.h" // for CPathPosition
|
||||
#include "ai_bot_fauna.h" // for CCorpseFaunaProfile
|
||||
#include "ai_grp_fauna.h"
|
||||
#include "ai_mgr_fauna.h"
|
||||
|
||||
class CSpawnBotFauna;
|
||||
class CMovementMagnet;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Debug defines
|
||||
// ---------------------------------------------------------------------------
|
||||
// COMPACT_POS_WARNINGS compress flooding warnings concerning path problems.
|
||||
// Positions where the problems occures are stored and displayed and cleared
|
||||
// every minute.
|
||||
// :TODO: /!\ As it cannot be tested without long-time run with several
|
||||
// players the following define can be commented to restore previous behavior.
|
||||
#define COMPACT_POS_WARNINGS 1
|
||||
|
||||
class CFaunaProfileFloodLogger
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, int> TLogPositions;
|
||||
|
||||
public:
|
||||
CFaunaProfileFloodLogger(int period)
|
||||
: logLastTick(0)
|
||||
, logPeriod(period)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
TLogPositions logPositions;
|
||||
int logLastTick;
|
||||
int logPeriod;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CPlanteIdleFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CPlanteIdleFaunaProfile
|
||||
: public CAIBaseProfile
|
||||
{
|
||||
public:
|
||||
CPlanteIdleFaunaProfile(CProfileOwner* owner);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_PLANTIDLE; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CAIFaunaActivityBaseSpawnProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CAIFaunaActivityBaseSpawnProfile
|
||||
: public CAIBaseProfile
|
||||
, public IMouvementMagnetOwner
|
||||
{
|
||||
public:
|
||||
CAIFaunaActivityBaseSpawnProfile(CProfileOwner* owner);
|
||||
|
||||
virtual NLMISC::CSmartPtr<CMovementMagnet> const& getMovementMagnet() const;
|
||||
|
||||
protected:
|
||||
NLMISC::CSmartPtr<CMovementMagnet> _MovementMagnet;
|
||||
CPathPosition _PathPos;
|
||||
bool _OutOfMagnet;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CWanderFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CWanderFaunaProfile
|
||||
: public CAIFaunaActivityBaseSpawnProfile
|
||||
{
|
||||
public:
|
||||
CWanderFaunaProfile(CProfileOwner* owner);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_WANDERING; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||
CSpawnBotFauna* _Bot;
|
||||
double _magnetDist; ///< distance from bot to his magnet at last move
|
||||
static CFaunaProfileFloodLogger _FloodLogger;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CGrazeFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CGrazeFaunaProfile
|
||||
: public CAIFaunaActivityBaseSpawnProfile
|
||||
{
|
||||
public:
|
||||
CGrazeFaunaProfile(CProfileOwner* owner);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_GRAZING; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
private:
|
||||
CAITimer _CycleTimer;
|
||||
uint _CycleTimerBaseTime;
|
||||
bool _ArrivedInZone;
|
||||
double _magnetDist; ///< distance from bot to his magnet at last move
|
||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||
static CFaunaProfileFloodLogger _FloodLogger;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CRestFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CRestFaunaProfile
|
||||
: public CAIFaunaActivityBaseSpawnProfile
|
||||
{
|
||||
public:
|
||||
CRestFaunaProfile(CProfileOwner* owner);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_RESTING; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
private:
|
||||
CAITimer _CycleTimer;
|
||||
uint _CycleTimerBaseTime;
|
||||
bool _ArrivedInZone;
|
||||
double _magnetDist; // distance from bot to his magnet at last move
|
||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||
static CFaunaProfileFloodLogger _FloodLogger;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CEatCorpseFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CEatCorpseFaunaProfile
|
||||
: public CAIBaseProfile
|
||||
{
|
||||
public:
|
||||
CEatCorpseFaunaProfile(CProfileOwner* owner, TDataSetRow const& corpse, RYAI_MAP_CRUNCH::TAStarFlag flag);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_EAT_CORPSE; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
TDataSetRow _eated;
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
private:
|
||||
bool _atGoodDist;
|
||||
CAITimer _eatTimer;
|
||||
CPathPosition _PathPos;
|
||||
CPathCont _PathCont;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CCuriosityFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CCuriosityFaunaProfile
|
||||
: public CAIBaseProfile
|
||||
{
|
||||
public:
|
||||
CCuriosityFaunaProfile(CProfileOwner* owner, TDataSetRow const& player, RYAI_MAP_CRUNCH::TAStarFlag flag);
|
||||
|
||||
/// @name IAIProfile implementation
|
||||
//@{
|
||||
virtual void beginProfile();
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate);
|
||||
virtual void endProfile();
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_CURIOSITY; }
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
//@}
|
||||
|
||||
TDataSetRow _player;
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
private:
|
||||
bool _atGoodDist;
|
||||
CAITimer _curiosityTimer;
|
||||
CPathPosition _PathPos;
|
||||
CPathCont _PathCont;
|
||||
uint32 _addCuriosityTime;
|
||||
bool _TooFar;
|
||||
RYAI_MAP_CRUNCH::TAStarFlag _Flag;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CCorpseFaunaProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CCorpseFaunaProfile
|
||||
: public CAIBaseProfile
|
||||
{
|
||||
public:
|
||||
CCorpseFaunaProfile(CProfileOwner* owner);
|
||||
|
||||
virtual void beginProfile();
|
||||
|
||||
virtual void endProfile() { }
|
||||
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate) { }
|
||||
|
||||
virtual std::string getOneLineInfoString() const { return NLMISC::toString("corpse fauna profile"); }
|
||||
|
||||
virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_CORPSE; }
|
||||
|
||||
bool eated() const { return _Eated; }
|
||||
void setEated(bool eated) { _Eated = eated; }
|
||||
|
||||
void setEater(bool eater) { _HaveEater = eater; }
|
||||
bool haveEater() const { return _HaveEater; }
|
||||
|
||||
protected:
|
||||
CSpawnBotFauna* _Bot;
|
||||
|
||||
private:
|
||||
bool _HaveEater;
|
||||
bool _Eated;
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
/* Profile factories */
|
||||
/****************************************************************************/
|
||||
|
||||
//- Simple profile factories -------------------------------------------------
|
||||
|
||||
// CPlanteIdleFaunaProfileFactory
|
||||
typedef CAIGenericProfileFactory<CPlanteIdleFaunaProfile> CPlanteIdleFaunaProfileFactory;
|
||||
|
||||
// CWanderFaunaProfileFactory
|
||||
typedef CAIGenericProfileFactory<CWanderFaunaProfile> CWanderFaunaProfileFactory;
|
||||
|
||||
// CGrazeFaunaProfileFactory
|
||||
typedef CAIGenericProfileFactory<CGrazeFaunaProfile> CGrazeFaunaProfileFactory;
|
||||
|
||||
// CRestFaunaProfileFactory
|
||||
typedef CAIGenericProfileFactory<CRestFaunaProfile> CRestFaunaProfileFactory;
|
||||
|
||||
// CCorpseFaunaProfileFactory
|
||||
typedef CAIGenericProfileFactory<CCorpseFaunaProfile> CCorpseFaunaProfileFactory;
|
||||
|
||||
//- Complex profile factories ------------------------------------------------
|
||||
|
||||
// CStaticFightFaunaProfile
|
||||
class CFightFaunaProfileFactory
|
||||
: public IAIProfileFactory
|
||||
{
|
||||
public:
|
||||
NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
// CStaticEatCorpseFaunaProfile
|
||||
class CEatCorpseFaunaProfileFactory
|
||||
: public IAIProfileFactory
|
||||
{
|
||||
public:
|
||||
NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner)
|
||||
{
|
||||
#ifdef NL_DEBUG
|
||||
nlassert(false);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
// CStaticCuriosityFaunaProfile
|
||||
class CCuriosityFaunaProfileFactory
|
||||
: public IAIProfileFactory
|
||||
{
|
||||
public:
|
||||
NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner)
|
||||
{
|
||||
#ifdef NL_DEBUG
|
||||
nlassert(false);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
//- Profile factories singletons ---------------------------------------------
|
||||
|
||||
extern CPlanteIdleFaunaProfileFactory PlanteIdleFaunaProfileFactory;
|
||||
extern CWanderFaunaProfileFactory WanderFaunaProfileFactory;
|
||||
extern CGrazeFaunaProfileFactory GrazeFaunaProfileFactory;
|
||||
extern CRestFaunaProfileFactory RestFaunaProfileFactory;
|
||||
extern CFightFaunaProfileFactory FightFaunaProfileFactory;
|
||||
extern CCorpseFaunaProfileFactory CorpseFaunaProfileFactory;
|
||||
extern CEatCorpseFaunaProfileFactory EatCorpseFaunaProfileFactory;
|
||||
extern CCuriosityFaunaProfileFactory CuriosityFaunaProfileFactory;
|
||||
|
||||
#endif
|
@ -1,266 +0,0 @@
|
||||
/** \file profile.h
|
||||
*
|
||||
* $Id: profile.h,v 1.34 2006/10/31 16:09:01 blanchard Exp $
|
||||
*
|
||||
* This file defines the classes:
|
||||
* - CProfileOwner
|
||||
* - IAIProfileFactory
|
||||
* - CAIGenericProfileFactory
|
||||
* - CAIBaseProfile
|
||||
* - CProfilePtr
|
||||
*/
|
||||
|
||||
#ifndef RYAI_AI_PROFILE_H
|
||||
#define RYAI_AI_PROFILE_H
|
||||
|
||||
|
||||
//#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list
|
||||
|
||||
// This is the base class for defining NPC behaviour profiles
|
||||
// The team infrastructure manages the allocation of AI profiles to bots
|
||||
|
||||
class CProfilePtr;
|
||||
class IAIProfile;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CProfileOwner //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CProfileOwner
|
||||
{
|
||||
public:
|
||||
virtual ~CProfileOwner() { }
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// IAIProfileFactory //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IAIProfileFactory
|
||||
: public NLMISC::CDbgRefCount<IAIProfileFactory>
|
||||
{
|
||||
public:
|
||||
friend class CProfilePtr;
|
||||
virtual ~IAIProfileFactory() { }
|
||||
virtual NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner *owner) = 0;
|
||||
};
|
||||
|
||||
#define RYAI_DECLARE_PROFILE_FACTORY(ProfileClass) RYAI_DECLARE_FACTORY(IAIProfileFactory, ProfileClass, std::string);
|
||||
#define RYAI_REGISTER_PROFILE_FACTORY(ProfileClass, KeyValue) RYAI_REGISTER_FACTORY(IAIProfileFactory, ProfileClass, std::string, std::string(KeyValue));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CAIGenericProfileFactory //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TProfile>
|
||||
class CAIGenericProfileFactory
|
||||
: public IAIProfileFactory
|
||||
{
|
||||
public:
|
||||
NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner)
|
||||
{
|
||||
return new TProfile(owner);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CAIBaseProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IAIProfile
|
||||
: public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
virtual ~IAIProfile() { }
|
||||
|
||||
/// @name Virtual interface
|
||||
//@{
|
||||
// routine called when a profOwner starts to use a given profile
|
||||
// note that bots have a data member called 'void *aiProfileData' reserved for the use of the profile code
|
||||
// this data member should be setup here if it is to be used by the profile
|
||||
virtual void beginProfile() = 0;
|
||||
// routine called every time the profOwner is updated (frequency depends on player proximity, etc)
|
||||
virtual void updateProfile(uint ticksSinceLastUpdate) = 0;
|
||||
// routine called just before profOwner starts to use a new profile or when a profOwner dies
|
||||
virtual void endProfile() = 0;
|
||||
virtual AITYPES::TProfiles getAIProfileType() const = 0;
|
||||
virtual std::string getOneLineInfoString() const = 0;
|
||||
// routine called every time the profOwner's group changes state but profOwner maintains same ai profile
|
||||
virtual void stateChangeProfile() = 0;
|
||||
virtual void resumeProfile() = 0;
|
||||
//@}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CAIBaseProfile //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CAIBaseProfile
|
||||
: public IAIProfile
|
||||
{
|
||||
public:
|
||||
virtual ~CAIBaseProfile() { }
|
||||
|
||||
/// @name IAIProfile base implementation
|
||||
//@{
|
||||
virtual void stateChangeProfile() { beginProfile(); }
|
||||
virtual void resumeProfile() { }
|
||||
//@}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CProfilePtr //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CProfilePtr
|
||||
{
|
||||
public:
|
||||
enum TStartProfileType
|
||||
{
|
||||
START_BEGIN = 0,
|
||||
START_RESUME
|
||||
};
|
||||
|
||||
public:
|
||||
CProfilePtr();
|
||||
|
||||
virtual ~CProfilePtr();
|
||||
|
||||
// std::string buildProfileDebugString() const;
|
||||
virtual std::string getOneLineInfoString() const;
|
||||
|
||||
AITYPES::TProfiles getAIProfileType() const;
|
||||
|
||||
template <class T>
|
||||
void setAIProfile(T* obj, IAIProfileFactory* profile, bool callStateChangedIfSame) const
|
||||
{
|
||||
if (profile)
|
||||
{
|
||||
setAIProfile(profile->createAIProfile(obj), callStateChangedIfSame);
|
||||
}
|
||||
}
|
||||
|
||||
void setAIProfile(NLMISC::CSmartPtr<IAIProfile> profile, bool callStateChangedIfSame = false, TStartProfileType startType = START_BEGIN) const;
|
||||
|
||||
void updateProfile(uint ticks) const;
|
||||
|
||||
void mayUpdateProfile(uint ticks) const;
|
||||
|
||||
IAIProfile* getAIProfile() const { return _AiProfile; }
|
||||
NLMISC::CSmartPtr<IAIProfile> const& getAISpawnProfile() const { return _AiProfile; }
|
||||
|
||||
private:
|
||||
mutable NLMISC::CSmartPtr<IAIProfile> _AiProfile;
|
||||
mutable NLMISC::CSmartPtr<IAIProfile> _NextAiProfile;
|
||||
mutable bool _NextAiProfileCallStateChangedIfSame;
|
||||
|
||||
mutable TStartProfileType _NextStartType;
|
||||
mutable bool _IsUpdating;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Global functions //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// the lookup routine that serves as a kind of repository interface
|
||||
IAIProfileFactory* lookupAIGrpProfile(char const* name);
|
||||
|
||||
/****************************************************************************/
|
||||
/* Inlined methods */
|
||||
/****************************************************************************/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CProfilePtr //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline
|
||||
CProfilePtr::CProfilePtr()
|
||||
: _AiProfile(NULL)
|
||||
, _NextAiProfile(NULL)
|
||||
, _NextStartType(START_BEGIN)
|
||||
, _IsUpdating(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CProfilePtr::~CProfilePtr()
|
||||
{
|
||||
_NextAiProfile = NULL;
|
||||
_AiProfile = NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string CProfilePtr::getOneLineInfoString() const
|
||||
{
|
||||
if (_AiProfile.isNull())
|
||||
return std::string("No Profile");
|
||||
return _AiProfile->getOneLineInfoString();
|
||||
}
|
||||
|
||||
inline
|
||||
AITYPES::TProfiles CProfilePtr::getAIProfileType() const
|
||||
{
|
||||
if (!_AiProfile.isNull())
|
||||
return _AiProfile->getAIProfileType();
|
||||
return AITYPES::BAD_TYPE; // unknown
|
||||
}
|
||||
|
||||
inline
|
||||
void CProfilePtr::setAIProfile(NLMISC::CSmartPtr<IAIProfile> profile, bool callStateChangedIfSame, TStartProfileType startType) const
|
||||
{
|
||||
// :NOTE: profile can be NULL
|
||||
if (_IsUpdating)
|
||||
{
|
||||
_NextAiProfileCallStateChangedIfSame = callStateChangedIfSame;
|
||||
_NextAiProfile = profile;
|
||||
_NextStartType = startType;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_AiProfile.isNull())
|
||||
{
|
||||
// we may use the == operator because it doesn't take account of parameters (which is bad) :(
|
||||
if (callStateChangedIfSame==true && _AiProfile->getAIProfileType ()==profile->getAIProfileType ()) // if we already have this profile, then call its stateChangeProfile method
|
||||
{
|
||||
_AiProfile->stateChangeProfile();
|
||||
return;
|
||||
}
|
||||
|
||||
_AiProfile->endProfile();
|
||||
_AiProfile = NULL;
|
||||
}
|
||||
|
||||
if (!profile.isNull())
|
||||
{
|
||||
_AiProfile = profile;
|
||||
if (startType==START_BEGIN)
|
||||
_AiProfile->beginProfile();
|
||||
else
|
||||
_AiProfile->resumeProfile();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void CProfilePtr::updateProfile(uint ticks) const
|
||||
{
|
||||
BOMB_IF(_AiProfile.isNull(),"Attempting updateProfile() with _AiProfile.isNull()",return);
|
||||
|
||||
_IsUpdating = true;
|
||||
_AiProfile->updateProfile(ticks);
|
||||
_IsUpdating = false;
|
||||
|
||||
if (!_NextAiProfile.isNull())
|
||||
{
|
||||
setAIProfile(_NextAiProfile, _NextAiProfileCallStateChangedIfSame, _NextStartType);
|
||||
_NextAiProfile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void CProfilePtr::mayUpdateProfile(uint ticks) const
|
||||
{
|
||||
if (_AiProfile)
|
||||
updateProfile(ticks);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,184 +0,0 @@
|
||||
/** \file stdpch.h
|
||||
*
|
||||
*
|
||||
* This is the ai_srevice executable's precopiled header controler file
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* $Id: stdpch.h,v 1.41 2006/02/24 17:29:11 guignot Exp $
|
||||
*/
|
||||
#ifndef STDPCH_H
|
||||
#define STDPCH_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// external files
|
||||
//----------------------------------------------------------------
|
||||
|
||||
// this is up top because it contains a certain number of #pragmas to
|
||||
// control compiler warnings with stlport
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// std libs
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// stl
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
//#include <sstream>
|
||||
#include <exception>
|
||||
#include <utility>
|
||||
#include <deque>
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// nel
|
||||
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "nel/misc/variable.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include "nel/misc/entity_id.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
#include "nel/misc/random.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
|
||||
#include "nel/misc/vector_2d.h"
|
||||
#include "nel/misc/vectord.h"
|
||||
|
||||
#include "nel/net/message.h"
|
||||
#include "nel/net/unified_network.h"
|
||||
|
||||
// NeL/ligo
|
||||
#include "nel/ligo/ligo_config.h"
|
||||
#include "nel/ligo/primitive.h"
|
||||
#include "nel/ligo/primitive_configuration.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// nel net
|
||||
#include "nel/net/service.h"
|
||||
//----------------------------------------------------------------
|
||||
// service basics
|
||||
|
||||
#define FOREACH(__itvar,__conttype,__contvar) \
|
||||
for (__conttype::iterator __itvar(__contvar.begin()),__itvar##end(__contvar.end()); __itvar!=__itvar##end; ++__itvar)
|
||||
|
||||
#define FOREACH_NOINC(__itvar,__conttype,__contvar) \
|
||||
for (__conttype::iterator __itvar(__contvar.begin()),__itvar##end(__contvar.end()); __itvar!=__itvar##end;)
|
||||
|
||||
#define FOREACHC(__itvar,__conttype,__contvar) \
|
||||
for (__conttype::const_iterator __itvar(__contvar.begin()),__itvar##end(__contvar.end()); __itvar!=__itvar##end; ++__itvar)
|
||||
|
||||
#define FOREACHC_NOINC(__itvar,__conttype,__contvar) \
|
||||
for (__conttype::const_iterator __itvar(__contvar.begin()),__itvar##end(__contvar.end()); __itvar!=__itvar##end; )
|
||||
|
||||
|
||||
class CStringWriter
|
||||
:public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
CStringWriter()
|
||||
{}
|
||||
virtual ~CStringWriter()
|
||||
{}
|
||||
virtual void append(const std::string &str) = 0;
|
||||
};
|
||||
|
||||
class CTrashStringWriter
|
||||
:public CStringWriter
|
||||
{
|
||||
public:
|
||||
CTrashStringWriter(NLMISC::CLog *log=NLMISC::InfoLog)
|
||||
{}
|
||||
virtual ~CTrashStringWriter()
|
||||
{}
|
||||
void append(const std::string &str)
|
||||
{}
|
||||
};
|
||||
|
||||
class CLogStringWriter
|
||||
:public CStringWriter
|
||||
{
|
||||
public:
|
||||
CLogStringWriter(NLMISC::CLog *log=NLMISC::InfoLog)
|
||||
:_Log(log)
|
||||
{}
|
||||
virtual ~CLogStringWriter()
|
||||
{}
|
||||
void append(const std::string &str)
|
||||
{
|
||||
#if !FINAL_VERSION
|
||||
nlassert(_Log);
|
||||
#endif
|
||||
if (_Log)
|
||||
_Log->displayNL(str.c_str());
|
||||
}
|
||||
NLMISC::CLog *_Log;
|
||||
};
|
||||
|
||||
|
||||
class CArrayStringWriter
|
||||
:public CStringWriter
|
||||
{
|
||||
public:
|
||||
CArrayStringWriter(std::vector<std::string> &stringVector)
|
||||
:_StringVector(stringVector)
|
||||
{}
|
||||
virtual ~CArrayStringWriter()
|
||||
{}
|
||||
void append(const std::string &str)
|
||||
{
|
||||
_StringVector.push_back(str);
|
||||
}
|
||||
std::vector<std::string> &_StringVector;
|
||||
};
|
||||
|
||||
|
||||
namespace MULTI_LINE_FORMATER {
|
||||
void pushTitle(std::vector<std::string>& container, std::string const& text);
|
||||
void pushEntry(std::vector<std::string>& container, std::string const& text);
|
||||
void pushFooter(std::vector<std::string>& container);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// game share
|
||||
|
||||
#include "game_share/ryzom_entity_id.h"
|
||||
#include "game_share/mode_and_behaviour.h"
|
||||
#include "game_share/player_visual_properties.h"
|
||||
#include "../ai_share/ai_event.h"
|
||||
#include "../server_share/msg_ai_service.h"
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// ai share
|
||||
|
||||
|
||||
#include "ai_share/ai_share.h"
|
||||
#include "ai_share/ai_types.h"
|
||||
#include "ai_share/ai_alias_description_node.h"
|
||||
#include "ai_share/ai_event_description.h"
|
||||
#include "ai_share/ai_coord.h"
|
||||
#include "ai_share/ai_vector.h"
|
||||
#include "ai_share/angle.h"
|
||||
#include "ai_share/world_map.h"
|
||||
|
||||
#endif /*STDPCH_H*/
|
@ -1,2 +1,17 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdpch.h"
|
||||
|
@ -1,2 +1,17 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdpch.h"
|
||||
|
@ -1,98 +0,0 @@
|
||||
/** \file stats_job_manager.h
|
||||
*
|
||||
* Part of STAT Module for GUS (general utilities service)
|
||||
*
|
||||
* This file is the header for a singleton 'job manager'. The job manager manages a list of jobs to be
|
||||
* executed one after another. Each job is assumed to require one or more calls to its update() method
|
||||
* in order to perform its work. Each job's finished() method returns true when the job is done
|
||||
*
|
||||
* $Id: stat_job_manager.h,v 1.3 2005/03/29 09:25:53 miller Exp $
|
||||
*/
|
||||
|
||||
#ifndef STAT_JOB_MANAGER_H
|
||||
#define STAT_JOB_MANAGER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
class CJobManager: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
static CJobManager* getInstance();
|
||||
|
||||
public:
|
||||
class IJob: public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
// virtual dtor
|
||||
virtual ~IJob() {}
|
||||
|
||||
// start a job running (one that isn't in progress)
|
||||
virtual void start()=0;
|
||||
|
||||
// return true if the job is finished -> the job object can be deleted
|
||||
virtual bool finished()=0;
|
||||
|
||||
// return a status string that can be displayed in an update variable
|
||||
virtual std::string getShortStatus()=0;
|
||||
|
||||
// get a detailed status string for display in a job list etc
|
||||
virtual std::string getStatus()=0;
|
||||
|
||||
// display the details of the job... eg the list of files being processed with related info
|
||||
virtual void display(NLMISC::CLog* log=NLMISC::InfoLog)=0;
|
||||
|
||||
// run the job's update to do a bit of work
|
||||
virtual void update()=0;
|
||||
};
|
||||
|
||||
public:
|
||||
// add a job to the job vector and assign it a new id
|
||||
uint32 addJob(NLMISC::CSmartPtr<IJob> job);
|
||||
|
||||
// move a job to the front of the queue - treat it as the active job
|
||||
void promoteJob(uint32 idx);
|
||||
|
||||
// the update method used to call job updates
|
||||
void serviceUpdate();
|
||||
|
||||
// do nothing during the service updates until 'resume()'
|
||||
void pause();
|
||||
|
||||
// resume after a 'pause()'
|
||||
void resume();
|
||||
|
||||
// accessors for the number of job updates per call to serviceUpdate()
|
||||
void setJobUpdatesPerUpdate(uint32 count);
|
||||
uint32 getJobUpdatesPerUpdate();
|
||||
|
||||
// get the 'pause'/'resume' state, the number of jobsUpdatesPerUpdate and the status of the active job
|
||||
std::string getStatus();
|
||||
|
||||
// list the status of all jobs that are not finished
|
||||
void listJobs(NLMISC::CLog* log=NLMISC::InfoLog);
|
||||
|
||||
// list the status of all jobs including those that are finished
|
||||
void listJobHistory(NLMISC::CLog* log=NLMISC::InfoLog);
|
||||
|
||||
// call the currently active job's 'display' method
|
||||
void displayCurrentJob(NLMISC::CLog* log=NLMISC::InfoLog);
|
||||
|
||||
// call the given job's 'display' method
|
||||
void displayJob(uint32 jobId,NLMISC::CLog* log=NLMISC::InfoLog);
|
||||
|
||||
private:
|
||||
CJobManager();
|
||||
|
||||
typedef std::list<uint32> TUnfinishedJobs;
|
||||
typedef std::vector<NLMISC::CSmartPtr<IJob> > TJobs;
|
||||
|
||||
bool _Paused;
|
||||
uint32 _JobUpdatesPerUpdate;
|
||||
TJobs _Jobs;
|
||||
TUnfinishedJobs _UnfinishedJobs;
|
||||
};
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue