Merge pull request #372 from TES3MP/0.6.2 while resolving conflicts

Conflicts:
	apps/openmw-mp/Script/Functions/Actors.cpp
	apps/openmw-mp/Script/Functions/Actors.hpp
	apps/openmw-mp/Script/Functions/Items.cpp
	apps/openmw-mp/Script/Functions/Items.hpp
	apps/openmw-mp/Script/Functions/World.cpp
	apps/openmw-mp/Script/Functions/World.hpp
	apps/openmw/mwmp/WorldEvent.cpp
	components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp
	components/openmw-mp/Version.hpp
sol2-server-rewrite
David Cernat 7 years ago
commit a037193e79

@ -97,7 +97,7 @@ int Inventory::getChangesSize() const
return netActor->getNetCreature()->inventoryChanges.items.size(); return netActor->getNetCreature()->inventoryChanges.items.size();
} }
void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, int enchantmentCharge) void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge)
{ {
netActor->getNetCreature()->equipmentItems[slot].refId = refId; netActor->getNetCreature()->equipmentItems[slot].refId = refId;
netActor->getNetCreature()->equipmentItems[slot].count = count; netActor->getNetCreature()->equipmentItems[slot].count = count;
@ -119,7 +119,7 @@ void Inventory::unequipItem( unsigned short slot)
} }
void Inventory::addItem(const std::string &refId, unsigned int count, int charge, int enchantmentCharge) void Inventory::addItem(const std::string &refId, unsigned int count, int charge, double enchantmentCharge)
{ {
if (inventoryChanged == mwmp::InventoryChanges::Type::Remove) if (inventoryChanged == mwmp::InventoryChanges::Type::Remove)
return; return;
@ -165,13 +165,13 @@ bool Inventory::hasItemEquipped(const std::string &refId) const
return false; return false;
} }
std::tuple<std::string, int, int, int> Inventory::getEquipmentItem(unsigned short slot) const std::tuple<std::string, int, int, double> Inventory::getEquipmentItem(unsigned short slot) const
{ {
const auto &item = netActor->getNetCreature()->equipmentItems[slot]; const auto &item = netActor->getNetCreature()->equipmentItems[slot];
return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge);
} }
std::tuple<std::string, int, int, int> Inventory::getInventoryItem(unsigned int slot) const std::tuple<std::string, int, int, double> Inventory::getInventoryItem(unsigned int slot) const
{ {
const auto &item = netActor->getNetCreature()->inventoryChanges.items.at(slot); const auto &item = netActor->getNetCreature()->inventoryChanges.items.at(slot);
return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge);

@ -25,7 +25,7 @@ public:
//inventory //inventory
int getChangesSize() const; int getChangesSize() const;
void addItem(const std::string& refId, unsigned int count, int charge, int enchantmentCharge); void addItem(const std::string& refId, unsigned int count, int charge, double enchantmentCharge);
void removeItem(const std::string& refId, unsigned short count); void removeItem(const std::string& refId, unsigned short count);
/** /**
@ -33,11 +33,11 @@ public:
* @param slot * @param slot
* @return refid, count, charge, enchantmentCharge * @return refid, count, charge, enchantmentCharge
*/ */
std::tuple<std::string,int, int, int> getInventoryItem(unsigned int slot) const; std::tuple<std::string,int, int, double> getInventoryItem(unsigned int slot) const;
// equipment // equipment
void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, int enchantmentCharge); void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge);
void unequipItem(unsigned short slot); void unequipItem(unsigned short slot);
bool hasItemEquipped(const std::string& refId) const; bool hasItemEquipped(const std::string& refId) const;
@ -47,7 +47,7 @@ public:
* @param slot * @param slot
* @return refid, count, charge, enchantmentCharge * @return refid, count, charge, enchantmentCharge
*/ */
std::tuple<std::string,int, int, int> getEquipmentItem(unsigned short slot) const; std::tuple<std::string,int, int, double> getEquipmentItem(unsigned short slot) const;
private: private:

@ -147,12 +147,12 @@ void Object::setCharge(int charge)
} }
int Object::getEnchantmentCharge() const double Object::getEnchantmentCharge() const
{ {
return object.enchantmentCharge; return object.enchantmentCharge;
} }
void Object::setEnchantmentCharge(int enchantmentCharge) void Object::setEnchantmentCharge(double enchantmentCharge)
{ {
changedObjectPlace = true; changedObjectPlace = true;
object.enchantmentCharge = enchantmentCharge; object.enchantmentCharge = enchantmentCharge;
@ -245,13 +245,13 @@ Container::Container()
} }
tuple<string, int, int, int> Container::getItem(int i) const tuple<string, int, int, double> Container::getItem(int i) const
{ {
auto &item = object.containerItems.at(i); auto &item = object.containerItems.at(i);
return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge);
} }
void Container::setItem(int i, const string &refId, int count, int charge, int enchantmentCharge) void Container::setItem(int i, const string &refId, int count, int charge, double enchantmentCharge)
{ {
auto &item = object.containerItems.at(i); auto &item = object.containerItems.at(i);
item.refId = refId; item.refId = refId;
@ -261,7 +261,7 @@ void Container::setItem(int i, const string &refId, int count, int charge, int e
changed = true; changed = true;
} }
void Container::addItem(const string &refId, int count, int charge, int enchantmentCharge) void Container::addItem(const string &refId, int count, int charge, double enchantmentCharge)
{ {
mwmp::ContainerItem item; mwmp::ContainerItem item;
item.refId = refId; item.refId = refId;

@ -66,8 +66,8 @@ public:
int getCharge() const; int getCharge() const;
void setCharge(int charge); void setCharge(int charge);
int getEnchantmentCharge() const; double getEnchantmentCharge() const;
void setEnchantmentCharge(int enchantmentCharge); void setEnchantmentCharge(double enchantmentCharge);
int getGoldValue() const; int getGoldValue() const;
void setGoldValue(int gold); void setGoldValue(int gold);
@ -98,10 +98,10 @@ public:
public: public:
Container(); Container();
std::tuple<std::string, int, int, int> getItem(int i) const; std::tuple<std::string, int, int, double> getItem(int i) const;
void addItem(const std::string &refId, int count, int charge, int enchantmentCharge); void addItem(const std::string &refId, int count, int charge, double enchantmentCharge);
void setItem(int i, const std::string &refId, int count, int charge, int enchantmentCharge); void setItem(int i, const std::string &refId, int count, int charge, double enchantmentCharge);
int getActionCount(int i) const; int getActionCount(int i) const;
size_t size() const; size_t size() const;

@ -97,7 +97,7 @@ namespace MWGui
Include a messagebox notifying players that player-made potions are not synced yet Include a messagebox notifying players that player-made potions are not synced yet
*/ */
MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for other players."); MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for the server or other players.");
/* /*
End of tes3mp addition End of tes3mp addition
*/ */

@ -127,6 +127,7 @@ namespace MWGui
containerItem.refId =itemPtr.getCellRef().getRefId(); containerItem.refId =itemPtr.getCellRef().getRefId();
containerItem.count = itemPtr.getRefData().getCount(); containerItem.count = itemPtr.getRefData().getCount();
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge();
containerItem.actionCount = count; containerItem.actionCount = count;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
@ -176,6 +177,7 @@ namespace MWGui
containerItem.count = mDragAndDrop->mDraggedCount; containerItem.count = mDragAndDrop->mDraggedCount;
containerItem.charge = itemPtr.getCellRef().getCharge(); containerItem.charge = itemPtr.getCellRef().getCharge();
containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge();
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),

@ -302,8 +302,8 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector
} }
case ID_INVALID_PASSWORD: case ID_INVALID_PASSWORD:
{ {
errmsg = "Connection failed.\n" errmsg = "Version mismatch!\nYour client is on version " TES3MP_VERSION "\n"
"The client or server is outdated."; "Please make sure the server is on the same version.";
queue = false; queue = false;
break; break;
} }

@ -75,6 +75,9 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
for (const auto &containerItem : worldObject.containerItems) for (const auto &containerItem : worldObject.containerItems)
{ {
if (containerItem.refId.find("$dynamic") != string::npos)
continue;
if (action == BaseEvent::Action::Add || action == BaseEvent::Action::Set) if (action == BaseEvent::Action::Add || action == BaseEvent::Action::Set)
{ {
// Create a ManualRef to be able to set item charge // Create a ManualRef to be able to set item charge
@ -152,6 +155,10 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, count: %i, charge: %i, enchantmentCharge: %i", worldObject.refId.c_str(), LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, count: %i, charge: %i, enchantmentCharge: %i", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum, worldObject.count, worldObject.charge, worldObject.enchantmentCharge); worldObject.refNumIndex, worldObject.mpNum, worldObject.count, worldObject.charge, worldObject.enchantmentCharge);
// Ignore generic dynamic refIds because they could be anything on other clients
if (worldObject.refId.find("$dynamic") != string::npos)
continue;
MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum);
// Only create this object if it doesn't already exist // Only create this object if it doesn't already exist
@ -187,6 +194,10 @@ void WorldEvent::spawnObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum); worldObject.refNumIndex, worldObject.mpNum);
// Ignore generic dynamic refIds because they could be anything on other clients
if (worldObject.refId.find("$dynamic") != string::npos)
continue;
MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum);
// Only create this object if it doesn't already exist // Only create this object if it doesn't already exist
@ -591,6 +602,12 @@ void WorldEvent::playVideo()
void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr) void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr)
{ {
if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos)
{
MWBase::Environment::get().getWindowManager()->messageBox("You're trying to place a custom item, but those are not synchronized in multiplayer yet.");
return;
}
cell = *ptr.getCell()->getCell(); cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
@ -616,6 +633,12 @@ void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr)
void WorldEvent::addObjectSpawn(const MWWorld::Ptr& ptr) void WorldEvent::addObjectSpawn(const MWWorld::Ptr& ptr)
{ {
if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos)
{
MWBase::Environment::get().getWindowManager()->messageBox("You're trying to spawn a custom object, but those are not synchronized in multiplayer yet.");
return;
}
cell = *ptr.getCell()->getCell(); cell = *ptr.getCell()->getCell();
mwmp::WorldObject worldObject; mwmp::WorldObject worldObject;
@ -813,6 +836,9 @@ void WorldEvent::addScriptGlobalShort(std::string varName, int shortVal)
void WorldEvent::sendObjectPlace() void WorldEvent::sendObjectPlace()
{ {
if (worldObjects.size() == 0)
return;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getDescription().c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getDescription().c_str());
for (const auto &worldObject : worldObjects) for (const auto &worldObject : worldObjects)
@ -824,6 +850,9 @@ void WorldEvent::sendObjectPlace()
void WorldEvent::sendObjectSpawn() void WorldEvent::sendObjectSpawn()
{ {
if (worldObjects.size() == 0)
return;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getDescription().c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getDescription().c_str());
for (const auto &worldObject : worldObjects) for (const auto &worldObject : worldObjects)

@ -12,7 +12,7 @@ namespace mwmp
std::string refId; std::string refId;
int count; int count;
int charge; int charge;
int enchantmentCharge; double enchantmentCharge;
int actionCount; int actionCount;
@ -29,7 +29,7 @@ namespace mwmp
unsigned mpNum; unsigned mpNum;
int count; int count;
int charge; int charge;
int enchantmentCharge; double enchantmentCharge;
int goldValue; int goldValue;
ESM::Position position; ESM::Position position;

@ -12,7 +12,7 @@ namespace mwmp
std::string refId; std::string refId;
int count; int count;
int charge; int charge;
int enchantmentCharge; double enchantmentCharge;
inline bool operator==(const Item& rhs) inline bool operator==(const Item& rhs)
{ {

@ -31,5 +31,6 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send)
RW(player->equipmentItems[equipmentIndex].refId, send); RW(player->equipmentItems[equipmentIndex].refId, send);
RW(player->equipmentItems[equipmentIndex].count, send); RW(player->equipmentItems[equipmentIndex].count, send);
RW(player->equipmentItems[equipmentIndex].charge, send); RW(player->equipmentItems[equipmentIndex].charge, send);
RW(player->equipmentItems[equipmentIndex].enchantmentCharge, send);
} }
} }

Loading…
Cancel
Save