diff --git a/game/shared/library/CMakeLists.txt b/game/shared/library/CMakeLists.txt index 2bb09fd4..adc811c7 100644 --- a/game/shared/library/CMakeLists.txt +++ b/game/shared/library/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(swgSharedNetworkMessages) add_subdirectory(swgSharedUtility) diff --git a/game/shared/library/swgSharedNetworkMessages/CMakeLists.txt b/game/shared/library/swgSharedNetworkMessages/CMakeLists.txt new file mode 100644 index 00000000..3243bdfe --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 2.8) + +project(swgSharedNetworkMessages) + +if(WIN32) + add_definitions(/D_CRT_SECURE_NO_WARNINGS) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public) + +add_subdirectory(src) diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/CombatActionCompleteMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/CombatActionCompleteMessage.h new file mode 100644 index 00000000..c4deb5ba --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/CombatActionCompleteMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/combat/CombatActionCompleteMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ConsentRequestMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ConsentRequestMessage.h new file mode 100644 index 00000000..c46592e7 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ConsentRequestMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/consent/ConsentRequestMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h new file mode 100644 index 00000000..15fed960 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h @@ -0,0 +1 @@ +#include "../../src/shared/core/FirstSwgSharedNetworkMessages.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatAction.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatAction.h new file mode 100644 index 00000000..10439f40 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatAction.h @@ -0,0 +1,2 @@ +#include "../../src/shared/combat/MessageQueueCombatAction.h" + diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatDamage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatDamage.h new file mode 100644 index 00000000..d5b183ce --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/MessageQueueCombatDamage.h @@ -0,0 +1,2 @@ +#include "../../src/shared/combat/MessageQueueCombatDamage.h" + diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListCreateMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListCreateMessage.h new file mode 100644 index 00000000..248ad488 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListCreateMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/permissionList/PermissionListCreateMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListModifyMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListModifyMessage.h new file mode 100644 index 00000000..e47e78da --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/PermissionListModifyMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/permissionList/PermissionListModifyMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ResourceListForSurveyMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ResourceListForSurveyMessage.h new file mode 100644 index 00000000..2bd0fd7e --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/ResourceListForSurveyMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/survey/ResourceListForSurveyMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h new file mode 100644 index 00000000..62e533c5 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h @@ -0,0 +1 @@ +#include "../../src/shared/core/SetupSwgSharedNetworkMessages.h" diff --git a/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SurveyMessage.h b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SurveyMessage.h new file mode 100644 index 00000000..39aa3999 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/include/public/swgSharedNetworkMessages/SurveyMessage.h @@ -0,0 +1 @@ +#include "../../src/shared/survey/SurveyMessage.h" diff --git a/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt b/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt new file mode 100644 index 00000000..d1aa2353 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt @@ -0,0 +1,64 @@ + +set(SHARED_SOURCES + shared/combat/CombatActionCompleteMessage.cpp + shared/combat/CombatActionCompleteMessage.h + shared/combat/MessageQueueCombatAction.cpp + shared/combat/MessageQueueCombatAction.h + shared/combat/MessageQueueCombatDamage.cpp + shared/combat/MessageQueueCombatDamage.h + + shared/consent/ConsentRequestMessage.cpp + shared/consent/ConsentRequestMessage.h + + shared/core/FirstSwgSharedNetworkMessages.h + shared/core/SetupSwgSharedNetworkMessages.cpp + shared/core/SetupSwgSharedNetworkMessages.h + + shared/permissionList/PermissionListCreateMessage.cpp + shared/permissionList/PermissionListCreateMessage.h + shared/permissionList/PermissionListModifyMessage.cpp + shared/permissionList/PermissionListModifyMessage.h + + shared/survey/ResourceListForSurveyMessage.cpp + shared/survey/ResourceListForSurveyMessage.h + shared/survey/SurveyMessage.cpp + shared/survey/SurveyMessage.h +) + +if(WIN32) + set(PLATFORM_SOURCES + win32/FirstSwgSharedNetworkMessages.cpp + ) + + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32) +else() + set(PLATFORM_SOURCES "") +endif() + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/shared + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public + ${SWG_GAME_SOURCE_DIR}/shared/library/swgSharedUtility/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localizationArchive/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public +) + +add_library(swgSharedNetworkMessages STATIC + ${SHARED_SOURCES} + ${PLATFORM_SOURCES} +) diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.cpp new file mode 100644 index 00000000..8de47808 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.cpp @@ -0,0 +1,46 @@ +// ====================================================================== +// +// CombatActionCompleteMessage.cpp +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +//----------------------------------------------------------------------- + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/CombatActionCompleteMessage.h" + +//----------------------------------------------------------------------- + +const char * const CombatActionCompleteMessage::MESSAGE_TYPE = "CombatActionCompleteMessage::MESSAGE_TYPE"; + +//----------------------------------------------------------------- + +CombatActionCompleteMessage::CombatActionCompleteMessage (uint32 sequenceId, bool nack) : +GameNetworkMessage (MESSAGE_TYPE), +m_sequenceId (sequenceId & ~(0x80000000)) +{ + addVariable (m_sequenceId); + + //-- set the high bit if this is a nack + if (nack) + m_sequenceId.set (m_sequenceId.get () | 0x80000000); +} + +//----------------------------------------------------------------------- + +CombatActionCompleteMessage::CombatActionCompleteMessage(Archive::ReadIterator & source) : +GameNetworkMessage (MESSAGE_TYPE), +m_sequenceId () +{ + addVariable (m_sequenceId); + unpack (source); +} + +//---------------------------------------------------------------------- + +CombatActionCompleteMessage::~CombatActionCompleteMessage() +{ +} + +//----------------------------------------------------------------------- diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.h new file mode 100644 index 00000000..3f688f3b --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/CombatActionCompleteMessage.h @@ -0,0 +1,65 @@ + +// ====================================================================== +// +// CombatActionCompleteMessage.h +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_CombatActionCompleteMessage_H +#define INCLUDED_CombatActionCompleteMessage_H + +//----------------------------------------------------------------------- + +#include "sharedNetworkMessages/GameNetworkMessage.h" +#include "Unicode.h" +#include "unicodeArchive/UnicodeArchive.h" + +//----------------------------------------------------------------------- + +class GameInByteStream; +class GameOutByteStream; + +//----------------------------------------------------------------------- + +class CombatActionCompleteMessage : public GameNetworkMessage +{ +public: + + static const char * const MESSAGE_TYPE; + + CombatActionCompleteMessage (uint32 sequenceId, bool nack = false); + explicit CombatActionCompleteMessage (Archive::ReadIterator & source); + virtual ~CombatActionCompleteMessage (); + + + uint32 getSequenceId () const; + bool isNack () const; + +private: + + //-- high bit is the nack flag, lower 31 bits is the id + Archive::AutoVariable m_sequenceId; + +private: + CombatActionCompleteMessage(const CombatActionCompleteMessage&); + CombatActionCompleteMessage& operator= (const CombatActionCompleteMessage&); +}; + +//----------------------------------------------------------------------- + +inline uint32 CombatActionCompleteMessage::getSequenceId () const +{ + return m_sequenceId.get () & ~(0x80000000); +} + +//---------------------------------------------------------------------- + +inline bool CombatActionCompleteMessage::isNack () const +{ + return (m_sequenceId.get () & 0x80000000) != 0; +} + +//----------------------------------------------------------------- + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.cpp new file mode 100644 index 00000000..7395e9f9 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.cpp @@ -0,0 +1,522 @@ +//======================================================================== +// +// MessageQueueCombatAction.cpp +// +// copyright 2001 Sony Online Entertainment +// +//======================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "MessageQueueCombatAction.h" +#include "sharedFoundation/CrcLowerString.h" + +#include "swgSharedUtility/Postures.h" + +#include +#include +#include "sharedFoundation/MemoryBlockManager.h" +#include "sharedFoundation/ExitChain.h" +#include "sharedFoundation/GameControllerMessage.h" +#include "sharedMathArchive/VectorArchive.h" +#include "sharedNetworkMessages/ControllerMessageFactory.h" +#include "sharedObject/NetworkIdManager.h" + +// ====================================================================== + +namespace MessageQueueCombatActionNamespace +{ + MessageQueueCombatAction::ActionNameLookupFunction s_actionNameLookupFunction; +} + +using namespace MessageQueueCombatActionNamespace; + +//=================================================================== + +CONTROLLER_MESSAGE_IMPLEMENTATION(MessageQueueCombatAction, CM_combatAction); + +// ====================================================================== + +/** + * Class constructor. + */ +MessageQueueCombatAction::AttackerData::AttackerData() +: id(), + weapon(), + endPosture(Postures::Upright), + trailBits(0), + clientEffectId(0), + actionNameCrc(0), + useLocation(false), + targetLocation() +{ +} // MessageQueueCombatAction::AttackerData::AttackerData + +/** + * Class constructor. + */ +MessageQueueCombatAction::DefenderData::DefenderData() +: id(), + endPosture(Postures::Upright), + defense(CombatEngineData::CD_miss), + clientEffectId(0), + hitLocation(0), + damageAmount(0) +{ +} // MessageQueueCombatAction::DefenderData:::DefenderData + +// ====================================================================== + +void MessageQueueCombatAction::setActionNameLookupFunction(ActionNameLookupFunction actionNameLookupFunction) +{ + s_actionNameLookupFunction = actionNameLookupFunction; +} + +// ====================================================================== + +/** + * Class constructor. + */ +MessageQueueCombatAction::MessageQueueCombatAction(void) +: Data(), + m_actionId(0), + m_attacker(), + m_defenders() +{ +} // MessageQueueCombatAction::MessageQueueCombatAction + +/** + * Class destructor. + */ +MessageQueueCombatAction::~MessageQueueCombatAction() +{ +} // MessageQueueCombatAction::~MessageQueueCombatAction + +/** + * Sets the action id based on a string value. + * + * @param id the action id + */ +void MessageQueueCombatAction::setActionId(const std::string & id) +{ + m_actionId = CrcLowerString::calculateCrc(id.c_str()); +} // MessageQueueCombatAction::setActionId + +/** + * Sets the info for the attacker of this action. + * + * @param attacker the attacker's id + */ +void MessageQueueCombatAction::setAttacker(const NetworkId & attacker, + const NetworkId & weapon) +{ + m_attacker.id = attacker; + m_attacker.weapon = weapon; +} // MessageQueueCombatAction::setAttacker(const NetworkId &) + +/** + * Sets the info for the attacker of this action. + * + * @param attacker the attacker's id + * @param posture the attacker's final posture + */ +void MessageQueueCombatAction::setAttacker(const NetworkId & attacker, + const NetworkId & weapon, Postures::Enumerator posture) +{ + m_attacker.id = attacker; + m_attacker.weapon = weapon; + m_attacker.endPosture = posture; +} // MessageQueueCombatAction::setAttacker(const NetworkId &, Postures::Enumerator) + +/** + * Sets the posture for the attacker. + * + * @param posture the attacker's final posture + */ +void MessageQueueCombatAction::setAttackerPosture(Postures::Enumerator posture) +{ + m_attacker.endPosture = posture; +} // MessageQueueCombatAction::setAttackerPosture + +/** + * Sets the trail bit field (trail special effect flags) for the attacker. + * + * @param trailBits the bit field describing the enabled SFX trails for the attacker. + */ +void MessageQueueCombatAction::setAttackerTrailBits(int trailBits) +{ + m_attacker.trailBits = trailBits; +} // MessageQueueCombatAction::setAttackerTrailBits + +/** + * Sets the client effect id used for the deferred client effect played on the attacker. + * + * @param clientEffectId the id (row number) of the effect to play on the client after a + * deferred amount of time. A value of zero (the default) will play no effect. + */ +void MessageQueueCombatAction::setAttackerActionNameCrc(int actionNameCrc) +{ + m_attacker.actionNameCrc = actionNameCrc; +} // MessageQueueCombatAction::setAttackerActionNameCrc + +/** + * Sets the client effect id used for the deferred client effect played on the attacker. + * + * @param clientEffectId the id (row number) of the effect to play on the client after a + * deferred amount of time. A value of zero (the default) will play no effect. + */ +void MessageQueueCombatAction::setAttackerClientEffectId(int clientEffectId) +{ + m_attacker.clientEffectId = clientEffectId; +} // MessageQueueCombatAction::setAttackerClientEffectId + +/** + * Sets the location for a location-based attack. + * + * @param location world-space location that is the target of the attack, if useLocation is true + * @param useLocation whether the attack targets a location + */ +void MessageQueueCombatAction::setAttackerTargetLocation(const Vector &location, const NetworkId &targetCell, bool useLocation) +{ + m_attacker.useLocation = useLocation; + m_attacker.targetLocation = location; + m_attacker.targetCell = targetCell; +} + +/** + * Adds info about a defender of this action. + * + * @param defender the defender's id + * @param defense the defense used on a failed attack + */ +void MessageQueueCombatAction::addDefender(const NetworkId & defender, + CombatEngineData::CombatDefense defense) +{ + m_defenders.push_back(DefenderData()); + DefenderData & data = m_defenders.back(); + data.id = defender; + data.defense = defense; +} // MessageQueueCombatAction::addDefender(const NetworkId &, CombatEngineData::CombatDefense) + +/** + * Adds info about a defender of this action. + * + * @param defender the defender's id + * @param defense the defense used on a failed attack + * @param posture the defender's final posture + * @param clientEffectId the deferred client effect id for the defender. + * @param damageAmount the amount of damage applied to the defender + */ +void MessageQueueCombatAction::addDefender(const NetworkId & defender, + CombatEngineData::CombatDefense defense, Postures::Enumerator posture, + int clientEffectId, int hitLocation, int damageAmount) +{ + m_defenders.push_back(DefenderData()); + DefenderData & data = m_defenders.back(); + data.id = defender; + data.defense = defense; + data.endPosture = posture; + data.clientEffectId = clientEffectId; + data.hitLocation = hitLocation; + data.damageAmount = damageAmount; +} // MessageQueueCombatAction::addDefender(const NetworkId &, CombatEngineData::CombatDefense, Postures::Enumerator) + +/** + * Sets the final posture for a defender. + * + * @param defender the defender's id + * @param posture the defender's posture + */ +void MessageQueueCombatAction::setDefenderPosture(const NetworkId & defender, Postures::Enumerator posture) +{ + for (DefenderDataVector::iterator iter(m_defenders.begin()); + iter != m_defenders.end(); ++iter) + { + DefenderData & data = *iter; + if (data.id == defender) + { + data.endPosture = posture; + return; + } + } +} // MessageQueueCombatAction::setDefenderPosture(const NetworkId &, Postures::Enumerator) + +/** + * Sets the final posture for a defender. + * + * @param defender the defender's id + * @param posture the defender's posture + * @param indexHint hint as to the vector index of the defender + */ +void MessageQueueCombatAction::setDefenderPosture(const NetworkId & defender, Postures::Enumerator posture, int indexHint) +{ + if (indexHint >= 0 && indexHint < static_cast(m_defenders.size())) + { + DefenderData & data = m_defenders[static_cast(indexHint)]; + if (data.id == defender) + { + data.endPosture = posture; + return; + } + } + setDefenderPosture(defender, posture); +} // MessageQueueCombatAction::setDefenderPosture(const NetworkId &, Postures::Enumerator, int) + + +/** + * Sets the amount of damge appied by the attacker. + * + * @param damage amount + */ +void MessageQueueCombatAction::setDefenderDamageAmount(const NetworkId & defender, int damageAmount) +{ + for (DefenderDataVector::iterator iter(m_defenders.begin()); + iter != m_defenders.end(); ++iter) + { + DefenderData & data = *iter; + if (data.id == defender) + { + data.damageAmount = damageAmount; + return; + } + } +} // MessageQueueCombatAction::setDamageAmount + +/** + * Dump out the contents of the message via DEBUG_REPORT_LOG. + */ +void MessageQueueCombatAction::debugDump() const +{ + //-- Get attacker and defender objects. + const Object *const attackerObject = NetworkIdManager::getObjectById(m_attacker.id); + UNREF(attackerObject); + + const Object *const weaponObject = NetworkIdManager::getObjectById(m_attacker.weapon); + UNREF(weaponObject); + + //-- Lookup action name if we have it. + bool hasActionName; + char actionName[256]; + + if (s_actionNameLookupFunction != NULL) + { + hasActionName = true; + (*s_actionNameLookupFunction)(m_actionId, actionName, sizeof(actionName)); + } + else + hasActionName = false; + + //-- Start the dump. + DEBUG_REPORT_LOG(true, ("MQCA: START.\n")); + + // Print action name or id. + if (!hasActionName) + DEBUG_REPORT_LOG(true, ("MQCA: actionId [0x%08X].\n", static_cast(m_actionId))); + else + DEBUG_REPORT_LOG(true, ("MQCA: action name [%s].\n", actionName)); + + // Print attacker info. + DEBUG_REPORT_LOG(true, ("MQCA: attacker: id =[%s].\n", m_attacker.id.getValueString().c_str())); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: template =[%s].\n", attackerObject ? attackerObject->getObjectTemplateName() : "")); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: weapon =[%s].\n", m_attacker.weapon.getValueString().c_str())); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: weapon template =[%s].\n", weaponObject ? weaponObject->getObjectTemplateName() : "")); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: end posture =[%s].\n", Postures::getPostureName(m_attacker.endPosture))); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: trailBits =[0x%02x].\n", m_attacker.trailBits)); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: client effect id=[%d].\n", m_attacker.clientEffectId)); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: action name crc =[%d].\n", m_attacker.actionNameCrc)); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: use location =[%s].\n", m_attacker.useLocation ? "TRUE" : "FALSE")); + if(m_attacker.useLocation) + { + DEBUG_REPORT_LOG(true, ("MQCA: attacker: location target =[%5.0f %5.0f %5.0f]", m_attacker.targetLocation.x, m_attacker.targetLocation.y, m_attacker.targetLocation.z)); + DEBUG_REPORT_LOG(true, ("MQCA: attacker: location target cell =[%s]", m_attacker.targetCell.getValueString().c_str())); + } + + // Print per-defender info. + const DefenderDataVector::size_type defenderCount = m_defenders.size(); + DEBUG_REPORT_LOG(true, ("MQCA: defender count [%u].\n", defenderCount)); + + for (DefenderDataVector::size_type i = 0; i < defenderCount; ++i) + { + const DefenderData &data = m_defenders[i]; + const Object *const defenderObject = NetworkIdManager::getObjectById(data.id); + UNREF(defenderObject); + + DEBUG_REPORT_LOG(true, ("MQCA: defender #%d: id =[%s].\n", i + 1, data.id.getValueString().c_str())); + DEBUG_REPORT_LOG(true, ("MQCA: defender #%d: template =[%s].\n", i + 1, defenderObject ? defenderObject->getObjectTemplateName() : "")); + DEBUG_REPORT_LOG(true, ("MQCA: defender #%d: end posture =[%s].\n", i + 1, Postures::getPostureName(data.endPosture))); + DEBUG_REPORT_LOG(true, ("MQCA: defender #%d: defense =[%s].\n", i + 1, CombatEngineData::getCombatDefenseName(data.defense))); + DEBUG_REPORT_LOG(true, ("MQCA: defender #%d: client effect id=[%d].\n", i + 1, data.clientEffectId)); + } + + DEBUG_REPORT_LOG(true, ("MQCA: END.\n")); +} // MessageQueueCombatAction::debugDump() + + + +// +// Get a checksum value that can be used to determine if two MessageQueueCombatAction packets +// can be combined into one. We only look at the attacker info because there can be multiple +// defenders. +// +uint32 MessageQueueCombatAction::getComparisonChecksum( void ) const +{ + uint32 retval = 0; + retval += m_actionId; + retval += NetworkId::Hash()(m_attacker.id); + retval += NetworkId::Hash()(m_attacker.weapon); + retval += int(m_attacker.endPosture); + retval += m_attacker.trailBits; + retval += m_attacker.clientEffectId; + retval += m_attacker.actionNameCrc; + retval += m_attacker.useLocation; + retval += static_cast(m_attacker.targetLocation.x); + retval += static_cast(m_attacker.targetLocation.y); + retval += static_cast(m_attacker.targetLocation.z); + + return retval; +} + +// +// Merge packets (possibly adding another defender if need be...) +// +void MessageQueueCombatAction::mergePacket( MessageQueueCombatAction* pOther ) +{ + DefenderDataVector::const_iterator oiter; + const DefenderDataVector& odefenders = pOther->getDefenders(); + + for ( oiter = odefenders.begin(); oiter != odefenders.end(); ++oiter ) + { +#if 0 +/******** This code does damage aggregation. It may look like a bug since it will make damage numbers higher ********* + bool b_defender_merged = false; + DefenderDataVector::iterator miter; + for ( miter = m_defenders.begin(); miter != m_defenders.end(); ++miter ) + { + if (( miter->id == oiter->id ) && ( miter->clientEffectId == oiter->clientEffectId )) + { + miter->damageAmount += oiter->damageAmount; + b_defender_merged = true; + } + } + if ( ! b_defender_merged ) // Add another defender for the one we couldn't merge +**********************************************************************************************************************/ +#endif + { + m_defenders.push_back( *oiter ); + } + } + +} + + + +// ---------------------------------------------------------------------- + +void MessageQueueCombatAction::pack(const MessageQueue::Data* const data, Archive::ByteStream & target) +{ + const MessageQueueCombatAction* const msg = safe_cast (data); + + if (msg) + { + Archive::put(target, msg->getActionId()); + + // write the attacker data + const MessageQueueCombatAction::AttackerData & attacker = msg->getAttacker(); + Archive::put(target, attacker.id); + Archive::put(target, attacker.weapon); + Archive::put(target, attacker.endPosture); + const uint8 trailBits = static_cast(attacker.trailBits); + Archive::put(target, trailBits); + Archive::put(target, static_cast(attacker.clientEffectId)); + Archive::put(target, attacker.actionNameCrc); + Archive::put(target, attacker.useLocation); + if(attacker.useLocation) + { + Archive::put(target, attacker.targetLocation); + Archive::put(target, attacker.targetCell); + } + + // write the defender data + const std::vector & defenderList = msg->getDefenders(); + uint16 count = static_cast(defenderList.size()); + Archive::put(target, count); + for (std::vector::const_iterator + iter = defenderList.begin(); iter != defenderList.end(); ++iter) + { + Archive::put(target, (*iter).id); + Archive::put(target, (*iter).endPosture); + uint8 defense = static_cast((*iter).defense); + Archive::put(target, defense); + Archive::put(target, static_cast((*iter).clientEffectId)); + Archive::put(target, static_cast((*iter).hitLocation)); + Archive::put(target, static_cast((*iter).damageAmount)); + } + } +} // ControllerMessageFactory::packCombatAction + +//----------------------------------------------------------------------- + + +MessageQueue::Data* MessageQueueCombatAction::unpack(Archive::ReadIterator & source) +{ + NetworkId id, weapon; + Postures::Enumerator postureEnd; + uint32 actionId; + uint8 defense; + int actionNameCrc; + + MessageQueueCombatAction * msg = new MessageQueueCombatAction; + NOT_NULL(msg); + + Archive::get(source, actionId); + msg->setActionId(actionId); + + // read the attacker data + Archive::get(source, id); + Archive::get(source, weapon); + Archive::get(source, postureEnd); + + msg->setAttacker(id, weapon, postureEnd); + + uint8 trailBits = 0; + Archive::get(source, trailBits); + msg->setAttackerTrailBits(static_cast(trailBits)); + + uint8 clientEffectId; + Archive::get(source, clientEffectId); + msg->setAttackerClientEffectId(static_cast(clientEffectId)); + + Archive::get(source, actionNameCrc); + msg->setAttackerActionNameCrc(actionNameCrc); + + bool useLocation; + Archive::get(source, useLocation); + + Vector locationTarget; + NetworkId cellTarget; + if(useLocation) + { + Archive::get(source, locationTarget); + Archive::get(source, cellTarget); + } + msg->setAttackerTargetLocation(locationTarget, cellTarget, useLocation); + + // read the defender data + uint8 hitLocation; + uint16 count; + uint16 damageAmount; + Archive::get(source, count); + for (uint16 i = 0; i < count; ++i) + { + Archive::get(source, id); + Archive::get(source, postureEnd); + Archive::get(source, defense); + Archive::get(source, clientEffectId); + Archive::get(source, hitLocation); + Archive::get(source, damageAmount); + msg->addDefender(id, static_cast(defense), postureEnd, clientEffectId, hitLocation, damageAmount); + } + + return msg; +} // ControllerMessageFactory::unpackCombatAction + +//----------------------------------------------------------------------- diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.h b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.h new file mode 100644 index 00000000..5ed9cd38 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatAction.h @@ -0,0 +1,130 @@ +//======================================================================== +// +// MessageQueueCombatAction.h +// +// copyright 2001 Sony Online Entertainment, Inc. +// All rights reserved. +// +//======================================================================== + + +#ifndef INCLUDED_MessageQueueCombatAction_H +#define INCLUDED_MessageQueueCombatAction_H + +#include "sharedFoundation/MessageQueue.h" +#include "sharedFoundation/NetworkId.h" +#include "sharedMath/Vector.h" +#include "swgSharedUtility/CombatEngineData.h" +#include "swgSharedUtility/Postures.def" + +#include +#include "sharedNetworkMessages/ControllerMessageMacros.h" + +class MemoryBlockManager; +class Object; + + +class MessageQueueCombatAction : public MessageQueue::Data +{ + CONTROLLER_MESSAGE_INTERFACE; + +public: + struct AttackerData + { + AttackerData(); + + NetworkId id; + NetworkId weapon; // attacker's weapon; if cms_invalid, use current weapon + Postures::Enumerator endPosture; // attacker's posture at the end of the frame + int trailBits; // bitfield for trail special effects. + int clientEffectId; // id for client effect to play on the attacker. + int actionNameCrc; // crc for action used by attacker + bool useLocation; // if true, there is a location as the target/defender + Vector targetLocation; // valid if useLocation == TRUE, target of attack + NetworkId targetCell; // valid if useLocation == TRUE + }; + + struct DefenderData + { + DefenderData(); + + NetworkId id; + Postures::Enumerator endPosture; // defender's posture at the end of the frame + CombatEngineData::CombatDefense defense; + int clientEffectId; // id for client effect to play on the defender. + int hitLocation; // location to target and play hit + int damageAmount; // amount of damage being applied + }; + + typedef stdvector::fwd DefenderDataVector; + + typedef void (*ActionNameLookupFunction)(uint32 actionId, char *buffer, int bufferLength); + +public: + + static void setActionNameLookupFunction(ActionNameLookupFunction actionNameLookupFunction); + +public: + + MessageQueueCombatAction(void); + virtual ~MessageQueueCombatAction(); + + MessageQueueCombatAction& operator= (const MessageQueueCombatAction & source); + MessageQueueCombatAction(const MessageQueueCombatAction & source); + + uint32 getActionId(void) const; + void setActionId(uint32 id); + void setActionId(const std::string & id); + const AttackerData & getAttacker(void) const; + void setAttacker(const NetworkId & attacker, const NetworkId & weapon); + void setAttacker(const NetworkId & attacker, const NetworkId & weapon, Postures::Enumerator posture); + void setAttackerPosture(Postures::Enumerator posture); + void setAttackerTrailBits(int trailBits); + void setAttackerClientEffectId(int clientEffectId); + void setAttackerActionNameCrc(int actionNameCrc); + void setAttackerTargetLocation(const Vector &location, const NetworkId &cell, bool useLocation); + const DefenderDataVector &getDefenders(void) const; + void addDefender(const NetworkId & defender, CombatEngineData::CombatDefense defense); + void addDefender(const NetworkId & defender, CombatEngineData::CombatDefense defense, Postures::Enumerator posture, int clientEffectId, int hitLocation, int damageAmount); + void setDefenderPosture(const NetworkId & defender, Postures::Enumerator posture); + void setDefenderPosture(const NetworkId & defender, Postures::Enumerator posture, int indexHint); + void setDefenderDamageAmount(const NetworkId & defender, int damageAmount); + + void debugDump() const; + + // If this value matches between two packets, they can be merged + uint32 getComparisonChecksum( void ) const; + void mergePacket( MessageQueueCombatAction* pOther ); + +private: + + uint32 m_actionId; + AttackerData m_attacker; + DefenderDataVector m_defenders; +}; + + +inline uint32 MessageQueueCombatAction::getActionId(void) const +{ + return m_actionId; +} // MessageQueueCombatAction::getActionId + +inline void MessageQueueCombatAction::setActionId(uint32 id) +{ + m_actionId = id; +} // MessageQueueCombatAction::setActionId + +inline const MessageQueueCombatAction::AttackerData & + MessageQueueCombatAction::getAttacker(void) const +{ + return m_attacker; +} // MessageQueueCombatAction::getAttacker + +inline const stdvector::fwd & + MessageQueueCombatAction::getDefenders(void) const +{ + return m_defenders; +} // MessageQueueCombatAction::getDefenders + + +#endif // INCLUDED_MessageQueueCombatAction_H diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.cpp new file mode 100644 index 00000000..25a16b29 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.cpp @@ -0,0 +1,113 @@ +// ====================================================================== +// +// MessageQueueCombatDamage.cpp +// Copyright 2001 Sony Online Entertainment Inc. +// All Rights Reserved. +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "MessageQueueCombatDamage.h" + +#include +#include "sharedFoundation/MemoryBlockManager.h" +#include "sharedFoundation/ExitChain.h" +#include "sharedFoundation/GameControllerMessage.h" +#include "sharedNetworkMessages/ControllerMessageFactory.h" + +//=================================================================== + +CONTROLLER_MESSAGE_IMPLEMENTATION(MessageQueueCombatDamage, CM_combatDamage); + +//=================================================================== + + +// ====================================================================== + +/** + * Class constructor. + */ +MessageQueueCombatDamage::MessageQueueCombatDamage(void) +: m_actionId(0), + m_defender(), + m_defenderAttributes(new CurrentAttributeVector) +{ +} + +// ---------------------------------------------------------------------- + +/** + * Class destructor. + */ +MessageQueueCombatDamage::~MessageQueueCombatDamage() +{ + delete m_defenderAttributes; +} + +// ---------------------------------------------------------------------- + +void MessageQueueCombatDamage::addDefenderAttribute( + Attributes::Enumerator attribute, Attributes::Value value) +{ + CurrentAttribute currentAttribute; + currentAttribute.attribute = attribute; + currentAttribute.value = value; + m_defenderAttributes->push_back(currentAttribute); +} + + +void MessageQueueCombatDamage::pack(const MessageQueue::Data* const data, Archive::ByteStream & target) +{ + const MessageQueueCombatDamage* const msg = safe_cast (data); + + if (msg) + { + Archive::put(target, msg->getActionId()); + Archive::put(target, msg->getDefender()); + + const std::vector & attribs = + msg->getDefenderAttributes(); + uint16 count = static_cast(attribs.size()); + Archive::put(target, count); + for (std::vector::const_iterator + iter = attribs.begin(); iter != attribs.end(); ++iter) + { + Archive::put(target, (*iter).attribute); + Archive::put(target, (*iter).value); + } + } +} + +//----------------------------------------------------------------------- + + +MessageQueue::Data* MessageQueueCombatDamage::unpack(Archive::ReadIterator & source) +{ + uint16 actionId; + NetworkId defenderId; + Attributes::Enumerator attribute; + Attributes::Value value; + + MessageQueueCombatDamage * msg = new MessageQueueCombatDamage; + NOT_NULL(msg); + + + Archive::get(source, actionId); + msg->setActionId(actionId); + + Archive::get(source, defenderId); + msg->setDefender(defenderId); + + uint16 count; + Archive::get(source, count); + for (uint16 i = 0; i < count; ++i) + { + Archive::get(source, attribute); + Archive::get(source, value); + msg->addDefenderAttribute(attribute, value); + } + + return msg; +} +//----------------------------------------------------------------------- +// ====================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.h new file mode 100644 index 00000000..77c41d7e --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/combat/MessageQueueCombatDamage.h @@ -0,0 +1,82 @@ +//======================================================================== +// +// MessageQueueCombatDamage.h +// +// copyright 2001 Sony Online Entertainment, Inc. +// All rights reserved. +// +//======================================================================== + + +#ifndef INCLUDED_MessageQueueCombatDamage_H +#define INCLUDED_MessageQueueCombatDamage_H + +#include "sharedFoundation/MessageQueue.h" +#include "sharedFoundation/NetworkId.h" +#include "swgSharedUtility/Attributes.def" +#include "sharedNetworkMessages/ControllerMessageMacros.h" + +class MemoryBlockManager; +class MessageQueueCombatDamage : public MessageQueue::Data +{ + CONTROLLER_MESSAGE_INTERFACE; + +public: + + struct CurrentAttribute + { + Attributes::Enumerator attribute; + Attributes::Value value; + }; + + typedef stdvector::fwd CurrentAttributeVector; + +public: + MessageQueueCombatDamage(void); + virtual ~MessageQueueCombatDamage(); + + MessageQueueCombatDamage& operator= (const MessageQueueCombatDamage & source); + MessageQueueCombatDamage(const MessageQueueCombatDamage & source); + + uint16 getActionId(void) const; + void setActionId(uint16 id); + NetworkId getDefender(void) const; + void setDefender(NetworkId defenderId); + const CurrentAttributeVector & getDefenderAttributes(void) const; + void addDefenderAttribute(Attributes::Enumerator attribute, + Attributes::Value value); + +private: + uint16 m_actionId; + NetworkId m_defender; + CurrentAttributeVector *m_defenderAttributes; +}; + + +inline uint16 MessageQueueCombatDamage::getActionId(void) const +{ + return m_actionId; +} // MessageQueueCombatDamage::getActionId + +inline void MessageQueueCombatDamage::setActionId(uint16 id) +{ + m_actionId = id; +} // MessageQueueCombatDamage::setActionId + +inline NetworkId MessageQueueCombatDamage::getDefender(void) const +{ + return m_defender; +} // MessageQueueCombatDamage::getDefender + +inline void MessageQueueCombatDamage::setDefender(NetworkId defenderId) +{ + m_defender = defenderId; +} // MessageQueueCombatDamage::setDefender + +inline const MessageQueueCombatDamage::CurrentAttributeVector & + MessageQueueCombatDamage::getDefenderAttributes(void) const +{ + return *m_defenderAttributes; +} // MessageQueueCombatDamage::getDefenderAttributes + +#endif // INCLUDED_MessageQueueCombatDamage_H diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.cpp new file mode 100644 index 00000000..8f9b1898 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.cpp @@ -0,0 +1,44 @@ +// ====================================================================== +// +// ConsentRequestMessage.cpp +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/ConsentRequestMessage.h" + +// ====================================================================== + +const char * const ConsentRequestMessage::cms_name = "ConsentRequestMessage"; + +// ====================================================================== + +ConsentRequestMessage::ConsentRequestMessage(const ProsePackage& question, int id) +: GameNetworkMessage(cms_name), + m_question(question), + m_id(id) +{ + addVariable(m_question); + addVariable(m_id); +} + +//----------------------------------------------------------------------- + +ConsentRequestMessage::ConsentRequestMessage(Archive::ReadIterator & source) +: GameNetworkMessage(cms_name), + m_question(), + m_id() +{ + addVariable(m_question); + addVariable(m_id); + unpack(source); +} + +// ---------------------------------------------------------------------- + +ConsentRequestMessage::~ConsentRequestMessage() +{ +} + +// ====================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.h new file mode 100644 index 00000000..4de21ebc --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/consent/ConsentRequestMessage.h @@ -0,0 +1,64 @@ +// ====================================================================== +// +// ConsentRequestMessage.h +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_ConsentRequestMessage_H +#define INCLUDED_ConsentRequestMessage_H + +// ====================================================================== + +#include "sharedGame/ProsePackage.h" +#include "sharedGame/ProsePackageArchive.h" + +#include "sharedNetworkMessages/GameNetworkMessage.h" + +//----------------------------------------------------------------------- + +/** + * Sent from: Client + * Sent to: Connection Server + * Action: Requests the state of the player's stomach(s). + */ +class ConsentRequestMessage : public GameNetworkMessage +{ +public: + static const char * const cms_name; + +public: + ConsentRequestMessage (const ProsePackage& question, int id); + explicit ConsentRequestMessage(Archive::ReadIterator & source); + virtual ~ConsentRequestMessage(); + +public: + const ProsePackage& getQuestion() const; + int getId () const; + + private: + ConsentRequestMessage(const ConsentRequestMessage&); + ConsentRequestMessage& operator= (const ConsentRequestMessage&); + +private: + Archive::AutoVariable m_question; + Archive::AutoVariable m_id; +}; + +// ---------------------------------------------------------------------- + +inline const ProsePackage& ConsentRequestMessage::getQuestion() const +{ + return m_question.get(); +} + +// ---------------------------------------------------------------------- + +inline int ConsentRequestMessage::getId() const +{ + return m_id.get(); +} + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h b/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h new file mode 100644 index 00000000..5c94cd82 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h @@ -0,0 +1,24 @@ +// ====================================================================== +// +// FirstSwgSharedNetworkObject.h +// +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_FirstSwgSharedNetworkObject_H +#define INCLUDED_FirstSwgSharedNetworkObject_H + +// ====================================================================== + +#include "sharedFoundation/FirstSharedFoundation.h" +#include "sharedDebug/FirstSharedDebug.h" +#include "sharedMemoryManager/FirstSharedMemoryManager.h" +#include "sharedNetworkMessages/GameNetworkMessage.h" +#include "Archive/AutoDeltaByteStream.h" +#include "sharedFoundation/NetworkId.h" +#include "unicodeArchive/UnicodeArchive.h" +#include "sharedFoundation/NetworkIdArchive.h" +// ====================================================================== + +#endif // INCLUDED_FirstSwgSharedNetworkObject_H diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.cpp new file mode 100644 index 00000000..fb9785c0 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.cpp @@ -0,0 +1,668 @@ +// ====================================================================== +// +// SetupSwgSharedNetworkMessages.cpp +// copyright 1998 Bootprint Entertainment +// copyright 2001 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" + +#include "StringId.h" +#include "localizationArchive/StringIdArchive.h" +#include "sharedFoundation/ExitChain.h" +#include "sharedFoundation/GameControllerMessage.h" +#include "sharedGame/MatchMakingCharacterResult.h" +#include "sharedGame/ProsePackage.h" +#include "sharedGame/ProsePackageArchive.h" +#include "sharedMath/Sphere.h" +#include "sharedMathArchive/SphereArchive.h" +#include "sharedMathArchive/VectorArchive.h" +#include "sharedNetworkMessages/ControllerMessageFactory.h" +#include "sharedNetworkMessages/MessageQueueCommandTimer.h" +#include "sharedNetworkMessages/MessageQueueGenericValueType.h" +#include "sharedUtility/StartingLocationData.h" +#include "sharedUtility/StartingLocationDataArchive.h" +#include "swgSharedNetworkMessages/MessageQueueCombatAction.h" +#include "swgSharedNetworkMessages/MessageQueueCombatDamage.h" +#include "swgSharedUtility/Behaviors.def" +#include "swgSharedUtility/Locomotions.def" +#include "swgSharedUtility/MentalStates.def" + +// ---------------------------------------------------------------------- + +namespace SetupSwgSharedNetworkMessagesNamespace +{ + static bool g_installed = false; + + void packAttributeMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackAttributeMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packMentalStatesMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackMentalStatesMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packMentalStatesTowardsMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > > * const msg = dynamic_cast > > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + MessageQueue::Data* unpackMentalStatesTowardsMessage(Archive::ReadIterator & source) + { + std::pair > v; + Archive::get(source, v); + MessageQueueGenericValueType > > * result = new MessageQueueGenericValueType > >(v); + return result; + } + + void packIntMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackIntMessage(Archive::ReadIterator & source) + { + int v; + Archive::get(source, v); + MessageQueueGenericValueType * result = new MessageQueueGenericValueType(v); + return result; + } + + void packUint32PairMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackUint32PairMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packBoolMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackBoolMessage(Archive::ReadIterator & source) + { + bool v; + Archive::get(source, v); + MessageQueueGenericValueType * result = new MessageQueueGenericValueType(v); + return result; + } + + void packMentalStateTowardClampBehaviorMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > > > * const msg = dynamic_cast > > > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackMentalStateTowardClampBehaviorMessage(Archive::ReadIterator & source) + { + std::pair > > v; + Archive::get(source, v); + MessageQueueGenericValueType > > > * result = new MessageQueueGenericValueType > > >(v); + return result; + } + + + void packMentalStateDecayMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackMentalStateDecayMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packLocomotionMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackLocomotionMessage(Archive::ReadIterator & source) + { + Locomotions::Enumerator v; + Archive::get(source, v); + MessageQueueGenericValueType * result = new MessageQueueGenericValueType(v); + return result; + } + + void packAddToPlayerSpawnQueueMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackAddToPlayerSpawnQueueMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packNetworkIdMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackNetworkIdMessage(Archive::ReadIterator & source) + { + NetworkId v; + Archive::get(source, v); + MessageQueueGenericValueType * result = new MessageQueueGenericValueType(v); + return result; + } + + void packGenericStringIdMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + Archive::put (target, msg->getValue ()); + } + + MessageQueue::Data* unpackGenericStringIdMessage(Archive::ReadIterator & source) + { + StringId v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + void packGenericStringVectorPairMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackGenericStringVectorPairMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packGenericStringIdProsePackageMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair, Unicode::String> Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + Archive::put (target, msg->getValue ()); + } + + MessageQueue::Data* unpackGenericStringIdProsePackageMessage(Archive::ReadIterator & source) + { + typedef std::pair, Unicode::String> Payload; + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + void packNetworkIdUnicodeStringPairMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackNetworkIdUnicodeStringPairMessage(Archive::ReadIterator & source) + { + std::pair v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + void packGenericVectorOfUnicodeStrings(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackGenericVectorOfUnicodeStrings(Archive::ReadIterator & source) + { + std::vector v; + Archive::get(source, v); + MessageQueueGenericValueType > * const result = new MessageQueueGenericValueType >(v); + return result; + } + + //---------------------------------------------------------------------- + + void packCharacterMatchResultVectorMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType * const msg = dynamic_cast *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackCharacterMatchResultVectorMessage(Archive::ReadIterator & source) + { + MatchMakingCharacterResult v; + Archive::get(source, v); + MessageQueueGenericValueType * result = new MessageQueueGenericValueType(v); + return result; + } + + //---------------------------------------------------------------------- + + void packStartingLocationSelectionResult(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair Payload; + + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + Archive::put (target, msg->getValue ()); + +// packGenericMessage (data, target); + } + + MessageQueue::Data* unpackStartingLocationSelectionResult(Archive::ReadIterator & source) + { + typedef std::pair Payload; + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + //---------------------------------------------------------------------- + + void packStartingLocations(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair PayloadData; + typedef std::vector Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + Archive::put (target, msg->getValue ()); + } + + MessageQueue::Data* unpackStartingLocations(Archive::ReadIterator & source) + { + typedef std::pair PayloadData; + typedef std::vector Payload; + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + //---------------------------------------------------------------------- + + void packStringNetworkIdPairVector(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair PayloadData; + typedef std::vector Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + Archive::put (target, msg->getValue ()); + } + + MessageQueue::Data* unpackStringNetworkIdPairVector(Archive::ReadIterator & source) + { + typedef std::pair PayloadData; + typedef std::vector Payload; + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + //---------------------------------------------------------------------- + + void packSphereVectorMessage(const MessageQueue::Data * data, Archive::ByteStream & target) + { + const MessageQueueGenericValueType > * const msg = dynamic_cast > *>(data); + if(msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackSphereVectorMessage(Archive::ReadIterator & source) + { + std::vector v; + Archive::get(source, v); + MessageQueueGenericValueType > * result = new MessageQueueGenericValueType >(v); + return result; + } + + + //---------------------------------------------------------------------- + + void packNetworkIdBoolPair(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + { + Archive::put (target, msg->getValue ()); + } + } + + MessageQueue::Data* unpackNetworkIdBoolPair(Archive::ReadIterator & source) + { + typedef std::pair Payload; + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + } + + //---------------------------------------------------------------------- + + void packNetworkIdNetworkIdVector(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::pair > Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + { + Archive::put(target, msg->getValue().first); + Archive::put(target, msg->getValue().second); + } + } + + MessageQueue::Data* unpackNetworkIdNetworkIdVector(Archive::ReadIterator & source) + { + typedef std::pair > Payload; + Payload payload; + Archive::get(source, payload.first); + Archive::get(source, payload.second); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(payload); + return result; + } + + //---------------------------------------------------------------------- + + void packNetworkIdVector(const MessageQueue::Data * data, Archive::ByteStream & target) + { + typedef std::vector Payload; + const MessageQueueGenericValueType * const msg = safe_cast *>(data); + if (msg) + { + Archive::put(target, msg->getValue()); + } + } + + MessageQueue::Data* unpackNetworkIdVector(Archive::ReadIterator & source) + { + typedef std::vector Payload; + Payload payload; + Archive::get(source, payload); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(payload); + return result; + } + + //---------------------------------------------------------------------- + + void packNothing(const MessageQueue::Data *, Archive::ByteStream &) + { + } + + MessageQueue::Data* unpackNothing(Archive::ReadIterator &) + { + return NULL; + } + + //---------------------------------------------------------------------- + + void packCommandTimerMessage( const MessageQueue::Data * data, Archive::ByteStream &target ) + { + /* + typedef std::pair< byte, std::vector< float > > Payload; + + const MessageQueueGenericValueType< Payload > * const msg = safe_cast< const MessageQueueGenericValueType< Payload > * >( data ); + if ( msg ) + { + Archive::put( target, msg->getValue() ); + } + */ + const MessageQueueCommandTimer * msg = safe_cast< const MessageQueueCommandTimer * >( data ); + + if ( msg ) + { + uint32 flags = msg->getFlags(); + + Archive::put( target, (byte)flags ); + Archive::put( target, msg->getSequenceId() ); + Archive::put( target, msg->getCommandNameCrc() ); + + if ( flags & MessageQueueCommandTimer::toBitValue( MessageQueueCommandTimer::F_cooldown ) ) + { + Archive::put( target, msg->getCooldownGroup() ); + } + if ( flags & MessageQueueCommandTimer::toBitValue( MessageQueueCommandTimer::F_cooldown2 ) ) + { + Archive::put( target, msg->getCooldownGroup2() ); + } + + for ( int i = 0; i < MessageQueueCommandTimer::F_MAX; ++i ) + { + MessageQueueCommandTimer::Flags flag = static_cast< MessageQueueCommandTimer::Flags >( i ); + + if ( flags & MessageQueueCommandTimer::toBitValue( flag ) ) + { + Archive::put( target, msg->getCurrentTime( flag ) ); + Archive::put( target, msg->getMaxTime( flag ) ); + } + } + } + + + } + + MessageQueue::Data* unpackCommandTimerMessage(Archive::ReadIterator & source) + { + /* + typedef std::pair< byte, std::vector< float > > Payload; + + Payload v; + Archive::get(source, v); + MessageQueueGenericValueType * const result = new MessageQueueGenericValueType(v); + return result; + */ + + + byte flags; + Archive::get( source, flags ); + + uint32 sequenceId; + Archive::get( source, sequenceId ); + + uint32 commandNameCrc; + Archive::get( source, commandNameCrc ); + + int cooldownGroup = NULL_COOLDOWN_GROUP; + + if ( flags & MessageQueueCommandTimer::toBitValue( MessageQueueCommandTimer::F_cooldown ) ) + { + Archive::get( source, cooldownGroup ); + } + + int cooldownGroup2 = NULL_COOLDOWN_GROUP; + + if ( flags & MessageQueueCommandTimer::toBitValue( MessageQueueCommandTimer::F_cooldown2 ) ) + { + Archive::get( source, cooldownGroup2 ); + } + + MessageQueueCommandTimer *msg = new MessageQueueCommandTimer( sequenceId, cooldownGroup, cooldownGroup2, commandNameCrc ); + + for ( int i = 0; i < MessageQueueCommandTimer::F_MAX; ++i ) + { + MessageQueueCommandTimer::Flags flag = static_cast< MessageQueueCommandTimer::Flags >( i ); + + if ( flags & MessageQueueCommandTimer::toBitValue( flag ) ) + { + float value; + Archive::get( source, value ); + msg->setCurrentTime( flag, value ); + + Archive::get( source, value ); + msg->setMaxTime( flag, value ); + } + } + + return msg; + } + +} + +using namespace SetupSwgSharedNetworkMessagesNamespace; + +// ---------------------------------------------------------------------- + +void SetupSwgSharedNetworkMessages::install () +{ + DEBUG_FATAL(g_installed, ("SetupSwgSharedNetworkMessages::install - is already installed")); + + MessageQueueCombatAction::install(); + MessageQueueCombatDamage::install(); + + ControllerMessageFactory::registerControllerMessageHandler(CM_setAttribute, packAttributeMessage, unpackAttributeMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMaxAttribute, packAttributeMessage, unpackAttributeMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMentalState, packMentalStatesMessage, unpackMentalStatesMessage ); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMaxMentalState, packMentalStatesMessage, unpackMentalStatesMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMentalStateToward, packMentalStatesTowardsMessage, unpackMentalStatesTowardsMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setCover, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMaxHitPoints, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setCombatAttitude, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setAutoAttack, packBoolMessage, unpackBoolMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setInvulnerable, packBoolMessage, unpackBoolMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMentalStateTowardClampBehavior, packMentalStateTowardClampBehaviorMessage, unpackMentalStateTowardClampBehaviorMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setMentalStateDecay, packMentalStateDecayMessage, unpackMentalStateDecayMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_setLocomotion, packLocomotionMessage, unpackLocomotionMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_addPlayerToSpawnQueue, packAddToPlayerSpawnQueueMessage, unpackAddToPlayerSpawnQueueMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_removePlayerFromSpawnQueue, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_forwardNpcConversationMessage, packGenericStringIdProsePackageMessage, unpackGenericStringIdProsePackageMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_musicFlourish, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_npcConversationSelect, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_craftingSessionEnded, packBoolMessage, unpackBoolMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_biographyRetrieved, packNetworkIdUnicodeStringPairMessage, unpackNetworkIdUnicodeStringPairMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_characterMatchRetrieved, packCharacterMatchResultVectorMessage, unpackCharacterMatchResultVectorMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_startingLocations, packStartingLocations, unpackStartingLocations); + ControllerMessageFactory::registerControllerMessageHandler(CM_startingLocationSelectionResult, packStartingLocationSelectionResult, unpackStartingLocationSelectionResult); + ControllerMessageFactory::registerControllerMessageHandler(CM_disconnect, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_emergencyDismountForRider, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_detachRiderForMount, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_formDataForEdit, packNetworkIdUnicodeStringPairMessage, unpackNetworkIdUnicodeStringPairMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_serverAsteroidDebugData, packSphereVectorMessage, unpackSphereVectorMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_commPlayer, packNetworkIdUnicodeStringPairMessage, unpackNetworkIdUnicodeStringPairMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_clientLookAtTargetComponent, packIntMessage, unpackIntMessage, true); + ControllerMessageFactory::registerControllerMessageHandler(CM_aboutToHyperspace, packGenericStringVectorPairMessage, unpackGenericStringVectorPairMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_playerTransitioningOut, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_playerTransitioningIn, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_addIgnoreIntersect, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_removeIgnoreIntersect, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_spaceTerminalRequest, packNetworkIdMessage, unpackNetworkIdMessage, true); + ControllerMessageFactory::registerControllerMessageHandler(CM_spaceTerminalResponse, packStringNetworkIdPairVector, unpackStringNetworkIdPairVector); + ControllerMessageFactory::registerControllerMessageHandler(CM_hyperspaceOrientShipToPointAndLockPlayerInput, packGenericStringVectorPairMessage, unpackGenericStringVectorPairMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_lockPlayerShipInputOnClient, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_unlockPlayerShipInputOnClient, packNothing, unpackNothing); + ControllerMessageFactory::registerControllerMessageHandler(CM_inviteOtherGroupMembersToLaunchIntoSpace, packNetworkIdMessage, unpackNetworkIdMessage, true); + ControllerMessageFactory::registerControllerMessageHandler(CM_askGroupMemberToLaunchIntoSpace, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_groupMemberInvitationToLaunchIntoSpaceResponse, packNetworkIdBoolPair, unpackNetworkIdBoolPair, true); + ControllerMessageFactory::registerControllerMessageHandler(CM_relayGroupMemberInvitationToLaunchAnswer, packNetworkIdBoolPair, unpackNetworkIdBoolPair); + ControllerMessageFactory::registerControllerMessageHandler(CM_groupOpenLotteryWindowOnClient, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_groupCloseLotteryWindowOnClient, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_groupLotteryWindowHeartbeat, packNetworkIdMessage, unpackNetworkIdMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_groupLotteryWindowCloseResults, packNetworkIdNetworkIdVector, unpackNetworkIdNetworkIdVector, true); + ControllerMessageFactory::registerControllerMessageHandler(CM_commandTimer, packCommandTimerMessage, unpackCommandTimerMessage ); + ControllerMessageFactory::registerControllerMessageHandler(CM_requestActivateQuest, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_requestCompleteQuest, packIntMessage, unpackIntMessage); + ControllerMessageFactory::registerControllerMessageHandler(CM_staticLootItemData, packGenericVectorOfUnicodeStrings, unpackGenericVectorOfUnicodeStrings); + ControllerMessageFactory::registerControllerMessageHandler(CM_showLootBox, packNetworkIdVector, unpackNetworkIdVector); + ControllerMessageFactory::registerControllerMessageHandler(CM_forceActivateQuest, packIntMessage, unpackIntMessage); + + g_installed = true; + ExitChain::add (SetupSwgSharedNetworkMessages::remove, "SetupSwgSharedNetworkMessages"); +} +// ---------------------------------------------------------------------- + +void SetupSwgSharedNetworkMessages::remove ( void ) +{ + DEBUG_FATAL(!g_installed, ("SetupSwgSharedNetworkMessages::remove - not already installed")); + g_installed = false; +} +// ---------------------------------------------------------------------- diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.h b/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.h new file mode 100644 index 00000000..928a7492 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/core/SetupSwgSharedNetworkMessages.h @@ -0,0 +1,30 @@ +// ====================================================================== +// +// SetupSwgSharedNetworkMessages.h +// copyright 2001 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_SetupSwgSharedNetworkMessages_H +#define INCLUDED_SetupSwgSharedNetworkMessages_H + +// ====================================================================== + +class SetupSwgSharedNetworkMessages +{ +public: + + static void install ( void ); + static void remove(); + +private: + + SetupSwgSharedNetworkMessages(); + ~SetupSwgSharedNetworkMessages(); + SetupSwgSharedNetworkMessages(const SetupSwgSharedNetworkMessages&); + SetupSwgSharedNetworkMessages& operator= (const SetupSwgSharedNetworkMessages&); +}; + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.cpp new file mode 100644 index 00000000..f00c9620 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.cpp @@ -0,0 +1,74 @@ +// ====================================================================== +// +// PermissionListCreateMessage.cpp +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/PermissionListCreateMessage.h" + +#include + +// ====================================================================== + +const char * const PermissionListCreateMessage::MessageType = "PermissionListCreateMessage"; + +//---------------------------------------------------------------------- + +PermissionListCreateMessage::PermissionListCreateMessage (const std::vector ¤tMembers, const std::vector &nearbyPeople, Unicode::String listName) +: GameNetworkMessage(MessageType), + m_currentMembers(), + m_nearbyPeople(), + m_listName() +{ + m_currentMembers.set(currentMembers); + m_nearbyPeople.set(nearbyPeople); + m_listName.set(listName); + addVariable(m_currentMembers); + addVariable(m_nearbyPeople); + addVariable(m_listName); +} + +//----------------------------------------------------------------------- + +PermissionListCreateMessage::PermissionListCreateMessage(Archive::ReadIterator & source) +: GameNetworkMessage(MessageType), + m_currentMembers(), + m_nearbyPeople(), + m_listName() +{ + addVariable(m_currentMembers); + addVariable(m_nearbyPeople); + addVariable(m_listName); + unpack(source); +} + +//---------------------------------------------------------------------- + +PermissionListCreateMessage::~PermissionListCreateMessage() +{ +} + +//---------------------------------------------------------------------- + +const std::vector& PermissionListCreateMessage::getCurrentMembers () const +{ + return m_currentMembers.get(); +} + +//---------------------------------------------------------------------- + +const std::vector& PermissionListCreateMessage::getNearbyPeople () const +{ + return m_nearbyPeople.get(); +} + +//---------------------------------------------------------------------- + +const Unicode::String& PermissionListCreateMessage::getListName () const +{ + return m_listName.get(); +} + +// ====================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.h new file mode 100644 index 00000000..66b334d9 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListCreateMessage.h @@ -0,0 +1,46 @@ +// ====================================================================== +// +// PermissionListCreateMessage.h +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_PermissionListCreateMessage_H +#define INCLUDED_PermissionListCreateMessage_H + +//----------------------------------------------------------------------- + +#include "sharedNetworkMessages/GameNetworkMessage.h" + +#include "Unicode.h" +#include "unicodeArchive/UnicodeArchive.h" + +//----------------------------------------------------------------------- + +class PermissionListCreateMessage : public GameNetworkMessage +{ +public: + + static const char * const MessageType; + + PermissionListCreateMessage (const stdvector::fwd ¤tMembers, const stdvector::fwd &nearbyPeople, Unicode::String listName); + explicit PermissionListCreateMessage (Archive::ReadIterator & source); + virtual ~PermissionListCreateMessage (); + const stdvector::fwd& getCurrentMembers () const; + const stdvector::fwd& getNearbyPeople () const; + const Unicode::String& getListName () const; + +private: + //disabled + PermissionListCreateMessage (const PermissionListCreateMessage&); + PermissionListCreateMessage& operator= (const PermissionListCreateMessage&); + +private: + Archive::AutoArray m_currentMembers; + Archive::AutoArray m_nearbyPeople; + Archive::AutoVariable m_listName; +}; + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.cpp new file mode 100644 index 00000000..1940ebac --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.cpp @@ -0,0 +1,68 @@ +// ====================================================================== +// +// PermissionListModifyMessage.cpp +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/PermissionListModifyMessage.h" + +// ====================================================================== + +PermissionListModifyMessage::PermissionListModifyMessage (const Unicode::String& person, const Unicode::String& listName, const Unicode::String& action) +: GameNetworkMessage("PermissionListModifyMessage"), + m_person (), + m_listName(), + m_action () +{ + m_person.set (person); + m_listName.set(listName); + m_action.set (action); + addVariable (m_person); + addVariable (m_listName); + addVariable (m_action); +} + +//----------------------------------------------------------------------- + +PermissionListModifyMessage::PermissionListModifyMessage(Archive::ReadIterator & source) +: GameNetworkMessage("PermissionListModifyMessage"), + m_person (), + m_listName(), + m_action () +{ + addVariable(m_person); + addVariable(m_listName); + addVariable(m_action); + unpack (source); +} + +//---------------------------------------------------------------------- + +PermissionListModifyMessage::~PermissionListModifyMessage() +{ +} + +//---------------------------------------------------------------------- + +const Unicode::String & PermissionListModifyMessage::getPerson () const +{ + return m_person.get(); +} + +//---------------------------------------------------------------------- + +const Unicode::String & PermissionListModifyMessage::getListName () const +{ + return m_listName.get(); +} + +//---------------------------------------------------------------------- + +const Unicode::String & PermissionListModifyMessage::getAction () const +{ + return m_action.get(); +} + +// ===================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.h new file mode 100644 index 00000000..7edca78b --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/permissionList/PermissionListModifyMessage.h @@ -0,0 +1,42 @@ +// ====================================================================== +// +// PermissionListModifyMessage.h +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_PermissionListModifyMessage_H +#define INCLUDED_PermissionListModifyMessage_H + +//----------------------------------------------------------------------- + +#include "sharedNetworkMessages/GameNetworkMessage.h" +#include "Unicode.h" +#include "unicodeArchive/UnicodeArchive.h" + +//----------------------------------------------------------------------- + +class PermissionListModifyMessage : public GameNetworkMessage +{ +public: + PermissionListModifyMessage (const Unicode::String& person, const Unicode::String& listName, const Unicode::String& action); + explicit PermissionListModifyMessage (Archive::ReadIterator & source); + virtual ~PermissionListModifyMessage (); + const Unicode::String & getPerson () const; + const Unicode::String & getListName () const; + const Unicode::String & getAction () const; + +private: + //disabled + PermissionListModifyMessage (const PermissionListModifyMessage&); + PermissionListModifyMessage& operator= (const PermissionListModifyMessage&); + +private: + Archive::AutoVariable m_person; + Archive::AutoVariable m_listName; + Archive::AutoVariable m_action; +}; + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.cpp new file mode 100644 index 00000000..1488ed7d --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.cpp @@ -0,0 +1,86 @@ +// ====================================================================== +// +// ResourceListForSurveyMessage.cpp +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/ResourceListForSurveyMessage.h" + +// ====================================================================== + +const char * const ResourceListForSurveyMessage::MessageType = "ResourceListForSurveyMessage"; + +//---------------------------------------------------------------------- + +ResourceListForSurveyMessage::ResourceListForSurveyMessage (const stdvector::fwd &data, const std::string& type, const NetworkId& surveyToolId) : + GameNetworkMessage(MessageType), + m_data(), + m_surveyType(), + m_surveyToolId() +{ + m_data.set(data); + m_surveyType.set(type); + m_surveyToolId.set(surveyToolId); + addVariable(m_data); + addVariable(m_surveyType); + addVariable(m_surveyToolId); +} + +//----------------------------------------------------------------------- + +ResourceListForSurveyMessage::ResourceListForSurveyMessage(Archive::ReadIterator & source) : + GameNetworkMessage(MessageType), + m_data() +{ + addVariable(m_data); + addVariable(m_surveyType); + addVariable(m_surveyToolId); + unpack(source); +} + +//---------------------------------------------------------------------- + +ResourceListForSurveyMessage::~ResourceListForSurveyMessage() +{ +} + +//---------------------------------------------------------------------- + +const std::vector &ResourceListForSurveyMessage::getData() const +{ + return m_data.get(); +} + +//---------------------------------------------------------------------- + +const std::string& ResourceListForSurveyMessage::getType() const +{ + return m_surveyType.get(); +} + +//---------------------------------------------------------------------- + +const NetworkId &ResourceListForSurveyMessage::getSurveyToolId() const +{ + return m_surveyToolId.get(); +} + +// ===================================================================== + +void Archive::put(ByteStream &target, const ResourceList_DataItem &data) +{ + put(target,data.resourceName); + put(target,data.resourceId); + put(target,data.parentClassName); +} + +void Archive::get(ReadIterator &source, ResourceList_DataItem &data) +{ + get(source,data.resourceName); + get(source,data.resourceId); + get(source,data.parentClassName); +} + +// ====================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.h new file mode 100644 index 00000000..cb0234d6 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/ResourceListForSurveyMessage.h @@ -0,0 +1,65 @@ +// ====================================================================== +// +// ResourceListForSurveyMessage.h +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_ResourceListForSurveyMessage_H +#define INCLUDED_ResourceListForSurveyMessage_H + +//----------------------------------------------------------------------- + +#include "sharedNetworkMessages/GameNetworkMessage.h" +#include "Unicode.h" +#include "sharedFoundation/NetworkIdArchive.h" +#include "unicodeArchive/UnicodeArchive.h" + +//----------------------------------------------------------------------- + +struct ResourceList_DataItem +{ + std::string resourceName; + NetworkId resourceId; + std::string parentClassName; +}; + +//----------------------------------------------------------------------- + +class ResourceListForSurveyMessage : public GameNetworkMessage +{ +public: + + static const char * const MessageType; + + typedef ResourceList_DataItem DataItem; + +public: + ResourceListForSurveyMessage (const stdvector::fwd &data, const std::string& type, const NetworkId& surveyToolId); + explicit ResourceListForSurveyMessage (Archive::ReadIterator & source); + virtual ~ResourceListForSurveyMessage (); + const std::vector &getData () const; + const std::string& getType () const; + const NetworkId &getSurveyToolId () const; + +private: + Archive::AutoArray m_data; + Archive::AutoVariable m_surveyType; + Archive::AutoVariable m_surveyToolId; + +private: + ResourceListForSurveyMessage (const ResourceListForSurveyMessage&); + ResourceListForSurveyMessage& operator= (const ResourceListForSurveyMessage&); +}; + +// ====================================================================== + +namespace Archive +{ + void put(ByteStream &target, const ResourceList_DataItem &data); + void get(ReadIterator &source, ResourceList_DataItem &data); +} + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.cpp b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.cpp new file mode 100644 index 00000000..980a4c24 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.cpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// SurveyMessage.cpp +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" +#include "swgSharedNetworkMessages/SurveyMessage.h" + +#include "sharedMathArchive/VectorArchive.h" + +// ====================================================================== + +const char * const SurveyMessage::MessageType = "SurveyMessage"; + +//---------------------------------------------------------------------- + +SurveyMessage::SurveyMessage (const stdvector::fwd &data) : + GameNetworkMessage(MessageType), + m_data() +{ + m_data.set(data); + addVariable(m_data); +} + +//----------------------------------------------------------------------- + +SurveyMessage::SurveyMessage(Archive::ReadIterator & source) : + GameNetworkMessage(MessageType), + m_data() +{ + addVariable(m_data); + unpack(source); +} + +//---------------------------------------------------------------------- + +SurveyMessage::~SurveyMessage() +{ +} + +//---------------------------------------------------------------------- + +const std::vector& SurveyMessage::getData() const +{ + return m_data.get(); +} + +// ====================================================================== + +void Archive::put(ByteStream &target, const Survey_DataItem &data) +{ + put(target,data.m_location); + put(target,data.m_efficiency); +} + +void Archive::get(ReadIterator &source, Survey_DataItem &data) +{ + get(source,data.m_location); + get(source,data.m_efficiency); +} + +// ====================================================================== diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.h b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.h new file mode 100644 index 00000000..f01a3bb6 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/survey/SurveyMessage.h @@ -0,0 +1,59 @@ +// ====================================================================== +// +// SurveyMessage.h +// copyright (c) 2002 Sony Online Entertainment +// +// ====================================================================== + +#ifndef INCLUDED_SurveyMessage_H +#define INCLUDED_SurveyMessage_H + +//----------------------------------------------------------------------- + +#include "sharedMath/Vector.h" +#include "sharedNetworkMessages/GameNetworkMessage.h" + +//----------------------------------------------------------------------- + +struct Survey_DataItem +{ + Vector m_location; + float m_efficiency; +}; + +//----------------------------------------------------------------------- + +class SurveyMessage : public GameNetworkMessage +{ +public: + + static const char * const MessageType; + + typedef Survey_DataItem DataItem; + +public: + SurveyMessage (const stdvector::fwd &data); + explicit SurveyMessage (Archive::ReadIterator & source); + virtual ~SurveyMessage (); + const stdvector::fwd& getData() const; + +private: + + Archive::AutoArray m_data; + +private: + SurveyMessage (const SurveyMessage&); + SurveyMessage& operator= (const SurveyMessage&); +}; + +// ====================================================================== + +namespace Archive +{ + void put(ByteStream &target, const Survey_DataItem &data); + void get(ReadIterator &source, Survey_DataItem &data); +} + +// ====================================================================== + +#endif diff --git a/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp b/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp new file mode 100644 index 00000000..c29a3b43 --- /dev/null +++ b/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp @@ -0,0 +1,9 @@ +//======================================================================== +// +// FirstSwgSharedNetworkMessages.cpp +// +// copyright 2001 Sony Online Entertainment +// +//======================================================================== + +#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h"