Commit Graph

219 Commits (a083439139b883b260605fac90d6304ea293effa)

Author SHA1 Message Date
David Cernat a083439139 Merge pull request #469 from davidcernat/master while resolving conflicts
# Conflicts:
#	apps/openmw/main.cpp
#	apps/openmw/mwbase/world.hpp
#	apps/openmw/mwdialogue/dialoguemanagerimp.cpp
#	apps/openmw/mwmechanics/actors.cpp
#	apps/openmw/mwscript/dialogueextensions.cpp
#	apps/openmw/mwworld/worldimp.hpp
6 years ago
Andrei Kortunov eeffe2e557 Check if item model exists inside drag and drop functions 6 years ago
Andrei Kortunov a08048da4e Avoid dereference after null check 6 years ago
David Cernat d93b67ef21 [General] Sync soul refIds for items and add related script functions 6 years ago
David Cernat 36ac2d9de4 [Client] Set packetOrigin for all ObjectList packets sent 6 years ago
David Cernat 2189ea1a63 [Client] Clean up sending of Container packets 6 years ago
David Cernat 09da24f1ea [General] Rename all instances of refNumIndex into refNum
This creates symmetry with mpNum and should cause less confusion in the future.
6 years ago
David Cernat c2411982d2 [Client] Log object refNumIndexes and mpNums in a consistent way 6 years ago
David Cernat b81ca18316 [Client] Don't clear container Ptrs when disposing of corpses
The reason for this is that only the server should be determine whether a corpse can be disposed of or not.
6 years ago
David Cernat fd05beef94 [Client] Don't delete disposed of corpses on client
Clients should instead await a server reply approving the deletion.
6 years ago
David Cernat 78234f9071 [General] Rename Event into ObjectList & WorldObject into BaseObject 6 years ago
David Cernat 6bf3a0be1e [General] Rename WorldPackets into ObjectPackets for clarity 6 years ago
David Cernat d8b48f6cf4 [Client] Remove redundant container methods from CellController 6 years ago
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.
6 years ago
David Cernat f746958afa [Client] Send enchantmentCharge for items added or removed in containers 6 years ago
David Cernat 07f0cc2b0e
Merge pull request #353 from OpenMW/master
Add OpenMW commits up to 4 Dec 2017
7 years ago
Andrei Kortunov 8decd35607 Fixes crash on quickload from the container menu (bug #4239) 7 years ago
David Cernat 2ba1c84cf7 Merge pull request #335 from OpenMW/master while resolving conflicts
# Conflicts:
#	apps/openmw/mwgui/container.cpp
7 years ago
Andrei Kortunov 03f129b53c remove redundant allowedToInsertItems() function from ItemModel 7 years ago
Andrei Kortunov 3694b6ec90 Move onClose() check to item models 7 years ago
Andrei Kortunov ac33ff9482 Move onDropItem() check to item models 7 years ago
Andrei Kortunov 3604b73d60 Move onTakeItem() to item models 7 years ago
David Cernat 711c4d83da [Client] Fix build after recent OpenMW changes to GUI 7 years ago
David Cernat 38247ff086 Merge pull request #303 from OpenMW/master while resolving conflicts
# Conflicts:
#	apps/openmw/mwbase/dialoguemanager.hpp
#	apps/openmw/mwdialogue/dialoguemanagerimp.hpp
#	apps/openmw/mwgui/container.cpp
#	apps/openmw/mwgui/windowmanagerimp.cpp
#	apps/openmw/mwscript/dialogueextensions.cpp
7 years ago
Andrei Kortunov 1cb7ed5db1 Use owned tooltips for items in containers correctly 7 years ago
Andrei Kortunov 04452b0949 Use a pickpocket crime instead of theft when pickpocketing was failed 7 years ago
scrawl 64e27c032b Merge pull request #1481 from scrawl/keyfocus
WindowManager overhaul & improved keyboard support
7 years ago
scrawl d58ff4a736 Remove obsolete Container GUI keyboard handling 7 years ago
scrawl 4fff2e2e34 Refactor exitCurrentGuiMode 7 years ago
scrawl 84657271c7 Improve WindowManager API with a generic way of passing a Ptr to the opened GUI window 7 years ago
scrawl 01391b7eed Rename WindowBase's open/close to onOpen/onClose 7 years ago
David Cernat 73e7aa838d Merge pull request #296 from OpenMW/master while resolving conflicts
# Conflicts:
#	apps/openmw/mwgui/container.cpp
7 years ago
Andrei Kortunov 4580024d76 Unequip all items from dead corpse when take all items (bug #4095) 7 years ago
David Cernat e3929df38a Merge pull request #239 from OpenMW/master
Add OpenMW commits up to 14 Jul 2017
7 years ago
Andrei Kortunov 54b4d93f79 Added a special function for GUI sounds playing 7 years ago
David Cernat 5bd95628ce [Client] Send an ObjectDelete packet when disposing of corpses 7 years ago
David Cernat 9d2c5c3502 [General] Simplify structure of BaseEvent 7 years ago
David Cernat a82646a130 [Client] Delineate tes3mp-only code more clearly, part 2 7 years ago
David Cernat 679e790d8d [Client] Rename WorldController into CellController to avoid confusion with Networking's WorldPacketController 7 years ago
David Cernat 9759764699 [Client] Clean up getting and resetting of WorldEvent 7 years ago
David Cernat 2bd81c3de0 [Client] Use mpNum for every WorldObject 7 years ago
Koncord 690211ad99 [General] Extract BaseEvent & BasePlayer from packets to functions
Move Send and Read functions to BasePacket
7 years ago
Koncord cea1425db1 [Client] Remove redundant newlines & keep ~120 columns 7 years ago
David Cernat a58601fb2b [Client] Delineate tes3mp-only code more clearly, part 1 7 years ago
David Cernat ed2176c984 [Client] Reuse 1 BaseEvent over and over instead of creating new ones 7 years ago
David Cernat a4526605a6 [General] Remove goldValue from ContainerItem because it is never useful 7 years ago
David Cernat 4f2b88df8a [General] Remove owner var from ContainerItem because it is always empty 7 years ago
David Cernat 3b604a432e [General] Restructure ID_CONTAINER to allow multiple containers at once 7 years ago
David Cernat f02840d638 [Client] Fix log messages when sending ID_CONTAINER 7 years ago
David Cernat e52823394c [Client] Use correct count for ID_CONTAINER when dropping items 7 years ago