mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 13:56:45 +00:00 
			
		
		
		
	[Client] Use ObjectActivate packets when picking up items from inventory
This commit is contained in:
		
							parent
							
								
									792fbfe2e1
								
							
						
					
					
						commit
						49fa35a516
					
				
					 3 changed files with 33 additions and 17 deletions
				
			
		|  | @ -306,7 +306,26 @@ namespace MWGui | |||
|             { | ||||
|                 // pick up object
 | ||||
|                 if (!object.isEmpty()) | ||||
|                     MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(object); | ||||
|                 /*
 | ||||
|                     Start of tes3mp change (major) | ||||
| 
 | ||||
|                     Disable unilateral picking up of objects on this client | ||||
| 
 | ||||
|                     Instead, send an ID_OBJECT_ACTIVATE packet every time an item is made to pick up | ||||
|                     an item here, and expect the server's reply to our packet to cause the actual | ||||
|                     picking up of items | ||||
|                 */ | ||||
|                     //MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(object);
 | ||||
|                 { | ||||
|                     mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); | ||||
|                     objectList->reset(); | ||||
|                     objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; | ||||
|                     objectList->addObjectActivate(object, MWMechanics::getPlayer()); | ||||
|                     objectList->sendObjectActivate(); | ||||
|                 } | ||||
|                 /*
 | ||||
|                     End of tes3mp change (major) | ||||
|                 */ | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -718,21 +718,6 @@ namespace MWGui | |||
|         // can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object
 | ||||
|         MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player); | ||||
| 
 | ||||
|         /*
 | ||||
|             Start of tes3mp addition | ||||
| 
 | ||||
|             Send an ID_OBJECT_DELETE packet every time an item from the world is picked up | ||||
|             by the player through the inventory HUD | ||||
|         */ | ||||
|         mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); | ||||
|         objectList->reset(); | ||||
|         objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; | ||||
|         objectList->addObjectDelete(object); | ||||
|         objectList->sendObjectDelete(); | ||||
|         /*
 | ||||
|             End of tes3mp addition | ||||
|         */ | ||||
| 
 | ||||
|         // remove from world
 | ||||
|         MWBase::Environment::get().getWorld()->deleteObject (object); | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,6 +17,8 @@ | |||
| #include "../mwbase/windowmanager.hpp" | ||||
| 
 | ||||
| #include "../mwgui/container.hpp" | ||||
| #include "../mwgui/inventorywindow.hpp" | ||||
| #include "../mwgui/windowmanagerimp.hpp" | ||||
| 
 | ||||
| #include "../mwmechanics/aifollow.hpp" | ||||
| #include "../mwmechanics/spellcasting.hpp" | ||||
|  | @ -321,7 +323,17 @@ void ObjectList::activateObjects(MWWorld::CellStore* cellStore) | |||
| 
 | ||||
|             if (activatingActorPtr) | ||||
|             { | ||||
|                 MWBase::Environment::get().getWorld()->activate(ptrFound, activatingActorPtr); | ||||
|                 // Is an item that can be picked up being activated by the local player with their inventory open?
 | ||||
|                 if (activatingActorPtr == MWBase::Environment::get().getWorld()->getPlayerPtr() && | ||||
|                     (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Container || | ||||
|                     MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Inventory)) | ||||
|                 { | ||||
|                     MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(ptrFound); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     MWBase::Environment::get().getWorld()->activate(ptrFound, activatingActorPtr); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue