1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-20 20:39:42 +00:00
openmw-tes3mp/apps/openmw/mwgui
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
..
alchemywindow.cpp [Client] Ignore dynamic object placements or spawns in packets 2018-01-17 11:01:31 +02:00
alchemywindow.hpp Include cleanup 2017-09-27 12:56:09 +00:00
backgroundimage.cpp
backgroundimage.hpp
birth.cpp Set default values for class and birthsign select menus (bug #4226) 2017-11-25 11:35:29 +04:00
birth.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
bookpage.cpp Do not show carriage return characters (bug #3696) 2017-11-23 14:58:20 +04:00
bookpage.hpp improve dialogue window performance 2017-07-26 18:58:27 +02:00
bookwindow.cpp Don't ignore my own advice 2017-09-27 12:55:58 +00:00
bookwindow.hpp Improve keyboard navigation of book/scroll windows 2017-09-25 00:47:04 +02:00
charactercreation.cpp [Client] Shorten player names to 31 characters after they are inputted 2017-08-31 18:41:37 +03:00
charactercreation.hpp Show starting abilities, powers and spells in stat-review window (Fixes #2410) 2016-11-19 21:51:19 +01:00
class.cpp Set default values for class and birthsign select menus (bug #4226) 2017-11-25 11:35:29 +04:00
class.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
companionitemmodel.cpp
companionitemmodel.hpp
companionwindow.cpp Round up displayed encumbrance 2018-02-24 15:13:14 +03:00
companionwindow.hpp Include cleanup 2017-09-27 12:56:09 +00:00
confirmationdialog.cpp Remove unused and slightly broken custom button titles in ConfirmationDialog 2017-09-24 19:08:14 +02:00
confirmationdialog.hpp Remove unused and slightly broken custom button titles in ConfirmationDialog 2017-09-24 19:08:14 +02:00
console.cpp [Client] Use new code to set the console's Ptrs from server scripts 2017-12-26 15:04:28 +02:00
console.hpp [Client] Use new code to set the console's Ptrs from server scripts 2017-12-26 15:04:28 +02:00
container.cpp [General] Rework container sync to prevent item duping 2018-03-26 19:27:36 +03:00
container.hpp [General] Rework container sync to prevent item duping 2018-03-26 19:27:36 +03:00
containeritemmodel.cpp Merge pull request #1549 from akortunov/itemmodels 2017-11-11 22:12:07 +00:00
containeritemmodel.hpp Move onClose() check to item models 2017-11-10 10:58:43 +04:00
controllers.cpp
controllers.hpp
countdialog.cpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
countdialog.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
cursor.cpp
cursor.hpp
debugwindow.cpp Fix build against bullet with profiler disabled (Fixes #3592) 2016-10-14 21:00:35 +02:00
debugwindow.hpp
dialogue.cpp Update dialogue topics list after result script is run 2017-11-15 17:20:06 +00:00
dialogue.hpp Update dialogue topics list after result script is run 2017-11-15 17:20:06 +00:00
draganddrop.cpp [General] Rework container sync to prevent item duping 2018-03-26 19:27:36 +03:00
draganddrop.hpp [General] Rework container sync to prevent item duping 2018-03-26 19:27:36 +03:00
enchantingdialog.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
enchantingdialog.hpp Make Enter on a name edit accept the dialog 2017-09-25 00:47:07 +02:00
exposedwindow.cpp
exposedwindow.hpp
formatting.cpp Improve keyboard navigation of book/scroll windows 2017-09-25 00:47:04 +02:00
formatting.hpp
hud.cpp [General] Track objects directly placed by players in ObjectPlace 2018-01-28 17:46:51 +02:00
hud.hpp Fix some style issues flagged by cppcheck 2017-10-15 17:06:58 +02:00
inventoryitemmodel.cpp Move onClose() check to item models 2017-11-10 10:58:43 +04:00
inventoryitemmodel.hpp Move onClose() check to item models 2017-11-10 10:58:43 +04:00
inventorywindow.cpp Merge pull request #389 from OpenMW/master 2018-02-25 22:05:32 +02:00
inventorywindow.hpp OnActivate is triggered when the item is picked up 2017-10-31 22:33:26 +00:00
itemchargeview.cpp Explicitely set the user data type to avoid const/non-const mismatch 2017-03-13 02:48:23 +01:00
itemchargeview.hpp convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs and updated by Bret Curtis 2017-06-09 16:49:25 +02:00
itemmodel.cpp remove redundant allowedToInsertItems() function from ItemModel 2017-11-11 11:58:22 +04:00
itemmodel.hpp remove redundant allowedToInsertItems() function from ItemModel 2017-11-11 11:58:22 +04:00
itemselection.cpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
itemselection.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
itemview.cpp Don't reset the item model's sort/filter options in updatePlayer (Fixes #2863) 2015-08-16 17:49:53 +02:00
itemview.hpp
itemwidget.cpp Don't use floating point arithmetics for formatted count (Bug #4346) 2018-03-07 15:36:10 +03:00
itemwidget.hpp ItemWidget: skip setImageTexture if the icon has not changed 2017-02-05 02:26:27 +01:00
jailscreen.cpp [Client] Prevent guards from arresting players who are currently jailed 2018-02-25 21:33:04 +02:00
jailscreen.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
journalbooks.cpp Do not display cyrillic soft/hard signs in the journal index 2017-12-04 22:42:17 +04:00
journalbooks.hpp Remove getEncoding() from WindowManager 2017-11-22 08:32:38 +04:00
journalviewmodel.cpp Move toUpper() from StringUtils to the JournalViewModel 2017-11-23 19:37:45 +04:00
journalviewmodel.hpp Convert topic name to Unicode 2017-11-21 12:31:23 +04:00
journalwindow.cpp Merge pull request #1558 from akortunov/rusjournal 2017-11-24 23:17:28 +00:00
journalwindow.hpp Remove getEncoding() from WindowManager 2017-11-22 08:32:38 +04:00
keyboardnavigation.cpp Add an option to disable GUI keyboard navigation (Bug #4333) 2018-03-08 23:39:35 +00:00
keyboardnavigation.hpp Add an option to disable GUI keyboard navigation (Bug #4333) 2018-03-08 23:39:35 +00:00
layout.cpp
layout.hpp
levelupdialog.cpp Fix wrong skin for levelup attribute values 2017-09-27 22:04:36 +02:00
levelupdialog.hpp Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
loadingscreen.cpp Make the CompositeMapRenderer use available time and add related setting 2018-02-13 00:40:41 +00:00
loadingscreen.hpp Fade screen out during loading screen (when travelling) 2017-10-04 16:00:38 +00:00
mainmenu.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
mainmenu.hpp Fix exiting savegamedialog with 'esc' when no game is running 2017-10-05 18:35:09 +02:00
mapwindow.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
mapwindow.hpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
merchantrepair.cpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
merchantrepair.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
messagebox.cpp Workaround to make sure message box remains on top (Fixes #4298) 2018-01-14 00:27:53 +00:00
messagebox.hpp Workaround to make sure message box remains on top (Fixes #4298) 2018-01-14 00:27:53 +00:00
mode.hpp Remove redundant RestBed gui mode 2017-09-24 19:08:14 +02:00
pickpocketitemmodel.cpp remove redundant allowedToInsertItems() function from ItemModel 2017-11-11 11:58:22 +04:00
pickpocketitemmodel.hpp remove redundant allowedToInsertItems() function from ItemModel 2017-11-11 11:58:22 +04:00
quickkeysmenu.cpp [General] Implement selected spell sync as part of PlayerMiscellaneous 2018-02-06 06:36:46 +02:00
quickkeysmenu.hpp Merge pull request #360 from TES3MP/0.6.1-openmw-updates while resolving conflicts 2017-12-25 02:25:01 +02:00
race.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
race.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
recharge.cpp Include cleanup 2017-09-27 12:56:09 +00:00
recharge.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
referenceinterface.cpp Remove redundant player cell variable 2017-09-24 19:08:13 +02:00
referenceinterface.hpp Remove redundant player cell variable 2017-09-24 19:08:13 +02:00
repair.cpp Include cleanup 2017-09-27 12:56:09 +00:00
repair.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
review.cpp Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
review.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
savegamedialog.cpp Fix unused event handler 2017-10-15 17:06:58 +02:00
savegamedialog.hpp Update the saves list/preview image when character selection changes to make it more convenient to flip through characters with the keyboard 2017-10-04 16:00:39 +00:00
screenfader.cpp Use MyGUI frame events for ScreenFader 2017-10-04 16:00:38 +00:00
screenfader.hpp Use MyGUI frame events for ScreenFader 2017-10-04 16:00:38 +00:00
scrollwindow.cpp Improve keyboard navigation of book/scroll windows 2017-09-25 00:47:04 +02:00
scrollwindow.hpp Improve keyboard navigation of book/scroll windows 2017-09-25 00:47:04 +02:00
settingswindow.cpp [Client] Hide difficulty widget because it has no use in multiplayer 2018-03-01 09:31:21 +02:00
settingswindow.hpp Call onResChange for every window 2017-09-24 19:08:15 +02:00
sortfilteritemmodel.cpp Remove missing souls, remove some runaway exceptions (Fixes #4111) 2018-03-08 23:38:04 +00:00
sortfilteritemmodel.hpp Move onClose() check to item models 2017-11-10 10:58:43 +04:00
soulgemdialog.cpp Improve WindowManager API with a generic way of passing a Ptr to the opened GUI window 2017-09-24 19:08:12 +02:00
soulgemdialog.hpp
spellbuyingwindow.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
spellbuyingwindow.hpp Fix some style issues flagged by cppcheck 2017-10-15 17:06:58 +02:00
spellcreationdialog.cpp Merge pull request #303 from OpenMW/master while resolving conflicts 2017-10-06 04:10:04 +03:00
spellcreationdialog.hpp Make Enter on a name edit accept the dialog 2017-09-25 00:47:07 +02:00
spellicons.cpp durations in tooltips : use "show effect duration" setting 2015-09-16 22:42:54 +02:00
spellicons.hpp
spellmodel.cpp Added checkMagicka parameter 2017-11-28 23:35:54 +01:00
spellmodel.hpp
spellview.cpp Adjust some more windows to be keyboard friendlier 2017-09-24 19:08:14 +02:00
spellview.hpp remove boost/tuple 2017-06-09 19:08:53 +02:00
spellwindow.cpp [General] Implement selected spell sync as part of PlayerMiscellaneous 2018-02-06 06:36:46 +02:00
spellwindow.hpp Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
statswindow.cpp Fix some style issues flagged by cppcheck 2017-10-15 17:06:58 +02:00
statswindow.hpp Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
textcolours.hpp improve dialogue window performance 2017-07-26 18:58:27 +02:00
textinput.cpp Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
textinput.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
timeadvancer.cpp
timeadvancer.hpp
tooltips.cpp Fix owned tooltip in the spellwindow 2017-10-06 11:38:27 +04:00
tooltips.hpp Use owned tooltips for items in containers correctly 2017-10-04 12:13:45 +04:00
tradeitemmodel.cpp Use owned tooltips for items in containers correctly 2017-10-04 12:13:45 +04:00
tradeitemmodel.hpp Use owned tooltips for items in containers correctly 2017-10-04 12:13:45 +04:00
tradewindow.cpp Merge pull request #360 from TES3MP/0.6.1-openmw-updates while resolving conflicts 2017-12-25 02:25:01 +02:00
tradewindow.hpp Make TradeWindow not depend on DialogueWindow 2017-09-25 18:07:49 +02:00
trainingwindow.cpp Merge pull request #360 from TES3MP/0.6.1-openmw-updates while resolving conflicts 2017-12-25 02:25:01 +02:00
trainingwindow.hpp Allow training window exit() 2017-10-08 20:38:20 +00:00
travelwindow.cpp Fade screen out during loading screen (when travelling) 2017-10-04 16:00:38 +00:00
travelwindow.hpp Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
videowidget.cpp Change the way that image origin is converted to OpenGL's lower-left convention 2016-02-05 21:03:11 +01:00
videowidget.hpp convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs and updated by Bret Curtis 2017-06-09 16:49:25 +02:00
waitdialog.cpp Add missing WaitDialog::clear() (Fixes #4196) 2017-11-08 00:24:04 +00:00
waitdialog.hpp Add missing WaitDialog::clear() (Fixes #4196) 2017-11-08 00:24:04 +00:00
widgets.cpp Fix what looks like a copy/paste error 2017-09-27 12:56:08 +00:00
widgets.hpp
windowbase.cpp Improve KeyboardNavigation to better handle modal windows 2017-09-27 12:55:58 +00:00
windowbase.hpp Improve KeyboardNavigation to better handle modal windows 2017-09-27 12:55:58 +00:00
windowmanagerimp.cpp [Client] Make it possible to get ContainerWindow from elsewhere in code 2018-03-24 09:00:15 +02:00
windowmanagerimp.hpp [Client] Make it possible to get ContainerWindow from elsewhere in code 2018-03-24 09:00:15 +02:00
windowpinnablebase.cpp
windowpinnablebase.hpp