1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 12:19:55 +00:00
Commit graph

66 commits

Author SHA1 Message Date
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
Andrei Kortunov
3694b6ec90 Move onClose() check to item models 2017-11-10 10:58:43 +04:00
scrawl
d58ff4a736 Remove obsolete Container GUI keyboard handling 2017-09-24 19:08:16 +02:00
scrawl
e7d2a8a4dc Call clear() for every window 2017-09-24 19:08:15 +02:00
scrawl
2b03bc0c56 Call WindowBase::onFrame() for every active window 2017-09-24 19:08:15 +02:00
scrawl
4fff2e2e34 Refactor exitCurrentGuiMode 2017-09-24 19:08:13 +02:00
scrawl
84657271c7 Improve WindowManager API with a generic way of passing a Ptr to the opened GUI window 2017-09-24 19:08:12 +02:00
scrawl
01391b7eed Rename WindowBase's open/close to onOpen/onClose 2017-09-24 19:08:12 +02:00
scrawl
e23775e338 Fix -Woverloaded-virtual clang warnings 2015-06-04 20:31:28 +02:00
scrawl
4b704f665f Reduce includes, move DragAndDrop to separate file 2015-01-10 01:21:17 +01:00
scrawl
715d357f24 Use a controller to move Drag&Drop widget with the mouse cursor 2014-08-01 17:14:35 +02:00
scrawl
f2799ea1d9 Reset item model when reference is reset (Fixes #1628)
This caused crashes when the window was resized after the reference no longer exists (e.g. when a savegame is loaded)
2014-07-12 18:53:22 +02:00
Digmaster
e3e51324a4 Esc button exits all non-modal GUI windows 2014-05-26 23:13:37 -04:00
slothlife
f33559fead Fixes for MSVC warnings, less overall changes
Kept some fixes from the first round of review. Found out that several
targets weren't being built with the same basic warnings disabled.
Disabled a few warnings for external libraries specifically, rather than
applying them to all targets.
2014-05-14 20:12:52 -05:00
scrawl
d01f89b153 Rewrite some awful code 2014-01-11 00:24:21 +01:00
scrawl
780bf5a2cd Implement pickpocket detection. Play a voiced dialogue entry when detected. 2014-01-07 03:01:33 +01:00
scrawl
0c4a963132 Container UI rewrite 2013-05-11 18:38:27 +02:00
Britt Mathis
6128b9276f Removed non-essential includes from all MWGui header files. 2013-04-11 00:21:56 -04:00
Britt Mathis
f7383905b7 Finally eliminated calls to MWBase::WindowManager in constructors 2013-04-10 14:46:21 -04:00
Britt Mathis
ce9bc6d9ba MwGui windowManager calls fixed to use MWBase::Environment::get().getWindowManager, filenames in MwGui now comply with naming conventions 2013-04-10 00:32:05 -04:00
scrawl
b0199c703c Companion UI 2013-03-31 13:13:46 +02:00
scrawl
c0b0227e8a enchanting 2013-03-16 19:00:14 +01:00
scrawl
0ee0dbdb97 Added "dispose corpse" button, added stealing (all items visible and no penalty yet) 2013-03-07 14:00:13 +01:00
greye
2057f5619e move ESMStore to MWWorld 2012-11-05 17:18:01 +04:00
Marc Zinnschlag
6534c2a55a Issue #107: WindowManager is accessed only through the interface class from now on 2012-08-12 18:11:09 +02:00
scrawl
30461438f6 still left: spell success formula 2012-05-29 12:35:03 +02:00
scrawl
f1d3978897 Issue #290: Auto-Close MW-reference related GUI windows 2012-05-27 01:14:33 +02:00
scrawl
6eb15f7680 auto-select the alchemy tools with highest quality 2012-05-25 15:24:33 +02:00
scrawl
c004f5d570 adjust the "total cost"/"total sold" value when trading items, added some checks with respective user notifications 2012-05-18 22:06:25 +02:00
scrawl
db49e2c046 bought/sold items now use a separate ContainerStore, this fixes a stacking issue among other things 2012-05-18 20:53:24 +02:00
scrawl
fb47681fbd fix a bug, some cleanup 2012-05-18 17:58:33 +02:00
scrawl
50a8eb05d9 transfering items between player and merchant works and shows a red frame for bought/sold items. 2012-05-18 17:27:55 +02:00
scrawl
e2400ca7b2 only show items in the trade window that the NPC actually trades (services enum) 2012-05-18 15:51:33 +02:00
scrawl
41efea4c1d in the trade window, don't show items that the merchant has equipped. 2012-05-17 21:56:16 +02:00
scrawl
c5185cf2e4 drop item on avatar from external container bugfix 2012-05-17 12:09:53 +02:00
scrawl
477f1b42ab fixed another item dropping bug 2012-05-15 23:28:04 +02:00
scrawl
3f4ce32727 implemented player encumbrance bar 2012-05-15 22:45:46 +02:00
scrawl
175623bf22 change the drag&drop to not use a seperate containerstore 2012-05-15 21:44:57 +02:00
scrawl
71de10cb7e equipping items works, but only if you have more than one of the item that you're equipping 2012-05-15 20:33:34 +02:00
scrawl
ab6336b745 using items via the inventory is now possible by dragging them on the avatar (only implemented for books right now) 2012-05-15 18:05:53 +02:00
scrawl
7fbee0d488 use MyGUI::InputManager instead of MWInputManager to detect ctrl/shift 2012-05-15 13:00:26 +02:00
scrawl
24a0fecd37 implemented item count selection dialog 2012-05-15 12:51:51 +02:00
scrawl
320cc7d020 implemented ctrl and shift-keys for item drag&drop (take all, take 1) 2012-05-15 11:02:50 +02:00
scrawl
d3e162ec83 dropping items works 2012-05-14 17:41:17 +02:00
scrawl
f31853d30b mouse wheel works when mouse is over an item 2012-05-13 01:27:17 +02:00
scrawl
78b06d0ebf inventory window pinning 2012-05-12 22:44:12 +02:00
scrawl
0114bf948c revised filters 2012-05-12 21:28:04 +02:00
scrawl
fd18c95c5f implemented filters (no gui yet) 2012-05-12 20:35:50 +02:00
scrawl
d64fccec6f display the item count in the tooltip 2012-05-12 13:46:03 +02:00
scrawl
ed6ff0a94a cleanup 3 2012-05-12 13:12:37 +02:00