Logo

CS.RIN.RU - Steam Underground Community

IRC: #cs.rin.ru at irc.rizon.net
It is currently Friday, 17 Apr 2015, 22:31

English | Русский




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message

Post Post subject: Private Server Emulator for Ubi DRM?   
Posted: Tuesday, 28 Dec 2010, 16:56   
Advanced forumer Завсегдатай
Joined: Monday, 09 Jun 2008, 13:18
Posts: 193
we all know that most of the upcoming ubi titles will use the DRM, maybe,we can counter this by creating our own "DRM private Server"?
it's possible to create private Server for MMO's this day's{a lot of MMO's have it},and Ubi titles are becoming more and more like MMO's{in terms that you need to be connected to them all the time}
there is Steam Emulators that created here... I think to make this forum more popular,it might good idea to "expend" to another DRM service...


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Tuesday, 28 Dec 2010, 17:58   
Super flooder Почетный графоман
User avatar
Joined: Saturday, 01 Aug 2009, 12:29
Posts: 669
UnderGamer wrote:
we all know that most of the upcoming ubi titles will use the DRM, maybe,we can counter this by creating our own "DRM private Server"?
it's possible to create private Server for MMO's this day's{a lot of MMO's have it},and Ubi titles are becoming more and more like MMO's{in terms that you need to be connected to them all the time}
there is Steam Emulators that created here... I think to make this forum more popular,it might good idea to "expend" to another DRM service...


You sir, won the "Idiot Award". You didn't get it yet, do you? All the data changes by game and you can not predict that.

_________________
There are 10 types of people in this world:
Those who get Binary, And those who don't.


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Tuesday, 28 Dec 2010, 21:06   
Advanced forumer Завсегдатай
Joined: Monday, 09 Jun 2008, 13:18
Posts: 193
CPAMX wrote:
UnderGamer wrote:
we all know that most of the upcoming ubi titles will use the DRM, maybe,we can counter this by creating our own "DRM private Server"?
it's possible to create private Server for MMO's this day's{a lot of MMO's have it},and Ubi titles are becoming more and more like MMO's{in terms that you need to be connected to them all the time}
there is Steam Emulators that created here... I think to make this forum more popular,it might good idea to "expend" to another DRM service...


You sir, won the "Idiot Award". You didn't get it yet, do you? All the data changes by game and you can not predict that.

but you can find what cause the change... this kind of protection as been cracked before.... sure,it's was the "weaker" version,but basically same...


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Wednesday, 29 Dec 2010, 14:48   
Super flooder Почетный графоман
User avatar
Joined: Sunday, 31 Dec 2006, 14:07
Posts: 579
Every game is using different pairs.
Data used by the games is different.


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Wednesday, 29 Dec 2010, 18:30   
A+
User avatar
Joined: Wednesday, 26 Dec 2007, 00:42
Posts: 7319
UnderGamer wrote:
I think to make this forum more popular,it might good idea to "expend" to another DRM service...

Why would we want to do that in the first place?

And even if it has been cracked before, there is no way to create a DRM server that works for all games, and even better that works without any client-side cracking. For most MMORPGs, you can redirect the targeted server pretty easy. However, this is not the case here. You can't simply replace the IP address of UbiSoft's server somewhere (due to server-side certificates) and make it connect there. Instead, it requires heavy clientside hacking as well. So what would be the point of that?

_________________
Game Industry Guardian (1K+).


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Wednesday, 29 Dec 2010, 18:59   
Advanced forumer Завсегдатай
Joined: Monday, 09 Jun 2008, 13:18
Posts: 193
sigh... guess we have to stick to the "regular" methods to crack this DRM...
ho well,at least some progress as been actually made cracking the newest DRM games and I'm pretty sure AC:B will be under "heavy fire" from crackers...


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Thursday, 30 Dec 2010, 06:34   
Super flooder Почетный графоман
User avatar
Joined: Saturday, 01 Aug 2009, 12:29
Posts: 669
Krzywy wrote:
Every game is using different pairs.
Data used by the games is different.


You also didn't get it either, only AC2 was using "pairs" the rest used different things such as door times on Prince of Persia and the whole Lever functionality was server side. Stop believing that this shit is so easy, its not.

If anyone here had at least a IQ over 100 you could assume what all the Data does and properly emulate it, but humanity gets more stupid by each new born child.

_________________
There are 10 types of people in this world:
Those who get Binary, And those who don't.


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Thursday, 30 Dec 2010, 22:12   
Super flooder Почетный графоман
User avatar
Joined: Sunday, 31 Dec 2006, 14:07
Posts: 579
Code that SKiDROW published for PoP emulation to prove their work.
Quite good in my opinion.

  1. #include "StdAfx.h"
  2. #include "DataMgrPoP.h"
  3. #include "Values.h"
  4.  
  5. static CDataMgrPoP s_DataMgrPoP;
  6. CDataMgrPoP* g_pDataMgrPoP = &s_DataMgrPoP;
  7.  
  8. static CPoPTimer s_Timer;
  9.  
  10. CDataMgrPoP::CDataMgrPoP(void) : m_Worker(m_IO)
  11. {
  12.     m_pPipe = NULL;
  13.     m_Thread = boost::thread( boost::bind(&boost::asio::io_service::run, &m_IO) );
  14.  
  15.     m_uCurrentLevel = 0;
  16.     m_uCurrentXP = 0;
  17.  
  18. #if !defined(_DEBUG) && !defined(_LOG)
  19.     CDataBuffer Doors(ValuesPoPDoors, sizeof(ValuesPoPDoors));
  20. #else
  21.     std::string strData;
  22.     std::string strFile = GetCurrentDir();
  23.     strFile += "\\doors.bin";
  24.  
  25.     if( !LoadFileData(strFile, strData) )
  26.     {
  27.         LOG_PRINT("WARNING: Unable to load file data '" << strFile << "'\n");
  28.     }
  29.  
  30.     CDataBuffer Doors;
  31.     Doors.Write( strData.c_str(), strData.size() );
  32.     Doors.Seek(0, SEEK_SET);
  33. #endif
  34.     while( !Doors.IsEOB() )
  35.     {
  36.         uint32 uDoorId;
  37.         uint32 uOpenTime;
  38.         uint32 uOpenDelay;
  39.         uint32 uCloseTime;
  40.         uint32 uCloseDelay;
  41.         Doors >> uDoorId;
  42.         Doors >> uOpenTime;
  43.         Doors >> uOpenDelay;
  44.         Doors >> uCloseTime;
  45.         Doors >> uCloseDelay;
  46.  
  47.         boost::shared_ptr<CPoPDoor> Door( new CPoPDoor(uDoorId, uOpenTime, uOpenDelay, uCloseTime, uCloseDelay, m_IO) );
  48.         m_vecDoors.push_back(Door);
  49.     }
  50.  
  51.     // XP to next Level, Level
  52.     for(int i = 0; i < 15; i++)
  53.         m_vecLevels.push_back( std::make_pair((i + 1) * 20, i) );   // Till 300
  54.     for(int i = 15; i < 50; i++)
  55.         m_vecLevels.push_back( std::make_pair(300, i) );            // 300 but next level
  56.  
  57.     // Skills
  58.     // 0A 0B 05 09 06 08 04 07 10 0E 0F 11 12 13 14
  59.     PoPUpgrade_t* pUpgrade = NULL;
  60.  
  61.     pUpgrade = InitUpgrade(0x00, 0x01, 1);  // Rewind & Other.
  62.     pUpgrade->vecFields[0] = 1;
  63.  
  64.     pUpgrade = InitUpgrade(0x03, 0x03, 1);  // Solid water & Other.
  65.     pUpgrade->vecFields[0] = 1;
  66.  
  67.     pUpgrade = InitUpgrade(0x04, 0x0A, 1);  // Time Power - 1 level.
  68.  
  69.     pUpgrade = InitUpgrade(0x05, 0x0B, 1);  // Flight Boost - 1 level
  70.     pUpgrade = InitUpgrade(0x06, 0x05, 1);  // Flow Power - 1 level.
  71.  
  72.     pUpgrade = InitUpgrade(0x07, 0x09, 1);  // Heavy Kick - 1 level.
  73.     pUpgrade = InitUpgrade(0x08, 0x06, 1);  // Double Health - 1 level.
  74.     pUpgrade = InitUpgrade(0x09, 0x08, 1);  // Double Energy - 1 level.
  75.     pUpgrade = InitUpgrade(0x0A, 0x04, 1);  // Aerial Boost - 1 level.
  76.     pUpgrade = InitUpgrade(0x0B, 0x07, 1);  // Power Attack - 1 level.
  77.     pUpgrade = InitUpgrade(0x0C, 0x10, 4);  // Stone Armor - 4 levels
  78.     pUpgrade = InitUpgrade(0x0D, 0x0E, 4);  // Whirlwind - 4 levels
  79.     pUpgrade = InitUpgrade(0x0E, 0x0F, 4);  // Ice Blast - 4 levels
  80.     pUpgrade = InitUpgrade(0x0F, 0x11, 4);  // Trial of Flame - 4 levels
  81.  
  82.     pUpgrade = InitUpgrade(0x10, 0x12, 4);  // Health Upgrade - 4 levels
  83.     pUpgrade->vecFields[0] = 1; // Not 0 as default
  84.  
  85.     pUpgrade = InitUpgrade(0x11, 0x13, 4);  // Energy Slot - 4 levels
  86.     pUpgrade->vecFields[0] = 1; // Not 0 as default
  87.  
  88.     pUpgrade = InitUpgrade(0x12, 0x14, 2);  // Battle rage / Battle Fury - 2 levels.
  89. }
  90.  
  91. CDataMgrPoP::~CDataMgrPoP(void)
  92. {
  93.     m_IO.stop();
  94.  
  95.     if( m_Thread.joinable() )
  96.         m_Thread.join();
  97. }
  98.  
  99. bool CDataMgrPoP::LoadUpgrades()
  100. {
  101.     std::string strSavePath = GetSaveGamePath(*g_puProdId);
  102.     std::string strUpgradeFile = strSavePath;
  103.     strUpgradeFile += "\\upgrades.ravcpa";
  104.  
  105.     std::ifstream fUpgrades;
  106.     fUpgrades.open(strUpgradeFile.c_str(), std::ios::binary);
  107.  
  108.     if( !fUpgrades.is_open() )
  109.         return false;
  110.  
  111.     CDataBuffer Packet;
  112.     std::string strPacket;
  113.     std::string strData;
  114.    
  115.     std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  116.     for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  117.     {
  118.         for( std::size_t i = 0; i< (*itr)->vecFields.size(); i++ )
  119.         {
  120.             uint8 uUpgrade;
  121.             fUpgrades.read( (char*)&uUpgrade, sizeof(uint8) );
  122.  
  123.             if( fUpgrades.fail() )
  124.                 break;
  125.  
  126.             (*itr)->vecFields[i] = uUpgrade;
  127.         }
  128.     }
  129.  
  130.     fUpgrades.close();
  131.     return true;
  132. }
  133.  
  134. bool CDataMgrPoP::SaveUpgrades()
  135. {
  136.     std::string strSavePath = GetSaveGamePath(*g_puProdId);
  137.     std::string strUpgradeFile = strSavePath;
  138.     strUpgradeFile += "\\upgrades.ravcpa";
  139.  
  140.     std::ofstream fUpgrades;
  141.     fUpgrades.open(strUpgradeFile.c_str(), std::ios::binary);
  142.  
  143.     if( !fUpgrades.is_open() )
  144.         return false;
  145.  
  146.     std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  147.     for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  148.     {
  149.         for( std::size_t i = 0; i< (*itr)->vecFields.size(); i++ )
  150.         {
  151.             uint8 uUpgrade = (*itr)->vecFields[i];
  152.             fUpgrades.write( (char*)&uUpgrade, sizeof(uint8) );
  153.         }
  154.     }
  155.  
  156.     fUpgrades.close();
  157.     return true;
  158. }
  159.  
  160. PoPUpgrade_t* CDataMgrPoP::InitUpgrade(uint32 uClientId, uint32 uServerId, uint8 uFields)
  161. {
  162.     PoPUpgrade_t* pUpgrade = new PoPUpgrade_t;
  163.     pUpgrade->uServerId = uServerId;
  164.     pUpgrade->uClientId = uClientId;
  165.  
  166.     for( uint8 i = 0; i < uFields; i++ )
  167.         pUpgrade->vecFields.push_back(0);   // Default is 0
  168.  
  169.     m_vecUpgrades.push_back( boost::shared_ptr<PoPUpgrade_t>(pUpgrade) );
  170.  
  171.     return pUpgrade;
  172. }
  173.  
  174. PoPUpgrade_t* CDataMgrPoP::GetUpdatedByGameId( uint32 uGameId )
  175. {
  176.     std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  177.     for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  178.     {
  179.         if( (*itr)->uClientId == uGameId )
  180.             return (*itr).get();
  181.     }
  182.     return NULL;    // Not found.
  183. }
  184.  
  185. PoPUpgrade_t* CDataMgrPoP::GetUpdatedByServerId( uint32 uServerId )
  186. {
  187.     std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  188.     for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  189.     {
  190.         if( (*itr)->uServerId == uServerId )
  191.             return (*itr).get();
  192.     }
  193.     return NULL;    // Not found.
  194. }
  195.  
  196. PoPUpgrade_t* CDataMgrPoP::UnlockUpgrade(uint16 uGameId, uint16 uFieldIndex, uint8 uFlag, bool bUnlockNextLevel)
  197. {
  198.     PoPUpgrade_t* pUpgrade = GetUpdatedByGameId(uGameId);
  199.     if(pUpgrade)
  200.     {
  201.         if( uFieldIndex >= pUpgrade->vecFields.size() )
  202.             return pUpgrade;
  203.  
  204.         pUpgrade->vecFields[uFieldIndex] = uFlag;
  205.         if( bUnlockNextLevel )
  206.         {
  207.             if( uFieldIndex + 1 < pUpgrade->vecFields.size() )
  208.                 pUpgrade->vecFields[uFieldIndex + 1] = 0x01;
  209.         }
  210.     }
  211.     return pUpgrade;
  212. }
  213.  
  214. uint8 CDataMgrPoP::GetUpgradeLevel(uint8 uGameId)
  215. {
  216.     uint8 uLevel = 0;
  217.  
  218.     PoPUpgrade_t* pUpgrade = GetUpdatedByGameId(uGameId);
  219.     if(pUpgrade)
  220.     {
  221.         std::vector<uint8>::iterator itr;
  222.         for( itr = pUpgrade->vecFields.begin(); itr != pUpgrade->vecFields.end(); itr++ )
  223.         {
  224.             if( (*itr) == 0x02 )
  225.                 uLevel++;
  226.         }
  227.     }
  228.  
  229.     return uLevel;
  230. }
  231.  
  232. CPoPLever* CDataMgrPoP::CreateLever( uint32 uLeverId )
  233. {
  234.     CPoPLever* pLever = new CPoPLever(m_IO, uLeverId);
  235.     m_vecLever.push_back( boost::shared_ptr<CPoPLever>(pLever) );
  236.  
  237.     return pLever;
  238. }
  239.  
  240. void CDataMgrPoP::DeleteLever( uint32 uLeverId )
  241. {
  242.     std::vector<boost::shared_ptr<CPoPLever>>::iterator itr;
  243.     for(itr = m_vecLever.begin(); itr != m_vecLever.end(); itr++)
  244.     {
  245.         if( (*itr)->LeverId() == uLeverId )
  246.         {
  247.             m_vecLever.erase(itr);
  248.             return;
  249.         }
  250.     }
  251. }
  252.  
  253. CPoPLever* CDataMgrPoP::GetLeverById( uint32 uLeverId )
  254. {
  255.     std::vector<boost::shared_ptr<CPoPLever>>::iterator itr;
  256.     for(itr = m_vecLever.begin(); itr != m_vecLever.end(); itr++)
  257.     {
  258.         if( (*itr)->LeverId() == uLeverId )
  259.             return (*itr).get();
  260.     }
  261.     return NULL;
  262. }
  263.  
  264. uint32 CDataMgrPoP::GetMaxXPPerLevel( uint32 uLevel )
  265. {
  266.     std::vector<std::pair<uint32, uint32>>::iterator itr;
  267.     for( itr = m_vecLevels.begin(); itr != m_vecLevels.end(); itr++ )
  268.     {
  269.         if( (*itr).second == uLevel )
  270.             return (*itr).first;
  271.     }
  272.     return 0;
  273. }
  274.  
  275. void CDataMgrPoP::OnConnect( CPipeInstance* pPipe )
  276. {
  277.     m_pPipe = pPipe;
  278.  
  279.     uint32 Temp32;
  280.  
  281.     CDataBuffer Packet;
  282.     Packet << *g_puProdId;
  283.     Packet << (uint32)endian_swap((Temp32 = 0x000000001));
  284.     Packet << (uint32)endian_swap((Temp32 = 0x000000001));
  285.  
  286.     std::string strPacket1 = MakePacket(0, Packet.Buffer());
  287.     std::string strPacket2 = MakePacket(6);
  288.     std::string strPacket3 = MakePacket(2);
  289.  
  290.     pPipe->Write( strPacket1 );
  291.     pPipe->Write( strPacket2 );
  292.     pPipe->Write( strPacket3 );
  293.  
  294.     s_Timer.Start();
  295. }
  296.  
  297. void CDataMgrPoP::ProcessPacket( CPipeInstance* pPipe, std::string& strPacket )
  298. {
  299.     m_pPipe = pPipe;
  300.  
  301.     uint16 usPacketId = *((uint16*)(strPacket.c_str() + 3));
  302.     endian_swap(usPacketId);
  303.  
  304.     std::string strData;
  305.  
  306.     if( strPacket.size() > 5 )
  307.     {
  308. #if defined(PRINT_PACKET)
  309.         LOG_PRINT("Packet: " << PrintPacket(strPacket) << "\n");
  310. #endif
  311.         strData = strPacket.substr(5);
  312.         CDataBuffer Buffer(strData.c_str(), strData.size());
  313.  
  314.         if( usPacketId == 0x0009 )
  315.         {
  316.             // Button
  317.             OnButtonStep(Buffer);
  318.         }
  319.         else if( usPacketId == 0x0008 )
  320.         {
  321.             // Area stuff
  322.             AreaLock(Buffer);
  323.         }
  324.         else if( usPacketId == 0x0007 )
  325.         {
  326.             // Area stuff
  327.             AreaUnlock(Buffer);
  328.         }
  329.         else if( usPacketId == 0x001A )
  330.         {
  331.             // Upgrades
  332.             GetUpgrades(Buffer);
  333.         }
  334.         else if( usPacketId == 0x0015 )
  335.         {
  336.             // Game start.
  337.             Upgrade(Buffer);
  338.         }
  339.         else if( usPacketId == 0x0017 )
  340.         {
  341.             // Info from game
  342.             UpdateGameInfo(Buffer);
  343.         }
  344.         else if( usPacketId == 0x0018 )
  345.         {
  346.             // XP Update
  347.             UpdateXP(Buffer);
  348.         }
  349.         else if( usPacketId == 0x000d )
  350.         {
  351.             // Open/Close door.
  352.             DoorEvent(Buffer);
  353.         }
  354.         else if( usPacketId == 0x0011 )
  355.         {
  356.             ObjectInit(Buffer);
  357.         }
  358.         else if( usPacketId == 0x0013 )
  359.         {
  360.             Lever(Buffer);
  361.         }
  362.         else if( usPacketId == 0x0012 )
  363.         {
  364.             OnLeverLock(Buffer);
  365.         }
  366.         else
  367.         {
  368.             if( usPacketId != 0x0005 && usPacketId != 0x0001d && usPacketId != 0x0004 && usPacketId != 0x0014 )
  369.             {
  370.                 // Unknown Packet.
  371.                 LOG_PRINT("Unknown Packet: " << PrintPacket(strPacket) << "\n");
  372.             }
  373.         }
  374.  
  375.  
  376.         /*
  377.         std::string strData;
  378.         strData.append("\x00\x00\x00\xA5\x00\x00\x00\x1E", 8);
  379.         std::string strPacket = MakePacket(0x19, strData);
  380.         pPipe->Write(strPacket);
  381.         */
  382.     }
  383. }
  384.  
  385. CPipeInstance* CDataMgrPoP::Pipe()
  386. {
  387.     return m_pPipe;
  388. }
  389.  
  390. void CDataMgrPoP::OnButtonStep(CDataBuffer& Buffer)
  391. {
  392.     uint32 uDoorId;
  393.     Buffer >> uDoorId;
  394.  
  395.     uint32 uDummy0;
  396.     Buffer >> uDummy0;
  397.  
  398.     bool bSteppedOff;
  399.     Buffer >> bSteppedOff;
  400.  
  401. do_again:
  402.  
  403.     std::vector<boost::shared_ptr<CPoPDoor>>::iterator itr;
  404.     for( itr = m_vecDoors.begin(); itr != m_vecDoors.end(); itr++ )
  405.     {
  406.         if( (*itr)->DoorId() != uDoorId )
  407.             continue;
  408.  
  409.         std::vector<uint32>::iterator itrLock;
  410.         for( itrLock = m_vecLocked.begin(); itrLock != m_vecLocked.end(); itrLock++ )
  411.         {
  412.             if( *itrLock == uDoorId )
  413.             {
  414.                 LOG_PRINT("Tried to enter locked area: " << (void*)uDoorId << "\n");
  415.                 m_vecLocked.erase(itrLock);
  416.                 return;
  417.             }
  418.         }
  419.  
  420.         if( !bSteppedOff )
  421.         {
  422.             (*itr)->BeginOpen(s_Timer.Elapsed());
  423.         }
  424.         else
  425.         {
  426.             (*itr)->BeginClose(s_Timer.Elapsed());
  427.         }
  428.  
  429.         return;
  430.     }
  431.  
  432. #if defined(CONFIG_SAFE_DOORS) && CONFIG_SAFE_DOORS
  433.     // In case a door doesn't exist, create a default one with 10sec close time, 1s open time.
  434.     CPoPDoor* pDoor = new CPoPDoor(uDoorId, 1000, 29, 10000, 29, m_IO);
  435.     m_vecDoors.push_back( boost::shared_ptr<CPoPDoor>(pDoor) );
  436.     LOG_PRINT("Door not found, creating: " << (void*)uDoorId << "\n");
  437.     goto do_again;
  438. #endif
  439.  
  440.     LOG_PRINT("Door not found: " << (void*)uDoorId << "\n");
  441. }
  442.  
  443. void CDataMgrPoP::AreaLock(CDataBuffer& Buffer)
  444. {
  445.     uint32 uAreaId;
  446.     uint32 uDummy0;
  447.     uint16 uLocked1;
  448.     uint16 uLocked2;
  449.     uint16 uDummy2;
  450.     uint8 uDummy1;
  451.     uint16 uAreaFlag;
  452.     std::string strData;
  453.     std::string strPacket;
  454.  
  455.     Buffer >> uAreaId;
  456.  
  457.     /*
  458.     std::string strRequest;
  459.     strRequest.assign( Buffer.Buffer() + Buffer.Offset(), Buffer.Size() - Buffer.Offset() );
  460.     */
  461.  
  462.     //0dce2162 00000001 00000000 0000 0001, 000000000000a040000000000000803f0000d040000000000001000001
  463.     //591c0fc1 00000001 00000000 0000 0000, 0000803f 000080400 00000000 00080400 000003f0 00000000 1000 00001
  464.     //347f98b0 00000001 00000000 0000 0000, 00000000 0000c0400 00000000 00080400 00000410 00000000 0010 00001
  465.     //6fdec12a 00000001 00000000 0000 0000, 0000803f 0000a0400 00000000 00080400 00000410 00000000 1000 00101
  466.     //0d920314 00000001 00000000 0000 0002, 0000803f 0000a0400 00000000 000803f0 000803f0 00000000 1000 00001
  467.     //6ab6464e 00000001 00000000 0000 0002, 00000000 0000a0400 00000000 000003f0 000a0400 00000000 0010 00001
  468.     //31644747 00000001 00000000 0000 0000, 00000000 0000a0400 00000000 00080400 00000410 00000000 0010 00001
  469.    
  470.     Buffer >> uDummy0;  // 00000001
  471.     Buffer >> uDummy0;  // 00000000
  472.  
  473.     Buffer >> uLocked1; // 0000
  474.     endian_swap(uLocked1);
  475.     Buffer >> uLocked2; // 0000 or 0002
  476.     endian_swap(uLocked2);
  477.  
  478.     Buffer >> uDummy0;  // 00000000
  479.     Buffer >> uDummy0;  // 00000000
  480.  
  481.     Buffer >> uDummy0;  // 00000000
  482.     Buffer >> uDummy0;  // 00000000
  483.  
  484.     Buffer >> uDummy0;  // 00000000
  485.     Buffer >> uDummy0;  // 00000000
  486.  
  487.     Buffer >> uAreaFlag;
  488.     endian_swap(uAreaFlag);
  489.  
  490.     if( (uLocked1 == 2 && uLocked2 == 1) || (uLocked1 == 0 && uLocked2 == 2) || (uLocked1 == 0 && uLocked2 == 1) )
  491.     {
  492.         LOG_PRINT("Locked Area: " << (void*)uAreaId << "\n");
  493.         m_vecLocked.push_back(uAreaId);
  494.     }
  495.     else
  496.     {
  497.         std::vector<uint32>::iterator itrLock;
  498.         for( itrLock = m_vecLocked.begin(); itrLock != m_vecLocked.end(); itrLock++ )
  499.         {
  500.             if( *itrLock == uAreaId )
  501.             {
  502.                 m_vecLocked.erase(itrLock);
  503.                 LOG_PRINT("Unlocked Area: " << (void*)uAreaId << "\n");
  504.                 break;
  505.             }
  506.         }
  507.     }
  508.  
  509.     CDataBuffer Packet;
  510.     Packet << uAreaId;
  511.  
  512.     if( uAreaFlag == 0x0000 )
  513.     {
  514.         Packet << endian_swap((uDummy2 = 2));
  515.         Packet << endian_swap((uDummy2 = 6));
  516.         Packet << (uDummy1 = 1);
  517.         Packet << endian_swap((uDummy2 = 3));
  518.         Packet << endian_swap((uDummy2 = 5));
  519.         m_vecLocked.push_back(uAreaId);
  520.     }
  521.     else if( uAreaFlag == 0x0100 )
  522.     {
  523.         Packet << endian_swap((uDummy2 = 1));
  524.         Packet << endian_swap((uDummy2 = 3));
  525.         Packet << endian_swap((uDummy2 = 5));
  526.     }
  527.     else if( uAreaFlag = 0x0001 )
  528.     {
  529.         Packet << endian_swap((uDummy2 = 1));
  530.         Packet << endian_swap((uDummy2 = 3));
  531.         Packet << endian_swap((uDummy2 = 2));
  532.     }
  533.     else
  534.     {
  535.         LOG_PRINT("WARNING: Needs to be implemented. (Missing: " << std::hex << std::setw(4) << std::setfill('0') << +(unsigned int)uAreaFlag << ")\n");
  536.         Packet << endian_swap((uDummy2 = 1));
  537.         Packet << endian_swap((uDummy2 = 3));
  538.         Packet << endian_swap((uDummy2 = 2));
  539.     }
  540.  
  541.     strData.assign( Packet.Buffer(), Packet.Size() );
  542.     strPacket = MakePacket(0x0a, strData);
  543.  
  544.     g_pDataMgrPoP->Pipe()->Write( strPacket );
  545.     LOG_PRINT("Area: " << Data_ConvertToHex(strPacket) << "\n");
  546. }
  547.  
  548. void CDataMgrPoP::AreaUnlock(CDataBuffer& Buffer)
  549. {
  550.     uint32 uAreaId;
  551.     Buffer >> uAreaId;
  552.  
  553.     std::vector<uint32>::iterator itrLock;
  554.     for( itrLock = m_vecLocked.begin(); itrLock != m_vecLocked.end(); itrLock++ )
  555.     {
  556.         if( *itrLock == uAreaId )
  557.         {
  558.             m_vecLocked.erase(itrLock);
  559.             break;
  560.         }
  561.     }
  562. }
  563.  
  564. void CDataMgrPoP::GetUpgrades(CDataBuffer& Buffer)
  565. {
  566.     //                                    010100000000000000000000000000000000000000000000000001000000010000000000
  567.     //                                    010100000000000000000000000000000000000000000000000001000000010000000000
  568.     // [18:52:02.0676]  [S->C] 002400001b 010201000000000000010100000001000000010000000100000002020201020201000100
  569.     uint8 uDummy0;
  570.     Buffer >> uDummy0;
  571.  
  572.     CDataBuffer Packet;
  573.     uint8 uTemp1;
  574.     std::string strData;
  575.     std::string strPacket;
  576.  
  577.     /*
  578.     Packet << (uTemp1 = 1);
  579.     Packet << (uTemp1 = 1);
  580.     */
  581.  
  582.     std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  583.     for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  584.     {
  585.         for( std::size_t i = 0; i< (*itr)->vecFields.size(); i++ )
  586.         {
  587.             Packet << (uTemp1 = (*itr)->vecFields[i]);
  588.         }
  589.     }
  590.  
  591.     strData.assign( Packet.Buffer(), Packet.Size() );
  592.     strPacket = MakePacket(0x1b, strData);
  593.  
  594.     g_pDataMgrPoP->Pipe()->Write( strPacket );
  595.     LOG_PRINT("Skills: " << Data_ConvertToHex(strPacket) << "\n");
  596. }
  597.  
  598. void CDataMgrPoP::UpdateXP(CDataBuffer& Buffer)
  599. {
  600.     uint32 uAdd = 0;
  601.  
  602.     Buffer >> uAdd;
  603.     endian_swap(uAdd);
  604.  
  605.     CDataBuffer Packet;
  606.     std::string strData;
  607.     std::string strPacket;
  608.  
  609.     m_uCurrentXP += uAdd;
  610.  
  611.     uint32 uMaxXP = GetMaxXPPerLevel(m_uCurrentLevel);
  612.     if( m_uCurrentXP >= uMaxXP )
  613.     {
  614.         m_uCurrentLevel++;
  615.         m_uCurrentXP = 0;
  616.  
  617.         Packet.Clear();
  618.  
  619.         // If level goes up a new packet is sent
  620.         uint32 uCurrentXP = m_uCurrentXP;
  621.         uint32 uCurrentLevel = m_uCurrentLevel;
  622.  
  623.         Packet << endian_swap(uCurrentXP);
  624.         Packet << endian_swap(uCurrentLevel);
  625.  
  626.         strData.assign(Packet.Buffer(), Packet.Size());
  627.         strPacket = MakePacket(0x19, strData);
  628.  
  629.         g_pDataMgrPoP->Pipe()->Write( strPacket );
  630.         LOG_PRINT("XP Update: " << Data_ConvertToHex(strPacket) << "\n");
  631.     }
  632.     else
  633.     {
  634.         uint32 uCurrentXP = m_uCurrentXP;
  635.         uint32 uCurrentLevel = m_uCurrentLevel;
  636.  
  637.         Packet << endian_swap(uCurrentXP);
  638.         Packet << endian_swap(uCurrentLevel);
  639.  
  640.         strData.assign(Packet.Buffer(), Packet.Size());
  641.         strPacket = MakePacket(0x19, strData);
  642.  
  643.         g_pDataMgrPoP->Pipe()->Write( strPacket );
  644.         LOG_PRINT("XP Update: " << Data_ConvertToHex(strPacket) << "\n");
  645.     }   
  646. }
  647.  
  648. void CDataMgrPoP::UpdateGameInfo(CDataBuffer& Buffer)
  649. {
  650.     // 009a000017 5c668002 0000 002b 0000 000a 00230000000000000014000000280000003c0000005000000064000000780000008c000000a0000000b4000000c8000000dc000000f000000104000001180000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c0000012c
  651.     uint32 uDummy0;
  652.     uint32 uCurrentXP;
  653.     uint32 uLevel;
  654.  
  655.     Buffer >> uDummy0;
  656.  
  657.     Buffer >> uCurrentXP;
  658.     endian_swap(uCurrentXP);
  659.  
  660.     Buffer >> uLevel;
  661.     endian_swap(uLevel);
  662.  
  663.     uint32 uMaxLevelXP = GetMaxXPPerLevel(uLevel);
  664.     if( uMaxLevelXP == 0 )
  665.         return;     // Invalid Level.
  666.  
  667.     m_uCurrentLevel = uLevel;
  668.     m_uCurrentXP = uCurrentXP;
  669. }
  670.  
  671. void CDataMgrPoP::Upgrade( CDataBuffer& Buffer )
  672. {
  673.     // Loose Upgrades
  674.     //[C->S] 000c000015 0000 0005 0000 0015 0000 0000
  675.     //[S->C] 000e000016 0004 0001 00 0002 0000 0000 0003 00
  676.  
  677.     // Keep Upgrades
  678.     //[C->S] 000c000015 0000 0005 0000 0015 0000 0000
  679.     //[S->C] 000b000016 0003 0001 00 0000 0000 0300
  680.  
  681.     // Upgrades.
  682.     //[C->S] 000c000015 0000 0000 0000 0011 0000 0002
  683.     //[S->C] 0006000016 0001 0013 0002
  684.  
  685.     //[C->S] 000c000015 0000 0000 0000 0006 0000 0000
  686.     //[S->C] 0005000016 0001 0005 01
  687.  
  688.     //[C->S] 000c000015 0000 0000 0000 0003 0000 0000
  689.     //[S->C] 0005000016 0001 0003 01
  690.  
  691.     //[C->S] 000c000015 0000 0000 0000 0010 0000 0000
  692.     //[S->C] 0006000016 0001 0012 0000
  693.  
  694.     uint16 uDummy0;
  695.     uint16 uGameId;
  696.     uint16 uFieldIndex;
  697.     uint16 uUpdate;
  698.  
  699.     uint16 uTemp;
  700.     uint8 uTemp2;
  701.     CDataBuffer Packet;
  702.     std::string strData;
  703.     std::string strPacket;
  704.  
  705.     Buffer >> uDummy0;      // Ignored
  706.  
  707.     Buffer >> uUpdate;
  708.     endian_swap(uUpdate);
  709.  
  710.     Buffer >> uDummy0;      // Ignored
  711.  
  712.     if( uUpdate == 0x0005 )
  713.     {
  714.         Packet << endian_swap((uTemp = 0x0004));
  715.         Packet << endian_swap((uTemp = 0x0001));
  716.         Packet << (uTemp2 = 0x00);
  717.         Packet << endian_swap((uTemp = 0x0002));
  718.         Packet << endian_swap((uTemp = 0x0000));
  719.         Packet << endian_swap((uTemp = 0x0000));
  720.         Packet << endian_swap((uTemp = 0x0003));
  721.         Packet << (uTemp2 = 0x00);
  722.  
  723.         strData.assign(Packet.Buffer(), Packet.Size());
  724.         strPacket = MakePacket(0x16, strData);
  725.  
  726.         g_pDataMgrPoP->Pipe()->Write( strPacket );
  727.         LOG_PRINT("New Upgrades: " << Data_ConvertToHex(strPacket) << "\n");
  728.  
  729.         // Reset Upgrades, fuck you PALYIER?!
  730.         std::vector<boost::shared_ptr<PoPUpgrade_t>>::iterator itr;
  731.         for( itr = m_vecUpgrades.begin(); itr != m_vecUpgrades.end(); itr++ )
  732.         {
  733.             for(std::size_t i = 0; i < (*itr)->vecFields.size(); i++ )
  734.                 (*itr)->vecFields[i] = 0x00;
  735.  
  736.             if( (*itr)->uClientId == 0x00 )
  737.                 (*itr)->vecFields[0] = 0x01;
  738.             else if( (*itr)->uClientId == 0x03 )
  739.                 (*itr)->vecFields[0] = 0x01;
  740.             else if( (*itr)->uClientId == 0x10 )
  741.                 (*itr)->vecFields[0] = 0x01;
  742.             else if( (*itr)->uClientId == 0x11 )
  743.                 (*itr)->vecFields[0] = 0x01;
  744.         }
  745.         return;
  746.     }
  747.  
  748.     Buffer >> uGameId;      // Power id on client side.
  749.     endian_swap(uGameId);
  750.  
  751.     Buffer >> uDummy0;      // Ignored
  752.  
  753.     Buffer >> uFieldIndex;  // Described as level.
  754.     endian_swap(uFieldIndex);
  755.  
  756.     PoPUpgrade_t* pUpgrade = GetUpdatedByGameId(uGameId);
  757.     if( !pUpgrade )
  758.     {
  759.         LOG_PRINT("WARNING: Upgrade '" << uGameId << "' not found, resulting default!\n");
  760.  
  761.         Buffer << endian_swap((uTemp = 0x0004));
  762.         Buffer << endian_swap((uTemp = 0x0001));
  763.         Buffer << (uTemp2 = 0x00);
  764.         Buffer << endian_swap((uTemp = 0x0002));
  765.         Buffer << endian_swap((uTemp = 0x0000));
  766.         Buffer << endian_swap((uTemp = 0x0000));
  767.         Buffer << (uTemp2 = 0x00);
  768.  
  769.         strData.assign(Packet.Buffer(), Packet.Size());
  770.         strPacket = MakePacket(0x16, strData);
  771.  
  772.         g_pDataMgrPoP->Pipe()->Write( strPacket );
  773.         LOG_PRINT("Upgrade: " << Data_ConvertToHex(strPacket) << "\n");
  774.  
  775.         return;
  776.     }
  777.  
  778.     /*
  779.     pUpgrade = InitUpgrade(0x04, 0x0A, 1);  // Time Power - 1 level.
  780.     pUpgrade = InitUpgrade(0x06, 0x05, 1);  // Flow Power - 1 level.
  781.     pUpgrade = InitUpgrade(0x05, 0x0B, 1);  // Flight Boost - 1 level
  782.     pUpgrade = InitUpgrade(0x07, 0x09, 1);  // Heavy Kick - 1 level.
  783.     pUpgrade = InitUpgrade(0x08, 0x06, 1);  // Double Health - 1 level.
  784.     pUpgrade = InitUpgrade(0x09, 0x08, 1);  // Double Energy - 1 level.
  785.     pUpgrade = InitUpgrade(0x0A, 0x04, 1);  // Aerial Boost - 1 level.
  786.     pUpgrade = InitUpgrade(0x0B, 0x07, 1);  // Power Attack - 1 level.
  787.     pUpgrade = InitUpgrade(0x0C, 0x10, 4);  // Stone Armor - 4 levels
  788.     pUpgrade = InitUpgrade(0x0D, 0x0E, 4);  // Whirlwind - 4 levels
  789.     pUpgrade = InitUpgrade(0x0E, 0x0F, 4);  // Ice Blast - 4 levels
  790.     pUpgrade = InitUpgrade(0x0F, 0x11, 4);  // Trial of Flame - 4 levels
  791.     pUpgrade = InitUpgrade(0x10, 0x12, 4);  // Health Upgrade - 4 levels
  792.     pUpgrade = InitUpgrade(0x11, 0x13, 4);  // Energy Slot - 4 levels
  793.     pUpgrade = InitUpgrade(0x12, 0x14, 2);  // Battle rage / Battle Fury - 2 levels.
  794.     */
  795.  
  796.     // Only Health and Energy goes up
  797.     UnlockUpgrade(uGameId, uFieldIndex, 0x02, uGameId == 0x11 || uGameId == 0x10 ? true : false );
  798.  
  799.     if( uGameId == 0x11 )
  800.     {
  801.         // Energy
  802.         if( uFieldIndex == 0 )
  803.         {
  804.             UnlockUpgrade(0x0D, 0, 0x01, false);
  805.             UnlockUpgrade(0x0E, 0, 0x01, false);
  806.         }
  807.         else if( uFieldIndex == 1 )
  808.         {
  809.             // Energy 2
  810.             if( GetUpgradeLevel(0x10) == 2 )
  811.                 UnlockUpgrade(0x04, 0, 0x01, false);    // Time Power
  812.  
  813.             UnlockUpgrade(0x0B, 0, 0x01, false);        // Power Attack 1
  814.  
  815.             if( GetUpgradeLevel(0x0D) == 1 )
  816.                 UnlockUpgrade(0x0D, 1, 0x01, false);    // Whirlwind 2
  817.  
  818.             if( GetUpgradeLevel(0x0E) == 1 )
  819.                 UnlockUpgrade(0x0E, 1, 0x01, false);    // Ice Blast 2
  820.         }
  821.         else if( uFieldIndex == 2 )
  822.         {
  823.             // Energy 3
  824.             if( GetUpgradeLevel(0x10) == 3 )
  825.                 UnlockUpgrade(0x06, 0, 0x01, false);    // Flow Power
  826.  
  827.             if( GetUpgradeLevel(0x0B) == 1 )
  828.                 UnlockUpgrade(0x07, 0, 0x01, false);    // Heavy Kick
  829.  
  830.             if( GetUpgradeLevel(0x0D) == 2 )
  831.                 UnlockUpgrade(0x0D, 2, 0x01, false);    // Whirlwind 3
  832.  
  833.             if( GetUpgradeLevel(0x0E) == 2 )
  834.                 UnlockUpgrade(0x0E, 2, 0x01, false);    // Ice Blast 3
  835.         }
  836.         else if( uFieldIndex == 3 )
  837.         {
  838.             // Energy 4
  839.             if( GetUpgradeLevel(0x10) == 3 )
  840.                 UnlockUpgrade(0x08, 0, 0x01, false);    // Double Health
  841.  
  842.             if( GetUpgradeLevel(0x07) == 1 )
  843.                 UnlockUpgrade(0x05, 0, 0x01, false);    // Power Attack 2
  844.  
  845.             if( GetUpgradeLevel(0x0D) == 3 )
  846.                 UnlockUpgrade(0x0D, 3, 0x01, false);    // Whirlwind 4
  847.  
  848.             if( GetUpgradeLevel(0x0E) == 3 )
  849.                 UnlockUpgrade(0x0E, 3, 0x01, false);    // Ice Blast 4
  850.         }
  851.     }
  852.     else if ( uGameId == 0x10 )
  853.     {
  854.         // Health
  855.         if( uFieldIndex == 0 )
  856.         {
  857.             // Health 1
  858.             UnlockUpgrade(0x0C, 0, 0x01, false);
  859.             UnlockUpgrade(0x0F, 0, 0x01, false);
  860.         }
  861.         else if( uFieldIndex == 1 )
  862.         {
  863.             // Health 2
  864.             if( GetUpgradeLevel(0x11) == 2 )
  865.                 UnlockUpgrade(0x04, 0, 0x01, false);    // Time Power
  866.  
  867.             UnlockUpgrade(0x12, 0, 0x01, false);        // Battle Rage 1
  868.  
  869.             if( GetUpgradeLevel(0x0C) == 1 )
  870.                 UnlockUpgrade(0x0C, 1, 0x01, false);    // Stone Armor 2
  871.  
  872.             if( GetUpgradeLevel(0x0F) == 1 )
  873.                 UnlockUpgrade(0x0F, 1, 0x01, false);    // Trail of Flame 2
  874.         }
  875.         else if( uFieldIndex == 2 )
  876.         {
  877.             // Health 3
  878.             if( GetUpgradeLevel(0x11) == 3 )
  879.                 UnlockUpgrade(0x06, 0, 0x01, false);    // Flow Power
  880.  
  881.             if( GetUpgradeLevel(0x12) == 1 )
  882.                 UnlockUpgrade(0x12, 1, 0x01, false);    // Battle Fury
  883.  
  884.             if( GetUpgradeLevel(0x0C) == 2 )
  885.                 UnlockUpgrade(0x0C, 2, 0x01, false);    // Stone Armor 2
  886.  
  887.             if( GetUpgradeLevel(0x0F) == 2 )
  888.                 UnlockUpgrade(0x0F, 2, 0x01, false);    // Trail of Flame 2
  889.         }
  890.         else if( uFieldIndex == 3 )
  891.         {
  892.             // Health 4
  893.             if( GetUpgradeLevel(0x11) == 4 )
  894.                 UnlockUpgrade(0x08, 0, 0x01, false);    // Double Health
  895.  
  896.             if( GetUpgradeLevel(0x12) == 2 )
  897.                 UnlockUpgrade(0x0A, 0, 0x01, false);    // Aerial Boost
  898.  
  899.             if( GetUpgradeLevel(0x0C) == 3 )
  900.                 UnlockUpgrade(0x0C, 3, 0x01, false);    // Stone Armor 3
  901.  
  902.             if( GetUpgradeLevel(0x0F) == 3 )
  903.                 UnlockUpgrade(0x0F, 3, 0x01, false);    // Trail of Flame 3
  904.         }
  905.     }
  906.     else if( uGameId == 0x0C )
  907.     {
  908.         // Stone Armor
  909.         for( uint8 i = (uFieldIndex + 1); i < pUpgrade->vecFields.size(); i++ )
  910.         {
  911.             if( GetUpgradeLevel(0x10) > i )
  912.                 UnlockUpgrade(0x0C, i, 0x01, false);
  913.         }
  914.     }
  915.     else if( uGameId == 0x0F )
  916.     {
  917.         // Trail of Flames
  918.         for( uint8 i = (uFieldIndex + 1); i < pUpgrade->vecFields.size(); i++ )
  919.         {
  920.             if( GetUpgradeLevel(0x10) > i )
  921.                 UnlockUpgrade(0x0F, i, 0x01, false);
  922.         }
  923.     }
  924.     else if( uGameId == 0x12 )
  925.     {
  926.         // Battle Rage
  927.         if( uFieldIndex == 0 )
  928.         {
  929.             if( GetUpgradeLevel(0x10) >= 2 )
  930.                 UnlockUpgrade(0x12, 1, 0x01, false);
  931.         }
  932.         else if( uFieldIndex == 1 )
  933.         {
  934.             if( GetUpgradeLevel(0x10) > 3 )
  935.                 UnlockUpgrade(0x0A, 0, 0x01, false);
  936.         }
  937.     }
  938.     else if( uGameId == 0x0D )
  939.     {
  940.         // Whirlwind
  941.         for( uint8 i = (uFieldIndex + 1); i < pUpgrade->vecFields.size(); i++ )
  942.         {
  943.             if( GetUpgradeLevel(0x11) > i )
  944.                 UnlockUpgrade(0x0D, i, 0x01, false);
  945.         }
  946.     }
  947.     else if( uGameId == 0x0E )
  948.     {
  949.         // Ice Blast
  950.         for( uint8 i = (uFieldIndex + 1); i < pUpgrade->vecFields.size(); i++ )
  951.         {
  952.             if( GetUpgradeLevel(0x11) > i )
  953.                 UnlockUpgrade(0x0E, i, 0x01, false);
  954.         }
  955.     }
  956.     else if( uGameId == 0x0B )
  957.     {
  958.         if( GetUpgradeLevel(0x11) >= 2 )
  959.             UnlockUpgrade(0x07, 0, 0x01, false);    // Heavy Kick.
  960.     }
  961.     else if( uGameId == 0x07 )
  962.     {
  963.         if( GetUpgradeLevel(0x11) > 3 )
  964.             UnlockUpgrade(0x05, 0, 0x01, false);    // Flight Boost
  965.     }
  966.  
  967.     // These must be level 4 to unlock Double Energy.
  968.     if( GetUpgradeLevel(0x0F) == 4 &&   // Trail of Flame
  969.         GetUpgradeLevel(0x0C) == 4 &&   // Stone Armor
  970.         GetUpgradeLevel(0x0D) == 4 &&   // Whirlwind
  971.         GetUpgradeLevel(0x0E) == 4      // Ice Blast
  972.         )
  973.     {
  974.         // Enable Double Energy.
  975.         pUpgrade = GetUpdatedByGameId(0x09);
  976.         if( pUpgrade )
  977.             pUpgrade->vecFields[0] = 0x01;
  978.     }
  979.  
  980.     // 0006000016 0001 0012 0100
  981.     Packet << endian_swap((uTemp = 1));     // 0001 OK
  982.     Packet << endian_swap((uTemp = (uint16)pUpgrade->uServerId));
  983.     if( pUpgrade->vecFields.size() == 1 || pUpgrade->vecFields.size() == 0 )
  984.         Packet << (uTemp2 = 1);
  985.     else
  986.         Packet << endian_swap((uTemp = (uint16)uFieldIndex));
  987.  
  988.     strData.assign(Packet.Buffer(), Packet.Size());
  989.     strPacket = MakePacket(0x16, strData);
  990.  
  991.     g_pDataMgrPoP->Pipe()->Write( strPacket );
  992.     LOG_PRINT("Upgrade: " << Data_ConvertToHex(strPacket) << "\n");
  993. }
  994.  
  995. void CDataMgrPoP::DoorEvent(CDataBuffer& Buffer)
  996. {
  997.     // 000500000d 480e0856 01
  998.  
  999.     uint32 uDoorId;
  1000.     Buffer >> uDoorId;
  1001.  
  1002.     bool bOpenEvent;
  1003.     Buffer >> bOpenEvent;
  1004.  
  1005.     if( bOpenEvent == true )
  1006.     {
  1007.         std::vector<boost::shared_ptr<CPoPButton>>::iterator itr;
  1008.         for( itr = m_vecButtons.begin(); itr != m_vecButtons.end(); itr++ )
  1009.         {
  1010.             if( (*itr)->Id() == uDoorId )
  1011.             {
  1012.                 (*itr)->Enter(s_Timer.Elapsed(), 2000);
  1013.                 return;
  1014.             }
  1015.         }
  1016.  
  1017.         CPoPButton* pButton = new CPoPButton(m_IO, uDoorId);
  1018.         m_vecButtons.push_back( boost::shared_ptr<CPoPButton>(pButton) );
  1019.         pButton->Enter(s_Timer.Elapsed(), 2000);
  1020.     }
  1021.     else
  1022.     {
  1023.         std::vector<boost::shared_ptr<CPoPButton>>::iterator itr;
  1024.         for( itr = m_vecButtons.begin(); itr != m_vecButtons.end(); itr++ )
  1025.         {
  1026.             if( (*itr)->Id() == uDoorId )
  1027.             {
  1028.                 (*itr)->Leave(s_Timer.Elapsed(), 2000);
  1029.                 return;
  1030.             }
  1031.         }
  1032.     }
  1033. }
  1034.  
  1035. void CDataMgrPoP::ObjectInit(CDataBuffer& Buffer)
  1036. {
  1037.     // [C->S] 001f000011 4aca871b 000000000000000000000000000000000000000000000000000000
  1038.     // [S->C] 000a000013 4aca871b 0001 0000 0000
  1039.  
  1040.     uint32 uId;
  1041.     Buffer >> uId;
  1042.  
  1043.     CDataBuffer Packet;
  1044.     std::string strData;
  1045.     std::string strPacket;
  1046.  
  1047.     uint16 uTemp;
  1048.     Packet << uId;
  1049.     Packet << endian_swap((uTemp = 0x0001));
  1050.     Packet << endian_swap((uTemp = 0x0000));
  1051.     Packet << endian_swap((uTemp = 0x0000));
  1052.  
  1053.     strData.assign(Packet.Buffer(), Packet.Size());
  1054.     strPacket = MakePacket(0x13, strData);
  1055.     m_pPipe->Write( strPacket );
  1056.  
  1057.     LOG_PRINT("Sent Object Init: " << Data_ConvertToHex(strPacket) << "\n");
  1058. }
  1059.  
  1060. void CDataMgrPoP::Lever(CDataBuffer& Buffer)
  1061. {
  1062.     uint32 uLeverId;
  1063.     uint16 uPacketId1;
  1064.     uint16 uPacketId2;
  1065.     //uint8 uTemp1;
  1066.     uint16 uTemp2;
  1067.  
  1068.     CDataBuffer Packet;
  1069.     std::string strData;
  1070.     std::string strPacket;
  1071.  
  1072.     Buffer >> uLeverId;
  1073.  
  1074.     Buffer >> uPacketId1;
  1075.     endian_swap(uPacketId1);
  1076.  
  1077.     Buffer >> uPacketId2;
  1078.     endian_swap(uPacketId2);
  1079.  
  1080.     CPoPLever* pLever = GetLeverById(uLeverId);
  1081.  
  1082.     if( uPacketId1 == 0x0001 && uPacketId2 == 0x0004 )
  1083.     {
  1084.         bool bEnter;
  1085.         Buffer >> bEnter;
  1086.  
  1087.         // Enter/Leave
  1088.         if( bEnter )
  1089.         {
  1090.             pLever = CreateLever(uLeverId);
  1091.             pLever->SetPlayerOnLever(true);
  1092.  
  1093.             LOG_PRINT("Entered Lever.\n");
  1094.         }
  1095.         else
  1096.         {
  1097.             // Deleting isnt a good idea in case the direction was changed
  1098.             // it would be forward after entering the lever again. So keep it alive :)
  1099.             if( pLever )
  1100.                 pLever->SetPlayerOnLever(false);
  1101.  
  1102.             LOG_PRINT("Left Lever.\n");
  1103.         }
  1104.     }
  1105.     else if( uPacketId1 == 0x0001 && uPacketId2 == 0x0005 )
  1106.     {
  1107.         // Push
  1108.         if(pLever)
  1109.             pLever->Push();
  1110.     }
  1111.     else if( uPacketId1 == 0x0002 && uPacketId2 == 0x0005 )
  1112.     {
  1113.      // Direction was previously set to backward (0x0002 is state)
  1114.         // Change direction and push.
  1115.         // [C->S] [LEVER] 000c000013 4aca871b 0002 0005 01 0006 01
  1116.         //                000f000013 33f4631b 0002 0005 01 0007 e8b40140
  1117.         uint8 uTemp1;
  1118.         uint16 uTemp2;
  1119.  
  1120.         Buffer >> uTemp1;
  1121.         Buffer >> uTemp2;
  1122.         endian_swap(uTemp2);
  1123.        
  1124.         // Moonwalk fix - That was funny shit :D
  1125.         if( uTemp2 == 0x0007 )
  1126.         {
  1127.             pLever->SetDirection( k_eLeverDirectionBackward );
  1128.  
  1129.             // 000a000013 33f4631b 0001 0002 0003
  1130.             Packet << uLeverId;
  1131.             Packet << endian_swap((uTemp2 = 0x0001));
  1132.             Packet << endian_swap((uTemp2 = 0x0002));
  1133.             Packet << endian_swap((uTemp2 = 0x0003));
  1134.  
  1135.             strData.assign(Packet.Buffer(), Packet.Size());
  1136.             strPacket = MakePacket(0x0013, strData);
  1137.  
  1138.             m_pPipe->Write(strPacket);
  1139.             //LOG_PRINT("Lever Object Lock: " << ValueDB_ConvertToHex(strPacket) << "\n");
  1140.         }
  1141.         else
  1142.         {
  1143.             bool bForward;
  1144.             Buffer >> bForward;
  1145.  
  1146.             pLever->SetDirection( bForward ? k_eLeverDirectionForward : k_eLeverDirectionBackward );
  1147.         }
  1148.     }
  1149.     else if( uPacketId1 == 0x0003 && uPacketId2 == 0x0005 )
  1150.     {
  1151.     // Direction was previously set to forward (0x0003 is state)
  1152.         // 0012000013 5940c11a 0003 0005 01 0006 01 0007 e8b40140
  1153.  
  1154.         // Change direction and push.
  1155.         // [C->S] [LEVER] 000c000013 4aca871b 0002 0005 01 0006 01
  1156.         //                000f000013 33f4631b 0002 0005 01 0007 e8b40140
  1157.         uint8 uTemp1;
  1158.         uint16 uTemp2;
  1159.  
  1160.         Buffer >> uTemp1;
  1161.         Buffer >> uTemp2;
  1162.         Buffer >> uTemp1;
  1163.    
  1164.         uint16 uObjectLock = 0x0006;
  1165.         if( !Buffer.IsEOB() )
  1166.         {
  1167.             Buffer >> uObjectLock;
  1168.             endian_swap(uObjectLock);
  1169.         }
  1170.  
  1171.         // Some relation to an object.
  1172.         Packet << uLeverId;
  1173.         Packet << endian_swap((uTemp2 = 0x0001));
  1174.         Packet << endian_swap((uTemp2 = 0x0002));
  1175.         Packet << endian_swap((uTemp2 = 0x0002));
  1176.  
  1177.         strData.assign(Packet.Buffer(), Packet.Size());
  1178.         strPacket = MakePacket(0x0013, strData);
  1179.  
  1180.         m_pPipe->Write(strPacket);
  1181.         //LOG_PRINT("Lever Object Lock: " << ValueDB_ConvertToHex(strPacket) << "\n");
  1182.     }
  1183.     else if( uPacketId1 == 0x0002 && uPacketId2 == 0x0002 )
  1184.     {
  1185.         // 4aca871b 0002 0002 0000 0005 00
  1186.  
  1187.         // Position (Forward).
  1188.         // 0002 0002 0000 0008 0000 0001    // No Response.
  1189.         // 0002 0002 0000 0005 00           // Response.
  1190.  
  1191.         // 0002 0002 0000 0001 0001 // WTF PACKET
  1192.         Buffer >> uTemp2;
  1193.         Buffer >> uTemp2;
  1194.         endian_swap(uTemp2);
  1195.  
  1196.         if( uTemp2 == 0x0005 )
  1197.         {
  1198.             if( pLever )
  1199.             {
  1200.                 //pLever->SetDirection( k_eLeverDirectionForward );
  1201.                 pLever->WaitForPositionChange();
  1202.             }
  1203.         }
  1204.         else if( uTemp2 == 0x0008 )
  1205.         {
  1206.             // Direction result flag.
  1207.             // 4aca871b 0001 0002 0001
  1208.             Buffer >> uTemp2;
  1209.  
  1210.             uint16 uPosition;
  1211.  
  1212.             Buffer >> uPosition;
  1213.             endian_swap(uPosition);
  1214.  
  1215.             if( pLever )
  1216.                 pLever->SetPosition(uPosition);
  1217.         }
  1218.         else if( uTemp2 == 0x0001 )
  1219.         {
  1220.         }
  1221.         else
  1222.         {
  1223.             LOG_PRINT("Unknown Packet for Lever: " << Data_ConvertToHex(strPacket) << "\n");
  1224.         }
  1225.     }
  1226.     else if( uPacketId1 == 0x0003 && uPacketId2 == 0x0002 )
  1227.     {
  1228.         // Position (Backward)
  1229.         Buffer >> uTemp2;
  1230.         Buffer >> uTemp2;
  1231.         endian_swap(uTemp2);
  1232.  
  1233.         if( uTemp2 == 0x0008 )
  1234.         {
  1235.             Buffer >> uTemp2;
  1236.  
  1237.             uint16 uPosition;
  1238.             Buffer >> uPosition;
  1239.             endian_swap(uPosition);
  1240.  
  1241.             if(pLever)
  1242.             {
  1243.                 //pLever->SetDirection( k_eLeverDirectionBackward );
  1244.                 pLever->WaitForPositionChange();
  1245.             }
  1246.         }
  1247.         else
  1248.         {
  1249.             LOG_PRINT("Unknown Packet for Lever: " << Data_ConvertToHex(strPacket) << "\n");
  1250.         }
  1251.     }
  1252.     else
  1253.     {
  1254.         LOG_PRINT("WARNING: Unknown Lever packet case: " << (void*)uPacketId1 << ", " << (void*)uPacketId2 << "\n");
  1255.     }
  1256. }
  1257.  
  1258. void CDataMgrPoP::OnLeverLock(CDataBuffer& Buffer)
  1259. {
  1260.     //[C->S] 0008000012 5940c11a00000003
  1261.     //[C->S] 0008000012 54f2c0ae00000000
  1262.     //[S->C] 000a000013 5940c11a000100000003
  1263.     //[S->C] 000a000013 54f2c0ae000100000000
  1264.  
  1265.     // This shit is sent when its supposed to be locked
  1266.     // No need for management just reply :D
  1267.     uint32 uLeverId;
  1268.     uint16 uTemp1;
  1269.     uint16 uLockFlag;
  1270.  
  1271.     Buffer >> uLeverId;
  1272.     Buffer >> uTemp1;
  1273.     Buffer >> uLockFlag;
  1274.  
  1275.     CDataBuffer Packet;
  1276.     std::string strData;
  1277.     std::string strPacket;
  1278.  
  1279.     Packet << uLeverId;
  1280.     Packet << endian_swap((uTemp1 = 0x0001));
  1281.     Packet << endian_swap((uTemp1 = 0x0000));
  1282.     Packet << uLockFlag;
  1283.  
  1284.     strData.assign(Packet.Buffer(), Packet.Size());
  1285.     strPacket = MakePacket(0x0013, strData);
  1286.  
  1287.     m_pPipe->Write(strPacket);
  1288.     LOG_PRINT("Lever Lock: " << Data_ConvertToHex(strPacket) << "\n");
  1289. }


Top
 Profile  

Post Post subject: Re: Private Server Emulator for Ubi DRM?   
Posted: Friday, 31 Dec 2010, 00:29   
Forum ghost Местное привидение
Joined: Sunday, 20 Nov 2005, 00:43
Posts: 424
...


Top
 Profile  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 


Who is online

Users browsing this forum: No registered users and 4 guests


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum




Powered by phpBB® Forum Software © phpBB Group