[General] Include ScriptLocalFloat as part of ClientScriptLocal

pull/558/head
David Cernat 5 years ago
parent b97fa7553c
commit abd18745df

@ -122,8 +122,8 @@ set(PROCESSORS_OBJECT
processors/object/ProcessorObjectRotate.hpp processors/object/ProcessorObjectScale.hpp
processors/object/ProcessorObjectSpawn.hpp processors/object/ProcessorObjectState.hpp
processors/object/ProcessorObjectTrap.hpp processors/object/ProcessorClientScriptLocal.hpp
processors/object/ProcessorScriptLocalFloat.hpp processors/object/ProcessorScriptMemberShort.hpp
processors/object/ProcessorScriptMemberFloat.hpp processors/object/ProcessorVideoPlay.hpp
processors/object/ProcessorScriptMemberShort.hpp processors/object/ProcessorScriptMemberFloat.hpp
processors/object/ProcessorVideoPlay.hpp
)
source_group(tes3mp-server\\processors\\object FILES ${PROCESSORS_OBJECT})

@ -326,12 +326,12 @@ const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept
const char *ObjectFunctions::GetScriptVariableName(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).varName.c_str();
return readObjectList->baseObjects.at(index).clientVariable.id.c_str();
}
int ObjectFunctions::GetScriptVariableShortValue(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).shortVal;
return readObjectList->baseObjects.at(index).clientVariable.intValue;
}
unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept
@ -549,12 +549,12 @@ void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexc
void ObjectFunctions::SetScriptVariableName(const char* varName) noexcept
{
tempObject.varName = varName;
tempObject.clientVariable.id = varName;
}
void ObjectFunctions::SetScriptVariableShortValue(int shortVal) noexcept
{
tempObject.shortVal = shortVal;
tempObject.clientVariable.intValue = shortVal;
}
void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept

@ -72,7 +72,6 @@
#include "object/ProcessorObjectState.hpp"
#include "object/ProcessorObjectTrap.hpp"
#include "object/ProcessorClientScriptLocal.hpp"
#include "object/ProcessorScriptLocalFloat.hpp"
#include "object/ProcessorScriptMemberShort.hpp"
#include "object/ProcessorScriptMemberFloat.hpp"
#include "object/ProcessorVideoPlay.hpp"
@ -155,7 +154,6 @@ void ProcessorInitializer()
ObjectProcessor::AddProcessor(new ProcessorObjectState());
ObjectProcessor::AddProcessor(new ProcessorObjectTrap());
ObjectProcessor::AddProcessor(new ProcessorClientScriptLocal());
ObjectProcessor::AddProcessor(new ProcessorScriptLocalFloat());
ObjectProcessor::AddProcessor(new ProcessorScriptMemberShort());
ObjectProcessor::AddProcessor(new ProcessorScriptMemberFloat());
ObjectProcessor::AddProcessor(new ProcessorVideoPlay());

@ -1,18 +0,0 @@
#ifndef OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP
#define OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP
#include "../ObjectProcessor.hpp"
namespace mwmp
{
class ProcessorScriptLocalFloat : public ObjectProcessor
{
public:
ProcessorScriptLocalFloat()
{
BPP_INIT(ID_SCRIPT_LOCAL_FLOAT)
}
};
}
#endif //OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP

@ -133,7 +133,7 @@ add_openmw_dir (mwmp/processors/object BaseObjectProcessor
ProcessorObjectActivate ProcessorObjectAnimPlay ProcessorObjectAttach ProcessorObjectDelete ProcessorObjectHit
ProcessorObjectLock ProcessorObjectMove ProcessorObjectPlace ProcessorObjectRestock ProcessorObjectRotate
ProcessorObjectScale ProcessorObjectSound ProcessorObjectSpawn ProcessorObjectState ProcessorObjectTrap
ProcessorClientScriptLocal ProcessorScriptLocalFloat ProcessorScriptMemberShort ProcessorScriptMemberFloat
ProcessorClientScriptLocal ProcessorScriptMemberShort ProcessorScriptMemberFloat
)
add_openmw_dir (mwmp/processors/worldstate ProcessorCellReset ProcessorClientScriptGlobal ProcessorClientScriptSettings

@ -862,31 +862,26 @@ void ObjectList::runConsoleCommands(MWWorld::CellStore* cellStore)
}
}
void ObjectList::setLocalShorts(MWWorld::CellStore* cellStore)
void ObjectList::setClientLocals(MWWorld::CellStore* cellStore)
{
for (const auto &baseObject : baseObjects)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s %i-%i, index: %i, shortVal: %i", baseObject.refId.c_str(),
baseObject.refNum, baseObject.mpNum, baseObject.index, baseObject.shortVal);
std::string valueAsString;
std::string variableType;
MWWorld::Ptr ptrFound = cellStore->searchExact(baseObject.refNum, baseObject.mpNum);
if (ptrFound)
if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::INTEGER)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- Found %s %i-%i", ptrFound.getCellRef().getRefId().c_str(),
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
ptrFound.getRefData().getLocals().mShorts.at(baseObject.index) = baseObject.shortVal;
valueAsString = std::to_string(baseObject.clientVariable.intValue);
variableType = "integer";
}
else if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::FLOAT)
{
valueAsString = std::to_string(baseObject.clientVariable.floatValue);
variableType = "float";
}
}
}
void ObjectList::setLocalFloats(MWWorld::CellStore* cellStore)
{
for (const auto &baseObject : baseObjects)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s %i-%i, index: %i, floatVal: %f", baseObject.refId.c_str(),
baseObject.refNum, baseObject.mpNum, baseObject.index, baseObject.floatVal);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s %i-%i, index: %i, type %s, value: %s", baseObject.refId.c_str(),
baseObject.refNum, baseObject.mpNum, baseObject.index, variableType.c_str(), valueAsString.c_str());
MWWorld::Ptr ptrFound = cellStore->searchExact(baseObject.refNum, baseObject.mpNum);
@ -895,7 +890,10 @@ void ObjectList::setLocalFloats(MWWorld::CellStore* cellStore)
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- Found %s %i-%i", ptrFound.getCellRef().getRefId().c_str(),
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
ptrFound.getRefData().getLocals().mFloats.at(baseObject.index) = baseObject.floatVal;
if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::INTEGER)
ptrFound.getRefData().getLocals().mShorts.at(baseObject.index) = baseObject.clientVariable.intValue;
else if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::FLOAT)
ptrFound.getRefData().getLocals().mFloats.at(baseObject.index) = baseObject.clientVariable.floatValue;
}
}
}
@ -1222,7 +1220,7 @@ void ObjectList::addConsoleCommandObject(const MWWorld::Ptr& ptr)
addBaseObject(baseObject);
}
void ObjectList::addClientScriptLocal(const MWWorld::Ptr& ptr, int index, int shortVal)
void ObjectList::addClientScriptLocal(const MWWorld::Ptr& ptr, int index, int value)
{
cell = *ptr.getCell()->getCell();
@ -1230,12 +1228,13 @@ void ObjectList::addClientScriptLocal(const MWWorld::Ptr& ptr, int index, int sh
baseObject.refId = ptr.getCellRef().getRefId();
baseObject.refNum = ptr.getCellRef().getRefNum().mIndex;
baseObject.mpNum = ptr.getCellRef().getMpNum();
baseObject.index = index;
baseObject.shortVal = shortVal;
baseObject.clientVariable.index = index;
baseObject.clientVariable.variableType = mwmp::VARIABLE_TYPE::INTEGER;
baseObject.clientVariable.intValue = value;
addBaseObject(baseObject);
}
void ObjectList::addScriptLocalFloat(const MWWorld::Ptr& ptr, int index, float floatVal)
void ObjectList::addClientScriptLocal(const MWWorld::Ptr& ptr, int index, float value)
{
cell = *ptr.getCell()->getCell();
@ -1243,8 +1242,9 @@ void ObjectList::addScriptLocalFloat(const MWWorld::Ptr& ptr, int index, float f
baseObject.refId = ptr.getCellRef().getRefId();
baseObject.refNum = ptr.getCellRef().getRefNum().mIndex;
baseObject.mpNum = ptr.getCellRef().getMpNum();
baseObject.index = index;
baseObject.floatVal = floatVal;
baseObject.clientVariable.index = index;
baseObject.clientVariable.variableType = mwmp::VARIABLE_TYPE::FLOAT;
baseObject.clientVariable.floatValue = value;
addBaseObject(baseObject);
}
@ -1368,23 +1368,27 @@ void ObjectList::sendClientScriptLocal()
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_CLIENT_SCRIPT_LOCAL about %s", cell.getDescription().c_str());
for (const auto &baseObject : baseObjects)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s-%i, index: %i, shortVal: %i", baseObject.refId.c_str(),
baseObject.refNum, baseObject.index, baseObject.shortVal);
mwmp::Main::get().getNetworking()->getObjectPacket(ID_CLIENT_SCRIPT_LOCAL)->setObjectList(this);
mwmp::Main::get().getNetworking()->getObjectPacket(ID_CLIENT_SCRIPT_LOCAL)->Send();
}
{
std::string valueAsString;
std::string variableType;
void ObjectList::sendScriptLocalFloat()
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT about %s", cell.getDescription().c_str());
if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::INTEGER)
{
valueAsString = std::to_string(baseObject.clientVariable.intValue);
variableType = "integer";
}
else if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::FLOAT)
{
valueAsString = std::to_string(baseObject.clientVariable.floatValue);
variableType = "float";
}
for (const auto &baseObject : baseObjects)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s-%i, index: %i, floatVal: %f", baseObject.refId.c_str(),
baseObject.refNum, baseObject.index, baseObject.floatVal);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s %i-%i, index: %i, type %s, value: %s", baseObject.refId.c_str(),
baseObject.refNum, baseObject.mpNum, baseObject.clientVariable.index, variableType.c_str(), valueAsString.c_str());
}
mwmp::Main::get().getNetworking()->getObjectPacket(ID_SCRIPT_LOCAL_FLOAT)->setObjectList(this);
mwmp::Main::get().getNetworking()->getObjectPacket(ID_SCRIPT_LOCAL_FLOAT)->Send();
mwmp::Main::get().getNetworking()->getObjectPacket(ID_CLIENT_SCRIPT_LOCAL)->setObjectList(this);
mwmp::Main::get().getNetworking()->getObjectPacket(ID_CLIENT_SCRIPT_LOCAL)->Send();
}
void ObjectList::sendScriptMemberShort()

@ -41,8 +41,7 @@ namespace mwmp
void setDoorDestinations(MWWorld::CellStore* cellStore);
void runConsoleCommands(MWWorld::CellStore* cellStore);
void setLocalShorts(MWWorld::CellStore* cellStore);
void setLocalFloats(MWWorld::CellStore* cellStore);
void setClientLocals(MWWorld::CellStore* cellStore);
void setMemberShorts();
void playMusic();
@ -68,8 +67,8 @@ namespace mwmp
void addMusicPlay(std::string filename);
void addVideoPlay(std::string filename, bool allowSkipping);
void addConsoleCommandObject(const MWWorld::Ptr& ptr);
void addClientScriptLocal(const MWWorld::Ptr& ptr, int index, int shortVal);
void addScriptLocalFloat(const MWWorld::Ptr& ptr, int index, float floatVal);
void addClientScriptLocal(const MWWorld::Ptr& ptr, int index, int value);
void addClientScriptLocal(const MWWorld::Ptr& ptr, int index, float value);
void addScriptMemberShort(std::string refId, int index, int shortVal);
void sendObjectActivate();
@ -87,7 +86,6 @@ namespace mwmp
void sendMusicPlay();
void sendVideoPlay();
void sendClientScriptLocal();
void sendScriptLocalFloat();
void sendScriptMemberShort();
void sendContainer();
void sendConsoleCommand();

@ -68,7 +68,6 @@
#include "object/ProcessorObjectState.hpp"
#include "object/ProcessorObjectTrap.hpp"
#include "object/ProcessorClientScriptLocal.hpp"
#include "object/ProcessorScriptLocalFloat.hpp"
#include "object/ProcessorScriptMemberShort.hpp"
#include "object/ProcessorScriptMemberFloat.hpp"
#include "object/ProcessorVideoPlay.hpp"
@ -171,7 +170,6 @@ void ProcessorInitializer()
ObjectProcessor::AddProcessor(new ProcessorObjectState());
ObjectProcessor::AddProcessor(new ProcessorObjectTrap());
ObjectProcessor::AddProcessor(new ProcessorClientScriptLocal());
ObjectProcessor::AddProcessor(new ProcessorScriptLocalFloat());
ObjectProcessor::AddProcessor(new ProcessorScriptMemberShort());
ObjectProcessor::AddProcessor(new ProcessorScriptMemberFloat());
ObjectProcessor::AddProcessor(new ProcessorVideoPlay());

@ -17,7 +17,7 @@ namespace mwmp
{
BaseObjectProcessor::Do(packet, objectList);
objectList.setLocalShorts(ptrCellStore);
objectList.setClientLocals(ptrCellStore);
}
};
}

@ -1,25 +0,0 @@
#ifndef OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP
#define OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP
#include "BaseObjectProcessor.hpp"
namespace mwmp
{
class ProcessorScriptLocalFloat final: public BaseObjectProcessor
{
public:
ProcessorScriptLocalFloat()
{
BPP_INIT(ID_SCRIPT_LOCAL_FLOAT)
}
virtual void Do(ObjectPacket &packet, ObjectList &objectList)
{
BaseObjectProcessor::Do(packet, objectList);
objectList.setLocalFloats(ptrCellStore);
}
};
}
#endif //OPENMW_PROCESSORSCRIPTLOCALFLOAT_HPP

@ -267,8 +267,8 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
objectList->addScriptLocalFloat(mReference, index, value);
objectList->sendScriptLocalFloat();
objectList->addClientScriptLocal(mReference, index, value);
objectList->sendClientScriptLocal();
}
/*
End of tes3mp addition

@ -207,8 +207,7 @@ add_component_dir (openmw-mp/Packets/Object
PacketConsoleCommand PacketContainer PacketObjectActivate PacketObjectAnimPlay PacketObjectAttach
PacketObjectDelete PacketObjectHit PacketObjectLock PacketObjectMove PacketObjectPlace PacketObjectRestock
PacketObjectRotate PacketObjectScale PacketObjectSound PacketObjectSpawn PacketObjectState PacketObjectTrap
PacketMusicPlay PacketVideoPlay PacketClientScriptLocal PacketScriptLocalFloat PacketScriptMemberShort
PacketScriptMemberFloat
PacketMusicPlay PacketVideoPlay PacketClientScriptLocal PacketScriptMemberShort PacketScriptMemberFloat
)
add_component_dir (openmw-mp/Packets/Worldstate

@ -54,10 +54,11 @@ namespace mwmp
std::string animGroup;
int animMode;
ClientVariable clientVariable;
int index;
int shortVal;
float floatVal;
std::string varName;
bool isDisarmed;
bool droppedByPlayer;

@ -29,6 +29,7 @@ namespace mwmp
struct ClientVariable
{
std::string id;
int index;
char variableType;

@ -22,7 +22,6 @@
#include "../Packets/Object/PacketConsoleCommand.hpp"
#include "../Packets/Object/PacketClientScriptLocal.hpp"
#include "../Packets/Object/PacketScriptLocalFloat.hpp"
#include "../Packets/Object/PacketScriptMemberShort.hpp"
#include "../Packets/Object/PacketScriptMemberFloat.hpp"
@ -62,7 +61,6 @@ mwmp::ObjectPacketController::ObjectPacketController(RakNet::RakPeerInterface *p
AddPacket<PacketConsoleCommand>(&packets, peer);
AddPacket<PacketClientScriptLocal>(&packets, peer);
AddPacket<PacketScriptLocalFloat>(&packets, peer);
AddPacket<PacketScriptMemberShort>(&packets, peer);
AddPacket<PacketScriptMemberFloat>(&packets, peer);
}

@ -12,6 +12,11 @@ PacketClientScriptLocal::PacketClientScriptLocal(RakNet::RakPeerInterface *peer)
void PacketClientScriptLocal::Object(BaseObject &baseObject, bool send)
{
ObjectPacket::Object(baseObject, send);
RW(baseObject.index, send);
RW(baseObject.shortVal, send);
RW(baseObject.clientVariable.index, send);
RW(baseObject.clientVariable.variableType, send);
if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::INTEGER)
RW(baseObject.clientVariable.intValue, send);
else if (baseObject.clientVariable.variableType == mwmp::VARIABLE_TYPE::FLOAT)
RW(baseObject.clientVariable.floatValue, send);
}

@ -1,17 +0,0 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketScriptLocalFloat.hpp"
using namespace mwmp;
PacketScriptLocalFloat::PacketScriptLocalFloat(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
{
packetID = ID_SCRIPT_LOCAL_FLOAT;
hasCellData = true;
}
void PacketScriptLocalFloat::Object(BaseObject &baseObject, bool send)
{
ObjectPacket::Object(baseObject, send);
RW(baseObject.index, send);
RW(baseObject.floatVal, send);
}

@ -1,17 +0,0 @@
#ifndef OPENMW_PACKETSCRIPTLOCALFLOAT_HPP
#define OPENMW_PACKETSCRIPTLOCALFLOAT_HPP
#include <components/openmw-mp/Packets/Object/ObjectPacket.hpp>
namespace mwmp
{
class PacketScriptLocalFloat : public ObjectPacket
{
public:
PacketScriptLocalFloat(RakNet::RakPeerInterface *peer);
virtual void Object(BaseObject &baseObject, bool send);
};
}
#endif //OPENMW_PACKETSCRIPTLOCALFLOAT_HPP
Loading…
Cancel
Save