Commit Graph

52 Commits (1f2349ef6e82b7b1b82e1de6db2776e2043fb18d)

Author SHA1 Message Date
David Cernat dcbc9d1831 [Client] Print cells for actor deaths 6 years ago
David Cernat 433a69a588 [Client] Send all data for newly initialized LocalActors at least once 6 years ago
David Cernat b69e6b96e6 [Client] Use verbose logging level for LocalActor debug 7 years ago
David Cernat 5466092582 [Client] Reduce log level for actor cell changes 7 years ago
David Cernat 528bd26a3b [General] Allow followers to follow non-authority players through cells 7 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.
7 years ago
David Cernat 17c234d9ca [Client] Use initial values for LocalPlayer and LocalActor killers 7 years ago
David Cernat 97cd3effa7 [Client] Make actor debug consistent with object debug 7 years ago
David Cernat c075496748 [General] Replace deathReason in death packets with a killer variable
Add serverside script functions for determining the killers of both players and actors.

Use unsigned ints for script functions returning an object or actor's refNumIndex or mpNum.

Remove updateDeadState() from LocalPlayer and make its code part of updateStatsDynamic() for simplicity.
7 years ago
David Cernat 7ffdb18bf9 [General] Implement ActorDeath packet, part 1
ActorDeath packets are sent for dead actors before their StatsDynamic packets. They contain the actor's deathReason in a manner similar to that of PlayerDeath packets.

A future commit will replace the deathReason with a variable named killer which will be an mwmp::Target.
7 years ago
David Cernat b9520c11da [General] Rework PlayerEquipment packets so they are of minimal size
Moreover, rename BaseNetCreature's equipedItems into equipmentItems.

(cherry picked from commit d1ad0c91f8)
7 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.
7 years ago
David Cernat 20caea083a [Client] Use correct count for items in equipment packets
Previously, throwing weapon sync was completely broken for players, as the count for their equipped throwing weapons was never set and – as a result – defaulted to a count of 1 on other clients. As a result, any time a player threw a dart, they would then appear as having switched to hand-to-hand for other players.

Moreover, the count of equipped items was mistakenly based on the total count of items with that refId in the inventory. As a result, if – for example – I equipped 1 Daedric Longsword and had 4 others in my inventory, my DedicatedPlayer on other clients would equip a Daedric Longsword with a count of 5. If I was overencumbered by having that many Daedric Longswords on me and then dropped 4 of them, allowing myself to move again, my DedicatedPlayer would still walk around with 5 Daedric Longswords and lack animations due to still being overencumbered on the other clients.

These problems were less prevalent for actors, but their equipment updating code has also been changed to match that of players.
7 years ago
David Cernat 77ce05b7d6 [Client] Fix spell casting probability synchronization 8 years ago
David Cernat 4db64e1721 [Client] Synchronize spellcasting for non-bipedal creatures 8 years ago
David Cernat 796118c266 [Client] Send StatsDynamic packets more often 8 years ago
Koncord 9519c467eb [Client] Simplify updateEquipment for LocalPlayer & LocalActor 8 years ago
Koncord 596f42e408 [Client] Fix "invalid iterator" error 8 years ago
Koncord aa12b35d03 [Client] Update LocalActor to C++11 8 years ago
Koncord 6222c20e82 [Client] Convert MechanicsHelper to namespace 8 years ago
David Cernat 312fc84a6f [Client] Use update timer in mwmp::Cell instead of LocalActor 8 years ago
David Cernat ea2a060c67 [Client] Sync actor movements from interiors to exteriors & vice versa 8 years ago
David Cernat 311ce4119d [General] Fix logic issues related to ActorEquipment 8 years ago
David Cernat 4f273932af [General] Implement sending and reading of ActorEquipment packets 8 years ago
David Cernat 5a786e6c56 [Client] Make all LocalActors get initialized correctly again 8 years ago
David Cernat d7d4dec200 [Client] Don't spam AnimFlags packets when a Player or Actor is flying 8 years ago
David Cernat cc559cf8e2 [General] Don't send packets for dead LocalActors, to fix Position spam 8 years ago
David Cernat 3def111ca1 [Client] Fix graphical glitches related to DedicatedActor initialization 8 years ago
David Cernat ef12a37d59 [Client] Send ActorPosition packets based on a timeout 8 years ago
David Cernat db3859565b [Client] Send ActorStatsDynamic packets only when stats change enough 8 years ago
David Cernat e05adbfe65 [Client] Add better debug for Actor cell changes 8 years ago
David Cernat e8e0090b9b [General] Use new SimpleCreatureStats struct in BaseActor 8 years ago
David Cernat ea7c3f2dc7 [Client] Make tes3mp combat code work with Creatures, not just NPCs 8 years ago
David Cernat 841e6a63f8 [Client] Initialize Creatures as LocalActors 8 years ago
David Cernat 1f6ba9d9ee [Client] Remove jump check from LocalActor that is irrelevant for NPCs 8 years ago
David Cernat 871d8c8308 [Client] Send and read ActorCellChange packets 8 years ago
David Cernat 2e8714afaa [Client] Rethink and restructure tes3mp combat code so it works for NPCs 8 years ago
David Cernat f0f0b2dcc9 [General] Send and read ActorSpeech packets 8 years ago
David Cernat d2178e5414 [Client] Assign LocalActor movement settings before rotations get reset 8 years ago
David Cernat 1fb11dafef [General] Send and read ActorStatsDynamic packets 8 years ago
David Cernat 2872675f5e [General] Send and read ActorAnimPlay packets 8 years ago
David Cernat 56aeb85965 [Client] Update method names in ActorList 8 years ago
David Cernat e7960eee76 [General] Rename DrawState packets into AnimFlags ones for clarity 8 years ago
David Cernat de8d28e2c3 [Client] Improve logic for updating LocalActors & sending their packets 8 years ago
David Cernat d2fe777f89 [General] Send and read ActorDrawState packets 8 years ago
David Cernat 9852076590 [Client] Send all NPC data to newly arriving players 8 years ago
David Cernat d14102716d [Client] Retool LocalActors and DedicatedActors for ActorPosition packet 8 years ago
David Cernat a5d0486c82 [General] Set actor data correctly 8 years ago
David Cernat d3f3fb5d05 [Client] Correctly implement movement animation sync for NPCs 8 years ago
David Cernat d829d219c3 [General] Add (very) partial animation sync for NPCs 8 years ago