Merge branch 'fixes'

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent 7f33e9bdd6
commit 0e833c37ef
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -19,6 +19,7 @@
#include "stdpch.h" #include "stdpch.h"
#include "server_share/r2_variables.h" #include "server_share/r2_variables.h"
#include "messages.h"
#include "ai_grp_npc.h" #include "ai_grp_npc.h"
#include "ai_mgr_npc.h" #include "ai_mgr_npc.h"
#include "ai_bot_npc.h" #include "ai_bot_npc.h"
@ -35,6 +36,7 @@ extern bool simulateBug(int bugId);
using namespace MULTI_LINE_FORMATER; using namespace MULTI_LINE_FORMATER;
using namespace NLMISC; using namespace NLMISC;
using namespace NLNET;
using namespace std; using namespace std;
using namespace AITYPES; using namespace AITYPES;
@ -60,6 +62,7 @@ CSpawnGroupNpc::CSpawnGroupNpc(CPersistent<CSpawnGroup>& owner)
{ {
sint32 const randomVal = (sint32)CTimeInterface::gameCycle()-CAIS::rand32(20); sint32 const randomVal = (sint32)CTimeInterface::gameCycle()-CAIS::rand32(20);
_LastUpdate = (randomVal>=0)?randomVal:CTimeInterface::gameCycle(); _LastUpdate = (randomVal>=0)?randomVal:CTimeInterface::gameCycle();
_Cell = 0;
_LastBotUpdate = CTimeInterface::gameCycle(); _LastBotUpdate = CTimeInterface::gameCycle();
activityProfile().setAIProfile(new CGrpProfileNormal(this)); activityProfile().setAIProfile(new CGrpProfileNormal(this));
_BotUpdateTimer.set((CAIS::rand32(40)+((intptr_t)this>>2))%20); // start with a random value. _BotUpdateTimer.set((CAIS::rand32(40)+((intptr_t)this>>2))%20); // start with a random value.
@ -148,10 +151,10 @@ void CSpawnGroupNpc::sendInfoToEGS() const
void CSpawnGroupNpc::update() void CSpawnGroupNpc::update()
{ {
H_AUTO(GrpNpcUpdate); H_AUTO(GrpNpcUpdate);
++AISStat::GrpTotalUpdCtr; ++AISStat::GrpTotalUpdCtr;
++AISStat::GrpNpcUpdCtr; ++AISStat::GrpNpcUpdCtr;
uint32 const Dt = CTimeInterface::gameCycle()-_LastUpdate; uint32 const Dt = CTimeInterface::gameCycle()-_LastUpdate;
bool const inFight = activityProfile().getAIProfileType()==FIGHT_NORMAL; bool const inFight = activityProfile().getAIProfileType()==FIGHT_NORMAL;
@ -174,27 +177,27 @@ void CSpawnGroupNpc::update()
{ {
updateTrigger = 30; updateTrigger = 30;
} }
bool const haveToUpdateGroupBehaviour = (Dt>=updateTrigger); // every second. bool const haveToUpdateGroupBehaviour = (Dt>=updateTrigger); // every second.
if (haveToUpdateGroupBehaviour) if (haveToUpdateGroupBehaviour)
{ {
H_AUTO(GrpNpcUpdateBehaviour); H_AUTO(GrpNpcUpdateBehaviour);
// record the tick at which we ran this update (for future refference) // record the tick at which we ran this update (for future refference)
_LastUpdate = CTimeInterface::gameCycle(); _LastUpdate = CTimeInterface::gameCycle();
checkDespawn(); checkDespawn();
checkRespawn(); checkRespawn();
getPersistent().updateStateInstance(); getPersistent().updateStateInstance();
} }
// bot update()s -------------------------------------------------- // bot update()s --------------------------------------------------
{ {
if (haveToUpdateGroupBehaviour) if (haveToUpdateGroupBehaviour)
{ {
H_AUTO(GrpNpcUpdateBots); H_AUTO(GrpNpcUpdateBots);
_GroupInVision = false; _GroupInVision = false;
FOREACH(first,CCont<CBot>, bots()) FOREACH(first,CCont<CBot>, bots())
{ {
CSpawnBotNpc const* const bot = static_cast<CBotNpc*>(*first)->getSpawn(); CSpawnBotNpc const* const bot = static_cast<CBotNpc*>(*first)->getSpawn();
@ -212,21 +215,21 @@ void CSpawnGroupNpc::update()
} }
if (!bot->havePlayersAround()) if (!bot->havePlayersAround())
continue; continue;
_GroupInVision = true; _GroupInVision = true;
break; break;
} }
} }
// TODO : hack : remove this when the "can't reach and turn arround" debility is corrected // TODO : hack : remove this when the "can't reach and turn arround" debility is corrected
bool fastUpdate = _GroupInVision || inFight; bool fastUpdate = _GroupInVision || inFight;
bool slowUpdate = (CTimeInterface::gameCycle()%_SlowUpdatePeriod)==_SlowUpdateCycle; bool slowUpdate = (CTimeInterface::gameCycle()%_SlowUpdatePeriod)==_SlowUpdateCycle;
if (fastUpdate || slowUpdate) if (fastUpdate || slowUpdate)
{ {
uint32 const botDt = CTimeInterface::gameCycle()-_LastBotUpdate; uint32 const botDt = CTimeInterface::gameCycle()-_LastBotUpdate;
_LastBotUpdate = CTimeInterface::gameCycle(); _LastBotUpdate = CTimeInterface::gameCycle();
FOREACH(first, CCont<CBot>, bots()) FOREACH(first, CCont<CBot>, bots())
{ {
CSpawnBotNpc* const bot = static_cast<CBotNpc*>(*first)->getSpawn(); CSpawnBotNpc* const bot = static_cast<CBotNpc*>(*first)->getSpawn();
@ -239,9 +242,9 @@ void CSpawnGroupNpc::update()
_BotUpdateTimer.set(10); _BotUpdateTimer.set(10);
} }
} }
if (haveToUpdateGroupBehaviour) if (haveToUpdateGroupBehaviour)
{ {
H_AUTO(GrpNpcUpdateGrpBehaviour); H_AUTO(GrpNpcUpdateGrpBehaviour);
if (!activityProfile().getAISpawnProfile().isNull()) // Check if we have a behaviour. if (!activityProfile().getAISpawnProfile().isNull()) // Check if we have a behaviour.
activityProfile().updateProfile(Dt); // If so, then update it ! activityProfile().updateProfile(Dt); // If so, then update it !
@ -263,27 +266,27 @@ void CSpawnGroupNpc::stateChange(CAIState const* oldState, CAIState const* newSt
// Find changing group profiles. // Find changing group profiles.
{ {
setProfileParameters(getPersistent().profileParameters()); setProfileParameters(getPersistent().profileParameters());
IAIProfileFactory* moveProfile = newState->moveProfile(); IAIProfileFactory* moveProfile = newState->moveProfile();
IAIProfileFactory* actProfile = newState->activityProfile(); IAIProfileFactory* actProfile = newState->activityProfile();
mergeProfileParameters(newState->profileParameters()); mergeProfileParameters(newState->profileParameters());
FOREACHC(it, CCont<CAIStateProfile>, newState->profiles()) FOREACHC(it, CCont<CAIStateProfile>, newState->profiles())
{ {
if (!it->testCompatibility(getPersistent())) if (!it->testCompatibility(getPersistent()))
continue; continue;
if (it->moveProfile()!= RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) if (it->moveProfile()!= RYAI_GET_FACTORY(CGrpProfileNoChangeFactory))
moveProfile = it->moveProfile(); moveProfile = it->moveProfile();
if (it->activityProfile()!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) if (it->activityProfile()!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory))
actProfile = it->activityProfile(); actProfile = it->activityProfile();
mergeProfileParameters(it->profileParameters()); mergeProfileParameters(it->profileParameters());
break; break;
} }
breakable breakable
{ {
if (oldState) if (oldState)
@ -294,36 +297,36 @@ void CSpawnGroupNpc::stateChange(CAIState const* oldState, CAIState const* newSt
// need to backup the current profiles // need to backup the current profiles
_PunctualHoldActivityProfile = activityProfile(); _PunctualHoldActivityProfile = activityProfile();
_PunctualHoldMovingProfile = movingProfile(); _PunctualHoldMovingProfile = movingProfile();
activityProfile() = CProfilePtr(); activityProfile() = CProfilePtr();
movingProfile() = CProfilePtr(); movingProfile() = CProfilePtr();
break; break;
} }
if (newState->isPositional() && !oldState->isPositional()) if (newState->isPositional() && !oldState->isPositional())
{ {
// end of punctual state // end of punctual state
// need to restore the backuped profile // need to restore the backuped profile
activityProfile() = _PunctualHoldActivityProfile; activityProfile() = _PunctualHoldActivityProfile;
movingProfile() = _PunctualHoldMovingProfile; movingProfile() = _PunctualHoldMovingProfile;
_PunctualHoldActivityProfile = CProfilePtr(); _PunctualHoldActivityProfile = CProfilePtr();
_PunctualHoldMovingProfile = CProfilePtr(); _PunctualHoldMovingProfile = CProfilePtr();
// resume the profiles // resume the profiles
activityProfile().getAISpawnProfile()->resumeProfile(); activityProfile().getAISpawnProfile()->resumeProfile();
movingProfile().getAISpawnProfile()->resumeProfile(); movingProfile().getAISpawnProfile()->resumeProfile();
break; break;
} }
} }
// normal behavior, transition from positionnal to positionnal state // normal behavior, transition from positionnal to positionnal state
if (moveProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) if (moveProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory))
setMoveProfileFromStateMachine(moveProfile); setMoveProfileFromStateMachine(moveProfile);
if (actProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) if (actProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory))
setActivityProfileFromStateMachine(actProfile); setActivityProfileFromStateMachine(actProfile);
break; break;
} }
} }
@ -343,8 +346,31 @@ void CSpawnGroupNpc::spawnBots()
FOREACH(itBot, CCont<CBot>, bots()) FOREACH(itBot, CCont<CBot>, bots())
{ {
CBot* bot = *itBot; CBot* bot = *itBot;
if (!bot->isSpawned()) if (!bot->isSpawned()) {
bot->spawn(); bot->spawn();
if (_Cell < 0) {
CEntityId id = bot->getSpawnObj()->getEntityId();
sint32 x = bot->getSpawnObj()->pos().x();
sint32 y = bot->getSpawnObj()->pos().y();
sint32 z = bot->getSpawnObj()->pos().h();
float t = bot->getSpawnObj()->pos().theta().asRadians();
uint8 cont = 0;
uint8 slide = 1;
NLMISC::TGameCycle tick = CTickEventHandler::getGameCycle() + 1;
CMessage msgout2("ENTITY_TELEPORTATION");
msgout2.serial( id );
msgout2.serial( x );
msgout2.serial( y );
msgout2.serial( z );
msgout2.serial( t );
msgout2.serial( tick );
msgout2.serial( cont );
msgout2.serial( _Cell );
msgout2.serial( slide );
sendMessageViaMirror("GPMS", msgout2);
}
}
} }
} }
@ -355,7 +381,7 @@ void CSpawnGroupNpc::despawnBots(bool immediately)
CBot* const bot = *itBot; CBot* const bot = *itBot;
if (!bot->isSpawned()) if (!bot->isSpawned())
continue; continue;
if (TheDataset.getOnlineTimestamp( bot->getSpawnObj()->dataSetRow()) >= CTickEventHandler::getGameCycle()) if (TheDataset.getOnlineTimestamp( bot->getSpawnObj()->dataSetRow()) >= CTickEventHandler::getGameCycle())
nlwarning("Bots %s:%s spawn/despawn in the same tick ! despawn ignored", getPersistent().getName().c_str(), bot->getName().c_str()); nlwarning("Bots %s:%s spawn/despawn in the same tick ! despawn ignored", getPersistent().getName().c_str(), bot->getName().c_str());
else else
@ -380,7 +406,7 @@ CGroupNpc::CGroupNpc(CMgrNpc* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MAP_
, CPersistentStateInstance(*mgr->getStateMachine()) , CPersistentStateInstance(*mgr->getStateMachine())
{ {
_BotsAreNamed = true; _BotsAreNamed = true;
_PlayerAttackable = false; _PlayerAttackable = false;
_BotAttackable = false; _BotAttackable = false;
_AggroDist = 0; _AggroDist = 0;
@ -393,25 +419,25 @@ CGroupNpc::CGroupNpc(CMgrNpc* mgr, uint32 alias, std::string const& name, RYAI_M
, CPersistentStateInstance(*mgr->getStateMachine()) , CPersistentStateInstance(*mgr->getStateMachine())
{ {
_BotsAreNamed = true; _BotsAreNamed = true;
_PlayerAttackable = false; _PlayerAttackable = false;
_BotAttackable = false; _BotAttackable = false;
_AggroDist = 0; _AggroDist = 0;
} }
CGroupNpc::~CGroupNpc() CGroupNpc::~CGroupNpc()
{ {
// avoid re-deletion by despawn // avoid re-deletion by despawn
_AutoDestroy = false; _AutoDestroy = false;
if (isSpawned()) // to avoid bad CDbgPtr link interpretation if (isSpawned()) // to avoid bad CDbgPtr link interpretation
despawnGrp(); despawnGrp();
// clear all persistent state instance // clear all persistent state instance
while (!_PSIChilds.empty()) while (!_PSIChilds.empty())
{ {
_PSIChilds.back()->setParentStateInstance(NULL); _PSIChilds.back()->setParentStateInstance(NULL);
} }
_PSIChilds.clear(); _PSIChilds.clear();
} }
@ -424,7 +450,7 @@ std::vector<std::string> CGroupNpc::getMultiLineInfoString() const
{ {
std::vector<std::string> container; std::vector<std::string> container;
std::vector<std::string> strings; std::vector<std::string> strings;
pushTitle(container, "CGroupNpc"); pushTitle(container, "CGroupNpc");
strings = CGroup::getMultiLineInfoString(); strings = CGroup::getMultiLineInfoString();
FOREACHC(itString, std::vector<std::string>, strings) FOREACHC(itString, std::vector<std::string>, strings)
@ -435,7 +461,7 @@ std::vector<std::string> CGroupNpc::getMultiLineInfoString() const
pushEntry(container, NLMISC::toString("attackable: player=%s bot=%s", _PlayerAttackable?"yes":"no", _BotAttackable?"yes":"no")); pushEntry(container, NLMISC::toString("attackable: player=%s bot=%s", _PlayerAttackable?"yes":"no", _BotAttackable?"yes":"no"));
pushEntry(container, "state=" + (getState()?getState()->getName():string("<null>"))); pushEntry(container, "state=" + (getState()?getState()->getName():string("<null>")));
pushFooter(container); pushFooter(container);
return container; return container;
} }
@ -445,9 +471,9 @@ CMgrNpc& CGroupNpc::mgr() const
} }
void CGroupNpc::updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner) void CGroupNpc::updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner)
{ {
switch(aliasTree.getType()) switch(aliasTree.getType())
{ {
case AITypeEvent: case AITypeEvent:
{ {
CAIEventReaction* const eventPtr = NLMISC::safe_cast<CAIEventReaction*>(mgr().getStateMachine()->eventReactions().getChildByAlias(aliasTree.getAlias())); CAIEventReaction* const eventPtr = NLMISC::safe_cast<CAIEventReaction*>(mgr().getStateMachine()->eventReactions().getChildByAlias(aliasTree.getAlias()));
@ -477,19 +503,19 @@ IAliasCont* CGroupNpc::getAliasCont(TAIType type)
CAliasTreeOwner* CGroupNpc::createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree) CAliasTreeOwner* CGroupNpc::createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree)
{ {
CAliasTreeOwner* child = NULL; CAliasTreeOwner* child = NULL;
switch (aliasTree->getType()) switch (aliasTree->getType())
{ {
case AITypeOutpostBuilding: case AITypeOutpostBuilding:
case AITypeBot: case AITypeBot:
child = new CBotNpc(this, aliasTree); child = new CBotNpc(this, aliasTree);
break; break;
case AITypeFolder: case AITypeFolder:
default: default:
break; break;
} }
if (child!=NULL) if (child!=NULL)
cont->addAliasChild(child); cont->addAliasChild(child);
return (child); return (child);
@ -503,7 +529,7 @@ CSmartPtr<CSpawnGroup> CGroupNpc::createSpawnGroup()
void CGroupNpc::serviceEvent (const CServiceEvent &info) void CGroupNpc::serviceEvent (const CServiceEvent &info)
{ {
CGroup::serviceEvent(info); CGroup::serviceEvent(info);
// If the EGS crash // If the EGS crash
if ( (info.getServiceName() == "EGS") && (info.getEventType() == CServiceEvent::SERVICE_DOWN) ) if ( (info.getServiceName() == "EGS") && (info.getEventType() == CServiceEvent::SERVICE_DOWN) )
{ {
@ -527,19 +553,19 @@ void CGroupNpc::serviceEvent (const CServiceEvent &info)
{ {
processStateEvent(getEventContainer().EventEGSUp); processStateEvent(getEventContainer().EventEGSUp);
} }
} }
bool CGroupNpc::spawn () bool CGroupNpc::spawn ()
{ {
if (CGroup::spawn()) if (CGroup::spawn())
{ {
setStartState(getStartState()); // stateInstance. setStartState(getStartState()); // stateInstance.
// inform the EGS of our existence - simulate connection of EGS // inform the EGS of our existence - simulate connection of EGS
serviceEvent (CServiceEvent(NLNET::TServiceId(0),std::string("EGS"),CServiceEvent::SERVICE_UP)); serviceEvent (CServiceEvent(NLNET::TServiceId(0),std::string("EGS"),CServiceEvent::SERVICE_UP));
if (isAutoSpawn()) if (isAutoSpawn())
{ {
CCont<CBot >::iterator first(bots().begin()), last(bots().end()); CCont<CBot >::iterator first(bots().begin()), last(bots().end());
@ -550,7 +576,7 @@ bool CGroupNpc::spawn ()
bot->spawn(); bot->spawn();
} }
} }
return true; return true;
} }
return false; return false;
} }
@ -604,19 +630,19 @@ void CGroupNpc::addParameter(std::string const& parameter)
_BotAttackable = true; _BotAttackable = true;
break; break;
} }
if (key == ATTACKABLE || key == PLAYER_ATTACKABLE) if (key == ATTACKABLE || key == PLAYER_ATTACKABLE)
{ {
// the bots are attackable ! // the bots are attackable !
_PlayerAttackable = true; _PlayerAttackable = true;
if (!IsRingShard) // In Ring shard, BotAttackable means attackable by bot not vulnerable if (!IsRingShard) // In Ring shard, BotAttackable means attackable by bot not vulnerable
{ {
// attackable implie vulnerable! // attackable implie vulnerable!
_BotAttackable = true; _BotAttackable = true;
} }
break; break;
} }
if (key == BADGUY) if (key == BADGUY)
{ {
// the bots are bad guys! they will attack players in their aggro range. // the bots are bad guys! they will attack players in their aggro range.
@ -648,7 +674,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
} }
break; break;
} }
if (key == ESCORT_RANGE) if (key == ESCORT_RANGE)
{ {
if (!tail.empty()) if (!tail.empty())
@ -663,7 +689,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
} }
break; break;
} }
if (key == RESPAWN_TIME) if (key == RESPAWN_TIME)
{ {
if (!tail.empty()) if (!tail.empty())
@ -681,7 +707,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
} }
break; break;
} }
if (key == DESPAWN_TIME) if (key == DESPAWN_TIME)
{ {
if (!tail.empty()) if (!tail.empty())
@ -699,7 +725,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
} }
break; break;
} }
if (key == DENIED_ASTAR_FLAGS) if (key == DENIED_ASTAR_FLAGS)
{ {
if (!tail.empty()) if (!tail.empty())
@ -724,7 +750,7 @@ void CGroupNpc::addParameter(std::string const& parameter)
if (parameter.empty()) if (parameter.empty())
break; break;
nlwarning("CAIBotNpc::addParameter unknown parameter '%s'", parameter.c_str()); nlwarning("CAIBotNpc::addParameter unknown parameter '%s'", parameter.c_str());
} }
} }
@ -740,7 +766,7 @@ void CGroupNpc::delHpUpTrigger(float threshold, int eventId)
CGroupNpc::THpTriggerList::iterator first, last, trigger; CGroupNpc::THpTriggerList::iterator first, last, trigger;
first = hpTriggers.lower_bound(threshold); first = hpTriggers.lower_bound(threshold);
last = hpTriggers.upper_bound(threshold); last = hpTriggers.upper_bound(threshold);
for (; first!=last; ++first) for (; first!=last; ++first)
{ {
if (first->second==eventId) if (first->second==eventId)
@ -761,7 +787,7 @@ void CGroupNpc::delHpDownTrigger(float threshold, int eventId)
CGroupNpc::THpTriggerList::iterator first, last, trigger; CGroupNpc::THpTriggerList::iterator first, last, trigger;
first = hpTriggers.lower_bound(threshold); first = hpTriggers.lower_bound(threshold);
last = hpTriggers.upper_bound(threshold); last = hpTriggers.upper_bound(threshold);
for (; first!=last; ++first) for (; first!=last; ++first)
{ {
if (first->second==eventId) if (first->second==eventId)
@ -782,7 +808,7 @@ void CGroupNpc::delHpUpTrigger(float threshold, std::string cbFunc)
CGroupNpc::THpTriggerList2::iterator first, last, trigger; CGroupNpc::THpTriggerList2::iterator first, last, trigger;
first = hpTriggers.lower_bound(threshold); first = hpTriggers.lower_bound(threshold);
last = hpTriggers.upper_bound(threshold); last = hpTriggers.upper_bound(threshold);
for (; first!=last; ++first) for (; first!=last; ++first)
{ {
if (first->second==cbFunc) if (first->second==cbFunc)
@ -803,7 +829,7 @@ void CGroupNpc::delHpDownTrigger(float threshold, std::string cbFunc)
CGroupNpc::THpTriggerList2::iterator first, last, trigger; CGroupNpc::THpTriggerList2::iterator first, last, trigger;
first = hpTriggers.lower_bound(threshold); first = hpTriggers.lower_bound(threshold);
last = hpTriggers.upper_bound(threshold); last = hpTriggers.upper_bound(threshold);
for (; first!=last; ++first) for (; first!=last; ++first)
{ {
if (first->second==cbFunc) if (first->second==cbFunc)
@ -944,7 +970,7 @@ void CGroupNpc::addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 D
{ {
_AutoSpawnWhenNoMoreHandle = isAutoSpawn(); _AutoSpawnWhenNoMoreHandle = isAutoSpawn();
} }
setAutoSpawn(true); setAutoSpawn(true);
// There is always a spawned object for group // There is always a spawned object for group
if (getSpawnObj() != NULL) if (getSpawnObj() != NULL)
@ -959,7 +985,7 @@ void CGroupNpc::addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 D
SHandle h; SHandle h;
h.MissionAlias = missionAlias; h.MissionAlias = missionAlias;
h.PlayerRowId = playerRowId; h.PlayerRowId = playerRowId;
set<SHandle>::const_iterator it = _Handles.find(h); set<SHandle>::const_iterator it = _Handles.find(h);
if (it != _Handles.end()) if (it != _Handles.end())
@ -1033,7 +1059,7 @@ std::string CSpawnGroupNpc::buildDebugString(uint idx) const
std::string CGroupNpc::buildDebugString(uint idx) const std::string CGroupNpc::buildDebugString(uint idx) const
{ {
switch(idx) switch(idx)
{ {
case 0: return "-- CGroupNpc -----------------------------"; case 0: return "-- CGroupNpc -----------------------------";
@ -1227,10 +1253,10 @@ NLMISC_COMMAND(verboseNPCGrp,"Turn on or off or check the state of verbose npc g
{ {
if(args.size()>1) if(args.size()>1)
return false; return false;
if(args.size()==1) if(args.size()==1)
StrToBool (VerboseLog, args[0]); StrToBool (VerboseLog, args[0]);
nlinfo("VerboseLogging is %s",VerboseLog?"ON":"OFF"); nlinfo("VerboseLogging is %s",VerboseLog?"ON":"OFF");
return true; return true;
} }

@ -39,43 +39,48 @@ class CSpawnGroupNpc
{ {
public: public:
CSpawnGroupNpc(CPersistent<CSpawnGroup>& owner); CSpawnGroupNpc(CPersistent<CSpawnGroup>& owner);
virtual ~CSpawnGroupNpc() { } virtual ~CSpawnGroupNpc() { }
CGroupNpc& getPersistent() const; CGroupNpc& getPersistent() const;
virtual void spawnBots(); virtual void spawnBots();
virtual void despawnBots(bool immediately); virtual void despawnBots(bool immediately);
void update(); void update();
void sendInfoToEGS() const; void sendInfoToEGS() const;
std::string buildDebugString(uint idx) const; std::string buildDebugString(uint idx) const;
void stateChange(CAIState const* oldState, CAIState const* newState); void stateChange(CAIState const* oldState, CAIState const* newState);
void botHaveDied(CBotNpc* bot); void botHaveDied(CBotNpc* bot);
void botHaveDespawn(CBotNpc* bot); void botHaveDespawn(CBotNpc* bot);
void botHaveSpawn(CBotNpc* bot); void botHaveSpawn(CBotNpc* bot);
public: public:
void resetSlowUpdateCycle(); void resetSlowUpdateCycle();
static void setSlowUpdatePeriod(uint32 ticks); static void setSlowUpdatePeriod(uint32 ticks);
static uint32 getSlowUpdatePeriod(); static uint32 getSlowUpdatePeriod();
static void displaySlowUpdateBuckets(); static void displaySlowUpdateBuckets();
void noMoreHandle(uint32 nNbTickBeforeDespawn); void noMoreHandle(uint32 nNbTickBeforeDespawn);
void handlePresent(); void handlePresent();
// set the cell
void setCell(sint32 cell) { _Cell = cell; }
sint32 getCell() { return _Cell; }
private: private:
bool _GroupInVision; bool _GroupInVision;
CAITimer _BotUpdateTimer; CAITimer _BotUpdateTimer;
uint32 _LastUpdate; // gamecycle at which update() last called uint32 _LastUpdate; // gamecycle at which update() last called
uint32 _LastBotUpdate; uint32 _LastBotUpdate;
uint32 _SlowUpdateCycle; uint32 _SlowUpdateCycle;
sint32 _Cell;
static uint32 _SlowUpdatePeriod; static uint32 _SlowUpdatePeriod;
static std::vector<uint32> _SlowUpdateBuckets; static std::vector<uint32> _SlowUpdateBuckets;
bool _DespawnBotsWhenNoMoreHandleTimerActive; bool _DespawnBotsWhenNoMoreHandleTimerActive;
CAITimer _DespawnBotsWhenNoMoreHandleTimer; CAITimer _DespawnBotsWhenNoMoreHandleTimer;
@ -93,13 +98,13 @@ class CGroupNpc
{ {
public: public:
typedef std::set<std::pair<std::string, sint32> > TFactionAttackableSet; typedef std::set<std::pair<std::string, sint32> > TFactionAttackableSet;
public: public:
CGroupNpc(CMgrNpc* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MAP_CRUNCH::TAStarFlag denyFlags); CGroupNpc(CMgrNpc* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MAP_CRUNCH::TAStarFlag denyFlags);
CGroupNpc(CMgrNpc* mgr, uint32 alias, std::string const& name, RYAI_MAP_CRUNCH::TAStarFlag denyFlags); CGroupNpc(CMgrNpc* mgr, uint32 alias, std::string const& name, RYAI_MAP_CRUNCH::TAStarFlag denyFlags);
virtual ~CGroupNpc(); virtual ~CGroupNpc();
/// @name CChild implementation /// @name CChild implementation
//@{ //@{
// virtual std::string getIndexString() const; // virtual std::string getIndexString() const;
@ -107,63 +112,63 @@ public:
virtual std::vector<std::string> getMultiLineInfoString() const; virtual std::vector<std::string> getMultiLineInfoString() const;
// virtual std::string getFullName() const; // virtual std::string getFullName() const;
//@} //@}
CDynGrpBase* getGrpDynBase() { return this; } CDynGrpBase* getGrpDynBase() { return this; }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// PersistentStateInstance // PersistentStateInstance
CAliasTreeOwner* aliasTreeOwner() { return this; } CAliasTreeOwner* aliasTreeOwner() { return this; }
void stateChange(CAIState const* oldState, CAIState const* newState); void stateChange(CAIState const* oldState, CAIState const* newState);
CGroup* getGroup() { return this; } CGroup* getGroup() { return this; }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
virtual void lastBotDespawned(); virtual void lastBotDespawned();
virtual void firstBotSpawned(); virtual void firstBotSpawned();
// debugging stuff // debugging stuff
CDebugHistory* getDebugHistory() { return this; } CDebugHistory* getDebugHistory() { return this; }
CAIS::CCounter& getSpawnCounter(); CAIS::CCounter& getSpawnCounter();
RYZOMID::TTypeId getRyzomType() { return RYZOMID::npc; } RYZOMID::TTypeId getRyzomType() { return RYZOMID::npc; }
NLMISC::CSmartPtr<CSpawnGroup> createSpawnGroup(); NLMISC::CSmartPtr<CSpawnGroup> createSpawnGroup();
CSpawnGroupNpc* getSpawnObj() const { return NLMISC::type_cast<CSpawnGroupNpc*>(CGroup::getSpawnObj()); } CSpawnGroupNpc* getSpawnObj() const { return NLMISC::type_cast<CSpawnGroupNpc*>(CGroup::getSpawnObj()); }
CPersistentStateInstance* getPersistentStateInstance() { return this; } CPersistentStateInstance* getPersistentStateInstance() { return this; }
void setEvent(uint eventId); void setEvent(uint eventId);
virtual void serviceEvent (const CServiceEvent &info); virtual void serviceEvent (const CServiceEvent &info);
void init() { } void init() { }
void release() { } void release() { }
// inheritted virtual interface ------------------------------------ // inheritted virtual interface ------------------------------------
virtual bool spawn(); virtual bool spawn();
virtual void despawnGrp(); virtual void despawnGrp();
virtual std::string buildDebugString(uint idx) const; virtual std::string buildDebugString(uint idx) const;
virtual void display(CStringWriter& stringWriter) const; virtual void display(CStringWriter& stringWriter) const;
void updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner); void updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner);
IAliasCont* getAliasCont(AITYPES::TAIType type); IAliasCont* getAliasCont(AITYPES::TAIType type);
CAliasTreeOwner* createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree); CAliasTreeOwner* createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree);
// basic utilities ------------------------------------------------- // basic utilities -------------------------------------------------
CMgrNpc& mgr() const; CMgrNpc& mgr() const;
// management of the bot population -------------------------------- // management of the bot population --------------------------------
// allocator for allocating new bot objects // allocator for allocating new bot objects
CGroupNpc* newBot(); CGroupNpc* newBot();
bool botsAreNamed() { return _BotsAreNamed; } bool botsAreNamed() { return _BotsAreNamed; }
void setBotsAreNamedFlag() { _BotsAreNamed = true; } void setBotsAreNamedFlag() { _BotsAreNamed = true; }
void clrBotsAreNamedFlag() { _BotsAreNamed = false; } void clrBotsAreNamedFlag() { _BotsAreNamed = false; }
@ -176,7 +181,7 @@ public:
void setStateEventAlias(const std::string &stateEvent, uint32 alias); void setStateEventAlias(const std::string &stateEvent, uint32 alias);
uint32 getStateEventAlias(const std::string &stateEvent); uint32 getStateEventAlias(const std::string &stateEvent);
// Parameter management ------------------------------------- // Parameter management -------------------------------------
void clearParameters(); void clearParameters();
// Parse a paremeter for this group. // Parse a paremeter for this group.
@ -185,65 +190,65 @@ public:
// set if the bots of the group are attackable by players // set if the bots of the group are attackable by players
void setPlayerAttackable(bool playerAttackable) { _PlayerAttackable = playerAttackable; } void setPlayerAttackable(bool playerAttackable) { _PlayerAttackable = playerAttackable; }
bool getPlayerAttackable() { return _PlayerAttackable; } bool getPlayerAttackable() { return _PlayerAttackable; }
// set if the bots of the group are attackable by other bots // set if the bots of the group are attackable by other bots
void setBotAttackable(bool botAttackable) { _BotAttackable = botAttackable; } void setBotAttackable(bool botAttackable) { _BotAttackable = botAttackable; }
bool getBotAttackable() { return _BotAttackable; } bool getBotAttackable() { return _BotAttackable; }
void setFactionAttackableAbove(std::string faction, sint32 threshold, bool botAttackable); void setFactionAttackableAbove(std::string faction, sint32 threshold, bool botAttackable);
TFactionAttackableSet const& getFactionAttackableAbove() const { return _FactionAttackableAbove; } TFactionAttackableSet const& getFactionAttackableAbove() const { return _FactionAttackableAbove; }
void setFactionAttackableBelow(std::string faction, sint32 threshold, bool botAttackable); void setFactionAttackableBelow(std::string faction, sint32 threshold, bool botAttackable);
TFactionAttackableSet const& getFactionAttackableBelow() const { return _FactionAttackableBelow; } TFactionAttackableSet const& getFactionAttackableBelow() const { return _FactionAttackableBelow; }
bool isFactionAttackable(std::string faction, sint32 fame); bool isFactionAttackable(std::string faction, sint32 fame);
uint32 getAggroDist() { return _AggroDist; } uint32 getAggroDist() { return _AggroDist; }
uint32& despawnTime() { return _DespawnTime; } uint32& despawnTime() { return _DespawnTime; }
uint32& respawnTime() { return _RespawnTime; } uint32& respawnTime() { return _RespawnTime; }
AITYPES::CPropertySetWithExtraList<TAllianceId>& faction() { return _faction; } AITYPES::CPropertySetWithExtraList<TAllianceId>& faction() { return _faction; }
AITYPES::CPropertySetWithExtraList<TAllianceId>& ennemyFaction() { return _ennemyFaction; } AITYPES::CPropertySetWithExtraList<TAllianceId>& ennemyFaction() { return _ennemyFaction; }
AITYPES::CPropertySetWithExtraList<TAllianceId>& friendFaction() { return _friendFaction; } AITYPES::CPropertySetWithExtraList<TAllianceId>& friendFaction() { return _friendFaction; }
AITYPES::CPropertySetWithExtraList<TAllianceId> const& faction() const { return _faction; } AITYPES::CPropertySetWithExtraList<TAllianceId> const& faction() const { return _faction; }
AITYPES::CPropertySetWithExtraList<TAllianceId> const& ennemyFaction() const { return _ennemyFaction; } AITYPES::CPropertySetWithExtraList<TAllianceId> const& ennemyFaction() const { return _ennemyFaction; }
AITYPES::CPropertySetWithExtraList<TAllianceId> const& friendFaction() const { return _friendFaction; } AITYPES::CPropertySetWithExtraList<TAllianceId> const& friendFaction() const { return _friendFaction; }
public: public:
void addHpUpTrigger(float threshold, int eventId); void addHpUpTrigger(float threshold, int eventId);
void delHpUpTrigger(float threshold, int eventId); void delHpUpTrigger(float threshold, int eventId);
void addHpUpTrigger(float threshold, std::string cbFunc); void addHpUpTrigger(float threshold, std::string cbFunc);
void delHpUpTrigger(float threshold, std::string cbFunc); void delHpUpTrigger(float threshold, std::string cbFunc);
void addHpDownTrigger(float threshold, int eventId); void addHpDownTrigger(float threshold, int eventId);
void delHpDownTrigger(float threshold, int eventId); void delHpDownTrigger(float threshold, int eventId);
void addHpDownTrigger(float threshold, std::string cbFunc); void addHpDownTrigger(float threshold, std::string cbFunc);
void delHpDownTrigger(float threshold, std::string cbFunc); void delHpDownTrigger(float threshold, std::string cbFunc);
bool haveHpTriggers(); bool haveHpTriggers();
void hpTriggerCb(float oldVal, float newVal); void hpTriggerCb(float oldVal, float newVal);
void addNamedEntityListener(std::string const& name, std::string const& prop, int event); void addNamedEntityListener(std::string const& name, std::string const& prop, int event);
void delNamedEntityListener(std::string const& name, std::string const& prop, int event); void delNamedEntityListener(std::string const& name, std::string const& prop, int event);
void addNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName); void addNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName);
void delNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName); void delNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName);
void namedEntityListenerCb(std::string const& name, std::string const& prop); void namedEntityListenerCb(std::string const& name, std::string const& prop);
void addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 DespawnTimeInTick); void addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 DespawnTimeInTick);
void delHandle(TDataSetRow playerRowId, uint32 missionAlias); void delHandle(TDataSetRow playerRowId, uint32 missionAlias);
uint32 getTimerWhenNoMoreHandle(); uint32 getTimerWhenNoMoreHandle();
void setSpawnZone(const CNpcZone *zone) { _SpawnZone = zone; } void setSpawnZone(const CNpcZone *zone) { _SpawnZone = zone; }
const CNpcZone *getSpawnZone() const { return _SpawnZone; } const CNpcZone *getSpawnZone() const { return _SpawnZone; }
void setColour(uint8 colour); void setColour(uint8 colour);
void setOutpostSide(OUTPOSTENUMS::TPVPSide side); void setOutpostSide(OUTPOSTENUMS::TPVPSide side);
void setOutpostFactions(std::string const& alias, OUTPOSTENUMS::TPVPSide side); void setOutpostFactions(std::string const& alias, OUTPOSTENUMS::TPVPSide side);
bool isRingGrp() const { return _RingGrp;} bool isRingGrp() const { return _RingGrp;}
private: private:
/// group basics /// group basics
bool _BotsAreNamed; // true if the bots in the group are explicitly placed in level editor tool - false otherwise bool _BotsAreNamed; // true if the bots in the group are explicitly placed in level editor tool - false otherwise
@ -261,20 +266,20 @@ private:
uint32 _RespawnTime; uint32 _RespawnTime;
/// Despawn time in ticks /// Despawn time in ticks
uint32 _DespawnTime; uint32 _DespawnTime;
AITYPES::CPropertySetWithExtraList<TAllianceId> _faction; AITYPES::CPropertySetWithExtraList<TAllianceId> _faction;
AITYPES::CPropertySetWithExtraList<TAllianceId> _ennemyFaction; AITYPES::CPropertySetWithExtraList<TAllianceId> _ennemyFaction;
AITYPES::CPropertySetWithExtraList<TAllianceId> _friendFaction; AITYPES::CPropertySetWithExtraList<TAllianceId> _friendFaction;
typedef std::multimap<float, int> THpTriggerList; typedef std::multimap<float, int> THpTriggerList;
typedef std::multimap<float, std::string> THpTriggerList2; typedef std::multimap<float, std::string> THpTriggerList2;
THpTriggerList _hpUpTriggers; THpTriggerList _hpUpTriggers;
THpTriggerList _hpDownTriggers; THpTriggerList _hpDownTriggers;
THpTriggerList2 _hpUpTriggers2; THpTriggerList2 _hpUpTriggers2;
THpTriggerList2 _hpDownTriggers2; THpTriggerList2 _hpDownTriggers2;
typedef std::multimap<std::pair<std::string, std::string>, int> TNamedEntityListenerList; typedef std::multimap<std::pair<std::string, std::string>, int> TNamedEntityListenerList;
TNamedEntityListenerList _namedEntityListeners; TNamedEntityListenerList _namedEntityListeners;
typedef std::multimap<std::pair<std::string, std::string>, std::string> TNamedEntityListenerList2; typedef std::multimap<std::pair<std::string, std::string>, std::string> TNamedEntityListenerList2;
@ -287,11 +292,11 @@ private:
{ {
TDataSetRow PlayerRowId; TDataSetRow PlayerRowId;
uint32 MissionAlias; uint32 MissionAlias;
bool operator < (const SHandle &h) const bool operator < (const SHandle &h) const
{ {
if (PlayerRowId < h.PlayerRowId) return true; if (PlayerRowId < h.PlayerRowId) return true;
if (PlayerRowId == h.PlayerRowId) if (PlayerRowId == h.PlayerRowId)
if (MissionAlias < h.MissionAlias) if (MissionAlias < h.MissionAlias)
return true; return true;

@ -675,8 +675,7 @@ static float randomAngle()
return val; return val;
} }
CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look) CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look, sint32 cell) {
{
if (!_EventNpcManager) if (!_EventNpcManager)
return NULL; return NULL;
@ -772,6 +771,8 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
return NULL; return NULL;
} }
spawnGroup->setCell(cell);
NLMISC::CSmartPtr<CNpcZonePlaceNoPrim> destZone = NLMISC::CSmartPtr<CNpcZonePlaceNoPrim>(new CNpcZonePlaceNoPrim()); NLMISC::CSmartPtr<CNpcZonePlaceNoPrim> destZone = NLMISC::CSmartPtr<CNpcZonePlaceNoPrim>(new CNpcZonePlaceNoPrim());
destZone->setPosAndRadius(AITYPES::vp_auto, CAIPos(pos, 0, 0), (uint32)(dispersionRadius*1000.)); destZone->setPosAndRadius(AITYPES::vp_auto, CAIPos(pos, 0, 0), (uint32)(dispersionRadius*1000.));
spawnGroup->movingProfile().setAIProfile(new CGrpProfileWanderNoPrim(spawnGroup, destZone)); spawnGroup->movingProfile().setAIProfile(new CGrpProfileWanderNoPrim(spawnGroup, destZone));
@ -941,7 +942,7 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber); CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber);
if (instance) if (instance)
{ {
CGroupNpc* npcGroup = instance->eventCreateNpcGroup(nbBots, sheetId, CAIVector(((double)x)/1000.0, ((double)y)/1000.0), dispersionRadius, spawnBots, ((double)orientation)/1000.0, botsName, look); CGroupNpc* npcGroup = instance->eventCreateNpcGroup(nbBots, sheetId, CAIVector(((double)x)/1000.0, ((double)y)/1000.0), dispersionRadius, spawnBots, ((double)orientation)/1000.0, botsName, look, cell);
if (npcGroup != NULL) if (npcGroup != NULL)
{ {
_PlayersLastCreatedNpcGroup[playerId] = npcGroup->getName(); _PlayersLastCreatedNpcGroup[playerId] = npcGroup->getName();

@ -208,7 +208,7 @@ public:
return NULL; return NULL;
} }
CGroupNpc* eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look); CGroupNpc* eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look, sint32 cell=0);
/// create a new easter egg /// create a new easter egg
CBotEasterEgg* createEasterEgg(uint32 easterEggId, NLMISC::CSheetId const& sheetId, std::string const& botName, double x, double y, double z, double heading, const std::string& look); CBotEasterEgg* createEasterEgg(uint32 easterEggId, NLMISC::CSheetId const& sheetId, std::string const& botName, double x, double y, double z, double heading, const std::string& look);

@ -46,7 +46,7 @@ using namespace NLNET;
/****************************************************************\ /****************************************************************\
cbAddEntity() cbAddEntity()
\****************************************************************/ \****************************************************************/
/* /*
void cbAddEntity( CMessage& msgin, const string &serviceName, uint16 serviceId ) void cbAddEntity( CMessage& msgin, const string &serviceName, uint16 serviceId )
@ -91,7 +91,7 @@ void cbAddEntity( CMessage& msgin, const string &serviceName, uint16 serviceId )
*/ */
/****************************************************************\ /****************************************************************\
cbAddIAObject() cbAddIAObject()
\****************************************************************/ \****************************************************************/
/* /*
void cbAddIAObject( CMessage& msgin, const string &serviceName, uint16 serviceId ) void cbAddIAObject( CMessage& msgin, const string &serviceName, uint16 serviceId )
@ -102,12 +102,12 @@ void cbAddIAObject( CMessage& msgin, const string &serviceName, uint16 serviceId
*/ */
/****************************************************************\ /****************************************************************\
cbAddEntities() cbAddEntities()
\****************************************************************/ \****************************************************************/
/*void cbAddEntities( CMessage& msgin, const string &serviceName, uint16 serviceId ) /*void cbAddEntities( CMessage& msgin, const string &serviceName, uint16 serviceId )
{ {
//nlinfo("received ADD_ENTITIES request"); //nlinfo("received ADD_ENTITIES request");
uint32 entitiesCount; uint32 entitiesCount;
msgin.serial( entitiesCount ); msgin.serial( entitiesCount );
@ -153,7 +153,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI
CEntityId id; CEntityId id;
id.serial( msgin ); id.serial( msgin );
nlinfo("received REMOVE_ENTITY request for id %s", id.toString().c_str() ); nlinfo("received REMOVE_ENTITY request for id %s", id.toString().c_str() );
CWorldPositionManager::onRemoveEntity( id ); CWorldPositionManager::onRemoveEntity( id );
@ -170,7 +170,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI
list<CEntityId> ids; list<CEntityId> ids;
msgin.serialCont( ids ); msgin.serialCont( ids );
list<CEntityId> idsAgents; list<CEntityId> idsAgents;
list<CEntityId>::iterator it; list<CEntityId>::iterator it;
@ -180,7 +180,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI
nlinfo(" REMOVE_ENTITY id %s", (*it).toString().c_str() ); nlinfo(" REMOVE_ENTITY id %s", (*it).toString().c_str() );
if( (*it).getType() == RYZOMID::npc ) if( (*it).getType() == RYZOMID::npc )
{ {
idsAgents.push_back( *it ); idsAgents.push_back( *it );
} }
} }
@ -188,7 +188,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI
if( idsAgents.size() != 0 ) if( idsAgents.size() != 0 )
{ {
CMessage msgout("REMOVE_ENTITY"); CMessage msgout("REMOVE_ENTITY");
for ( it = idsAgents.begin() ; it != idsAgents.end() ; ++it) for ( it = idsAgents.begin() ; it != idsAgents.end() ; ++it)
msgout.serial( const_cast<CEntityId&> (*it) ); msgout.serial( const_cast<CEntityId&> (*it) );
@ -199,7 +199,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI
/****************************************************************\ /****************************************************************\
CGPMPlayerPrivilegeInst::callback CGPMPlayerPrivilegeInst::callback
\****************************************************************/ \****************************************************************/
void CGPMPlayerPrivilegeInst::callback (const std::string &name, NLNET::TServiceId id) void CGPMPlayerPrivilegeInst::callback (const std::string &name, NLNET::TServiceId id)
{ {
@ -216,7 +216,7 @@ void CGPMPlayerPrivilegeInst::callback (const std::string &name, NLNET::TService
} }
/****************************************************************\ /****************************************************************\
cbSetPlayerFlags() cbSetPlayerFlags()
\****************************************************************/ \****************************************************************/
void cbSetPlayerFlags( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbSetPlayerFlags( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -250,7 +250,7 @@ void cbBag( CMessage& msgin, const string &serviceName, NLNET::TServiceId servic
/****************************************************************\ /****************************************************************\
cbLoadContinent() cbLoadContinent()
\****************************************************************/ \****************************************************************/
void cbLoadContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbLoadContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -272,7 +272,7 @@ void cbLoadContinent( CMessage& msgin, const string &serviceName, NLNET::TServic
} }
/****************************************************************\ /****************************************************************\
cbRemoveContinent() cbRemoveContinent()
\****************************************************************/ \****************************************************************/
void cbRemoveContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbRemoveContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -284,10 +284,10 @@ void cbRemoveContinent( CMessage& msgin, const string &serviceName, NLNET::TServ
// remove continent from position manager // remove continent from position manager
CWorldPositionManager::removeContinent(continent); CWorldPositionManager::removeContinent(continent);
} }
/****************************************************************\ /****************************************************************\
cbCreateIndoorUnit() cbCreateIndoorUnit()
\****************************************************************/ \****************************************************************/
void cbCreateIndoorUnit( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbCreateIndoorUnit( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -310,7 +310,7 @@ void cbCreateIndoorUnit( CMessage& msgin, const string &serviceName, NLNET::TSer
} }
/****************************************************************\ /****************************************************************\
cbCreateBuilding() cbCreateBuilding()
\****************************************************************/ \****************************************************************/
void cbCreateBuilding( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbCreateBuilding( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -321,12 +321,12 @@ void cbCreateBuilding( CMessage& msgin, const string &serviceName, NLNET::TServi
msgin.serial(continent); msgin.serial(continent);
msgin.serial(id); msgin.serial(id);
msgin.serial(position); msgin.serial(position);
CWorldPositionManager::createBuildingInstance(continent, id, position); CWorldPositionManager::createBuildingInstance(continent, id, position);
} }
/****************************************************************\ /****************************************************************\
cbCreateObstacle() cbCreateObstacle()
\****************************************************************/ \****************************************************************/
void cbCreateObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbCreateObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -342,7 +342,7 @@ void cbCreateObstacle( CMessage& msgin, const string &serviceName, NLNET::TServi
} }
/****************************************************************\ /****************************************************************\
cbRemoveObstacle() cbRemoveObstacle()
\****************************************************************/ \****************************************************************/
void cbRemoveObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbRemoveObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -356,7 +356,7 @@ void cbRemoveObstacle( CMessage& msgin, const string &serviceName, NLNET::TServi
} }
/****************************************************************\ /****************************************************************\
cbSetObstacle() cbSetObstacle()
\****************************************************************/ \****************************************************************/
void cbSetObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbSetObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -371,7 +371,7 @@ void cbSetObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceI
} }
/****************************************************************\ /****************************************************************\
cbUpdateEntityPosition() cbUpdateEntityPosition()
\****************************************************************/ \****************************************************************/
/* /*
void cbUpdateEntityPosition( CMessage& msgin, const string &serviceName, uint16 serviceId ) void cbUpdateEntityPosition( CMessage& msgin, const string &serviceName, uint16 serviceId )
@ -403,7 +403,7 @@ void cbUpdateEntityPosition( CMessage& msgin, const string &serviceName, uint16
*/ */
/****************************************************************\ /****************************************************************\
cbUpdateEntitiesPositions() cbUpdateEntitiesPositions()
\****************************************************************/ \****************************************************************/
/* /*
void cbUpdateEntitiesPositions( CMessage& msgin, const string &serviceName, uint16 serviceId ) void cbUpdateEntitiesPositions( CMessage& msgin, const string &serviceName, uint16 serviceId )
@ -439,7 +439,7 @@ void cbUpdateEntitiesPositions( CMessage& msgin, const string &serviceName, uint
*/ */
/****************************************************************\ /****************************************************************\
cbUpdateEntitiesPositions() cbUpdateEntitiesPositions()
\****************************************************************/ \****************************************************************/
/* /*
void cbUpdateEntitiesPositionsUsingSize( CMessage& msgin, const string &serviceName, uint16 serviceId ) void cbUpdateEntitiesPositionsUsingSize( CMessage& msgin, const string &serviceName, uint16 serviceId )
@ -484,7 +484,7 @@ void cbUpdateEntitiesOrientationsUsingSize( CMessage& msgin, const string &servi
/****************************************************************\ /****************************************************************\
cbEntityTeleport() cbEntityTeleport()
\****************************************************************/ \****************************************************************/
void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
{ {
@ -493,7 +493,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T
id.serial( msgin ); id.serial( msgin );
TDataSetRow index = CWorldPositionManager::getEntityIndex(id); TDataSetRow index = CWorldPositionManager::getEntityIndex(id);
if (!index.isValid()) if (!index.isValid())
return; return;
@ -506,7 +506,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T
pCGPMS->RingVisionUniverse->setEntityPosition(index,0,0); pCGPMS->RingVisionUniverse->setEntityPosition(index,0,0);
// update the player coordinates in the mirror // update the player coordinates in the mirror
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSX )= 0; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSX )= 0;
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSY )= 0; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSY )= 0;
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSZ )= 0; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSZ )= 0;
} }
@ -559,7 +559,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T
pCGPMS->MoveChecker->teleport(index, x, y, tick); pCGPMS->MoveChecker->teleport(index, x, y, tick);
// update the player coordinates in the mirror // update the player coordinates in the mirror
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSX )= x; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSX )= x;
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSY )= y; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSY )= y;
CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSZ )= z; CMirrorPropValue1DS<sint32>( TheDataset, index, DSPropertyPOSZ )= z;
CMirrorPropValue1DS<float>( TheDataset, index, DSPropertyORIENTATION )= t; CMirrorPropValue1DS<float>( TheDataset, index, DSPropertyORIENTATION )= t;
@ -573,7 +573,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T
} }
else else
{ {
nlinfo("MSG: Teleporting entity %d to continent %d cell %d (%d, %d, %d) at tick: %d",index.getIndex(),continent,cell,x,y,z,tick); //nlinfo("MSG: Teleporting entity %d to continent %d cell %d (%d, %d, %d) at tick: %d",index.getIndex(),continent,cell,x,y,z,tick);
CWorldPositionManager::teleport(index, x, y, z, t, continent, cell, tick); CWorldPositionManager::teleport(index, x, y, z, t, continent, cell, tick);
} }
} }
@ -592,25 +592,25 @@ void cbEntityPosition( CMessage& msgin, const string &serviceName, NLNET::TServi
{ {
// CEntityId sender; // CEntityId sender;
// sender.serial( msgin ); // sender.serial( msgin );
CEntityId id; CEntityId id;
id.serial( msgin ); id.serial( msgin );
TDataSetRow index = CWorldPositionManager::getEntityIndex(id); TDataSetRow index = CWorldPositionManager::getEntityIndex(id);
const CWorldEntity *pEntity = CWorldPositionManager::getEntity( index ); const CWorldEntity *pEntity = CWorldPositionManager::getEntity( index );
if( pEntity ) if( pEntity )
{ {
CMessage msgout( "ENTITY_POS" ); CMessage msgout( "ENTITY_POS" );
// msgout.serial( sender ); // msgout.serial( sender );
msgout.serial( id ); msgout.serial( id );
sint32 val; sint32 val;
val = pEntity->X(); val = pEntity->X();
msgout.serial( val ); msgout.serial( val );
val = pEntity->Y(); val = pEntity->Y();
msgout.serial( val ); msgout.serial( val );
@ -824,7 +824,7 @@ void cbEntitiesArroundEntity( NLNET::CMessage& msgin, const std::string &service
void cbEndEntitiesArroundEntity( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId ) void cbEndEntitiesArroundEntity( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{ {
CEntityId id; // base entity for decide list of entities arround this CEntityId id; // base entity for decide list of entities arround this
msgin.serial( id ); msgin.serial( id );
CWorldPositionManager::unrequestForEntityAround( serviceId, id ); CWorldPositionManager::unrequestForEntityAround( serviceId, id );
@ -870,10 +870,10 @@ void cbR2ForceVisionReset( NLNET::CMessage& msgin, const std::string &serviceNam
msgin.serial(eid); msgin.serial(eid);
TDataSetRow entityIndex = TheDataset.getDataSetRow( eid ); TDataSetRow entityIndex = TheDataset.getDataSetRow( eid );
BOMB_IF(!entityIndex.isValid() , "Try to reset the vision of a invalid player "+eid.toString(), return); BOMB_IF(!entityIndex.isValid() , "Try to reset the vision of a invalid player "+eid.toString(), return);
pCGPMS->RingVisionUniverse->forceResetVision(entityIndex); pCGPMS->RingVisionUniverse->forceResetVision(entityIndex);
} }
@ -925,14 +925,14 @@ TUnifiedCallbackItem CbGPMSArray[]=
// / *?DEAD?* / { "DISABLE_VISION_PROC", cbDisableVisionProcessing }, // ask for player vision not to be updated any longer // / *?DEAD?* / { "DISABLE_VISION_PROC", cbDisableVisionProcessing }, // ask for player vision not to be updated any longer
/*?DEAD?*/ { "ENTITY_POS", cbEntityPosition }, // ask for position of an entity /*?DEAD?*/ { "ENTITY_POS", cbEntityPosition }, // ask for position of an entity
/*?DEAD?*/ { "ASK_VISION_ARROUND_ENTITY", cbEntitiesArroundEntity }, // ask for vision update around an entity /*?DEAD?*/ { "ASK_VISION_ARROUND_ENTITY", cbEntitiesArroundEntity }, // ask for vision update around an entity
/*?DEAD?*/ { "UNASK_VISION_ARROUND_ENTITY",cbEndEntitiesArroundEntity }, // remove vision update around an entity /*?DEAD?*/ { "UNASK_VISION_ARROUND_ENTITY",cbEndEntitiesArroundEntity }, // remove vision update around an entity
/*?DEAD?*/ { "VISION_REQUEST", cbVisionRequest }, /*?DEAD?*/ { "VISION_REQUEST", cbVisionRequest },
{ "SET_PLAYER_FLAGS", cbSetPlayerFlags }, // set flags for player (limit speed, etc) { "SET_PLAYER_FLAGS", cbSetPlayerFlags }, // set flags for player (limit speed, etc)
{ "R2_VISION_REFRESH", cbR2ForceVisionReset }, // force the update of the vision (because some message must have been discared in Ring (in edition mode the network is not listen) { "R2_VISION_REFRESH", cbR2ForceVisionReset }, // force the update of the vision (because some message must have been discared in Ring (in edition mode the network is not listen)
}; };

Loading…
Cancel
Save