forked from mirror/openmw-tes3mp
[Client] Delineate tes3mp-only code more clearly, part 1
This commit is contained in:
parent
341ec28b1f
commit
a58601fb2b
25 changed files with 402 additions and 75 deletions
|
@ -82,11 +82,21 @@ void OMW::Engine::executeLocalScripts()
|
|||
MWScript::InterpreterContext interpreterContext (
|
||||
&script.second.getRefData().getLocals(), script.second);
|
||||
|
||||
// Added by tes3mp to check and set whether packets should be sent about this script
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
By comparing its name with a list of script names, check if this script
|
||||
is allowed to send packets about its value changes
|
||||
|
||||
If it is, set a tes3mp-only boolean to true in its interpreterContext
|
||||
*/
|
||||
if (mwmp::Main::isValidPacketScript(script.first))
|
||||
{
|
||||
interpreterContext.sendPackets = true;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
mEnvironment.getScriptManager()->run (script.first, interpreterContext);
|
||||
}
|
||||
|
|
|
@ -408,8 +408,15 @@ namespace MWBase
|
|||
/// @note throws an exception when invoked on a teleport door
|
||||
virtual void activateDoor(const MWWorld::Ptr& door, int state) = 0;
|
||||
|
||||
// Added by tes3mp to allow saving a door state received from a packet
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Useful self-contained method for saving door states
|
||||
*/
|
||||
virtual void saveDoorState(const MWWorld::Ptr& door, int state) = 0;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
virtual bool getPlayerStandingOn (const MWWorld::ConstPtr& object) = 0; ///< @return true if the player is standing on \a object
|
||||
virtual bool getActorStandingOn (const MWWorld::ConstPtr& object) = 0; ///< @return true if any actor is standing on \a object
|
||||
|
|
|
@ -101,7 +101,12 @@ namespace MWGui
|
|||
if (!onTakeItem(mModel->getItem(mSelectedItem), count))
|
||||
return;
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_CONTAINER packet every time an item starts being dragged
|
||||
from a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::REMOVE;
|
||||
|
@ -129,6 +134,9 @@ namespace MWGui
|
|||
worldEvent->cell.getDescription().c_str(),
|
||||
containerItem.refId.c_str(),
|
||||
containerItem.count);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
|
||||
}
|
||||
|
@ -156,7 +164,11 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_CONTAINER packet every time an item is dropped in a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::ADD;
|
||||
|
@ -186,6 +198,9 @@ namespace MWGui
|
|||
worldEvent->cell.getDescription().c_str(),
|
||||
containerItem.refId.c_str(),
|
||||
containerItem.count);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
mDragAndDrop->drop(mModel, mItemView);
|
||||
}
|
||||
|
@ -306,7 +321,12 @@ namespace MWGui
|
|||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_CONTAINER packet every time the Take All button is used on
|
||||
a container
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *mPtr.getCell()->getCell();
|
||||
worldEvent->action = mwmp::BaseEvent::SET;
|
||||
|
@ -322,6 +342,9 @@ namespace MWGui
|
|||
worldObject.refId.c_str(),
|
||||
worldObject.refNumIndex,
|
||||
worldEvent->cell.getDescription().c_str());
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,12 @@ namespace MWGui
|
|||
cellStore->setLastRefNumIndex(cellStore->getLastRefNumIndex() + 1);
|
||||
dropped.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_PLACE packet every time an object is dropped into the world from
|
||||
the inventory screen
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *dropped.getCell()->getCell();
|
||||
|
||||
|
@ -94,6 +99,9 @@ namespace MWGui
|
|||
worldObject.refId.c_str(),
|
||||
worldObject.refNumIndex,
|
||||
worldObject.count);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
return dropped;
|
||||
}
|
||||
|
@ -288,10 +296,16 @@ namespace MWGui
|
|||
WorldItemModel drop (mouseX, mouseY);
|
||||
mDragAndDrop->drop(&drop, NULL);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer's inventory has changed, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_INVENTORY packet every time a player loses an item
|
||||
by dropping it in the world
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
||||
}
|
||||
|
|
|
@ -635,7 +635,15 @@ namespace MWGui
|
|||
// can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object
|
||||
MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player);
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_DELETE packet every time an item from the world is picked up
|
||||
by the player through the inventory HUD
|
||||
|
||||
Send an ID_PLAYER_INVENTORY packet as well because of the item thus gained
|
||||
by the player
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *object.getCell()->getCell();
|
||||
|
||||
|
@ -645,9 +653,10 @@ namespace MWGui
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
|
||||
|
||||
// LocalPlayer's inventory has changed, so send a packet with it
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
// remove from world
|
||||
MWBase::Environment::get().getWorld()->deleteObject (object);
|
||||
|
|
|
@ -144,10 +144,15 @@ namespace MWGui
|
|||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
spells.add (mSpellsWidgetMap.find(_sender)->second);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has gained a spell, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_SPELLBOOK packet every time a player buys a spell
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(mSpellsWidgetMap.find(_sender)->second);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);
|
||||
|
||||
|
|
|
@ -407,10 +407,16 @@ namespace MWGui
|
|||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
spells.add (spell->mId);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has gained a spell, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_SPELLBOOK packet every time a player buys a custom spell from
|
||||
the Spellmaking screen
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(*spell);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_SpellCreation);
|
||||
}
|
||||
|
|
|
@ -189,10 +189,15 @@ namespace MWGui
|
|||
|
||||
spells.remove(mSpellToDelete);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has lost a spell, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_SPELLBOOK packet every time a player deletes one of their spells
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(mSpellToDelete);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
updateSpells();
|
||||
}
|
||||
|
|
|
@ -284,23 +284,47 @@ int MWMechanics::NpcStats::getLevelProgress () const
|
|||
return mLevelProgress;
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set a player's level progress directly instead of going
|
||||
through other methods
|
||||
*/
|
||||
void MWMechanics::NpcStats::setLevelProgress(int value)
|
||||
{
|
||||
mLevelProgress = value;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to get a player's skill increases for an attribute directly
|
||||
instead of going through other methods
|
||||
*/
|
||||
int MWMechanics::NpcStats::getSkillIncrease(int attribute) const
|
||||
{
|
||||
return mSkillIncreases[attribute];
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set a player's skill increases for an attribute directly
|
||||
instead of going through other methods
|
||||
*/
|
||||
void MWMechanics::NpcStats::setSkillIncrease(int attribute, int value)
|
||||
{
|
||||
mSkillIncreases[attribute] = value;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void MWMechanics::NpcStats::levelUp()
|
||||
{
|
||||
|
|
|
@ -84,10 +84,18 @@ namespace MWMechanics
|
|||
void increaseSkill (int skillIndex, const ESM::Class& class_, bool preserveProgress);
|
||||
|
||||
int getLevelProgress() const;
|
||||
void setLevelProgress(int value); // Added by tes3mp
|
||||
|
||||
int getSkillIncrease(int attribute) const; // Added by tes3mp
|
||||
void setSkillIncrease(int attribute, int value); // Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Useful methods for setting player stats
|
||||
*/
|
||||
void setLevelProgress(int value);
|
||||
int getSkillIncrease(int attribute) const;
|
||||
void setSkillIncrease(int attribute, int value);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
int getLevelupAttributeMultiplier(int attribute) const;
|
||||
|
||||
|
|
|
@ -58,7 +58,11 @@ namespace MWMechanics
|
|||
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, lock);
|
||||
if (Misc::Rng::roll0to99() <= x)
|
||||
{
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_UNLOCK packet every time an object is unlocked
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *lock.getCell()->getCell();
|
||||
|
||||
|
@ -68,6 +72,9 @@ namespace MWMechanics
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
lock.getClass().unlock(lock);
|
||||
resultMessage = "#{sLockSuccess}";
|
||||
|
|
|
@ -63,7 +63,12 @@ namespace MWScript
|
|||
throw std::runtime_error ("animation mode out of range");
|
||||
}
|
||||
|
||||
// Added by tes3mp to check and set whether packets should be sent about this script
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_ANIM_PLAY every time an animation is played for an object
|
||||
through an approved script
|
||||
*/
|
||||
if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr)))
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
@ -78,6 +83,9 @@ namespace MWScript
|
|||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(worldEvent);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true);
|
||||
}
|
||||
|
|
|
@ -70,10 +70,16 @@ namespace MWScript
|
|||
// Spawn a messagebox (only for items added to player's inventory and if player is talking to someone)
|
||||
if (ptr == MWBase::Environment::get().getWorld ()->getPlayerPtr() )
|
||||
{
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer's inventory has changed, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_INVENTORY packet every time a player gains an item
|
||||
through a script
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
// The two GMST entries below expand to strings informing the player of what, and how many of it has been added to their inventory
|
||||
std::string msgBox;
|
||||
|
|
|
@ -47,10 +47,16 @@ namespace MWScript
|
|||
{
|
||||
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has gained a journal entry, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_JOURNAL packet every time a journal entry is added
|
||||
through a script
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendJournalEntry(quest, index, ptr);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -74,10 +80,16 @@ namespace MWScript
|
|||
|
||||
MWBase::Environment::get().getJournal()->setJournalIndex (quest, index);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has gained a journal index, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_JOURNAL packet every time a journal index is set
|
||||
through a script
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->sendJournalIndex(quest, index);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -151,8 +151,16 @@ namespace MWScript
|
|||
if (targetId.empty() && !reference.isEmpty())
|
||||
mTargetId = reference.getCellRef().getRefId();
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Boolean used to check whether value change packets should be sent for the
|
||||
script being processed by the InterpreterContext
|
||||
*/
|
||||
sendPackets = false;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
int InterpreterContext::getLocalShort (int index) const
|
||||
|
@ -186,7 +194,12 @@ namespace MWScript
|
|||
|
||||
mLocals->mShorts.at (index) = value;
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_SCRIPT_LOCAL_SHORT packet every time a local short changes its value
|
||||
in a script approved for packet sending
|
||||
*/
|
||||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
@ -208,6 +221,9 @@ namespace MWScript
|
|||
worldObject.index,
|
||||
worldObject.shortVal);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
void InterpreterContext::setLocalLong (int index, int value)
|
||||
|
@ -225,9 +241,13 @@ namespace MWScript
|
|||
|
||||
mLocals->mFloats.at (index) = value;
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// Only send a packet if this float has no decimals (to avoid spam)
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_SCRIPT_LOCAL_FLOAT packet every time a local float changes its value
|
||||
to one without decimals (to avoid packet spam for timers) in a script approved
|
||||
for packet sending
|
||||
*/
|
||||
if (sendPackets && value == (int) value)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
@ -249,6 +269,9 @@ namespace MWScript
|
|||
worldObject.index,
|
||||
worldObject.floatVal);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
void InterpreterContext::messageBox (const std::string& message,
|
||||
|
@ -292,7 +315,12 @@ namespace MWScript
|
|||
|
||||
void InterpreterContext::setGlobalShort (const std::string& name, int value)
|
||||
{
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_SCRIPT_GLOBAL_SHORT packet every time a global short changes its value
|
||||
in a script approved for packet sending
|
||||
*/
|
||||
if (sendPackets)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
@ -308,6 +336,9 @@ namespace MWScript
|
|||
worldObject.varName.c_str(),
|
||||
worldObject.shortVal);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->setGlobalInt (name, value);
|
||||
}
|
||||
|
@ -629,7 +660,12 @@ namespace MWScript
|
|||
|
||||
locals.mShorts[index] = value;
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_SCRIPT_MEMBER_SHORT packet every time a member short changes its value
|
||||
in a script approved for packet sending
|
||||
*/
|
||||
if (sendPackets && !global)
|
||||
{
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
@ -647,6 +683,9 @@ namespace MWScript
|
|||
worldObject.index,
|
||||
worldObject.shortVal);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
void InterpreterContext::setMemberLong (const std::string& id, const std::string& name, int value, bool global)
|
||||
|
|
|
@ -55,8 +55,15 @@ namespace MWScript
|
|||
const std::string& targetId = "");
|
||||
///< The ownership of \a locals is not transferred. 0-pointer allowed.
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Useful boolean for setting whether scripts send packets
|
||||
*/
|
||||
bool sendPackets;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
virtual int getLocalShort (int index) const;
|
||||
|
||||
|
|
|
@ -89,7 +89,12 @@ namespace MWScript
|
|||
bool allowSkipping = runtime[0].mInteger != 0;
|
||||
runtime.pop();
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_VIDEO_PLAY packet every time a video is played
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -98,6 +103,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping);
|
||||
}
|
||||
|
@ -197,7 +205,12 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_LOCK packet every time an object is locked
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -208,6 +221,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
ptr.getClass().lock (ptr, lockLevel);
|
||||
|
||||
|
@ -235,7 +251,12 @@ namespace MWScript
|
|||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_UNLOCK packet every time an object is unlocked
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -245,6 +266,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
ptr.getClass().unlock (ptr);
|
||||
}
|
||||
|
@ -706,7 +730,12 @@ namespace MWScript
|
|||
|
||||
if (parameter == 1)
|
||||
{
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_DELETE packet every time an object is deleted
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -716,6 +745,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,12 @@ namespace MWScript
|
|||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_MUSIC_PLAY packet every time new music is streamed through
|
||||
a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
|
@ -78,6 +83,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->streamMusic (sound);
|
||||
}
|
||||
|
|
|
@ -446,11 +446,17 @@ namespace MWScript
|
|||
|
||||
ptr.getClass().getCreatureStats (ptr).getSpells().add (id);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has gained a spell, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_SPELLBOOK packet every time a player gains a spell
|
||||
through a script
|
||||
*/
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(id);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -476,11 +482,17 @@ namespace MWScript
|
|||
wm->unsetSelectedSpell();
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has lost a spell, so send a packet with it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_SPELLBOOK packet every time a player loses a spell
|
||||
through a script
|
||||
*/
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(id);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,12 @@ namespace MWScript
|
|||
Interpreter::Type_Float scale = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_SCALE every time an object's scale is changed
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -57,6 +62,9 @@ namespace MWScript
|
|||
worldEvent->addObject(worldObject);
|
||||
|
||||
mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(worldEvent);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
|
||||
}
|
||||
|
@ -549,7 +557,12 @@ namespace MWScript
|
|||
cellStore->setLastRefNumIndex(cellStore->getLastRefNumIndex() + 1);
|
||||
ptr.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex());
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_PLACE packet every time an object is placed in the world
|
||||
through a script
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *ptr.getCell()->getCell();
|
||||
|
||||
|
@ -571,6 +584,9 @@ namespace MWScript
|
|||
worldObject.refId.c_str(),
|
||||
worldObject.refNumIndex,
|
||||
worldObject.count);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -25,7 +25,15 @@ namespace MWWorld
|
|||
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
||||
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_OBJECT_DELETE packet every time an item is taken from the world
|
||||
by the player outside of the inventory screen
|
||||
|
||||
Send an ID_PLAYER_INVENTORY packet as well because of the item thus gained
|
||||
by the player
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *getTarget().getCell()->getCell();
|
||||
|
||||
|
@ -41,8 +49,10 @@ namespace MWWorld
|
|||
worldObject.refNumIndex,
|
||||
worldEvent->cell.getDescription().c_str());
|
||||
|
||||
// LocalPlayer's inventory has changed, so send a packet with it
|
||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||
setTarget(newitem);
|
||||
|
|
|
@ -28,10 +28,15 @@ namespace MWWorld
|
|||
*/
|
||||
MWWorld::CellRef mRef;
|
||||
|
||||
/* Added by tes3mp to prevent dedicated players' references from automatically
|
||||
* and unpredictably moving across exterior cell boundaries on clients
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Useful boolean for stopping momentum-based cell changes not approved by server
|
||||
*/
|
||||
bool canChangeCell;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/** runtime-data */
|
||||
RefData mData;
|
||||
|
|
|
@ -259,10 +259,15 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getSoundManager()->stopSound (*iter);
|
||||
mActiveCells.erase(*iter);
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has unloaded a cell, so store it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Store a cell unload for the LocalPlayer
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->storeCellState(*(*iter)->getCell(), mwmp::CellState::UNLOAD);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
void Scene::loadCell (CellStore *cell, Loading::Listener* loadingListener, bool respawn)
|
||||
|
@ -332,10 +337,15 @@ namespace MWWorld
|
|||
if (!cell->isExterior() && !(cell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
|
||||
mRendering.configureAmbient(cell->getCell());
|
||||
|
||||
// Added by tes3mp
|
||||
//
|
||||
// LocalPlayer has loaded a cell, so store it
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Store a cell load for the LocalPlayer
|
||||
*/
|
||||
mwmp::Main::get().getLocalPlayer()->storeCellState(*cell->getCell(), mwmp::CellState::LOAD);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
mPreloader->notifyLoaded(cell);
|
||||
|
@ -452,12 +462,20 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_CELL_STATE packet with all cell states stored in LocalPlayer
|
||||
and then clear them, but only if the player has finished character generation
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->sendCellStates();
|
||||
mwmp::Main::get().getLocalPlayer()->clearCellStates();
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
CellStore* current = MWBase::Environment::get().getWorld()->getExterior(X,Y);
|
||||
MWBase::Environment::get().getWindowManager()->changeCell(current);
|
||||
|
@ -588,12 +606,20 @@ namespace MWWorld
|
|||
// Load cell.
|
||||
loadCell (cell, loadingListener, changeEvent);
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_CELL_STATE packet with all cell states stored in LocalPlayer
|
||||
and then clear them, but only if the player has finished character generation
|
||||
*/
|
||||
if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->sendCellStates();
|
||||
mwmp::Main::get().getLocalPlayer()->clearCellStates();
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
changePlayerCell(cell, position, adjustPlayerPos);
|
||||
|
||||
|
|
|
@ -2320,7 +2320,11 @@ namespace MWWorld
|
|||
break;
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *door.getCell()->getCell();
|
||||
|
||||
|
@ -2337,6 +2341,9 @@ namespace MWWorld
|
|||
worldObject.refNumIndex,
|
||||
worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.doorState ? "true" : "false");
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
door.getClass().setDoorState(door, state);
|
||||
mDoorStates[door] = state;
|
||||
|
@ -2344,7 +2351,11 @@ namespace MWWorld
|
|||
|
||||
void World::activateDoor(const Ptr &door, int state)
|
||||
{
|
||||
// Added by tes3mp
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_DOOR_STATE packet every time a door is activated
|
||||
*/
|
||||
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->resetWorldEvent();
|
||||
worldEvent->cell = *door.getCell()->getCell();
|
||||
|
||||
|
@ -2361,6 +2372,9 @@ namespace MWWorld
|
|||
worldObject.refNumIndex,
|
||||
worldEvent->cell.getDescription().c_str(),
|
||||
worldObject.doorState ? "true" : "false");
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
door.getClass().setDoorState(door, state);
|
||||
mDoorStates[door] = state;
|
||||
|
@ -2368,13 +2382,20 @@ namespace MWWorld
|
|||
mDoorStates.erase(door);
|
||||
}
|
||||
|
||||
// Added by tes3mp to allow saving a door state received from a packet
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow the saving of door states without going through World::activateDoor()
|
||||
*/
|
||||
void World::saveDoorState(const Ptr &door, int state)
|
||||
{
|
||||
mDoorStates[door] = state;
|
||||
if (state == 0)
|
||||
mDoorStates.erase(door);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
bool World::getPlayerStandingOn (const MWWorld::ConstPtr& object)
|
||||
{
|
||||
|
|
|
@ -524,8 +524,15 @@ namespace MWWorld
|
|||
/// @note throws an exception when invoked on a teleport door
|
||||
virtual void activateDoor(const MWWorld::Ptr& door, int state);
|
||||
|
||||
// Added by tes3mp to allow saving a door state received from a packet
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Useful self-contained method for saving door states
|
||||
*/
|
||||
virtual void saveDoorState(const MWWorld::Ptr& door, int state);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
virtual bool getPlayerStandingOn (const MWWorld::ConstPtr& object); ///< @return true if the player is standing on \a object
|
||||
virtual bool getActorStandingOn (const MWWorld::ConstPtr& object); ///< @return true if any actor is standing on \a object
|
||||
|
|
Loading…
Reference in a new issue