mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-05 23:09:04 +00:00
Removed: useless backup files
This commit is contained in:
parent
de9ba8fbe4
commit
e1242bffea
25 changed files with 3 additions and 4368 deletions
|
@ -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,9 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
# Filter out the source files not actually compiled.
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ admin_modules.cpp)
|
||||
|
||||
|
||||
ADD_LIBRARY(admin_modules STATIC ${SRC})
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
|
|
@ -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*/
|
|
@ -10,10 +10,7 @@ LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/ai_entity_id.cpp
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/gpms_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gpms_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ios_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ios_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ ai_profile_fauna.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ profile.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ stdpch.h)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ios_interface.h)
|
||||
|
||||
ADD_EXECUTABLE(ai_service ${SRC})
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
# Filter out the source files not actually compiled.
|
||||
#LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ admin_modules.cpp)
|
||||
|
||||
IF(WIN32)
|
||||
ADD_LIBRARY(gameplay_module_lib STATIC ${SRC})
|
||||
ELSE(WIN32)
|
||||
|
|
|
@ -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
|
|
@ -1,7 +1,6 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ stat_job_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ec_event_chat.cpp
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/ec_event_chat.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gus_mfc_popups.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gus_mfc_popups.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gus_mfc_select_with_text.cpp
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
/** \file file_repository.h
|
||||
*
|
||||
* ***********************************************************************
|
||||
* ****************************** IMPORTANT ******************************
|
||||
* ***********************************************************************
|
||||
*
|
||||
* The following set of routines all need to be called by the derived
|
||||
* class for the repositry to function correctly:
|
||||
* - init()
|
||||
* - onModuleUp()
|
||||
* - onModuleDown()
|
||||
* - onModuleUpdate()
|
||||
* - onDispatchMessage()
|
||||
* - getModuleManifest()
|
||||
*
|
||||
* ***********************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILE_REPOSITORY_H
|
||||
#define FILE_REPOSITORY_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// includes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// nel
|
||||
#include "nel/misc/md5.h"
|
||||
#include "nel/net/module_builder_parts.h"
|
||||
|
||||
// game share
|
||||
#include "game_share/deployment_configuration.h"
|
||||
|
||||
// local
|
||||
#include "module_admin_itf.h"
|
||||
#include "administered_module.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// namespace PATCHMAN
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace PATCHMAN
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// class CFileRepository
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CFileRepository:
|
||||
public CFileRepositorySkel,
|
||||
public IFileRequestValidator,
|
||||
public IFileInfoUpdateListener
|
||||
{
|
||||
public:
|
||||
// get the module manifest component required for CFileReceiver modules to recognise us
|
||||
std::string buildModuleManifest() const;
|
||||
|
||||
public:
|
||||
// ctor and init
|
||||
CFileRepository();
|
||||
|
||||
// methods for use in derived classes
|
||||
void init(NLNET::IModule* parent,const NLMISC::CSString& rootDirectory);
|
||||
void onModuleUp(NLNET::IModuleProxy *module);
|
||||
void onModuleDown(NLNET::IModuleProxy *module);
|
||||
void onModuleUpdate();
|
||||
|
||||
// update methods
|
||||
void rescanFull();
|
||||
void rescanPartial();
|
||||
void updateFile(const NLMISC::CSString& fileName);
|
||||
|
||||
// overloadable method for getting the file list for subscribers
|
||||
virtual void getFileInfo(const NLMISC::CSString& fileSpec,TFileInfoVector& result,const NLNET::IModuleProxy* sender) const;
|
||||
|
||||
// query methods
|
||||
TRepositoryDirectoryPtr getRepositoryDirectory();
|
||||
void getFile(const NLMISC::CSString& fileName,NLMISC::CSString& resultData,const NLNET::IModuleProxy* sender) const;
|
||||
void dump(NLMISC::CLog& log);
|
||||
|
||||
// stats system accessors
|
||||
void setMaxHistorySize(uint32 maxHistorySize);
|
||||
uint32 getMaxHistorySize() const;
|
||||
|
||||
protected:
|
||||
// treatment of incoming file requests
|
||||
void requestFileInfo(NLNET::IModuleProxy *sender,const NLMISC::CSString& fileSpec);
|
||||
void requestFileData(NLNET::IModuleProxy *sender, const NLMISC::CSString &fileName, uint32 startOffset, uint32 numBytes);
|
||||
|
||||
// treatment of subscriptions and unsubscriptions
|
||||
void subscribe(NLNET::IModuleProxy *sender, const NLMISC::CSString &fileSpec);
|
||||
void unsubscribe(NLNET::IModuleProxy *sender, const NLMISC::CSString &fileSpec);
|
||||
void unsubscribeAll(NLNET::IModuleProxy *sender);
|
||||
void getInfo(NLNET::IModuleProxy *sender, const NLMISC::CSString &fileSpec);
|
||||
|
||||
// IFileInfoUpdateListener specialisation implementation
|
||||
void cbFileInfoUpdate(const SFileInfo& fileInfo);
|
||||
void cbFileInfoErased(const NLMISC::CSString& fileName);
|
||||
|
||||
// broadcast a set of file info changes to all subscribers
|
||||
void _broadcastFileInfoChanges(const TFileInfoVector& fileInfoChanges);
|
||||
|
||||
// overloadable method for treating my module down
|
||||
virtual void onFileRepositoryModuleDown(NLNET::IModuleProxy *module);
|
||||
|
||||
private:
|
||||
// private data
|
||||
|
||||
typedef NLNET::CInterceptorForwarder<CFileRepository> TInterceptor;
|
||||
/// module interceptor forwarder
|
||||
TInterceptor _Interceptor;
|
||||
|
||||
friend class NLNET::CInterceptorForwarder<CFileRepository>;
|
||||
|
||||
// the module object that this object is part of
|
||||
NLNET::IModule* _Parent;
|
||||
|
||||
// a wrapper round '_Parent' to allow us to log to the parent's CAdministeredModuleBase interface
|
||||
CAdministeredModuleWrapper _AdministeredModuleWrapper;
|
||||
|
||||
// the set of subscribers
|
||||
typedef std::map<NLMISC::CSString,NLNET::IModuleProxy*> TSubscribers;
|
||||
TSubscribers _Subscribers;
|
||||
|
||||
// the recent info changes that the subscribers may be interested in
|
||||
TFileInfoVector _FileInfoChanges;
|
||||
|
||||
// system for history of recent info requests and data requests
|
||||
uint32 _MaxHistorySize;
|
||||
typedef std::list<NLMISC::CSString> THistory;
|
||||
|
||||
// the history for info requests
|
||||
THistory _FileInfoHistory;
|
||||
uint32 _FileInfoHistorySize;
|
||||
uint32 _FileInfoCount;
|
||||
|
||||
// the history for file data requests
|
||||
THistory _FileRequestHistory;
|
||||
uint32 _FileRequestHistorySize;
|
||||
uint32 _FileRequestCount;
|
||||
|
||||
protected:
|
||||
// data that may be accessed directlry by derived objects
|
||||
|
||||
// a smart pointers to our repository directory
|
||||
TRepositoryDirectoryPtr _Directory;
|
||||
|
||||
|
||||
protected:
|
||||
// declaration of NLMISC_COMMANDS implemented by this class
|
||||
NLMISC_CLASS_COMMAND_DECL(dump);
|
||||
NLMISC_CLASS_COMMAND_DECL(incRescan);
|
||||
NLMISC_CLASS_COMMAND_DECL(fullRescan);
|
||||
NLMISC_CLASS_COMMAND_DECL(getFile);
|
||||
NLMISC_CLASS_COMMAND_DECL(getFileInfo);
|
||||
NLMISC_CLASS_COMMAND_DECL(updateFile);
|
||||
NLMISC_CLASS_COMMAND_DECL(MaxHistorySize);
|
||||
|
||||
// macro for adding the NLMISC_COMMANDS provided here to the derived class's command table
|
||||
#define NLMISC_COMMAND_HANDLER_ADDS_FOR_FILE_REPOSITORY(className) \
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, incRescan, "Perform next increment of incremental rescan", "no args")\
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, fullRescan, "Perform a full rescan", "no args")\
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, getFile, "get a file", "<file name>")\
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, getFileInfo, "get info on a set of files", "<file spec>")\
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, updateFile, "force a rescan of a given file", "<file name>")\
|
||||
NLMISC_COMMAND_HANDLER_ADD(className, MaxHistorySize, "the maximum size allowed for the history buffers", "[<num entries>]")
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ file_repository.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.cpp
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.h)
|
||||
|
||||
ADD_EXECUTABLE(patchman_service ${SRC})
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
# Filter out the source files not actually compiled.
|
||||
#LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ admin_modules.cpp)
|
||||
|
||||
ADD_LIBRARY(server_share STATIC ${SRC})
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
#include "record.h"
|
||||
|
||||
CRecord::CRecord()
|
||||
{
|
||||
}
|
||||
|
||||
CRecord::CRecord(std::vector<IValue *> &)
|
||||
{
|
||||
}
|
||||
|
||||
CRecord::~CRecord()
|
||||
{
|
||||
/* std::vector<IValue *>::iterator it_val = _Values.begin();
|
||||
while ( it_val != _Values.end() )
|
||||
{
|
||||
IValue *val = *it_val;
|
||||
it_val++;
|
||||
delete val;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CRecord::addValue(IValue *value)
|
||||
{
|
||||
_Values.push_back( value );
|
||||
}
|
||||
|
||||
void CRecord::addValue(std::string &str)
|
||||
{
|
||||
_Values.push_back( new CValue<std::string>(str) );
|
||||
}
|
||||
|
||||
void CRecord::addValue(bool b)
|
||||
{
|
||||
_Values.push_back( new CValue<bool>(b) );
|
||||
}
|
||||
|
||||
void CRecord::addValue(int val)
|
||||
{
|
||||
_Values.push_back( new CValue<int>(val) );
|
||||
}
|
||||
|
||||
const std::vector<IValue *> &CRecord::getValues()
|
||||
{
|
||||
return _Values;
|
||||
}
|
||||
|
||||
const IValue *CRecord::operator[](int index)
|
||||
{
|
||||
return _Values[index];
|
||||
}
|
||||
|
||||
int CRecord::size()
|
||||
{
|
||||
return _Values.size();
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
// 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 "record.h"
|
||||
|
||||
CRecord::CRecord()
|
||||
{
|
||||
}
|
||||
|
||||
CRecord::CRecord(std::vector<IValue *> &)
|
||||
{
|
||||
}
|
||||
|
||||
CRecord::~CRecord()
|
||||
{
|
||||
/* std::vector<IValue *>::iterator it_val = _Values.begin();
|
||||
while ( it_val != _Values.end() )
|
||||
{
|
||||
IValue *val = *it_val;
|
||||
it_val++;
|
||||
delete val;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CRecord::addValue(IValue *value)
|
||||
{
|
||||
_Values.push_back( value );
|
||||
}
|
||||
|
||||
void CRecord::addValue(std::string &str)
|
||||
{
|
||||
_Values.push_back( new CValue<std::string>(str) );
|
||||
}
|
||||
|
||||
void CRecord::addValue(bool b)
|
||||
{
|
||||
_Values.push_back( new CValue<bool>(b) );
|
||||
}
|
||||
|
||||
void CRecord::addValue(int val)
|
||||
{
|
||||
_Values.push_back( new CValue<int>(val) );
|
||||
}
|
||||
|
||||
const std::vector<IValue *> &CRecord::getValues()
|
||||
{
|
||||
return _Values;
|
||||
}
|
||||
|
||||
const IValue *CRecord::operator[](int index)
|
||||
{
|
||||
return _Values[index];
|
||||
}
|
||||
|
||||
int CRecord::size()
|
||||
{
|
||||
return _Values.size();
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
LIST(REMOVE_ITEM SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ record.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 2\ of\ record.cpp)
|
||||
|
||||
ADD_EXECUTABLE(assoc_mem ${SRC})
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
|
||||
|
|
|
@ -1,546 +0,0 @@
|
|||
/*
|
||||
author : Fabien Houlmann - houlmann@nevrax.com
|
||||
date : 13/10/2005
|
||||
|
||||
named2csv: convert named_items.txt to .csv format and convert it back
|
||||
to named_items.txt after changes.
|
||||
|
||||
use: named2csv.exe named_items.txt filter.script (to generate a .csv based on filter)
|
||||
named2csv.exe named_items.txt named_items.csv (to modify .txt with .csv)
|
||||
|
||||
*/
|
||||
|
||||
#include "nel\misc\common.h"
|
||||
#include "nel\misc\debug.h"
|
||||
#include "nel\misc\sstring.h"
|
||||
#include "nel\misc\path.h"
|
||||
#include "nel\misc\file.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
// function declaration
|
||||
int verifItemsFile (const char *filename);
|
||||
int verifCsvFile (const char *filename);
|
||||
void processItemLine (const string &s);
|
||||
int getItemsFromFile (const char *filename);
|
||||
int getFieldsFromFile(const char *filename);
|
||||
int getNbItemFromFile(const char *filename);
|
||||
int exportCsv (const char *filename);
|
||||
int importCsv (const char *filename);
|
||||
void getItemBounds (const CVectorSString &lines, uint num, uint &a, uint &b);
|
||||
void updateItemField (CVectorSString &lines, uint itemIndex, uint fieldIndex, uint &a, uint &b);
|
||||
void addNewItem (CVectorSString &lines, uint itemIndex);
|
||||
int updateItems (const char *filename);
|
||||
|
||||
// global access
|
||||
CVectorSString fields;
|
||||
vector<CVectorSString> items;
|
||||
|
||||
// check the items file (locSlot and item number coherence)
|
||||
int verifItemsFile (const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
char buffer[1024];
|
||||
while (fgets(buffer, 1024, f))
|
||||
{
|
||||
string s(buffer);
|
||||
|
||||
// null or comment
|
||||
if (s == "" || s.find("//") == 0)
|
||||
continue;
|
||||
|
||||
if (s.find("_LocSlot") == string::npos)
|
||||
continue;
|
||||
|
||||
// get item numbers
|
||||
int n1, n2;
|
||||
sscanf(buffer, "_Items#%d._LocSlot=%d", &n1, &n2);
|
||||
|
||||
// check
|
||||
if (n1 != n2)
|
||||
nlerror("item number (%d) and _LocSlot(%d) don't match !", n1, n2);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check csv file (locSlot and item number coherence)
|
||||
int verifCsvFile (const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
uint prevId = -1;
|
||||
char buffer[1024];
|
||||
// skip first line
|
||||
fgets(buffer, 1024, f);
|
||||
while (fgets(buffer, 1024, f))
|
||||
{
|
||||
uint id = atoi(buffer);
|
||||
if (id-1 != prevId)
|
||||
nlerror("item number (%d) and previous item (%d) don't match !", id, prevId);
|
||||
prevId = id;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// parse a line from source file
|
||||
void processItemLine(const string &s)
|
||||
{
|
||||
// null or comment
|
||||
if (s == "" || s.find("//") == 0)
|
||||
return;
|
||||
|
||||
// other stuff
|
||||
if (s.find("_Items#") == string::npos)
|
||||
return;
|
||||
|
||||
// get item number
|
||||
int n;
|
||||
sscanf(s.c_str(), "_Items#%d", &n);
|
||||
|
||||
// check fields
|
||||
for (uint i=0 ; i<fields.size() ; i++)
|
||||
{
|
||||
string field = "_Items#" + toString(n) + "." + fields[i];
|
||||
|
||||
// compare line with field
|
||||
if (s.find(fields[i]) != string::npos)
|
||||
{
|
||||
// check is next char is not valid because of names like Protection in Protection1
|
||||
if (!CSString::isValidFileNameChar(s[field.size()]))
|
||||
{
|
||||
// get value
|
||||
int pos = s.find("=");
|
||||
nlassert(pos != string::npos);
|
||||
string val(s, pos+1);
|
||||
|
||||
items[n][i] = (CSString(val).strtok("\n")).strip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fill 'items' structure with values from file
|
||||
int getItemsFromFile(const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
char buffer[1024];
|
||||
while (fgets(buffer, 1024, f))
|
||||
processItemLine(buffer);
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fill 'fields' structure with values from file
|
||||
int getFieldsFromFile(const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
char buffer[1024];
|
||||
while (fgets(buffer, 1024, f))
|
||||
{
|
||||
CSString s(buffer);
|
||||
s = s.strtok("\n");
|
||||
|
||||
// skip null or comment
|
||||
if (s == "" || s.find("//") == 0)
|
||||
continue;
|
||||
|
||||
// add the field
|
||||
fields.push_back(s);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// parse the file to count the number of items
|
||||
int getNbItemFromFile(const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
int max = 0;
|
||||
char buffer[1024];
|
||||
while (fgets(buffer, 1024, f))
|
||||
{
|
||||
int n;
|
||||
fscanf(f, "_Items#%d", &n);
|
||||
if (n > max)
|
||||
max = n;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return max;
|
||||
}
|
||||
|
||||
// generate .csv file based on actual filled structure
|
||||
int exportCsv(const char *filename)
|
||||
{
|
||||
nlassert(fields.size() != 0);
|
||||
|
||||
uint i, j;
|
||||
FILE *f = fopen(filename, "w");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
// print fields name
|
||||
for (i=0 ; i<fields.size()-1 ; i++)
|
||||
fprintf(f, "%s;", fields[i].c_str());
|
||||
fprintf(f, "%s\n", fields[fields.size()-1].c_str());
|
||||
|
||||
// print values for each item
|
||||
for (i=0 ; i<items.size() ; i++)
|
||||
{
|
||||
for (j=0 ; j<items[i].size()-1 ; j++)
|
||||
fprintf(f, "%s;", items[i][j].c_str());
|
||||
fprintf(f, "%s\n", items[i][items[i].size()-1].c_str());
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read .csv file to fill the structures 'items' and 'fields'
|
||||
int importCsv(const char *filename)
|
||||
{
|
||||
verifCsvFile(filename);
|
||||
|
||||
char buffer[1024];
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (f == NULL)
|
||||
nlerror("Can't open file : %s", filename);
|
||||
|
||||
// read fields name
|
||||
{
|
||||
fgets(buffer, 1024, f);
|
||||
CSString s(buffer);
|
||||
s = s.strtok("\n");
|
||||
|
||||
do
|
||||
{
|
||||
fields.push_back(s.splitTo(';', true));
|
||||
} while (s != "");
|
||||
}
|
||||
|
||||
// read values for each item
|
||||
while (fgets(buffer, 1024, f))
|
||||
{
|
||||
CSString s(buffer), val;
|
||||
|
||||
// first is the number
|
||||
val = (s.splitTo(';', true));
|
||||
uint n = val.atosi();
|
||||
|
||||
// resize if needed
|
||||
if (n+1 > items.size())
|
||||
items.resize(n+1);
|
||||
|
||||
// add item id
|
||||
items[n].push_back(val);
|
||||
|
||||
// add others
|
||||
do
|
||||
{
|
||||
val = s.splitTo(';', true);
|
||||
items[n].push_back(val);
|
||||
} while (s != "");
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// compute item boundary in the file (min and max lines)
|
||||
void getItemBounds(const CVectorSString &lines, uint num, uint &a, uint &b)
|
||||
{
|
||||
a = b = 0;
|
||||
uint i = -1;
|
||||
bool ok = false;
|
||||
|
||||
while (++i < lines.size() && !ok)
|
||||
{
|
||||
if (lines[i] == "" || lines[i].find("//") != string::npos)
|
||||
continue;
|
||||
|
||||
// get item number
|
||||
uint n;
|
||||
if (sscanf(lines[i].c_str(), "_Items#%d", &n) == 0)
|
||||
continue;
|
||||
|
||||
// find it
|
||||
if (n == num)
|
||||
{
|
||||
// frist line
|
||||
if (a == 0)
|
||||
a = b = i+1;
|
||||
// more line
|
||||
else
|
||||
b++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// end
|
||||
if (a != 0)
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
// found it ?
|
||||
if (a != 0)
|
||||
{
|
||||
ok = true;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
// update an item field with a new value
|
||||
void updateItemField(CVectorSString &lines, uint itemIndex, uint fieldIndex, uint &a, uint &b)
|
||||
{
|
||||
string field = fields[fieldIndex];
|
||||
string val = items[itemIndex][fieldIndex];
|
||||
string s = "_Items#";
|
||||
s += toString(itemIndex);
|
||||
s += ".";
|
||||
s += field;
|
||||
|
||||
// remove jump
|
||||
val = CSString(val).strtok("\n");
|
||||
|
||||
uint craftLine = 0;
|
||||
bool found = false;
|
||||
uint i = a-1;
|
||||
|
||||
// first pass to check if param have changed
|
||||
for (i=a ; i<b ; i++)
|
||||
{
|
||||
string line = s + "= " + val;
|
||||
uint pos = pos = lines[i].find(line.c_str());
|
||||
if (pos != string::npos)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// second pass if new value
|
||||
i = a-1;
|
||||
while (++i<b && !found)
|
||||
{
|
||||
uint pos;
|
||||
|
||||
// store the line "_CraftParameters" : reference line
|
||||
if (craftLine == 0)
|
||||
{
|
||||
pos = lines[i].find("_CraftParameters");
|
||||
if (pos != string::npos)
|
||||
craftLine = i;
|
||||
}
|
||||
|
||||
// search string
|
||||
pos = lines[i].find(s.c_str());
|
||||
if (pos == string::npos)
|
||||
continue;
|
||||
|
||||
if (val != "")
|
||||
{
|
||||
// check if the attribute is the right one and not included in another one
|
||||
// for example: Protection is in ProtectionFactor
|
||||
if (!CSString::isValidFileNameChar(lines[i][s.size()]))
|
||||
{
|
||||
found = true;
|
||||
|
||||
if (val != "nul")
|
||||
{
|
||||
// udpdate value
|
||||
lines[i] = s;
|
||||
lines[i] += "= ";
|
||||
lines[i] += val;
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove value
|
||||
CVectorSString::iterator it = lines.begin() + i;
|
||||
lines.erase(it);
|
||||
i--;
|
||||
b--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// param not found
|
||||
if (!found && val != "" && val != "nul")
|
||||
{
|
||||
// add it
|
||||
if (field.find("_CraftParameters") == string::npos)
|
||||
{
|
||||
// before craftLine
|
||||
CVectorSString::iterator it = lines.begin() + craftLine;
|
||||
lines.insert(it, s + "= " + val);
|
||||
}
|
||||
else
|
||||
{
|
||||
// after craftLine
|
||||
CVectorSString::iterator it = lines.begin() + craftLine + 1;
|
||||
lines.insert(it, s + "= " + val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add a new item a the end of the file
|
||||
void addNewItem(CVectorSString &lines, uint itemIndex)
|
||||
{
|
||||
CVectorSString::iterator it = lines.end();
|
||||
|
||||
string s = "_Items#" + toString(itemIndex);
|
||||
lines.insert(lines.end(), s);
|
||||
lines.insert(lines.end(), s + "._SheetId=undef");
|
||||
lines.insert(lines.end(), s + "._ClientInventoryPosition= -1");
|
||||
lines.insert(lines.end(), s + "._Recommended= 250");
|
||||
lines.insert(lines.end(), s + "._LocSlot= " + toString(itemIndex));
|
||||
lines.insert(lines.end(), s + "._PhraseId=undef");
|
||||
lines.insert(lines.end(), s + "._CraftParameters");
|
||||
lines.insert(lines.end(), "\n");
|
||||
}
|
||||
|
||||
// update all items with new values
|
||||
int updateItems(const char *filename)
|
||||
{
|
||||
// verify file
|
||||
verifItemsFile(filename);
|
||||
|
||||
CSString data;
|
||||
data.readFromFile(filename);
|
||||
|
||||
CVectorSString lines;
|
||||
data.splitLines(lines);
|
||||
|
||||
for (uint itemIndex=0 ; itemIndex<items.size() ; itemIndex++)
|
||||
{
|
||||
nlassert(fields.size() >= items[itemIndex].size());
|
||||
cout << "Updating item " << itemIndex << endl;
|
||||
|
||||
uint a, b;
|
||||
getItemBounds(lines, itemIndex, a, b);
|
||||
|
||||
// no bound found, it's a new item
|
||||
if (b == 0)
|
||||
{
|
||||
addNewItem(lines, itemIndex);
|
||||
getItemBounds(lines, itemIndex, a, b);
|
||||
}
|
||||
|
||||
for (uint fieldIndex=0 ; fieldIndex<items[itemIndex].size() ; fieldIndex++)
|
||||
updateItemField(lines, itemIndex, fieldIndex, a, b);
|
||||
}
|
||||
|
||||
// rewrite file
|
||||
data.clear();
|
||||
for (uint i=0 ; i<lines.size() ; i++)
|
||||
data += lines[i] + "\n";
|
||||
data.writeToFile(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NLMISC::CApplicationContext AppContext;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
string csvFile, itemsFile, scriptFile, curDir;
|
||||
|
||||
|
||||
|
||||
// check number of arguments
|
||||
if (argc != 3)
|
||||
nlerror("Bad arguments number !");
|
||||
|
||||
curDir = CPath::standardizePath(CPath::getCurrentPath());
|
||||
|
||||
// check extensions
|
||||
{
|
||||
string ext = CFile::getExtension(argv[2]);
|
||||
|
||||
if (ext == "csv")
|
||||
csvFile = argv[2];
|
||||
else if (ext == "script")
|
||||
scriptFile = argv[2];
|
||||
else
|
||||
nlerror("Bad extension : %s (use .csv or .script)", ext.c_str());
|
||||
|
||||
itemsFile = argv[1];
|
||||
}
|
||||
|
||||
// create a .csv file
|
||||
if (scriptFile != "")
|
||||
{
|
||||
if (CFile::getFilename(scriptFile) == scriptFile)
|
||||
scriptFile = curDir + scriptFile;
|
||||
|
||||
if (CFile::getFilename(itemsFile) == itemsFile)
|
||||
itemsFile = curDir + itemsFile;
|
||||
|
||||
// auto-add : _LocSlot & _PhraseId & _SheetId & _Recommended
|
||||
fields.push_back("_LocSlot");
|
||||
fields.push_back("_PhraseId");
|
||||
fields.push_back("_SheetId");
|
||||
fields.push_back("_Recommended");
|
||||
|
||||
// add other fields from file
|
||||
getFieldsFromFile(scriptFile.c_str());
|
||||
|
||||
// verify file
|
||||
verifItemsFile(itemsFile.c_str());
|
||||
|
||||
// How many items ?
|
||||
uint n = getNbItemFromFile(itemsFile.c_str()) + 1;
|
||||
items.resize(n);
|
||||
|
||||
// reserve memory
|
||||
for (uint i=0 ; i<n ; i++)
|
||||
items[i].resize(fields.size());
|
||||
|
||||
// read values from items file
|
||||
getItemsFromFile(itemsFile.c_str());
|
||||
|
||||
// generate the new file
|
||||
string csv = CFile::getFilename(itemsFile);
|
||||
string ext = CFile::getExtension(csv);
|
||||
exportCsv((CSString(csv).replace(string('.' + ext).c_str(), ".csv")).c_str());
|
||||
}
|
||||
|
||||
// create a .txt file
|
||||
if (csvFile != "")
|
||||
{
|
||||
if (CFile::getFilename(csvFile) == csvFile)
|
||||
csvFile = curDir + csvFile;
|
||||
|
||||
// load csv values
|
||||
importCsv(csvFile.c_str());
|
||||
if (itemsFile != "" && CFile::isExists(itemsFile.c_str()))
|
||||
updateItems(itemsFile.c_str());
|
||||
else
|
||||
nlerror("Can't find file : %s", itemsFile.c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ named_items_2_csv.cpp)
|
||||
|
||||
ADD_EXECUTABLE(named2csv ${SRC})
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
|
||||
|
|
|
@ -1,290 +0,0 @@
|
|||
/*
|
||||
Petite documentation sur le fonctionnement du plugin
|
||||
|
||||
1) Le WorldEditor se connecte au plugin (config dans WorldEditorPlugin.cfg)
|
||||
|
||||
2) Le plugin se connecte au World_Editor_Service
|
||||
|
||||
3) Le World_Editor_Service (config dans WorldEditorService.cfg) envoie des paquets contenant au maximum 100 joueurs.
|
||||
Ces joueurs sont soit nouveaux, soit leurs coordonnées ont changé.
|
||||
|
||||
4) Les informations des joueurs sont envoyées (voir onIdle) sous forme de primitives "player":
|
||||
|
||||
Voici la définition de la primitive "player", dans WORLD_EDITOR_SCRIPT.XML
|
||||
|
||||
<PRIMITIVE CLASS_NAME="root" TYPE="node" AUTO_INIT="true" DELETABLE="true">
|
||||
<DYNAMIC_CHILD CLASS_NAME="player"/>
|
||||
</PRIMITIVE>
|
||||
|
||||
<!-- player node -->
|
||||
<PRIMITIVE CLASS_NAME="player" TYPE="point" R="255" G="0" B="0" A="128" AUTO_INIT="true" DELETABLE="false" LINK_BROTHERS="false" SHOW_ARROW="false">
|
||||
<PARAMETER NAME= "x" TYPE="string" VISIBLE="true"> <DEFAULT_VALUE VALUE= "0" /> </PARAMETER>
|
||||
<PARAMETER NAME= "y" TYPE="string" VISIBLE="true"> <DEFAULT_VALUE VALUE= "0" /> </PARAMETER>
|
||||
</PRIMITIVE>
|
||||
|
||||
5) World_Editor_Service utilise un cache pour stocker les déplacements des joueurs, afin de n'envoyer que ce qui bouge
|
||||
|
||||
6) World_Editor_Plugin utilise aussi un cache avec un pointeur sur les Primitives, afin de ne modifier dans WE que ce qui bouge
|
||||
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
#include "plugin.h"
|
||||
#include "resource.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "LoadDialog.h"
|
||||
#include "nel/sound/u_listener.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace NLLIGO;
|
||||
using namespace NLSOUND;
|
||||
using namespace NLNET;
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
string _name;
|
||||
float _x, _y;
|
||||
const IPrimitive *primitive;
|
||||
// Constructor
|
||||
Player::Player()
|
||||
{
|
||||
primitive = NULL;
|
||||
}
|
||||
|
||||
Player::Player(string name, float x, float y)
|
||||
{
|
||||
primitive = NULL;
|
||||
_name = name;
|
||||
_x = x;
|
||||
_y = y;
|
||||
}
|
||||
/// Destructor
|
||||
Player::~Player()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
vector<Player> StackPlayers;
|
||||
|
||||
map<string, Player> StoredPlayers;
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void *createPlugin()
|
||||
{
|
||||
return new CPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
CPlugin::CPlugin()
|
||||
: _PluginAccess(0)
|
||||
{
|
||||
m_Initialized = false;
|
||||
_Client = NULL;
|
||||
StackPlayers.clear();
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
delete _Client;
|
||||
|
||||
if (m_Initialized)
|
||||
{
|
||||
_PluginAccess->deleteRootPluginPrimitive();
|
||||
m_Initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::progress (float progressValue)
|
||||
{
|
||||
/*char tmp[1024];
|
||||
sprintf(tmp, "Initializing mixer : %i%%", int(progressValue * 100));
|
||||
LoadDlg->Message = tmp;
|
||||
LoadDlg->UpdateData(FALSE);
|
||||
LoadDlg->RedrawWindow();*/
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void serverSentPos (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
|
||||
{
|
||||
// Called when the server sent a POS message
|
||||
uint32 count;
|
||||
|
||||
msgin.serial(count);
|
||||
for (uint i = 0;i < count;++i)
|
||||
{
|
||||
string name;
|
||||
msgin.serial(name);
|
||||
|
||||
float x, y;
|
||||
msgin.serial(x);
|
||||
msgin.serial(y);
|
||||
// we received name, x, y, we save it in the stack
|
||||
StackPlayers.push_back (Player(name, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void serverSentInfo (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
|
||||
{
|
||||
// Called when the server sent a INFO message
|
||||
string text;
|
||||
msgin.serial(text);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// All messages handled by this server
|
||||
#define NB_CB 2
|
||||
TCallbackItem CallbackArray[NB_CB] =
|
||||
{
|
||||
{ "POS", serverSentPos },
|
||||
{ "INFO", serverSentInfo },
|
||||
};
|
||||
|
||||
void CPlugin::init(IPluginAccess *pluginAccess)
|
||||
{
|
||||
CLoadDialog *LoadDlg;
|
||||
|
||||
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||
AfxEnableControlContainer();
|
||||
_PluginAccess = pluginAccess;
|
||||
//#undef new
|
||||
LoadDlg = new CLoadDialog;
|
||||
//#define new NL_NEW
|
||||
LoadDlg->Create(IDD_DIALOG_LOAD);
|
||||
LoadDlg->Message = "Connecting...";
|
||||
LoadDlg->UpdateData(FALSE);
|
||||
//LoadDlg->Invalidate();
|
||||
LoadDlg->ShowWindow(SW_SHOW);
|
||||
//LoadDlg->RedrawWindow();
|
||||
|
||||
// connect to the server here...
|
||||
|
||||
// Read the host where to connect in the client.cfg file
|
||||
CConfigFile ConfigFile;
|
||||
ConfigFile.load ("client.cfg");
|
||||
string LSHost(ConfigFile.getVar("LSHost").asString());
|
||||
|
||||
// Init and Connect the client to the server located on port 3333
|
||||
_Client = new CCallbackClient();
|
||||
_Client->addCallbackArray (CallbackArray, NB_CB);
|
||||
|
||||
//printf("Please wait connecting...\n");
|
||||
try
|
||||
{
|
||||
CInetAddress addr(LSHost+":48888");
|
||||
_Client->connect(addr);
|
||||
}
|
||||
catch(ESocket &e)
|
||||
{
|
||||
MessageBox (NULL, e.what(), "Error", MB_ICONERROR|MB_OK);
|
||||
delete LoadDlg;
|
||||
LoadDlg = 0;
|
||||
return;
|
||||
}
|
||||
delete LoadDlg;
|
||||
LoadDlg = 0;
|
||||
|
||||
if (!_Client->connected())
|
||||
{
|
||||
MessageBox (NULL, "The connection failed", "Error", MB_ICONERROR|MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
//#undef new
|
||||
_DialogFlag = new CDialogFlags(/*_Mixer*/);
|
||||
//#define new NL_NEW
|
||||
// open the dialog flag window
|
||||
_DialogFlag->Create(IDD_DIALOG_FLAGS, CWnd::FromHandle(_PluginAccess->getMainWindow()->m_hWnd));
|
||||
_DialogFlag->init(this);
|
||||
_DialogFlag->ShowWindow(TRUE);
|
||||
|
||||
//
|
||||
{
|
||||
CMessage msg;
|
||||
msg.setType("WINDOW");
|
||||
float xmin = 0;
|
||||
float xmax = 10000;
|
||||
float ymin = 0;
|
||||
float ymax = 10000;
|
||||
msg.serial (xmin);
|
||||
msg.serial (ymin);
|
||||
msg.serial (xmax);
|
||||
msg.serial (ymax);
|
||||
_Client->send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/// The current region has changed.
|
||||
void CPlugin::primitiveChanged(const NLLIGO::IPrimitive *root)
|
||||
{
|
||||
}
|
||||
|
||||
/// The listener has been moved on the map.
|
||||
void CPlugin::positionMoved(const NLMISC::CVector &position)
|
||||
{
|
||||
}
|
||||
|
||||
void CPlugin::lostPositionControl()
|
||||
{
|
||||
}
|
||||
|
||||
void CPlugin::onIdle()
|
||||
{
|
||||
if (_Client && _Client->connected())
|
||||
{
|
||||
// during the first call, we create a Root primitive to store all players
|
||||
if (!m_Initialized)
|
||||
{
|
||||
m_Initialized = true;
|
||||
_PluginAccess->createRootPluginPrimitive();
|
||||
}
|
||||
else
|
||||
{
|
||||
// first, we receive the stack of messages, which is composed of players informations
|
||||
_Client->update();
|
||||
// now, we insert the players into the GUI
|
||||
for (uint i = 0; i < StackPlayers.size(); ++i)
|
||||
{
|
||||
map<string, Player>::const_iterator ite;
|
||||
ite = StoredPlayers.find(StackPlayers[i]._name);
|
||||
if (ite == StoredPlayers.end())
|
||||
{
|
||||
// if the player doesn't exist in the static list, we add it
|
||||
//StoredPlayers.insert(map<string, Player>::value_type(StackPlayers[i]._name, StackPlayers[i]));
|
||||
StoredPlayers[StackPlayers[i]._name] = StackPlayers[i];
|
||||
std::vector<CPrimitiveClass::CInitParameters> Parameters;
|
||||
|
||||
Parameters.push_back (CPrimitiveClass::CInitParameters ());
|
||||
CPrimitiveClass::CInitParameters ¶m1 = Parameters.back ();
|
||||
param1.DefaultValue.resize (1);
|
||||
param1.Name = "x";
|
||||
param1.DefaultValue[0].GenID = false;
|
||||
param1.DefaultValue[0].Name = toString(StackPlayers[i]._x);
|
||||
|
||||
Parameters.push_back (CPrimitiveClass::CInitParameters ());
|
||||
CPrimitiveClass::CInitParameters ¶m2 = Parameters.back ();
|
||||
param2.DefaultValue.resize (1);
|
||||
param2 = Parameters.back ();
|
||||
param2.Name = "y";
|
||||
param2.DefaultValue[0].GenID = false;
|
||||
param2.DefaultValue[0].Name = toString(StackPlayers[i]._y);
|
||||
|
||||
// create a player in WorldEditor
|
||||
StoredPlayers[StackPlayers[i]._name].primitive = _PluginAccess->createPluginPrimitive("player",StackPlayers[i]._name.c_str(),NLMISC::CVector(StackPlayers[i]._x,StackPlayers[i]._y,0),0,Parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the player has moved, we need to change its coordinates
|
||||
_PluginAccess->movePluginPrimitive(StoredPlayers[StackPlayers[i]._name].primitive, CVector(StackPlayers[i]._x, StackPlayers[i]._y, 0));
|
||||
}
|
||||
}
|
||||
// we clear the stack
|
||||
StackPlayers.clear();
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,289 +0,0 @@
|
|||
/*#include "std_header.h"
|
||||
//
|
||||
#include "village.h"
|
||||
#include "zone_util.h"
|
||||
//
|
||||
#include "nel/georges/u_form.h"
|
||||
#include "nel/georges/u_form_elm.h"
|
||||
#include "nel/georges/u_form_loader.h"
|
||||
//
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/file.h"
|
||||
//
|
||||
#include "3d/shape.h"
|
||||
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
//**********************************************************************************************
|
||||
CVillageGrid::CVillageGrid()
|
||||
{
|
||||
_ZoneMinX = 0;
|
||||
_ZoneMinY = 0;
|
||||
|
||||
}
|
||||
|
||||
//**********************************************************************************************
|
||||
void CVillageGrid::init(uint gridWidth, uint gridHeight, sint zoneMinX, sint zoneMinY)
|
||||
{
|
||||
reset();
|
||||
nlassert(gridWidth > 0);
|
||||
nlassert(gridHeight > 0);
|
||||
_ZoneMinX = zoneMinX;
|
||||
_ZoneMinY = zoneMinY;
|
||||
VillageGrid.init(gridWidth, gridHeight);
|
||||
}
|
||||
|
||||
//**********************************************************************************************
|
||||
void CVillageGrid::reset()
|
||||
{
|
||||
NLMISC::contReset(*this);
|
||||
}
|
||||
|
||||
//**********************************************************************************************
|
||||
void CVillageGrid::addVillagesFromContinent(const std::string &continentSheetName)
|
||||
{
|
||||
// Load the form
|
||||
NLGEORGES::UFormLoader *loader = NLGEORGES::UFormLoader::createLoader();
|
||||
//
|
||||
std::string path = CPath::lookup(continentSheetName, false, false);
|
||||
if (path.empty())
|
||||
{
|
||||
nlwarning("Path not found for %s.", continentSheetName.c_str());
|
||||
return;
|
||||
}
|
||||
NLGEORGES::UForm *villageForm;
|
||||
villageForm = loader->loadForm(path.c_str());
|
||||
if(villageForm != NULL)
|
||||
{
|
||||
NLGEORGES::UFormElm &rootItem = villageForm->getRootNode();
|
||||
// try to get the village list
|
||||
// Load the village list
|
||||
NLGEORGES::UFormElm *villagesItem;
|
||||
if(!(rootItem.getNodeByName (&villagesItem, "Villages") && villagesItem))
|
||||
{
|
||||
nlwarning("No villages where found in %s", continentSheetName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get number of village
|
||||
uint numVillage;
|
||||
nlverify (villagesItem->getArraySize (numVillage));
|
||||
|
||||
// For each village
|
||||
for(uint k = 0; k < numVillage; ++k)
|
||||
{
|
||||
NLGEORGES::UFormElm *currVillage;
|
||||
if (!(villagesItem->getArrayNode (&currVillage, k) && currVillage))
|
||||
{
|
||||
nlwarning("Couldn't get village %d in continent %s", continentSheetName.c_str(), k);
|
||||
continue;
|
||||
}
|
||||
// check that this village is in the dependency zones
|
||||
NLGEORGES::UFormElm *zoneNameItem;
|
||||
if (!currVillage->getNodeByName (&zoneNameItem, "Zone") && zoneNameItem)
|
||||
{
|
||||
nlwarning("Couldn't get zone item of village %d in continent %s", continentSheetName.c_str(), k);
|
||||
continue;
|
||||
}
|
||||
std::string zoneName;
|
||||
if (!zoneNameItem->getValue(zoneName))
|
||||
{
|
||||
nlwarning("Couldn't get zone name of village %d in continent %s", continentSheetName.c_str(), k);
|
||||
continue;
|
||||
}
|
||||
sint zoneX, zoneY;
|
||||
if (!getZonePos(zoneName, zoneX, zoneY))
|
||||
{
|
||||
nlwarning("Zone name of village %d in continent %s is invalid", continentSheetName.c_str(), k);
|
||||
continue;
|
||||
}
|
||||
sint villageMinX, villageMinY;
|
||||
sint villageMaxX, villageMaxY;
|
||||
|
||||
|
||||
// retrieve width & height of covered region
|
||||
uint32 regionWidth;
|
||||
uint32 regionHeight;
|
||||
float centerX, centerY;
|
||||
if (!currVillage->getValueByName(regionWidth, "Width") ||
|
||||
!currVillage->getValueByName(regionHeight, "Height") ||
|
||||
!currVillage->getValueByName(centerX, "CenterX") ||
|
||||
!currVillage->getValueByName(centerY, "CenterY"))
|
||||
{
|
||||
nlwarning("Can't retrieve region covered by village %d in continent %s", continentSheetName.c_str(), k);
|
||||
continue;
|
||||
}
|
||||
//
|
||||
villageMinX = villageMaxX = zoneX;
|
||||
villageMinY = villageMaxY = zoneY;
|
||||
// extends with bbox from center to min corner if leveldesigner forgot to enter good width & height
|
||||
villageMaxX = std::max(villageMaxX, (sint) ((zoneX * 160.f + 2.f * centerX) / 160.f));
|
||||
villageMaxY = std::max(villageMaxY, (sint) ((zoneY * 160.f + 2.f * centerY) / 160.f));
|
||||
//
|
||||
villageMinX -= _ZoneMinX;
|
||||
villageMaxX -= _ZoneMinX;
|
||||
villageMinY -= _ZoneMinY;
|
||||
villageMaxY -= _ZoneMinY;
|
||||
//
|
||||
CVillage village;
|
||||
if (loadVillageSheet(currVillage, continentSheetName, k, village))
|
||||
{
|
||||
//
|
||||
village.FileModificationDate = std::max(village.FileModificationDate, CFile::getFileModificationDate(path));
|
||||
//
|
||||
Villages.push_back(CVillage());
|
||||
Villages.back().swap(village);
|
||||
//
|
||||
for (sint y = villageMinY; y <= (sint) villageMaxY; ++y)
|
||||
{
|
||||
if (y < 0) continue;
|
||||
if (y >= (sint) VillageGrid.getHeight()) continue;
|
||||
for (sint x = villageMinX; x <= (sint) villageMaxX; ++x)
|
||||
{
|
||||
if (x < 0) continue;
|
||||
if (x >= (sint) VillageGrid.getWidth()) continue;
|
||||
VillageGrid(x, y).push_back(Villages.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Can't load continent form : %s", continentSheetName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//**********************************************************************************************
|
||||
bool CVillageGrid::loadVillageSheet(const NLGEORGES::UFormElm *villageItem, const std::string &continentSheetName, uint villageIndex, CVillage &dest)
|
||||
{
|
||||
dest.IG.clear();
|
||||
const NLGEORGES::UFormElm *igNamesItem;
|
||||
if (! (villageItem->getNodeByName (&igNamesItem, "IgList") && igNamesItem) )
|
||||
{
|
||||
nlwarning("No list of IGs was found in the continent form %s, village #%d", continentSheetName.c_str(), (int) villageIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get number of village
|
||||
uint numIgs;
|
||||
nlverify (igNamesItem->getArraySize (numIgs));
|
||||
const NLGEORGES::UFormElm *currIg;
|
||||
uint32 mostRecentIGDate = 0;
|
||||
for(uint l = 0; l < numIgs; ++l)
|
||||
{
|
||||
if (!(igNamesItem->getArrayNode (&currIg, l) && currIg))
|
||||
{
|
||||
nlwarning("Couldn't get ig #%d in the continent form %s, in village #%d", l, continentSheetName.c_str(), (int) villageIndex);
|
||||
continue;
|
||||
}
|
||||
const NLGEORGES::UFormElm *igNameItem;
|
||||
currIg->getNodeByName (&igNameItem, "IgName");
|
||||
std::string igName;
|
||||
if (!igNameItem->getValue (igName))
|
||||
{
|
||||
nlwarning("Couldn't get ig name of ig #%d in the continent form %s, in village #%d", l, continentSheetName.c_str(), (int) villageIndex);
|
||||
continue;
|
||||
}
|
||||
if (igName.empty())
|
||||
{
|
||||
nlwarning("Ig name of ig #%d in the continent form %s, in village #%d is an empty string", l, continentSheetName.c_str(), (int) villageIndex);
|
||||
continue;
|
||||
}
|
||||
// ensure .ig
|
||||
igName = CFile::getFilenameWithoutExtension(igName) + ".ig";
|
||||
|
||||
|
||||
CIGInfo igInfo;
|
||||
|
||||
// add this ig
|
||||
std::string nameLookup = CPath::lookup (igName, false, true);
|
||||
if (!nameLookup.empty())
|
||||
{
|
||||
igInfo.Path = nameLookup;
|
||||
dest.IG.push_back(igInfo);
|
||||
mostRecentIGDate = std::max(mostRecentIGDate, CFile::getFileModificationDate(nameLookup));
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Couldn't find ig %s in continent form %s, in village %d", igName.c_str(), continentSheetName.c_str(), (int) villageIndex);
|
||||
}
|
||||
}
|
||||
dest.FileModificationDate = mostRecentIGDate;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//**********************************************************************************************
|
||||
void CVillage::load(TShapeCache &shapeCache)
|
||||
{
|
||||
for(std::vector<CIGInfo>::iterator it = IG.begin(); it != IG.end(); ++it)
|
||||
{
|
||||
it->load(shapeCache);
|
||||
}
|
||||
}
|
||||
|
||||
//**********************************************************************************************
|
||||
void CIGInfo::load(TShapeCache &shapeCache)
|
||||
{
|
||||
if (Loaded) return;
|
||||
Loaded = true; // even if loading fails, don't try twice to load it
|
||||
try
|
||||
{
|
||||
CIFile stream;
|
||||
stream.open(Path);
|
||||
printf(Path.c_str());
|
||||
CSmartPtr<CInstanceGroup> ig = new CInstanceGroup;
|
||||
ig->serial(stream);
|
||||
IG = ig; // commit
|
||||
}
|
||||
catch(EStream &e)
|
||||
{
|
||||
nlwarning(e.what());
|
||||
}
|
||||
if (IG)
|
||||
{
|
||||
// complete cache
|
||||
for(uint k = 0; k < IG->getNumInstance(); ++k)
|
||||
{
|
||||
std::string shapeName = standardizeShapeName(IG->getShapeName(k));
|
||||
if (NLMISC::strlwr(CFile::getExtension(shapeName)) == "pacs_prim")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
TShapeCache::iterator it = shapeCache.find(shapeName);
|
||||
CShapeInfo si;
|
||||
bool buildOK = false;
|
||||
if (it == shapeCache.end())
|
||||
{
|
||||
CShapeStream ss;
|
||||
try
|
||||
{
|
||||
|
||||
CIFile stream;
|
||||
std::string path = CPath::lookup(shapeName, false, false);
|
||||
if (!path.empty())
|
||||
{
|
||||
stream.open(path);
|
||||
ss.serial(stream);
|
||||
CShapeInfo si;
|
||||
si.build(*ss.getShapePointer());
|
||||
delete ss.getShapePointer();
|
||||
shapeCache[shapeName].swap(si);
|
||||
}
|
||||
}
|
||||
catch (EStream &e)
|
||||
{
|
||||
// shape not loaded
|
||||
nlwarning(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
|
@ -1,72 +0,0 @@
|
|||
/*#ifndef _VILLAGE_H
|
||||
#define _VILLAGE_H
|
||||
|
||||
#include "nel/misc/array_2d.h"
|
||||
#include "3d/shape_info.h"
|
||||
//
|
||||
#include "3d/scene_group.h"
|
||||
//
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
//
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace NLGEORGES
|
||||
{
|
||||
class UFormElm;
|
||||
}
|
||||
|
||||
class CIGInfo
|
||||
{
|
||||
public:
|
||||
std::string Path;
|
||||
NLMISC::CSmartPtr<NL3D::CInstanceGroup> IG; // NULL if not loaded yet
|
||||
bool Loaded;
|
||||
public:
|
||||
CIGInfo() : Loaded(false) {}
|
||||
// load data & complete shape cache. no-op if datas where already loaded
|
||||
void load(NL3D::TShapeCache &shapeCache);
|
||||
};
|
||||
|
||||
|
||||
class CVillage
|
||||
{
|
||||
public:
|
||||
std::vector<CIGInfo> IG;
|
||||
uint32 FileModificationDate;
|
||||
public:
|
||||
void swap(CVillage &other)
|
||||
{
|
||||
IG.swap(other.IG);
|
||||
std::swap(other.FileModificationDate, FileModificationDate);
|
||||
}
|
||||
// load data & complete shape cache. no-op if datas where already loaded
|
||||
void load(NL3D::TShapeCache &shapeCache);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CVillageGrid
|
||||
{
|
||||
public:
|
||||
std::vector<CVillage> Villages;
|
||||
NLMISC::CArray2D<std::list<uint> > VillageGrid; // each grid cells gives the list of villages that overlap that cell (identified by their indices into 'Villages')
|
||||
public:
|
||||
CVillageGrid();
|
||||
//
|
||||
void init(uint gridWidth, uint gridHright, sint zoneMinX, sint zoneMinY);
|
||||
void reset();
|
||||
// Load & add all villages of a continent to the map
|
||||
void addVillagesFromContinent(const std::string &continentSheetName);
|
||||
private:
|
||||
sint _ZoneMinX;
|
||||
sint _ZoneMinY;
|
||||
private:
|
||||
bool loadVillageSheet(const NLGEORGES::UFormElm *villageItem, const std::string &continentSheetName, uint villageIndex, CVillage &dest);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
*/
|
|
@ -1,283 +0,0 @@
|
|||
/** \file char_commands.cpp
|
||||
*
|
||||
* $id$
|
||||
*
|
||||
* todo:
|
||||
* - charScanScript commands
|
||||
* * path for script files in cfg
|
||||
* - charScanScriptNew <description>
|
||||
* - charScanScriptLoad <file_name>
|
||||
* - charScanScriptSave <file_name>
|
||||
* - charScanScriptListFiles
|
||||
* - charScanScriptListLines
|
||||
* - charScanScriptDeleteLine <line_number>
|
||||
* - charScanScriptAddInputFiles <directory> <wildcards>
|
||||
* - charScanScriptAddInfoExtractor <infoExtractorName> [<args>]
|
||||
* - charScanScriptAddFilter <filterName> [<args>]
|
||||
* - charScanScriptAddPreInclude <include_file_name>
|
||||
* - charScanScriptAddPostInclude <include_file_name>
|
||||
* - charScanScriptSetOutputDirectory <directoryName>
|
||||
* - charScanScriptSetDescription <description>
|
||||
* - charScanScriptRun [-s <file_name>] [-o <output_directory>]
|
||||
* - addJobCharScanScript [-s <file_name>] [-o <output_directory>]
|
||||
* - charScanScriptListOutputFiles [<output_directory>]
|
||||
* - charScanScriptListOutputFileContents <file_name> [<output_directory>]
|
||||
* - charScanScriptTestFileList
|
||||
* - charScanScriptTestOutput <test_input_file_path>
|
||||
* - charScanScriptHelp
|
||||
* - path for generated files (from cfg + override) => managed incrementally with directory numbering
|
||||
* - add incremental update systems
|
||||
* - add tables with a column per day ()
|
||||
* - add tables with a column per week (limited number of weeks)
|
||||
* - add tables with a column per month (limited number of months)
|
||||
*/
|
||||
|
||||
/*
|
||||
bool CCharFilterFactory::beginScanJob(const std::vector<std::string>& files, const std::vector<std::string>& filters)
|
||||
{
|
||||
bool noErrors= true;
|
||||
|
||||
// create a new job
|
||||
NLMISC::CSmartPtr<CCharacterScanJob> job=new CCharacterScanJob;
|
||||
|
||||
// look after the filters
|
||||
for (uint32 i=0;i<filters.size();++i)
|
||||
{
|
||||
// locate the info extractor corresponding to the given name
|
||||
uint32 j=0;
|
||||
for (j=0;j<_Filters.size();++j)
|
||||
if (filters[i]==_Filters[j]->getName())
|
||||
break;
|
||||
|
||||
// if none found then warn and skip passed
|
||||
if(j>=_Filters.size())
|
||||
{
|
||||
nlwarning("Unknown info extractor: %s",filters[i].c_str());
|
||||
noErrors=false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// add the info extractor to the new job
|
||||
job->addFilter(_Filters[j]);
|
||||
}
|
||||
|
||||
// look after the files
|
||||
job->addFiles(files);
|
||||
|
||||
// add the job to the job manager
|
||||
if (noErrors==true)
|
||||
CJobManager::getInstance()->addJob(&*job);
|
||||
|
||||
return noErrors;
|
||||
}
|
||||
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// includes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "nel/misc/variable.h"
|
||||
#include "nel/misc/algo.h"
|
||||
#include "game_share/persistent_data.h"
|
||||
|
||||
#include "character.h"
|
||||
#include "job_manager.h"
|
||||
#include "char_info_extractor_factory.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Namespaces
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CVariable<string> SourceDirectory("variables", "SourceDirectory", "Directory we scan for files", string("."), 0, true);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands - misc character related
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NLMISC_COMMAND(listCharNames,"display the names of the characters int he listed save files","<input file name>")
|
||||
{
|
||||
if (args.size()!=1 && args.size()!=0)
|
||||
return false;
|
||||
|
||||
std::string wildcard="pdr_account*";
|
||||
if (args.size()==1)
|
||||
wildcard=args[0];
|
||||
|
||||
std::vector<std::string> files;
|
||||
NLMISC::CPath::getPathContent(SourceDirectory.get().c_str(),false,false,true,files);
|
||||
for (uint32 i=files.size();i--;)
|
||||
{
|
||||
if (!NLMISC::testWildCard(NLMISC::CFile::getFilename(files[i]),wildcard))
|
||||
{
|
||||
files[i]=files.back();
|
||||
files.pop_back();
|
||||
}
|
||||
}
|
||||
std::sort(files.begin(),files.end());
|
||||
for (uint32 i=0;i<files.size();++i)
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(files[i].c_str());
|
||||
|
||||
CStatsScanCharacter c;
|
||||
c.apply(pdr);
|
||||
|
||||
log.displayNL("%-40s Name: %s ",files[i].c_str(),c.EntityBase._Name.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands - charScanner
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NLMISC_COMMAND(listCharInfoExtractors,"display the list of info extractors that exist for characters","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
CCharInfoExtractorFactory::getInstance()->displayInfoExtractorList(&log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands - jobsManager
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NLMISC_COMMAND(jobsPause,"pause execution of jobs","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
CJobManager::getInstance()->pause();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsResume,"resume execution of jobs","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
CJobManager::getInstance()->resume();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsPromote,"pause execution of jobs","<jobId>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
uint32 idx= atoi(args[0].c_str());
|
||||
if ( (idx==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid job id - should be a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
CJobManager::getInstance()->promoteJob(idx);
|
||||
CJobManager::getInstance()->listJobs(&log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(JobUpdatesPerUpdate,"set or display the number of job updates per service update","[<count>]")
|
||||
{
|
||||
if (args.size()>1)
|
||||
return false;
|
||||
|
||||
if (args.size()==1)
|
||||
{
|
||||
uint32 count= atoi(args[0].c_str());
|
||||
if ( (count==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid number");
|
||||
return false;
|
||||
}
|
||||
CJobManager::getInstance()->setJobUpdatesPerUpdate(count);
|
||||
}
|
||||
|
||||
nlinfo("JobUpdatesPerUpdate %d",CJobManager::getInstance()->getJobUpdatesPerUpdate());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsStatus,"display the status of the job manager","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
log.displayNL("%s",CJobManager::getInstance()->getStatus().c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsList,"display the list of unfinished jobs","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
CJobManager::getInstance()->listJobs(&log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsListAll,"display the list of all jobs (unfinished jobs are marked with a '*')","")
|
||||
{
|
||||
if (args.size()!=0)
|
||||
return false;
|
||||
|
||||
CJobManager::getInstance()->listJobHistory(&log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(jobsDisplayDetails,"display detailed info for the current job (or a given job)","[<job id>]")
|
||||
{
|
||||
switch (args.size())
|
||||
{
|
||||
case 0:
|
||||
CJobManager::getInstance()->displayCurrentJob(&log);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
uint32 idx= atoi(args[0].c_str());
|
||||
if ( (idx==0 && args[0]!="0") )
|
||||
{
|
||||
nlwarning("Argument is not a valid job id - should be a number");
|
||||
return false;
|
||||
}
|
||||
CJobManager::getInstance()->displayJob(idx,&log);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands - charScanScript
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
|
@ -1,7 +1,5 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/Backup\ 1\ of\ char_commands.cpp)
|
||||
|
||||
ADD_EXECUTABLE(stats_scan ${SRC})
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
|
||||
|
|
Loading…
Reference in a new issue