mirror of
https://github.com/SWG-Source/src.git
synced 2026-08-03 03:16:01 -04:00
planet and metrics
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include "MonAPI2/MonitorAPI.h"
|
||||
#include "serverNetworkMessages/MetricsInitiationMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -79,34 +81,42 @@ void MetricsGatheringConnection::onReceive(const Archive::ByteStream & message)
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(m.isType("ConnectionServerMetricsMessage"))
|
||||
{
|
||||
DEBUG_FATAL(true, ("This message has been depricated"));
|
||||
}
|
||||
else if (m.isType("MetricsInitiationMessage"))
|
||||
{
|
||||
WARNING_STRICT_FATAL(m_initialized, ("Received initialize metrics on initialized connection"));
|
||||
//Get process name and secondary field (i.e. planet)
|
||||
MetricsInitiationMessage mx(ri);
|
||||
bool dynamic = mx.getIsDynamic();
|
||||
std::string process = mx.getPrimaryName();
|
||||
std::string planet = mx.getSecondaryName();
|
||||
int index = mx.getIndex();
|
||||
initialize(process, planet, dynamic, index);
|
||||
}
|
||||
else if (m.isType("MetricsDataMessage"))
|
||||
{
|
||||
if (!m_initialized)
|
||||
const uint32 messageType = m.getType();
|
||||
|
||||
switch(messageType) {
|
||||
case constcrc("ConnectionServerMetricsMessage") :
|
||||
{
|
||||
//Received data on uninitialized connection.
|
||||
return;
|
||||
DEBUG_FATAL(true, ("This message has been depricated"));
|
||||
break;
|
||||
}
|
||||
case constcrc("MetricsInitiationMessage") :
|
||||
{
|
||||
WARNING_STRICT_FATAL(m_initialized, ("Received initialize metrics on initialized connection"));
|
||||
//Get process name and secondary field (i.e. planet)
|
||||
MetricsInitiationMessage mx(ri);
|
||||
bool dynamic = mx.getIsDynamic();
|
||||
std::string process = mx.getPrimaryName();
|
||||
std::string planet = mx.getSecondaryName();
|
||||
int index = mx.getIndex();
|
||||
initialize(process, planet, dynamic, index);
|
||||
break;
|
||||
}
|
||||
case constcrc("MetricsDataMessage") :
|
||||
{
|
||||
if (!m_initialized)
|
||||
{
|
||||
//Received data on uninitialized connection.
|
||||
return;
|
||||
}
|
||||
MetricsDataMessage metricsData(ri);
|
||||
update(metricsData.getData());
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
ServerConnection::onReceive(message);
|
||||
break;
|
||||
}
|
||||
MetricsDataMessage metricsData(ri);
|
||||
update(metricsData.getData());
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerConnection::onReceive(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,8 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedUtility/LocationManager.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
Scene::Scene() :
|
||||
@@ -96,95 +98,104 @@ void Scene::receiveMessage(const MessageDispatch::Emitter & source, const Messag
|
||||
const GameServerConnection *gameServer=dynamic_cast<const GameServerConnection*>(&source);
|
||||
WARNING_DEBUG_FATAL(gameServer==0,("Source was nullptr or source was not a GameServerConnection."));
|
||||
|
||||
if (message.isType("GameConnectionClosed"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Handling a game server crash for server %lu\n", gameServer->getProcessId()));
|
||||
handleCrash(gameServer->getProcessId());
|
||||
}
|
||||
|
||||
else if (message.isType("UpdateObjectOnPlanetMessage"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
UpdateObjectOnPlanetMessage msg(ri);
|
||||
|
||||
int interestRadius = msg.getInterestRadius();
|
||||
|
||||
if(msg.getWatched() && interestRadius == 0)
|
||||
interestRadius = 1;
|
||||
|
||||
if (m_deletedObjects.find(msg.getObjectId())!=m_deletedObjects.end())
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
switch(messageType) {
|
||||
case constcrc("GameConnectionClosed") :
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Ignoring update for object %s which has been removed.\n",msg.getObjectId().getValueString().c_str()));
|
||||
DEBUG_REPORT_LOG(true, ("Handling a game server crash for server %lu\n", gameServer->getProcessId()));
|
||||
handleCrash(gameServer->getProcessId());
|
||||
break;
|
||||
}
|
||||
else
|
||||
case constcrc("UpdateObjectOnPlanetMessage") :
|
||||
{
|
||||
NetworkId container(msg.getTopmostContainer());
|
||||
if (container==msg.getObjectId()) // game server sends container == objectId if the object is not contained
|
||||
container=NetworkId::cms_invalid;
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
UpdateObjectOnPlanetMessage msg(ri);
|
||||
|
||||
bool processUpdate = true;
|
||||
if (container != NetworkId::cms_invalid)
|
||||
int interestRadius = msg.getInterestRadius();
|
||||
|
||||
if(msg.getWatched() && interestRadius == 0)
|
||||
interestRadius = 1;
|
||||
|
||||
if (m_deletedObjects.find(msg.getObjectId())!=m_deletedObjects.end())
|
||||
{
|
||||
PlanetProxyObject const *const containerObject = findObjectByID(container);
|
||||
if (containerObject)
|
||||
DEBUG_REPORT_LOG(true,("Ignoring update for object %s which has been removed.\n",msg.getObjectId().getValueString().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
NetworkId container(msg.getTopmostContainer());
|
||||
if (container==msg.getObjectId()) // game server sends container == objectId if the object is not contained
|
||||
container=NetworkId::cms_invalid;
|
||||
|
||||
bool processUpdate = true;
|
||||
if (container != NetworkId::cms_invalid)
|
||||
{
|
||||
if (containerObject->getAuthoritativeServer() != gameServer->getProcessId())
|
||||
PlanetProxyObject const *const containerObject = findObjectByID(container);
|
||||
if (containerObject)
|
||||
{
|
||||
// This update message came from a server that is not
|
||||
// authoritative for the container of this object. This
|
||||
// can happen when the planet server is in control of
|
||||
// switching the container's authority but is not in
|
||||
// charge of changing the container content's authority.
|
||||
// This happens to the rider of a mount when the mount
|
||||
// switches authority.
|
||||
processUpdate = false;
|
||||
if (containerObject->getAuthoritativeServer() != gameServer->getProcessId())
|
||||
{
|
||||
// This update message came from a server that is not
|
||||
// authoritative for the container of this object. This
|
||||
// can happen when the planet server is in control of
|
||||
// switching the container's authority but is not in
|
||||
// charge of changing the container content's authority.
|
||||
// This happens to the rider of a mount when the mount
|
||||
// switches authority.
|
||||
processUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (processUpdate)
|
||||
{
|
||||
PlanetProxyObject *theObject=findObjectByID(msg.getObjectId());
|
||||
if (!theObject)
|
||||
if (processUpdate)
|
||||
{
|
||||
// this is a new object
|
||||
theObject=new PlanetProxyObject(msg.getObjectId());
|
||||
addObject(theObject);
|
||||
PlanetProxyObject *theObject=findObjectByID(msg.getObjectId());
|
||||
if (!theObject)
|
||||
{
|
||||
// this is a new object
|
||||
theObject=new PlanetProxyObject(msg.getObjectId());
|
||||
addObject(theObject);
|
||||
}
|
||||
|
||||
theObject->onReceivedMessageFromServer(gameServer->getProcessId());
|
||||
theObject->update(msg.getX(), msg.getY(), msg.getZ(), container, gameServer->getProcessId(), interestRadius, msg.getObjectTypeTag(), msg.getLevel(), msg.getHibernating(), msg.getTemplateCrc(), msg.getAiActivity(), msg.getCreationType());
|
||||
|
||||
//-- handle updating LocationManager
|
||||
if (msg.getLocationReservationRadius () > 0.f)
|
||||
LocationManager::updateObject (msg.getObjectId (), msg.getX (), msg.getZ (), msg.getLocationReservationRadius ());
|
||||
}
|
||||
|
||||
theObject->onReceivedMessageFromServer(gameServer->getProcessId());
|
||||
theObject->update(msg.getX(), msg.getY(), msg.getZ(), container, gameServer->getProcessId(), interestRadius, msg.getObjectTypeTag(), msg.getLevel(), msg.getHibernating(), msg.getTemplateCrc(), msg.getAiActivity(), msg.getCreationType());
|
||||
|
||||
//-- handle updating LocationManager
|
||||
if (msg.getLocationReservationRadius () > 0.f)
|
||||
LocationManager::updateObject (msg.getObjectId (), msg.getX (), msg.getZ (), msg.getLocationReservationRadius ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (message.isType("PlanetRemoveObject"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
PlanetRemoveObject msg(ri);
|
||||
handleRemoveObject(msg.getObjectId());
|
||||
case constcrc("PlanetRemoveObject") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
PlanetRemoveObject msg(ri);
|
||||
handleRemoveObject(msg.getObjectId());
|
||||
|
||||
//-- handle updating LocationManager
|
||||
LocationManager::removeObject (msg.getObjectId ());
|
||||
}
|
||||
else if (message.isType("ForceLoadArea"))
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::pair<float, float>, std::pair<float, float> > > > const msg(ri);
|
||||
//-- handle updating LocationManager
|
||||
LocationManager::removeObject (msg.getObjectId ());
|
||||
break;
|
||||
}
|
||||
case constcrc("ForceLoadArea") :
|
||||
{
|
||||
Archive::ReadIterator ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
GenericValueTypeMessage<std::pair<uint32, std::pair<std::pair<float, float>, std::pair<float, float> > > > const msg(ri);
|
||||
|
||||
handleForceLoadArea(
|
||||
msg.getValue().first,
|
||||
static_cast<int>(msg.getValue().second.first.first),
|
||||
static_cast<int>(msg.getValue().second.first.second),
|
||||
static_cast<int>(msg.getValue().second.second.first),
|
||||
static_cast<int>(msg.getValue().second.second.second));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Scene.cpp received an unidentified message.\n"));
|
||||
handleForceLoadArea(
|
||||
msg.getValue().first,
|
||||
static_cast<int>(msg.getValue().second.first.first),
|
||||
static_cast<int>(msg.getValue().second.first.second),
|
||||
static_cast<int>(msg.getValue().second.second.first),
|
||||
static_cast<int>(msg.getValue().second.second.second
|
||||
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
DEBUG_REPORT_LOG(true,("Scene.cpp received an unidentified message.\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user