openmw-tes3coop/components
David Cernat 5f6ddcfc59 [General] Rework container sync to prevent item duping
A main priority in TES3MP development is to avoid making major changes to OpenMW code, so as to avoid merge conflicts in the future. Whenever avoiding potential conflicts seems especially difficult for the proper implementation of a particular multiplayer feature, that multiplayer feature is often put off until later or partially implemented with the intent of being revisited in the future.

Container sync is the perfect example. Previously, the OpenMW code for container actions was kept exactly as it was, with clients unilaterally accepting their own container changes as per singleplayer-specific code, with only the addition that clients sent container packets every time they made a change in a container, packets which were then forwarded unquestioningly by the server to other players. This meant that two players clicking on the same item in a container at the same time both managed to take it, thus duplicating the item.

Immediately after the packets were already forwarded, server scripts were able to check for incorrect changes, such as the removal of more items than should have existed in a container, but they had to send their own packets that attempted to fix what had already been accepted on the initial client and then forwarded to all clients, which was quite onerous in some scenarios, such as when a player on a slow connection immediately dropped items in the world after taking them from a container (which is why the default TES3MP serverside scripts made no attempt at sending corrective packets at all, preferring to expect the matter to be solved in a later C++ implementation).

This commit fixes item duping in containers by preventing container actions from initially running on clients and by ending the automatic forwarding of container packets by the server. Instead, clients now send container packets that act as requests for container actions, and serverside scripts have to forward these requests themselves. In other words, without a matching Container event in the server's Lua scripts, players are completely unable to affect containers for themselves or for others.

To forward a received Container packet, the following line must be used in a Container event in the Lua scripts:

tes3mp.SendContainer(true, true)

When an invalid action count is used in a container request, the serverside scripts can amend it using the following new function:

tes3mp.SetReceivedContainerItemActionCount(objectIndex, itemIndex, actionCount)

Thus, the serverside scripts are able to allow only container actions that are correct based on their own recorded contents for that container.

The OpenMW code allowing unilateral container actions in mwgui/container.cpp is now prevented from executing. When a player's container request is returned to them, code in mwmp/WorldEvent.cpp simulates those container actions instead.
2018-03-26 19:27:36 +03:00
..
bsa http to https for supported urls (#1625) 2018-03-08 21:23:24 +01:00
compiler allow . and - in the name part of a begin script statement, but not at the beginning of a name. Fixes #4061 2018-01-12 16:37:06 +01:00
config Fix assert with empty setting value 2017-10-22 10:10:04 +02:00
contentselector purge the rest of boost::shared and any other boost related things that no longer are required 2017-06-09 19:08:53 +02:00
esm Merge pull request #375 from OpenMW/master 2018-01-29 02:36:48 +02:00
esmterrain Cast LAND_SIZE to integer to avoid linking error 2017-03-28 01:57:31 +09:00
fallback be explicit about what we are trying to catch instead of catching everything and fixed up formatting 2017-06-12 00:32:29 +02:00
files Removed escape_hash_filter::mPrevious, removed usage of boost::replace_all 2017-11-11 22:58:02 +00:00
fontloader Fix shadowing warnings 2016-08-29 12:38:24 +02:00
interpreter More consistent wording of errors/warnings 2017-03-04 21:48:31 +01:00
loadinglistener LoadingScreen: add support for important labels 2015-12-15 21:16:20 +01:00
misc Move toUpper() from StringUtils to the JournalViewModel 2017-11-23 19:37:45 +04:00
myguiplatform purge unnecessary imports 2017-06-09 19:08:53 +02:00
nif http to https for supported urls (#1625) 2018-03-08 21:23:24 +01:00
nifbullet removed the unnecessary comment 2018-02-09 16:34:55 +01:00
nifosg Don't incorrectly discard root node transformation (Fixes #4272) 2017-12-31 23:49:43 +00:00
openmw-mp [General] Rework container sync to prevent item duping 2018-03-26 19:27:36 +03:00
process OSX build fix 2014-11-20 18:14:49 +01:00
resource Add NPC base skeleton files to the optimizer blacklist (Fixes #4159) 2017-11-10 22:51:32 +00:00
sceneutil Fix the optimizer messing up LOD node's children (Fixes #4301) 2018-01-29 19:44:12 +00:00
sdlutil GraphicsWindowSDL2: support setting up GLESv2 context for android 2018-01-18 17:11:22 -05:00
settings http to https for supported urls (#1625) 2018-03-08 21:23:24 +01:00
shader Reduce error spam 2017-11-08 00:24:03 +00:00
terrain Fix timing error 2018-02-13 18:25:28 +00:00
to_utf8 Fix typo in a comment 2015-12-10 00:15:55 +01:00
translation Merge pull request #228 from OpenMW/master while resolving conflicts 2017-06-18 18:16:10 +03:00
version Allow getting available version information even when clone is shallow 2017-03-07 21:53:49 +01:00
vfs Ignore duplicate data directories to work around the fallout of (Fixes #3557) 2018-01-14 00:25:20 +00:00
widgets Add an option to disable GUI keyboard navigation (Bug #4333) 2018-03-08 23:39:35 +00:00
CMakeLists.txt [General] Add placeholders for new packet types, part 2 2018-01-30 16:01:33 +02:00
doc.hpp second set of additional doxygen comments 2010-09-25 20:15:05 +02:00