Commit Graph

795 Commits (ffi-server-rewrite)

Author SHA1 Message Date
David Cernat 2f1ef049d2 [Server] Turn sendToAttachedPlayer into skipAttachedPlayer
Unfortunately, default values set in the C++ code for our script function parameters don't actually seem to work, and they always default to false because they receive a nil value from Lua. As a result, to not break compatibility with previous scripts, I've decided to use a skipAttachedPlayer argument instead so it can default to false while still providing the same benefits that sendToAttachedPlayer provided.
7 years ago
David Cernat 141e404ed9 [Server] Move server administration functions to ServerFunctions class 7 years ago
David Cernat 6041425122 [Server] Move Chat functions to new ChatFunctions class 7 years ago
David Cernat 6a3fbf4e98 [Server] Use consistent arguments for script functions that send packets
Previously, there was a confusing separation between script functions that had a "broadcast" argument and script functions that had a "toOthers" argument.

Those with broadcast sent the packet to all players on the server when broadcast was true. Those with toOthers sent the packet to all players other than the packet's attached player.

The former was based on the pattern of the original SendMessage() script function. The latter more closely resembled RakNet's own broadcast argument as seen here:

https://github.com/TES3MP/CrabNet/blob/master/include/raknet/RakPeer.h#L219

This commit makes it so all sending functions have a sendToOtherPlayers argument that is false by default and a sendToAttachedPlayer that is true by default. This should simultaneously allow sending to be more intuitive, while not breaking previous existing scripts to a significant degree.

Additionally, this commit also reduces some code repetition for all instances of packet-fetching in script functions.
7 years ago
David Cernat 14e4f64296 [Server] Add GetVideoFilename() and SendVideoPlay() script functions 7 years ago
David Cernat 7f0549fc4f [Server] Remove hardcoded sync for VideoPlay and add OnVideoPlay event 7 years ago
David Cernat ae8b5a0709 [Server] Remove hardcoded sync for Place, Spawn & other Object packets 7 years ago
David Cernat b0bd12f9dd Merge branch '0.6.3' of https://github.com/TES3MP/openmw-tes3mp into 0.6.3 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 934e592bdb [Server] Make spacing in CharClass consistent with other categories 7 years ago
David Cernat e8ce009521 [Server] Use regular int as return value for GetObjectSummonerPid()
Additionally, clarify descriptions of script functions for getting information about summoners.
7 years ago
Koncord 470ea50b54 [General] Use LuaJit instead default Lua 7 years ago
David Cernat 7010575075 [Server] Return -1 in GetObjectSummonerPid() when the player is invalid 7 years ago
David Cernat 3438061b55 [Server] Add script function for getting a summoner's pid
Additionally, fix typos in the comments for other script functions relating to summoners.
7 years ago
Koncord 1f4e6e9114 [General] Add integrity checks to Handshake packet 7 years ago
Koncord fa2bf0663e [General] Simplify vectorContains 7 years ago
David Cernat 3aa125ceda [Server] Add script functions for getting a summoner's refId and indexes 7 years ago
Koncord d999cc0d55 [General] Add packetValid flag to packets 7 years ago
David Cernat f9ebe400f7 [Server] Add script function for checking if object's summoner is player 7 years ago
Koncord d162f6fd3a [General] Explicitly use limitations of the master server 7 years ago
Koncord 62877f38b7 [General] Remove Terra support
Use LuaJIT instead.
7 years ago
Koncord 685a80887b Remove Pawn support 7 years ago
David Cernat bef53749ed [General] Replace BaseObject's hasMaster variable with isSummon
Additionally, add a GetObjectSummonState() script function to the server.
7 years ago
David Cernat 958b220835 [General] Send summon duration to server in ObjectSpawn packets 7 years ago
David Cernat 9102df7fde [General] Make WorldCollisionOverride also work with specific refIds
For now, this only makes it possible to enforce collision for specific refIds for placed objects.
7 years ago
David Cernat 84af9d9999 [Server] Reorder world map script functions 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 15bfa30070 [Server] Make it possible to resend received worldstates 7 years ago
David Cernat 914b79fcc9 [General] Make it possible to check which placed objects have containers 7 years ago
David Cernat 5bb2ba1e9e [General] Limit maximum imageData size in WorldMap packets 7 years ago
David Cernat c3c7f2c8f9 [Server] Don't automatically synchronize ObjectDelete packets 7 years ago
David Cernat aa3639f2da
Merge pull request #450 from TES3MP/0.6.2
Add 0.6.2 commits up to 19 Jun 2018
7 years ago
David Cernat 29be79e852 [General] Switch RakNet enums to CrabNet enums
CrabNet is TES3MP's fork of RakNet that has deviated too far from RakNet to still be compatible with it.
7 years ago
David Cernat 72862dc255 [General] Turn PlayerMap into WorldMap, now a Worldstate packet 7 years ago
David Cernat bacecc93e3 [Server] Make it possible to resend a received ObjectList of any kind
Additionally, make existing related functions less confusing.
7 years ago
David Cernat 3efe05a88e [General] Implement WorldCollisionOverride packet 7 years ago
David Cernat 49ea76aa9d [General] Add notes for InputDialogs in GUIBoxes packet 7 years ago
David Cernat 3b5fb9cd6b [General] Make it possible to set year via WorldTime 7 years ago
David Cernat 4acf93b7db [General] Make it possible to set days passed via WorldTime 7 years ago
David Cernat 46744ee90f [General] Make WorldTime script functions more consistent with others 7 years ago
David Cernat 8d36d0d945 [General] Make it possible to change world's time scale via WorldTime 7 years ago
David Cernat 0be6de6607 [General] Turn RecordDynamic into a Worldstate packet 7 years ago
David Cernat 02ba641bef [Server] Use correct index changes for dynamic stat script functions 7 years ago
David Cernat da66face25 [General] Rename GameTime packet into WorldTime 7 years ago
David Cernat 5af1150ab2 [General] Turn GameTime into a Worldstate packet 7 years ago
David Cernat e87e1dbb30 [General] Fix Worldstate packets by adding missing lines 7 years ago
David Cernat 43a944ddaf [General] Add and implement new Worldstate packet type 7 years ago
David Cernat e8b22a2e5e [Server] Use correct source group for ObjectProcessors 7 years ago
David Cernat 049d0d9ba7 [General] Fix remaining references to world packets/events 7 years ago
David Cernat 2ac334664b [Server] Add deprecated alternatives for ObjectList functions
This will avoid server crashes in older scripts.
7 years ago
David Cernat 02d8e08c58 [Server] Rename WorldProcessor into ObjectProcessor 7 years ago
David Cernat bef36f77ca [Server] Create WorldstateFunctions and move GameTime functions there 7 years ago
David Cernat d4f7936a76 [Server] Rename WorldFunctions into ObjectFunctions 7 years ago
David Cernat 78234f9071 [General] Rename Event into ObjectList & WorldObject into BaseObject 7 years ago
David Cernat 6bf3a0be1e [General] Rename WorldPackets into ObjectPackets for clarity 7 years ago
David Cernat 77389538e8 [General] Implement ActorAI packet, part 1
The server can now make actors become followers of players or other actors.
7 years ago
David Cernat 12727b66ea [Server] Use consistent variable names in map tile script functions 7 years ago
David Cernat 715012f087 [General] Implement sending of image data for map tiles in PlayerMap 7 years ago
David Cernat 980ddcb114 [Server] Add DoesFileExist() script function 7 years ago
David Cernat 51fd937250 [Server] Remove hardcoded debug messages when using script callbacks 7 years ago
David Cernat 099f85be0a [General] Implement PlayerMomentum packet & associated script functions 7 years ago
David Cernat 4b501a39f4 [General] Implement DoorDestination packet & associated script functions 7 years ago
David Cernat d47b06fe7a [Server] Prevent SetGameMode() and SetHostname() from crashing server
Previously, turning off communication with the MasterServer from the server config and then attempting to use SetGameMode() or SetHostname() led to a server crash.
7 years ago
David Cernat 66d5109509 [General] Fix information exchange for players sharing a cell
Previously, two players entering the same cell only sent and received their latest changes for dynamic stats, attributes, skills and equipment when they started sharing that cell.
7 years ago
David Cernat a541d7df3c [General] Rework PlayerStatsDynamic packets so they are of minimal size
(cherry picked from commit fc5e883160)
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 c5b08d6109 [General] Simplify storing of attribute and skill index changes
(cherry picked from commit bd9e8bd10f)
7 years ago
David Cernat 7b702bf8c2 [General] Add and use utility function for int value checks in vectors
(cherry picked from commit a796f81444)
7 years ago
David Cernat b6099024df [General] Rework PlayerAttribute packets so they are of minimal size
Previously, whenever a single attribute value changed for a player, that player then sent a PlayerAttribute packet with all values for all 8 attributes.

This did not cause anywhere as much packet spam as PlayerSkill used to, but there was no good reason not to fix it as well.

(cherry picked from commit b0965f094a)
7 years ago
David Cernat 78441c769a [General] Rework PlayerSkill packets so they are of minimal size
Previously, whenever a single skill value changed for a player, that player then sent a PlayerSkill packet with all values for all 27 skills, plus the player's progress towards the next level and the bonuses to each attribute on the next level up as the result of sklll increases thus far.

This commit makes PlayerSkill contain only the values of specific skills, moves the player's progress towards the next level to PlayerLevel packets, and moves the bonuses to each attribute on the next level up to PlayerAttribute packets.

Players now also send a PlayerSkill packet whenever their progress towards a new point in a skill changes. This was previously avoided so as to not have massive packet spam.

(cherry picked from commit ef79a98544)
7 years ago
David Cernat 28f1c1b0d3 [General] Rework CharGen slightly for clarity purposes
Previously, charGenStage.end was doing double duty as both the variable indicating the number of CharGen stages and – when set to 0 – the variable indicating that CharGen was over. The latter role is now filled by a new boolean.

(cherry picked from commit 926106cf8c)
7 years ago
David Cernat 306252ecdc [Server] Fix confusing script function names 7 years ago
David Cernat 311f770de7 [Server] Document script functions, part 4
Additionally, clean up some variable names.
7 years ago
David Cernat 76e7392a84 [Server] Create ShapeshiftFunctions and move relevant functions there 7 years ago
David Cernat 2bb7a4253e [Server] Forcibly kick players after too many handshake attempts 7 years ago
David Cernat 36e0f0471a [Server] Add SetCreatureNameDisplayState script function 7 years ago
David Cernat db41704e52 [Server] Use clearer function name for checking creature name display 7 years ago
David Cernat bdc9132e7c [General] Add SetResetStats server script function
Add reading and writing of resetStats variable to PlayerBaseInfo Packet

Fix typos in various server script function descriptions
7 years ago
David Cernat 34893ff631 [Server] Split up handshake handling into multiple functions for debug
Unfortunately, the handshake attempt limit implemented in 4ebfcc4a21 for 0.7 and then ported over to 0.6 in a3a341fee6 does not appear to work properly, which is why gathering more information on it is important.
7 years ago
David Cernat c8abd11f5d [General] Move creature disguises for players to PlayerShapeshift packet
Additionally, make associated variables clearer, and move associated server script functions next to other shapeshifting functions.
7 years ago
David Cernat 76468dc8c6 [Server] Remove remnant of hardcoded container sync 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 b249162ca1 [General] Implement setting of enforced client log level in GameSettings
Certain servers do not want the players to have debug information about the locations and actions of other players, so a client's log level can now be enforced by the server via the GameSettings packet.
7 years ago
David Cernat a3a341fee6 [Server] Reimplement 4ebfcc4a21 for 0.6 7 years ago
David Cernat 60f686ee43 [General] Implement setting of physics framerate as part of GameSettings 7 years ago
David Cernat 74765b3ace [General] Implement selected spell sync as part of PlayerMiscellaneous 7 years ago
David Cernat 029dfc56ba [General] Implement player scale as part of PlayerShapeshift 7 years ago
David Cernat 66078bfea7 [General] Implement Mark location sync as part of PlayerMiscellaneous 7 years ago
David Cernat 989f6e6b51 [General] Implement PlayerReputation packet 7 years ago
David Cernat 88ae0772cf [Server] Initialize new processors and fix issues with RecordDynamic 7 years ago
David Cernat 02af7f6ba1 [General] Add placeholders for new packet types 7 years ago
David Cernat 420dab10e1 [General] Track objects directly placed by players in ObjectPlace
This allows the OnPCDrop variable to get set correctly even when object placements have to go through the server first in order to gain a unique multiplayer index (mpNum).

Among other things, this makes it possible to roll marijuana joints in the popular mod "Tribunal Code Patch".
7 years ago
David Cernat 9935f56d46 [General] Use doubles instead of ints for enchantmentCharge
Additionally, include enchantmentCharges for items  in PlayerEquipment packets.
7 years ago
David Cernat 1cf2f35a28 [Server] Add script functions to set & get plugin enforcement state 7 years ago
David Cernat 47a3dc9ff2 [Server] Add broadcast argument to functions for sending WorldPackets 7 years ago
David Cernat 1e2517698d [Server] Send player speech and animation packets only to nearby players 7 years ago
David Cernat cac2c6c1e8 Merge pull request #360 from TES3MP/0.6.1-openmw-updates while resolving conflicts 7 years ago
David Cernat 993081ba1e [General] Add enchantmentCharge to worldObjects and items 7 years ago
David Cernat e97c9f72a2 [General] Rework getting/clearing of skill modifiers as with attributes 7 years ago
David Cernat 2944be18ae [Server] Actually, turn SetAttributeModifier into ClearAttributeModifier
There's no way SetAttributeModifier() was going to make sense if, say, a player had drunk 3 different potions fortifying the same attribute and was wearing equipment fortifying it as well. How would one change the sum modifier of those while accounting for each specific effect's duration and magnitude?

The only workable solution is to allow the server to clear the modifier.
7 years ago
David Cernat e8d636ebc3 [Server] Rework Get/SetAttributeCurrent into Get/SetAttributeModifier
As seen here, attributes don't use the concept of current values, but rather of value modifiers and value damage:

https://github.com/OpenMW/openmw/blob/master/apps/openmw/mwmechanics/stat.cpp#L217
7 years ago
David Cernat c9c363ebef [General] Allow GameSettings to set bed & wilderness resting separately 7 years ago
David Cernat 3508a16836 [General] Use GameSettings packet to set ability to rest and wait 7 years ago
David Cernat 6668b9ab42 [General] Implement ConsoleCommand packet 7 years ago
David Cernat be25decee2 [General] Implement PlayerSpeech packet 7 years ago
David Cernat 413893aa51 [General] Implement PlayerAnimPlay packet 7 years ago
David Cernat 50d5fffb7f [General] Add and implement PlayerQuickKeys packet 7 years ago
David Cernat a94d4ce6f5 Merge pull request #323 from TES3MP/0.6.1
Add hotfix commit for 0.6.1 from 23 Oct 2017
7 years ago
David Cernat 3aedc2e5bc [Server] Don't automatically share PlayerTopic packets between players 7 years ago
David Cernat ec2c964ae1 Merge pull request #311 from TES3MP/0.6.1
Add hotfix commit for 0.6.1 from 10 Oct 2017
7 years ago
David Cernat f532ab241d [Server] Avoid duplicates of the same player in a cell's loaders 7 years ago
David Cernat 3d38da0e85 [Server] Put includes in a specific order 7 years ago
David Cernat 61b1a59814 [General] Move server's version printing method to Utils 7 years ago
Koncord 74c9a26d16 [Server] Fix "wrong packet with id: 14" 7 years ago
David Cernat ac3254d85f [General] Don't send PlayerAttribute and PlayerSkill packets as werewolf
This will prevent the server from overwriting a player's human form stats with their werewolf form stats.

Additionally, share PlayerShapeshift packets last when exchanging data with another player.
7 years ago
David Cernat 98a7769b91 Merge branch 'master' into 0.6.0 7 years ago
David Cernat 499c7db121 [Server] Initialize interiors correctly if exterior 0, 0 has been loaded 7 years ago
David Cernat 833d2a5dbe Merge pull request #277 from TES3MP/0.6.0
Add hotfix commits for 0.6.0 up to 29 Aug 2017, part 1
7 years ago
David Cernat 92553b8e29 [Server] Log startup errors by not deleting logger too early 7 years ago
David Cernat cffd985038 Merge pull request #266 from TES3MP/0.6.0
Add hotfix commits for 0.6.0 up to 18 Aug 2017
7 years ago
David Cernat 0820b7e92b [Server] Add GetCaseInsensitiveFilename() script function
Additionally, make header order consistent in script function files.
7 years ago
David Cernat 0e2038f045 [General] Record and get player positions before their last cell change 8 years ago
Unknown bfbfbeac43 Added networking and saving for custom spells 8 years ago
David Cernat c9550fc560 [Server] Use case-insensitive filename comparison for plugins
Additionally, clarify the comments related to plugin comparison.
8 years ago
David Cernat 9d05063af4 [General] Add server script functions for banning & unbanning IPs
Additionally, use a more informative message for the client when trying to connecting to a server that it is banned from.
8 years ago
David Cernat d543edbd9a [Server] Make sure players are initialized as non-werewolves 8 years ago
David Cernat cd8d064761 [Server] Add PlayerShapeshift to PlayerCellChange's information exchange 8 years ago
David Cernat 8b79cdd4f4 [Server] Document script functions, part 3
Also reorder functions in Cells and CharClass so they are consistent with the rest.
8 years ago
David Cernat 5e5440b697 [Server] Document script functions, part 2 8 years ago
David Cernat cc91b32b2f [Server] Make spell script functions consistent with others 8 years ago
David Cernat 8bd33e5fbb [Server] Document script functions, part 1 8 years ago
David Cernat f65f996418 [Server] Add script functions for werewolf states 8 years ago
David Cernat 43a3daf0aa [General] Add & implement PlayerShapeshift packet for werewolf states 8 years ago
David Cernat ad9fa0631a [General] Rename jailText to jailEndText and add jailProgressText in PlayerJail 8 years ago
David Cernat e36c0afc59 [General] Send faction reputation via PlayerFaction packets 8 years ago
David Cernat be93ec8ef6 [General] Implement ObjectState packet 8 years ago
David Cernat 083b46394d [General] Add ignoreJailSkillIncreases to PlayerJail packets 8 years ago
David Cernat 5962570c48 [General] Add jailText to PlayerJail packets 8 years ago
David Cernat 3280f0c5ee [General] Implement PlayerJail packet
Rework server's DeathFunctions into MechanicsFunctions

Remove connection between PlayerResurrect and jailing
8 years ago
David Cernat b1b27728e2 [Server] Move functions dealing with PlayerKillCount to QuestFunctions 8 years ago
Koncord 9cc07f100c [Server] Add OnObjectState callback 8 years ago
David Cernat 3529f9b090 [General] Add placeholders for PlayerJail, ObjectState & ConsoleCommand 8 years ago
David Cernat 4e74910fdb [General] Disable automatic sync for PlayerJournal and PlayerFaction
Simplify PlayerFaction packets by removing BOTH action
8 years ago
David Cernat 6dde0ca9c9 [Server] Rework script functons by removing unnecessary vector buffers
Add new initialization script functions to allow clearing all player changes vectors in a manner consistent with Actor and World functions

Add toOthers boolean to all methods that send packets with player changes vectors
8 years ago
David Cernat 2c05b7f747 [Server] Rename InitiateEvent() into InitializeEvent() for consistency 8 years ago
David Cernat 1d504a665f [General] Add RANK, EXPULSION and BOTH actions to PlayerFaction packets 8 years ago
Koncord 940ae5c2fb [Server] Implement GetIP API function 8 years ago
Koncord 1f3cbb46e2 [Server] Use __ARM_ARCH definition for detecting ARM 8 years ago
Koncord 768790e9b4 [Server] Move Base processors and Initializer to processors subdirectory 8 years ago
Koncord 60ac884d13 [Server] Delete commented line 8 years ago