diff --git a/.gitignore b/.gitignore index 5ca0b68..049ca8d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.sdf *.opensdf *.aps +*.db \ No newline at end of file diff --git a/Dependencies/Detours.props b/Dependencies/Detours.props index 5d0247e..bf8e2a3 100644 --- a/Dependencies/Detours.props +++ b/Dependencies/Detours.props @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Dependencies/MySQL.props b/Dependencies/MySQL.props index cfb6c00..b25ff30 100644 --- a/Dependencies/MySQL.props +++ b/Dependencies/MySQL.props @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Dependencies/Poco.props b/Dependencies/Poco.props index f474222..8f928b3 100644 --- a/Dependencies/Poco.props +++ b/Dependencies/Poco.props @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Dependencies/PostgreSQL.props b/Dependencies/PostgreSQL.props index 8ab02b3..7a36ac3 100644 --- a/Dependencies/PostgreSQL.props +++ b/Dependencies/PostgreSQL.props @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Dependencies/TBB.props b/Dependencies/TBB.props index 7b956a9..9a5a0b6 100644 --- a/Dependencies/TBB.props +++ b/Dependencies/TBB.props @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Hive/Source/Database/Database.vcxproj b/Hive/Source/Database/Database.vcxproj index 435d000..0575147 100644 --- a/Hive/Source/Database/Database.vcxproj +++ b/Hive/Source/Database/Database.vcxproj @@ -47,20 +47,21 @@ {E0E04F80-0DB4-4946-B956-4BCA754DAB71} Win32Proj Database + 10.0.15063.0 StaticLibrary true Unicode - v120 + v141 StaticLibrary false true Unicode - v120 + v141 @@ -80,11 +81,12 @@ true - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) false + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 @@ -117,7 +119,7 @@ true DATABASE_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt Windows diff --git a/Hive/Source/Database/Field.h b/Hive/Source/Database/Field.h index c7eaa84..e674c2e 100644 --- a/Hive/Source/Database/Field.h +++ b/Hive/Source/Database/Field.h @@ -50,6 +50,17 @@ class Field float getFloat() const { return static_cast(getDouble()); } bool getBool() const { return _value ? atoi(_value) > 0 : false; } Int32 getInt32() const { return _value ? static_cast(atol(_value)) : Int32(0); } + Int64 getInt64() const + { + if (!_value) + return 0; + + Int64 parsedVal; + if (!Poco::NumberParser::tryParse64(_value, parsedVal)) + return 0; + + return parsedVal; + } Int8 getInt8() const { return _value ? static_cast(atol(_value)) : Int8(0); } UInt8 getUInt8() const { return _value ? static_cast(atol(_value)) : UInt8(0); } UInt16 getUInt16() const { return _value ? static_cast(atol(_value)) : UInt16(0); } diff --git a/Hive/Source/Database/Implementation/DatabaseMySql/DatabaseMySql.vcxproj b/Hive/Source/Database/Implementation/DatabaseMySql/DatabaseMySql.vcxproj index ffa8655..5f50707 100644 --- a/Hive/Source/Database/Implementation/DatabaseMySql/DatabaseMySql.vcxproj +++ b/Hive/Source/Database/Implementation/DatabaseMySql/DatabaseMySql.vcxproj @@ -32,20 +32,21 @@ {E6BA8EFD-342A-409B-9273-6463009E5DCA} Win32Proj DatabaseMySql + 10.0.15063.0 DynamicLibrary true Unicode - v120 + v141 - DynamicLibrary + StaticLibrary false true Unicode - v120 + v141 @@ -67,11 +68,12 @@ true - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) false + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 @@ -104,7 +106,7 @@ true DATABASEMYSQL_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt Windows diff --git a/Hive/Source/Database/Implementation/DatabasePostgre/DatabasePostgre.vcxproj b/Hive/Source/Database/Implementation/DatabasePostgre/DatabasePostgre.vcxproj index 582c8af..24dc7e0 100644 --- a/Hive/Source/Database/Implementation/DatabasePostgre/DatabasePostgre.vcxproj +++ b/Hive/Source/Database/Implementation/DatabasePostgre/DatabasePostgre.vcxproj @@ -32,20 +32,21 @@ {3A94A40D-418F-4890-829D-7CD16EA1AB6C} Win32Proj DatabasePostgre + 10.0.15063.0 DynamicLibrary true Unicode - v120 + v141 DynamicLibrary false true Unicode - v120 + v141 @@ -67,8 +68,8 @@ true - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) false diff --git a/Hive/Source/HiveExt/HiveExt.vcxproj b/Hive/Source/HiveExt/HiveExt.vcxproj index 3af548d..41cb9eb 100644 --- a/Hive/Source/HiveExt/HiveExt.vcxproj +++ b/Hive/Source/HiveExt/HiveExt.vcxproj @@ -34,19 +34,20 @@ Win32Proj HiveExt HiveExt + 10.0.15063.0 true Unicode - v120 + v141 false true Unicode DynamicLibrary - v120 + v141 @@ -66,11 +67,12 @@ true - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) false + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 @@ -111,7 +113,7 @@ true %(PreprocessorDefinitions) MultiThreadedDLL - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt Windows diff --git a/Hive/Source/HiveLib/DataSource/CharDataSource.cpp b/Hive/Source/HiveLib/DataSource/CharDataSource.cpp index c7deb65..8263c93 100644 --- a/Hive/Source/HiveLib/DataSource/CharDataSource.cpp +++ b/Hive/Source/HiveLib/DataSource/CharDataSource.cpp @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* "Hatchet_Swing","Crowbar_Swing","Machete_Swing","Bat_Swing","BatBarbed_Swing","BatNails_Swing","Fishing_Swing" */ #include "CharDataSource.h" @@ -26,6 +28,11 @@ namespace { MELEE_HATCHET, MELEE_CROWBAR, + MELEE_MACHETE, + MELEE_BAT, + MELEE_BATBARBED, + MELEE_BATNAILS, + MELEE_FISHING, MELEE_COUNT }; @@ -34,34 +41,50 @@ namespace public: MeleeAmmoType operator()(const string& itemClass) const { - if (boost::iequals(itemClass,"Hatchet_Swing")) + //"Hatchet_Swing","Crowbar_Swing","Machete_Swing","Bat_Swing","BatBarbed_Swing","BatNails_Swing","Fishing_Swing" + if (boost::iequals(itemClass, "Hatchet_Swing")) return MELEE_HATCHET; - else if (boost::iequals(itemClass,"crowbar_swing")) + else if (boost::iequals(itemClass, "crowbar_swing")) return MELEE_CROWBAR; + else if (boost::iequals(itemClass, "Machete_Swing")) + return MELEE_MACHETE; + else if (boost::iequals(itemClass, "Bat_Swing")) + return MELEE_BAT; + else if (boost::iequals(itemClass, "BatBarbed_Swing")) + return MELEE_BATBARBED; + else if (boost::iequals(itemClass, "BatNails_Swing")) + return MELEE_BATNAILS; + else if (boost::iequals(itemClass, "Fishing_Swing")) + return MELEE_FISHING; else return MELEE_COUNT; } - template MeleeAmmoType operator()(const T& other) const { return MELEE_COUNT; } + template MeleeAmmoType operator()(const T& other) const { return MELEE_COUNT; } }; } -int CharDataSource::SanitiseInv( Sqf::Parameters& origInv ) +int CharDataSource::SanitiseInv(Sqf::Parameters& origInv) { if (origInv.size() != 2) //empty inv or not conforming to [weapons, magazines] layout return 0; - map numAmmo; + map numAmmo; numAmmo[MELEE_HATCHET] = 0; numAmmo[MELEE_CROWBAR] = 0; + numAmmo[MELEE_MACHETE] = 0; + numAmmo[MELEE_BAT] = 0; + numAmmo[MELEE_BATBARBED] = 0; + numAmmo[MELEE_BATNAILS] = 0; + numAmmo[MELEE_FISHING] = 0; try { int numErased = 0; Sqf::Parameters& magazines = boost::get(origInv.at(1)); - for (auto it=magazines.begin();it!=magazines.end();) + for (auto it = magazines.begin(); it != magazines.end();) { - MeleeAmmoType ammoType = boost::apply_visitor(MeleeAmmoVisitor(),*it); + MeleeAmmoType ammoType = boost::apply_visitor(MeleeAmmoVisitor(), *it); if (ammoType != MELEE_COUNT) { ++numAmmo[ammoType]; diff --git a/Hive/Source/HiveLib/DataSource/CharDataSource.h b/Hive/Source/HiveLib/DataSource/CharDataSource.h index ce0ae12..44d90dd 100644 --- a/Hive/Source/HiveLib/DataSource/CharDataSource.h +++ b/Hive/Source/HiveLib/DataSource/CharDataSource.h @@ -26,13 +26,15 @@ class CharDataSource virtual ~CharDataSource() {} virtual Sqf::Value fetchCharacterInitial( string playerId, int serverId, const string& playerName ) = 0; - virtual Sqf::Value fetchCharacterDetails( int characterId ) = 0; + virtual Sqf::Value fetchCharacterDetails( Int64 characterId ) = 0; virtual Sqf::Value fetchTraderObject( int traderObjectId, int action ) = 0; typedef map FieldsType; - virtual bool updateCharacter( int characterId, int serverId, const FieldsType& fields ) = 0; - virtual bool initCharacter( int characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) = 0; - virtual bool killCharacter( int characterId, int duration, int infected ) = 0; - virtual bool recordLogin( string playerId, int characterId, int action ) = 0; + virtual bool updateCharacter( Int64 characterId, int serverId, const FieldsType& fields ) = 0; + virtual bool updateCharacterGroup(string playerId, int serverId, const Sqf::Value& playerGroup ) = 0; + virtual bool updatePlayerCoins(string playerId, int serverId, Int64 coinsValue, Int64 playerBank ) = 0; + virtual bool initCharacter( Int64 characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) = 0; + virtual bool killCharacter( Int64 characterId, int duration, int infected ) = 0; + virtual bool recordLogin( string playerId, Int64 characterId, int action ) = 0; protected: static int SanitiseInv(Sqf::Parameters& origInv); }; \ No newline at end of file diff --git a/Hive/Source/HiveLib/DataSource/ObjDataSource.h b/Hive/Source/HiveLib/DataSource/ObjDataSource.h index e783677..2286f4f 100644 --- a/Hive/Source/HiveLib/DataSource/ObjDataSource.h +++ b/Hive/Source/HiveLib/DataSource/ObjDataSource.h @@ -27,13 +27,14 @@ class ObjDataSource typedef std::queue ServerObjectsQueue; virtual void populateObjects( int serverId, ServerObjectsQueue& queue ) = 0; - virtual void populateTraderObjects( int characterId, ServerObjectsQueue& queue ) = 0; + virtual void populateTraderObjects( Int64 characterId, ServerObjectsQueue& queue ) = 0; virtual bool updateObjectInventory( int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory ) = 0; + virtual bool updateObjectInventoryWCoins(int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory, Int64 coinsValue ) = 0; virtual bool deleteObject( int serverId, Int64 objectIdent, bool byUID ) = 0; virtual bool updateDatestampObject( int serverId, Int64 objectIdent, bool byUID ) = 0; virtual bool updateVehicleMovement( int serverId, Int64 objectIdent, const Sqf::Value& worldspace, double fuel ) = 0; virtual bool updateVehicleStatus( int serverId, Int64 objectIdent, const Sqf::Value& hitPoints, double damage ) = 0; - virtual bool createObject( int serverId, const string& className, double damage, int characterId, + virtual bool createObject( int serverId, const string& className, double damage, Int64 characterId, const Sqf::Value& worldSpace, const Sqf::Value& inventory, const Sqf::Value& hitPoints, double fuel, Int64 uniqueId ) = 0; virtual Sqf::Value fetchObjectId( int serverId, Int64 objectUID ) = 0; }; \ No newline at end of file diff --git a/Hive/Source/HiveLib/DataSource/SqlCharDataSource.cpp b/Hive/Source/HiveLib/DataSource/SqlCharDataSource.cpp index de9d514..9285237 100644 --- a/Hive/Source/HiveLib/DataSource/SqlCharDataSource.cpp +++ b/Hive/Source/HiveLib/DataSource/SqlCharDataSource.cpp @@ -33,10 +33,13 @@ SqlCharDataSource::~SqlCharDataSource() {} Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int serverId, const string& playerName ) { + Sqf::Value playerGroup = lexical_cast("[]"); bool newPlayer = false; + Int64 playerCoins = 0; + Int64 BankCoins = 0; //make sure player exists in db { - auto playerRes(getDB()->queryParams(("SELECT `PlayerName`, `PlayerSex` FROM `Player_DATA` WHERE `"+_idFieldName+"`='%s'").c_str(), getDB()->escape(playerId).c_str())); + auto playerRes(getDB()->queryParams(("SELECT `PlayerName`, `PlayerSex`, `playerGroup`, `PlayerCoins`, `BankCoins` FROM `Player_DATA` WHERE `"+_idFieldName+"`='%s'").c_str(), getDB()->escape(playerId).c_str())); if (playerRes && playerRes->fetchRow()) { newPlayer = false; @@ -50,14 +53,18 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server poco_assert(exRes == true); _logger.information("Changed name of player " + playerId + " from '" + playerRes->at(0).getString() + "' to '" + playerName + "'"); } + playerGroup = lexical_cast(playerRes->at(2).getString()); + playerCoins = playerRes->at(3).getInt64(); + BankCoins = playerRes->at(4).getInt64(); } else { newPlayer = true; //insert new player into db - auto stmt = getDB()->makeStatement(_stmtInsertPlayer, "INSERT INTO `Player_DATA` (`"+_idFieldName+"`, `PlayerName`) VALUES (?, ?)"); + auto stmt = getDB()->makeStatement(_stmtInsertPlayer, "INSERT INTO `Player_DATA` (`"+_idFieldName+"`, `PlayerName`, playerGroup) VALUES (?, ?, ?)"); stmt->addString(playerId); stmt->addString(playerName); + stmt->addString(lexical_cast(playerGroup)); bool exRes = stmt->execute(); poco_assert(exRes == true); _logger.information("Created a new player " + playerId + " named '" + playerName + "'"); @@ -70,19 +77,20 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server "TIMESTAMPDIFF(MINUTE,`Datestamp`,`LastLogin`) as `SurvivalTime`, " "TIMESTAMPDIFF(MINUTE,`LastAte`,NOW()) as `MinsLastAte`, " "TIMESTAMPDIFF(MINUTE,`LastDrank`,NOW()) as `MinsLastDrank`, " - "`Model` FROM `Character_DATA` WHERE `"+_idFieldName+"` = '%s' AND `Alive` = 1 ORDER BY `CharacterID` DESC LIMIT 1").c_str(), getDB()->escape(playerId).c_str()); + "`Model`, `duration`, `Coins` FROM `Character_DATA` WHERE `"+_idFieldName+"` = '%s' AND `Alive` = 1 ORDER BY `CharacterID` DESC LIMIT 1").c_str(), getDB()->escape(playerId).c_str()); int infected = 0; bool newChar = false; //not a new char - int characterId = -1; //invalid charid + Int64 characterId = -1; //invalid charid Sqf::Value worldSpace = Sqf::Parameters(); //empty worldspace Sqf::Value inventory = lexical_cast("[]"); //empty inventory Sqf::Value backpack = lexical_cast("[]"); //empty backpack - Sqf::Value survival = lexical_cast("[0,0,0]"); //0 mins alive, 0 mins since last ate, 0 mins since last drank + Sqf::Value survival = lexical_cast("[0,0,0,0]"); //0 mins alive, 0 mins since last ate, 0 mins since last drank, 0 time played string model = ""; //empty models will be defaulted by scripts + Int64 CharacterCoins = 0; //Coins if (charsRes && charsRes->fetchRow()) { newChar = false; - characterId = charsRes->at(0).getInt32(); + characterId = charsRes->at(0).getInt64(); try { worldSpace = lexical_cast(charsRes->at(1).getString()); @@ -120,6 +128,7 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server survivalArr[0] = charsRes->at(4).getInt32(); survivalArr[1] = charsRes->at(5).getInt32(); survivalArr[2] = charsRes->at(6).getInt32(); + survivalArr[3] = charsRes->at(8).getInt32(); } try { @@ -129,12 +138,13 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server { model = charsRes->at(7).getString(); } + CharacterCoins = charsRes->at(9).getInt64(); //update last login { //update last character login auto stmt = getDB()->makeStatement(_stmtUpdateCharacterLastLogin, "UPDATE `Character_DATA` SET `LastLogin` = CURRENT_TIMESTAMP WHERE `CharacterID` = ?"); - stmt->addInt32(characterId); + stmt->addInt64(characterId); bool exRes = stmt->execute(); poco_assert(exRes == true); } @@ -202,7 +212,7 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server retVal.push_back(string("ERROR")); return retVal; } - characterId = newCharRes->at(0).getInt32(); + characterId = newCharRes->at(0).getInt64(); } _logger.information("Created a new character " + lexical_cast(characterId) + " for player '" + playerName + "' (" + playerId + ")" ); } @@ -217,23 +227,27 @@ Sqf::Value SqlCharDataSource::fetchCharacterInitial( string playerId, int server retVal.push_back(inventory); retVal.push_back(backpack); retVal.push_back(survival); + retVal.push_back(CharacterCoins); //Character coins } else { retVal.push_back(infected); } retVal.push_back(model); + retVal.push_back(playerGroup); //Persistent group + retVal.push_back(playerCoins); //Global player coins + retVal.push_back(BankCoins); //Global bank coins (BANK SALDO) //hive interface version - retVal.push_back(0.96f); + retVal.push_back(0.97f); return retVal; } -Sqf::Value SqlCharDataSource::fetchCharacterDetails( int characterId ) +Sqf::Value SqlCharDataSource::fetchCharacterDetails( Int64 characterId ) { Sqf::Parameters retVal; //get details from db auto charDetRes = getDB()->queryParams( - "SELECT `%s`, `Medical`, `Generation`, `KillsZ`, `HeadshotsZ`, `KillsH`, `KillsB`, `CurrentState`, `Humanity`, `InstanceID` " + "SELECT `%s`, `Medical`, `Generation`, `KillsZ`, `HeadshotsZ`, `KillsH`, `KillsB`, `CurrentState`, `Humanity`, `InstanceID`, `Coins` " "FROM `Character_DATA` WHERE `CharacterID`=%d", _wsFieldName.c_str(), characterId); if (charDetRes && charDetRes->fetchRow()) @@ -245,6 +259,7 @@ Sqf::Value SqlCharDataSource::fetchCharacterDetails( int characterId ) Sqf::Value currentState = Sqf::Parameters(); //empty state (aiming, etc) int humanity = 2500; int instance = 1; + Int64 coins = 0; //get stuff from row { try @@ -282,6 +297,7 @@ Sqf::Value SqlCharDataSource::fetchCharacterDetails( int characterId ) } humanity = charDetRes->at(8).getInt32(); instance = charDetRes->at(9).getInt32(); + coins = charDetRes->at(10).getInt64(); } retVal.push_back(string("PASS")); @@ -300,7 +316,7 @@ Sqf::Value SqlCharDataSource::fetchCharacterDetails( int characterId ) return retVal; } -bool SqlCharDataSource::updateCharacter( int characterId, int serverId, const FieldsType& fields ) +bool SqlCharDataSource::updateCharacter( Int64 characterId, int serverId, const FieldsType& fields ) { map sqlFields; @@ -308,7 +324,6 @@ bool SqlCharDataSource::updateCharacter( int characterId, int serverId, const Fi { const string& name = it->first; const Sqf::Value& val = it->second; - //arrays if (name == "Worldspace" || name == "Inventory" || name == "Backpack" || name == "Medical" || name == "CurrentState") sqlFields[name] = "'"+getDB()->escape(lexical_cast(val))+"'"; @@ -341,7 +356,16 @@ bool SqlCharDataSource::updateCharacter( int characterId, int serverId, const Fi } //strings else if (name == "Model") - sqlFields[name] = "'"+getDB()->escape(boost::get(val))+"'"; + { + sqlFields[name] = "'" + getDB()->escape(boost::get(val)) + "'"; + } + else if (name == "Coins") + { + Int64 coinNum = static_cast(Sqf::GetBigInt(val)); + if (coinNum >= 0) { + sqlFields[name] = lexical_cast(coinNum); + } + } } if (sqlFields.size() > 0) @@ -359,6 +383,7 @@ bool SqlCharDataSource::updateCharacter( int characterId, int serverId, const Fi query += " , "; } query += ", `InstanceID` = " + lexical_cast(serverId) + " WHERE `CharacterID` = " + lexical_cast(characterId); + bool exRes = getDB()->execute(query.c_str()); poco_assert(exRes == true); @@ -368,37 +393,82 @@ bool SqlCharDataSource::updateCharacter( int characterId, int serverId, const Fi return true; } -bool SqlCharDataSource::initCharacter( int characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) +bool SqlCharDataSource::updateCharacterGroup(string playerId, int serverId, const Sqf::Value& playerGroup) +{ + auto stmt = getDB()->makeStatement(_stmtUpdatePlayerGroup, "UPDATE `Player_DATA` SET `playerGroup`=? WHERE `" + _idFieldName + "`=?"); + stmt->addString(lexical_cast(playerGroup)); + stmt->addString(playerId); + bool exRes = stmt->execute(); + poco_assert(exRes == true); + + return exRes; +} + +bool SqlCharDataSource::updatePlayerCoins(string playerId, int serverId, Int64 coinsValue, Int64 playerBank) +{ + unique_ptr stmt; + bool exRes = true; + if (coinsValue >= 0 && playerBank >= 0) { + stmt = getDB()->makeStatement(_stmtUpdatePlayerCoinsA, "UPDATE `Player_DATA` SET `PlayerCoins`=?, `BankCoins`=? WHERE `" + _idFieldName + "`=?"); + stmt->addInt64(coinsValue); //BANK + stmt->addInt64(playerBank); //BANKSALDO + stmt->addString(playerId); + exRes = stmt->execute(); + } + else if (coinsValue >= 0) { + stmt = getDB()->makeStatement(_stmtUpdatePlayerCoinsB, "UPDATE `Player_DATA` SET `PlayerCoins`=? WHERE `" + _idFieldName + "`=?"); + _logger.information("SQF Failed to pass player bank value, skipping column: `BankCoins` update"); + stmt->addInt64(coinsValue); //BANK + stmt->addString(playerId); + exRes = stmt->execute(); + } + else if (playerBank >= 0) { + stmt = getDB()->makeStatement(_stmtUpdatePlayerCoinsC, "UPDATE `Player_DATA` SET `BankCoins`=? WHERE `" + _idFieldName + "`=?"); + _logger.information("SQF Failed to pass player coins value, skipping column: `PlayerCoins` update"); + stmt->addInt64(playerBank); //BANKSALDO + stmt->addString(playerId); + exRes = stmt->execute(); + } + else + { + _logger.information("SQF Failed to pass both player coins and player bank values skipping update"); + } + poco_assert(exRes == true); + + return exRes; +} + +bool SqlCharDataSource::initCharacter( Int64 characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) { auto stmt = getDB()->makeStatement(_stmtInitCharacter, "UPDATE `Character_DATA` SET `Inventory` = ? , `Backpack` = ? WHERE `CharacterID` = ?"); stmt->addString(lexical_cast(inventory)); stmt->addString(lexical_cast(backpack)); - stmt->addInt32(characterId); + stmt->addInt64(characterId); bool exRes = stmt->execute(); poco_assert(exRes == true); return exRes; } -bool SqlCharDataSource::killCharacter( int characterId, int duration, int infected ) +bool SqlCharDataSource::killCharacter( Int64 characterId, int duration, int infected ) { auto stmt = getDB()->makeStatement(_stmtKillCharacter, "UPDATE `Character_DATA` SET `Alive` = 0, `Infected` = ?, `LastLogin` = DATE_SUB(CURRENT_TIMESTAMP, INTERVAL ? MINUTE) WHERE `CharacterID` = ? AND `Alive` = 1"); stmt->addInt32(infected); stmt->addInt32(duration); - stmt->addInt32(characterId); + stmt->addInt64(characterId); bool exRes = stmt->execute(); poco_assert(exRes == true); return exRes; } -bool SqlCharDataSource::recordLogin( string playerId, int characterId, int action ) +bool SqlCharDataSource::recordLogin( string playerId, Int64 characterId, int action ) { auto stmt = getDB()->makeStatement(_stmtRecordLogin, "INSERT INTO `Player_LOGIN` (`"+_idFieldName+"`, `CharacterID`, `Datestamp`, `Action`) VALUES (?, ?, CURRENT_TIMESTAMP, ?)"); stmt->addString(playerId); - stmt->addInt32(characterId); + stmt->addInt64(characterId); stmt->addInt32(action); bool exRes = stmt->execute(); poco_assert(exRes == true); @@ -439,8 +509,6 @@ Sqf::Value SqlCharDataSource::fetchTraderObject( int traderObjectId, int action) retVal.push_back(string("ERROR")); return retVal; } - - } else { diff --git a/Hive/Source/HiveLib/DataSource/SqlCharDataSource.h b/Hive/Source/HiveLib/DataSource/SqlCharDataSource.h index 262797c..6b3f5a6 100644 --- a/Hive/Source/HiveLib/DataSource/SqlCharDataSource.h +++ b/Hive/Source/HiveLib/DataSource/SqlCharDataSource.h @@ -29,12 +29,14 @@ class SqlCharDataSource : public SqlDataSource, public CharDataSource ~SqlCharDataSource(); Sqf::Value fetchCharacterInitial( string playerId, int serverId, const string& playerName ) override; - Sqf::Value fetchCharacterDetails( int characterId ) override; + Sqf::Value fetchCharacterDetails( Int64 characterId ) override; Sqf::Value fetchTraderObject( int traderObjectId, int action) override; - bool updateCharacter( int characterId, int serverId, const FieldsType& fields ) override; - bool initCharacter( int characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) override; - bool killCharacter( int characterId, int duration, int infected ) override; - bool recordLogin( string playerId, int characterId, int action ) override; + bool updateCharacter( Int64 characterId, int serverId, const FieldsType& fields ) override; + bool updateCharacterGroup( string playerId, int serverId, const Sqf::Value& playerGroup) override; + bool updatePlayerCoins(string playerId, int serverId, Int64 coinsValue, Int64 playerBank) override; + bool initCharacter( Int64 characterId, const Sqf::Value& inventory, const Sqf::Value& backpack ) override; + bool killCharacter( Int64 characterId, int duration, int infected ) override; + bool recordLogin( string playerId, Int64 characterId, int action ) override; private: string _idFieldName; @@ -42,6 +44,10 @@ class SqlCharDataSource : public SqlDataSource, public CharDataSource //statement ids SqlStatementID _stmtChangePlayerName; + SqlStatementID _stmtUpdatePlayerGroup; + SqlStatementID _stmtUpdatePlayerCoinsA; + SqlStatementID _stmtUpdatePlayerCoinsB; + SqlStatementID _stmtUpdatePlayerCoinsC; SqlStatementID _stmtInsertPlayer; SqlStatementID _stmtUpdateCharacterLastLogin; SqlStatementID _stmtInsertNewCharacter; diff --git a/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp b/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp index 96b0715..98c2006 100644 --- a/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp +++ b/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp @@ -81,23 +81,43 @@ SqlObjDataSource::SqlObjDataSource( Poco::Logger& logger, shared_ptr d _objTableName = getDB()->escape(conf->getString("Table",defaultTable)); _cleanupPlacedDays = conf->getInt("CleanupPlacedAfterDays",6); _vehicleOOBReset = conf->getBool("ResetOOBVehicles",false); + _maintenanceObjs = conf->getString("MaintenanceObjects","'Land_DZE_GarageWoodDoorLocked','Land_DZE_LargeWoodDoorLocked','Land_DZE_WoodDoorLocked','CinderWallDoorLocked_DZ','CinderWallDoorSmallLocked_DZ','Plastic_Pole_EP1_DZ'"); } else { _objTableName = defaultTable; _cleanupPlacedDays = -1; _vehicleOOBReset = false; + _maintenanceObjs = "'Land_DZE_GarageWoodDoorLocked','Land_DZE_LargeWoodDoorLocked','Land_DZE_WoodDoorLocked','CinderWallDoorLocked_DZ','CinderWallDoorSmallLocked_DZ','Plastic_Pole_EP1_DZ'"; } } void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue ) { + + //Prevent duplicate ObjectUID by setting ObjectUID = (ObjectID + 1) + string commonUpdateUIDSql = " WHERE `Instance` = " + lexical_cast(serverId) + " AND `ObjectID` <> 0 AND `ObjectID` <> (`ObjectUID` - 1)"; + int numIDUpdated = 0; + { + auto numObjsToUpdate = getDB()->query(("SELECT COUNT(*) FROM " + _objTableName + commonUpdateUIDSql).c_str()); + if (numObjsToUpdate && numObjsToUpdate->fetchRow()) + numIDUpdated = numObjsToUpdate->at(0).getInt32(); + } + if (numIDUpdated > 0) + { + _logger.information("Updating " + lexical_cast(numIDUpdated) + " Object_Data ObjectUID"); + auto stmt2 = getDB()->makeStatement(_stmtChangeObjectUID, "UPDATE " + _objTableName + " SET ObjectUID = (ObjectID + 1) " + commonUpdateUIDSql); + if (!stmt2->directExecute()) + _logger.error("Error executing update ObjectUID statement"); + } + if (_cleanupPlacedDays >= 0) { - string commonSql = "FROM `"+_objTableName+"` WHERE `Instance` = " + lexical_cast(serverId) + + string commonSql = "FROM `" + _objTableName + "` WHERE `Instance` = " + lexical_cast(serverId) + " AND `ObjectUID` <> 0 AND `CharacterID` <> 0" + - " AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL "+lexical_cast(_cleanupPlacedDays)+" DAY)" + - " AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') )"; + " AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL " + lexical_cast(_cleanupPlacedDays) + " DAY)" + + " AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') " + + " OR (`Classname` IN ( " + _maintenanceObjs + ") ))"; int numCleaned = 0; { @@ -107,7 +127,7 @@ void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue } if (numCleaned > 0) { - _logger.information("Removing " + lexical_cast(numCleaned) + " empty placed objects older than " + lexical_cast(_cleanupPlacedDays) + " days"); + _logger.information("Removing " + lexical_cast(numCleaned) + " placed objects older than " + lexical_cast(_cleanupPlacedDays) + " days"); auto stmt = getDB()->makeStatement(_stmtDeleteOldObject, "DELETE "+commonSql); if (!stmt->directExecute()) @@ -115,7 +135,7 @@ void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue } } - auto worldObjsRes = getDB()->queryParams("SELECT `ObjectID`, `Classname`, `CharacterID`, `Worldspace`, `Inventory`, `Hitpoints`, `Fuel`, `Damage` FROM `%s` WHERE `Instance`=%d AND `Classname` IS NOT NULL", _objTableName.c_str(), serverId); + auto worldObjsRes = getDB()->queryParams("SELECT `ObjectID`, `Classname`, `CharacterID`, `Worldspace`, `Inventory`, `Hitpoints`, `Fuel`, `Damage`, `StorageCoins` FROM `%s` WHERE `Instance`=%d AND `Classname` IS NOT NULL AND `Damage` < 1", _objTableName.c_str(), serverId); if (!worldObjsRes) { _logger.error("Failed to fetch objects from database"); @@ -133,10 +153,10 @@ void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue try { objParams.push_back(row[1].getString()); //classname - objParams.push_back(lexical_cast(row[2].getInt32())); //ownerId should be stringified + objParams.push_back(lexical_cast(row[2].getInt64())); //ownerId should be stringified Sqf::Value worldSpace = lexical_cast(row[3].getString()); - if (_vehicleOOBReset && row[2].getInt32() == 0) // no owner = vehicle + if (_vehicleOOBReset && row[2].getInt64() == 0) // no owner = vehicle { PositionInfo posInfo = FixOOBWorldspace(worldSpace); if (posInfo.is_initialized()) @@ -156,6 +176,7 @@ void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue objParams.push_back(lexical_cast(row[5].getCStr())); objParams.push_back(row[6].getDouble()); objParams.push_back(row[7].getDouble()); + objParams.push_back(row[8].getInt64()); //Coins } catch (const bad_lexical_cast&) { @@ -166,7 +187,7 @@ void SqlObjDataSource::populateObjects( int serverId, ServerObjectsQueue& queue queue.push(objParams); } } -void SqlObjDataSource::populateTraderObjects( int characterId, ServerObjectsQueue& queue ) +void SqlObjDataSource::populateTraderObjects( Int64 characterId, ServerObjectsQueue& queue ) { auto worldObjsRes = getDB()->queryParams("SELECT `id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile` FROM `Traders_DATA` WHERE `tid`=%d", characterId); @@ -199,15 +220,34 @@ void SqlObjDataSource::populateTraderObjects( int characterId, ServerObjectsQueu } } -bool SqlObjDataSource::updateObjectInventory( int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory ) +bool SqlObjDataSource::updateObjectInventory(int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory) +{ + unique_ptr stmt; + if (byUID) + stmt = getDB()->makeStatement(_stmtUpdateObjectbyUID, "UPDATE `" + _objTableName + "` SET `Inventory` = ? WHERE `ObjectUID` = ? AND `Instance` = ?"); + else + stmt = getDB()->makeStatement(_stmtUpdateObjectByID, "UPDATE `" + _objTableName + "` SET `Inventory` = ? WHERE `ObjectID` = ? AND `Instance` = ?"); + + stmt->addString(lexical_cast(inventory)); + stmt->addInt64(objectIdent); + stmt->addInt32(serverId); + + bool exRes = stmt->execute(); + poco_assert(exRes == true); + + return exRes; +} + +bool SqlObjDataSource::updateObjectInventoryWCoins(int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory, Int64 coinsValue) { unique_ptr stmt; if (byUID) - stmt = getDB()->makeStatement(_stmtUpdateObjectbyUID, "UPDATE `"+_objTableName+"` SET `Inventory` = ? WHERE `ObjectUID` = ? AND `Instance` = ?"); + stmt = getDB()->makeStatement(_stmtUpdateObjectbyUIDCoins, "UPDATE `" + _objTableName + "` SET `Inventory` = ?, `StorageCoins` = ? WHERE `ObjectUID` = ? AND `Instance` = ?"); else - stmt = getDB()->makeStatement(_stmtUpdateObjectByID, "UPDATE `"+_objTableName+"` SET `Inventory` = ? WHERE `ObjectID` = ? AND `Instance` = ?"); + stmt = getDB()->makeStatement(_stmtUpdateObjectByIDCoins, "UPDATE `" + _objTableName + "` SET `Inventory` = ?, `StorageCoins` = ? WHERE `ObjectID` = ? AND `Instance` = ?"); stmt->addString(lexical_cast(inventory)); + stmt->addInt64(coinsValue); stmt->addInt64(objectIdent); stmt->addInt32(serverId); @@ -277,7 +317,7 @@ bool SqlObjDataSource::updateVehicleStatus( int serverId, Int64 objectIdent, con return exRes; } -bool SqlObjDataSource::createObject( int serverId, const string& className, double damage, int characterId, +bool SqlObjDataSource::createObject( int serverId, const string& className, double damage, Int64 characterId, const Sqf::Value& worldSpace, const Sqf::Value& inventory, const Sqf::Value& hitPoints, double fuel, Int64 uniqueId ) { auto stmt = getDB()->makeStatement(_stmtCreateObject, @@ -288,7 +328,7 @@ bool SqlObjDataSource::createObject( int serverId, const string& className, doub stmt->addInt32(serverId); stmt->addString(className); stmt->addDouble(damage); - stmt->addInt32(characterId); + stmt->addInt64(characterId); stmt->addString(lexical_cast(worldSpace)); stmt->addString(lexical_cast(inventory)); stmt->addString(lexical_cast(hitPoints)); @@ -303,7 +343,9 @@ Sqf::Value SqlObjDataSource::fetchObjectId( int serverId, Int64 objectIdent ) { Sqf::Parameters retVal; //get details from db - auto worldObjsRes = getDB()->queryParams("SELECT `ObjectID` FROM `%s` WHERE `Instance` = %d AND `ObjectUID` = %"PRIu64"", _objTableName.c_str(), serverId, objectIdent); + //auto worldObjsRes = getDB()->queryParams("SELECT `ObjectID` FROM `%s` WHERE `Instance` = %d AND `ObjectUID` = %" PRIu64 "", _objTableName.c_str(), serverId, objectIdent); + + auto worldObjsRes = getDB()->queryParams("CALL retObjID('%s', %d, %" PRIu64 ", @OID)", _objTableName.c_str(), serverId, objectIdent); if (worldObjsRes && worldObjsRes->fetchRow()) { diff --git a/Hive/Source/HiveLib/DataSource/SqlObjDataSource.h b/Hive/Source/HiveLib/DataSource/SqlObjDataSource.h index 20a6894..acfa501 100644 --- a/Hive/Source/HiveLib/DataSource/SqlObjDataSource.h +++ b/Hive/Source/HiveLib/DataSource/SqlObjDataSource.h @@ -31,25 +31,30 @@ class SqlObjDataSource : public SqlDataSource, public ObjDataSource void populateObjects( int serverId, ServerObjectsQueue& queue ) override; - void populateTraderObjects( int characterId, ServerObjectsQueue& queue ) override; + void populateTraderObjects( Int64 characterId, ServerObjectsQueue& queue ) override; bool updateObjectInventory( int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory ) override; + bool updateObjectInventoryWCoins(int serverId, Int64 objectIdent, bool byUID, const Sqf::Value& inventory, Int64 coinsValue ) override; bool deleteObject( int serverId, Int64 objectIdent, bool byUID ) override; bool updateDatestampObject( int serverId, Int64 objectIdent, bool byUID ) override; bool updateVehicleMovement( int serverId, Int64 objectIdent, const Sqf::Value& worldspace, double fuel ) override; bool updateVehicleStatus( int serverId, Int64 objectIdent, const Sqf::Value& hitPoints, double damage ) override; - bool createObject( int serverId, const string& className, double damage, int characterId, + bool createObject( int serverId, const string& className, double damage, Int64 characterId, const Sqf::Value& worldSpace, const Sqf::Value& inventory, const Sqf::Value& hitPoints, double fuel, Int64 uniqueId ) override; Sqf::Value fetchObjectId( int serverId, Int64 objectIdent ) override; private: string _objTableName; int _cleanupPlacedDays; bool _vehicleOOBReset; + string _maintenanceObjs; //statement ids + SqlStatementID _stmtChangeObjectUID; SqlStatementID _stmtDeleteOldObject; SqlStatementID _stmtUpdateObjectbyUID; SqlStatementID _stmtUpdateObjectByID; + SqlStatementID _stmtUpdateObjectByIDCoins; + SqlStatementID _stmtUpdateObjectbyUIDCoins; SqlStatementID _stmtDeleteObjectByUID; SqlStatementID _stmtDeleteObjectByID; SqlStatementID _stmtUpdateDatestampObjectByUID; diff --git a/Hive/Source/HiveLib/HiveExtApp.cpp b/Hive/Source/HiveLib/HiveExtApp.cpp index 708673a..9569396 100644 --- a/Hive/Source/HiveLib/HiveExtApp.cpp +++ b/Hive/Source/HiveLib/HiveExtApp.cpp @@ -153,6 +153,8 @@ HiveExtApp::HiveExtApp(string suffixDir) : AppServer("HiveExt",suffixDir), _serv handlers[201] = boost::bind(&HiveExtApp::playerUpdate,this,_1); handlers[202] = boost::bind(&HiveExtApp::playerDeath,this,_1); handlers[203] = boost::bind(&HiveExtApp::playerInit,this,_1); + handlers[204] = boost::bind(&HiveExtApp::updateGroup, this,_1); //update player group in player_data + handlers[205] = boost::bind(&HiveExtApp::updateGlobalCoins, this, _1); //update global coins in player_data - use existing calls 303/309 for saving object_data coins. use 201 for character coins } #include @@ -295,8 +297,9 @@ Sqf::Value HiveExtApp::getDateTime( Sqf::Parameters params ) #include "DataSource/ObjDataSource.h" #include -Sqf::Value HiveExtApp::streamObjects( Sqf::Parameters params ) +Sqf::Value HiveExtApp::streamObjects( Sqf::Parameters params) { + bool legacyStream = boost::get(params.at(1)); if (_srvObjects.empty()) { if (_initKey.length() < 1) @@ -326,17 +329,54 @@ Sqf::Value HiveExtApp::streamObjects( Sqf::Parameters params ) else { Sqf::Parameters retVal; - retVal.push_back(string("ERROR")); - retVal.push_back(string("Instance already initialized")); + if (legacyStream) { + retVal.push_back(string("ERROR")); + retVal.push_back(string("Instance already initialized")); + } else { + string LastFileName = boost::get(params.at(0)); + remove(LastFileName.c_str()); //delete file + retVal.push_back(string("NOTICE")); + retVal.push_back(string("" + LastFileName + " has been deleted")); + } return retVal; } } else { - Sqf::Parameters retVal = _srvObjects.front(); - _srvObjects.pop(); + if (legacyStream) { + Sqf::Parameters retVal = _srvObjects.front(); + _srvObjects.pop(); + return retVal; + } else { + string fileName = "ObjectData" + _initKey + ".sqf"; //filename will not be predictable if the init key is appended + std::ofstream ofs; + ofs.open(fileName, std::ofstream::out | std::ofstream::trunc); //clear file contents just incase it exists + ofs.close(); + ofs.open(fileName, std::ofstream::out | std::ofstream::app); //open file again to write objects + int i = 0; + + while (!(_srvObjects.empty())) { //write queue to file, formated as array in SQF + Sqf::Value writeVal = _srvObjects.front(); + if (_srvObjects.size() == 1) { + ofs << writeVal; + ofs << "];"; + } + else if (i < 1) { + ofs << "["; + ofs << writeVal; + ofs << ","; + i = 1; + } + else { + ofs << writeVal; + ofs << ","; + } + _srvObjects.pop(); + } - return retVal; + ofs.close(); + return fileName; + } } } @@ -344,10 +384,23 @@ Sqf::Value HiveExtApp::objectInventory( Sqf::Parameters params, bool byUID /*= f { Int64 objectIdent = Sqf::GetBigInt(params.at(0)); Sqf::Value inventory = boost::get(params.at(1)); + Int64 coinsValue = -1; - if (objectIdent != 0) //all the vehicles have objectUID = 0, so it would be bad to update those - return ReturnBooleanStatus(_objData->updateObjectInventory(getServerId(),objectIdent,byUID,inventory)); + try + { + if (!Sqf::IsNull(params.at(2))) { + coinsValue = Sqf::GetBigInt(params.at(2)); + } + } + catch (const std::out_of_range&) {} //not using the coin system + if (objectIdent != 0) { + if (coinsValue >= 0) { + return ReturnBooleanStatus(_objData->updateObjectInventoryWCoins(getServerId(), objectIdent, byUID, inventory, coinsValue)); + } else { + return ReturnBooleanStatus(_objData->updateObjectInventory(getServerId(), objectIdent, byUID, inventory)); + } + } return ReturnBooleanStatus(true); } @@ -399,7 +452,7 @@ Sqf::Value HiveExtApp::objectPublish( Sqf::Parameters params ) { string className = boost::get(params.at(1)); double damage = Sqf::GetDouble(params.at(2)); - int characterId = Sqf::GetIntAny(params.at(3)); + Int64 characterId = Sqf::GetBigInt(params.at(3)); Sqf::Value worldSpace = boost::get(params.at(4)); Sqf::Value inventory = boost::get(params.at(5)); Sqf::Value hitPoints = boost::get(params.at(6)); @@ -427,7 +480,7 @@ Sqf::Value HiveExtApp::loadPlayer( Sqf::Parameters params ) Sqf::Value HiveExtApp::loadCharacterDetails( Sqf::Parameters params ) { - int characterId = Sqf::GetIntAny(params.at(0)); + Int64 characterId = Sqf::GetBigInt(params.at(0)); return _charData->fetchCharacterDetails(characterId); } @@ -436,7 +489,7 @@ Sqf::Value HiveExtApp::loadTraderDetails( Sqf::Parameters params ) { if (_srvObjects.empty()) { - int characterId = Sqf::GetIntAny(params.at(0)); + Int64 characterId = Sqf::GetBigInt(params.at(0)); _objData->populateTraderObjects(characterId, _srvObjects); @@ -464,7 +517,7 @@ Sqf::Value HiveExtApp::tradeObject( Sqf::Parameters params ) Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params ) { string playerId = Sqf::GetStringAny(params.at(0)); - int characterId = Sqf::GetIntAny(params.at(1)); + Int64 characterId = Sqf::GetBigInt(params.at(1)); int action = Sqf::GetIntAny(params.at(2)); return ReturnBooleanStatus(_charData->recordLogin(playerId,characterId,action)); @@ -472,7 +525,7 @@ Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params ) Sqf::Value HiveExtApp::playerUpdate( Sqf::Parameters params ) { - int characterId = Sqf::GetIntAny(params.at(0)); + Int64 characterId = Sqf::GetBigInt(params.at(0)); CharDataSource::FieldsType fields; try @@ -586,15 +639,25 @@ Sqf::Value HiveExtApp::playerUpdate( Sqf::Parameters params ) logger().warning("Update of character " + lexical_cast(characterId) + " only had " + lexical_cast(params.size()) + " parameters out of 16"); } - if (fields.size() > 0) - return ReturnBooleanStatus(_charData->updateCharacter(characterId,getServerId(),fields)); + try + { + if (!Sqf::IsNull(params.at(16))) + { + Int64 coinsValue = static_cast(Sqf::GetBigInt(params.at(16))); + fields["Coins"] = coinsValue; + } + } catch (const std::out_of_range&) {} //not using the coin system + + if (fields.size() > 0) { + return ReturnBooleanStatus(_charData->updateCharacter(characterId, getServerId(), fields)); + } return ReturnBooleanStatus(true); } Sqf::Value HiveExtApp::playerInit( Sqf::Parameters params ) { - int characterId = Sqf::GetIntAny(params.at(0)); + Int64 characterId = Sqf::GetBigInt(params.at(0)); Sqf::Value inventory = boost::get(params.at(1)); Sqf::Value backpack = boost::get(params.at(2)); @@ -603,13 +666,30 @@ Sqf::Value HiveExtApp::playerInit( Sqf::Parameters params ) Sqf::Value HiveExtApp::playerDeath( Sqf::Parameters params ) { - int characterId = Sqf::GetIntAny(params.at(0)); + Int64 characterId = Sqf::GetBigInt(params.at(0)); int duration = static_cast(Sqf::GetDouble(params.at(1))); int infected = Sqf::GetIntAny(params.at(2)); return ReturnBooleanStatus(_charData->killCharacter(characterId,duration,infected)); } +Sqf::Value HiveExtApp::updateGroup(Sqf::Parameters params) +{ + string playerId = Sqf::GetStringAny(params.at(0)); + const Sqf::Value& playerGroup = boost::get(params.at(2)); + + return ReturnBooleanStatus(_charData->updateCharacterGroup(playerId, getServerId(), playerGroup)); +} + +Sqf::Value HiveExtApp::updateGlobalCoins(Sqf::Parameters params) +{ + string playerId = Sqf::GetStringAny(params.at(0)); + Int64 coinsValue = Sqf::GetBigInt(params.at(2)); + Int64 playerBank = Sqf::GetBigInt(params.at(3)); + + return ReturnBooleanStatus(_charData->updatePlayerCoins(playerId, getServerId(), coinsValue, playerBank)); +} + namespace { class WhereVisitor : public boost::static_visitor diff --git a/Hive/Source/HiveLib/HiveExtApp.h b/Hive/Source/HiveLib/HiveExtApp.h index 759b1b2..adaaab9 100644 --- a/Hive/Source/HiveLib/HiveExtApp.h +++ b/Hive/Source/HiveLib/HiveExtApp.h @@ -98,6 +98,8 @@ class HiveExtApp: public AppServer Sqf::Value playerUpdate(Sqf::Parameters params); Sqf::Value playerInit(Sqf::Parameters params); Sqf::Value playerDeath(Sqf::Parameters params); + Sqf::Value updateGroup(Sqf::Parameters params); + Sqf::Value updateGlobalCoins(Sqf::Parameters params); Sqf::Value dataRequest(Sqf::Parameters params, bool async = false); Sqf::Value dataStatus(Sqf::Parameters params); diff --git a/Hive/Source/HiveLib/HiveLib.vcxproj b/Hive/Source/HiveLib/HiveLib.vcxproj index 5ec8150..937d7f3 100644 --- a/Hive/Source/HiveLib/HiveLib.vcxproj +++ b/Hive/Source/HiveLib/HiveLib.vcxproj @@ -37,20 +37,21 @@ {591D3468-3D70-4D83-B522-BDBD22DC7ADC} Win32Proj HiveLib + 10.0.15063.0 StaticLibrary true Unicode - v120 + v141 StaticLibrary false true Unicode - v120 + v141 @@ -67,11 +68,13 @@ - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) - + + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + @@ -105,7 +108,7 @@ true true %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt MultiThreadedDLL diff --git a/Hive/Source/HiveLib/version_gen.py b/Hive/Source/HiveLib/version_gen.py index feb355b..bc4efd4 100644 --- a/Hive/Source/HiveLib/version_gen.py +++ b/Hive/Source/HiveLib/version_gen.py @@ -1,8 +1,8 @@ import os import sys -with os.popen("git rev-list HEAD", "r") as out: +with os.popen("git rev-list HEAD ^origin", "r") as out: version = out.read().split("\n")[0].strip("\r") - with open(sys.argv[1], "rb") as _in: - with open(sys.argv[2], "wb") as _out: + with open(sys.argv[1], "r") as _in: + with open(sys.argv[2], "w") as _out: _out.write(_in.read().replace("%GIT_VERSION%", version)) \ No newline at end of file diff --git a/Hive/Source/HiveLib/version_gen.sh b/Hive/Source/HiveLib/version_gen.sh index 6e5d73f..33224ab 100644 --- a/Hive/Source/HiveLib/version_gen.sh +++ b/Hive/Source/HiveLib/version_gen.sh @@ -1,6 +1,6 @@ #!/bin/bash -gitVer=`git rev-list HEAD | head -n 1` +gitVer=`git rev-list HEAD ^origin | head -n 1` sedCommand="s/%GIT_VERSION%/${gitVer}/g" echo "Generating Git version file" sed "$sedCommand" $1 > $2 \ No newline at end of file diff --git a/Hive/Source/Restarter/Restarter.vcxproj b/Hive/Source/Restarter/Restarter.vcxproj index 438053f..dd1fc77 100644 --- a/Hive/Source/Restarter/Restarter.vcxproj +++ b/Hive/Source/Restarter/Restarter.vcxproj @@ -17,20 +17,21 @@ {11AFA4C2-C32F-467D-A7C5-D4B629068E2B} Win32Proj Restarter + 10.0.15063.0 Application true Unicode - v120 + v141 Application false true Unicode - v120 + v141 @@ -48,11 +49,12 @@ true - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) false + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\HiveDeps\boost\lib\x86\v141\lib; @@ -84,7 +86,7 @@ true %(PreprocessorDefinitions) MultiThreadedDLL - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt Console diff --git a/Hive/Source/Shared/Shared.vcxproj b/Hive/Source/Shared/Shared.vcxproj index aa5b733..0a9660d 100644 --- a/Hive/Source/Shared/Shared.vcxproj +++ b/Hive/Source/Shared/Shared.vcxproj @@ -37,20 +37,21 @@ {92C57338-E848-422B-8E81-6F6D11671750} Win32Proj Shared + 10.0.15063.0 StaticLibrary true Unicode - v120 + v141 StaticLibrary false true Unicode - v120 + v141 @@ -71,11 +72,13 @@ - C:\Development\Libraries\boost_1_55_0\include;$(IncludePath) - C:\Development\Libraries\boost_1_55_0\lib\x86\v120\lib;$(LibraryPath) + C:\HiveDeps\boost\boost;$(IncludePath) + C:\HiveDeps\boost\lib\x86\v141\lib;$(LibraryPath) - + + C:\HiveDeps\boost\lib\x86\v141\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + @@ -102,7 +105,7 @@ true true %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt MultiThreadedDLL diff --git a/HiveDeps/Detours/Detours.props b/HiveDeps/Detours/Detours.props new file mode 100644 index 0000000..4cd1d3a --- /dev/null +++ b/HiveDeps/Detours/Detours.props @@ -0,0 +1,22 @@ + + + + + + + + $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)lib.$(PlatformShortName);%(AdditionalLibraryDirectories) + detours.lib;%(AdditionalDependencies) + + + detours.lib;%(AdditionalDependencies) + + + $(MSBuildThisFileDirectory)lib.$(PlatformShortName);%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/Detours/src/Makefile b/HiveDeps/Detours/src/Makefile new file mode 100644 index 0000000..c44caa2 --- /dev/null +++ b/HiveDeps/Detours/src/Makefile @@ -0,0 +1,107 @@ +############################################################################## +## +## Makefile for Detours. +## +## Microsoft Research Detours Package, Version 3.0 Build_339. +## +## Copyright (c) Microsoft Corporation. All rights reserved. +## + +ROOT = .. +!include "$(ROOT)\system.mak" + +!IF "$(DETOURS_SOURCE_BROWSING)" == "" +DETOURS_SOURCE_BROWSING = 0 +!ENDIF + +#######################/####################################################### +## +CFLAGS=/W4 /WX /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=$(DETOURS_BITS) + +!IF $(DETOURS_SOURCE_BROWSING)==1 +CFLAGS=$(CFLAGS) /FR +!ELSE +CFLAGS=$(CFLAGS) /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x501 +!ENDIF + +!IF "$(DETOURS_TARGET_PROCESSOR)" == "X86" +CFLAGS=$(CFLAGS) /wd4163 # intrinsic rdtebex not available; using newer Windows headers with older compiler +!ENDIF + +!if defined(DETOURS_WIN_7) && defined(DETOURS_CL_17_OR_NEWER) +CFLAGS=$(CFLAGS) /D_USING_V110_SDK71_ +!elseif defined(DETOURS_ANALYZE) +CFLAGS=$(CFLAGS) /analyze +!endif + +OBJS = \ + $(OBJD)\detours.obj \ + $(OBJD)\modules.obj \ + $(OBJD)\disasm.obj \ + $(OBJD)\image.obj \ + $(OBJD)\creatwth.obj \ + +############################################################################## +## +.SUFFIXES: .cpp .h .obj + +!ifdef DETOURS_ANALYZE +.cpp{$(OBJD)}.obj: + $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< +!else +.cpp{$(OBJD)}.obj:: + $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< +!endif + +############################################################################## + +all: dirs \ + $(LIBD)\detours.lib \ + $(INCD)\detours.h \ + $(INCD)\detver.h \ +!IF $(DETOURS_SOURCE_BROWSING)==1 + $(OBJD)\detours.bsc \ +!endif + +############################################################################## + +clean: + -del *~ 2>nul + -del $(LIBD)\detours.pdb $(LIBD)\detours.lib 2>nul + -rmdir /q /s $(OBJD) 2>nul + +realclean: clean + -rmdir /q /s $(OBJDS) 2>nul + +############################################################################## + +dirs: + @if not exist "$(INCD)" mkdir "$(INCD)" && echo. Created $(INCD) + @if not exist "$(LIBD)" mkdir "$(LIBD)" && echo. Created $(LIBD) + @if not exist "$(BIND)" mkdir "$(BIND)" && echo. Created $(BIND) + @if not exist "$(OBJD)" mkdir "$(OBJD)" && echo. Created $(OBJD) + +$(OBJD)\detours.bsc : $(OBJS) + bscmake /v /n /o $@ $(OBJS:.obj=.sbr) + +$(LIBD)\detours.lib : $(OBJS) + link /lib /out:$@ $(OBJS) + +$(INCD)\detours.h : detours.h + copy detours.h $@ + +$(INCD)\detver.h : detver.h + copy detver.h $@ + +$(OBJD)\detours.obj : detours.cpp detours.h +$(OBJD)\modules.obj : modules.cpp detours.h +$(OBJD)\disasm.obj : disasm.cpp detours.h +$(OBJD)\image.obj : image.cpp detours.h +$(OBJD)\creatwth.obj : creatwth.cpp uimports.cpp detours.h + +test: all + cd $(MAKEDIR)\..\samples\slept + nmake /nologo test + cd $(MAKEDIR) + +################################################################# End of File. diff --git a/HiveDeps/MySQL/MySQL.props b/HiveDeps/MySQL/MySQL.props new file mode 100644 index 0000000..abd6da4 --- /dev/null +++ b/HiveDeps/MySQL/MySQL.props @@ -0,0 +1,20 @@ + + + + + + + + $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + mysqlclient.lib;%(AdditionalDependencies) + $(MSBuildThisFileDirectory)lib;%(AdditionalLibraryDirectories) + + + mysqlclient.lib;%(AdditionalDependencies) + $(MSBuildThisFileDirectory)lib;%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/PostgreSQL/PostgreSQL.props b/HiveDeps/PostgreSQL/PostgreSQL.props new file mode 100644 index 0000000..775c23a --- /dev/null +++ b/HiveDeps/PostgreSQL/PostgreSQL.props @@ -0,0 +1,16 @@ + + + + + + + + $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + pqclient.lib;%(AdditionalDependencies) + $(MSBuildThisFileDirectory)lib\$(Platform)\$(PlatformToolset)\$(Configuration);%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/TBB/TBB.props b/HiveDeps/TBB/TBB.props new file mode 100644 index 0000000..fdd29e7 --- /dev/null +++ b/HiveDeps/TBB/TBB.props @@ -0,0 +1,15 @@ + + + + + + + + $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)build\windows_ia32_cl_vc14_release;%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/poco/Common.props b/HiveDeps/poco/Common.props new file mode 100644 index 0000000..7ac94a3 --- /dev/null +++ b/HiveDeps/poco/Common.props @@ -0,0 +1,19 @@ + + + + + + $(SolutionDir)obj\$(ProjectName)\$(Platform)\$(PlatformToolset)\$(Configuration)\ + + + + $(ProjectDir)include;$(SolutionDir)include;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)lib;%(AdditionalLibraryDirectories) + true + $(MSBuildThisFileDirectory)lib\$(TargetName).lib + + + + \ No newline at end of file diff --git a/HiveDeps/poco/Executable.props b/HiveDeps/poco/Executable.props new file mode 100644 index 0000000..62e8709 --- /dev/null +++ b/HiveDeps/poco/Executable.props @@ -0,0 +1,12 @@ + + + + + + + + $(MSBuildThisFileDirectory)bin\ + + + + \ No newline at end of file diff --git a/HiveDeps/poco/MySQL.props b/HiveDeps/poco/MySQL.props new file mode 100644 index 0000000..8500e4b --- /dev/null +++ b/HiveDeps/poco/MySQL.props @@ -0,0 +1,27 @@ + + + + + Release + Debug + + + + + $(MYSQL_DIR)\include;%(AdditionalIncludeDirectories) + + + libmysql.lib;%(AdditionalDependencies) + $(MYSQL_DIR)\lib;%(AdditionalLibraryDirectories) + + + libmysql.lib;%(AdditionalDependencies) + $(MYSQL_DIR)\lib;%(AdditionalLibraryDirectories) + + + + + $(RealConfiguration) + + + \ No newline at end of file diff --git a/HiveDeps/poco/Poco.props b/HiveDeps/poco/Poco.props new file mode 100644 index 0000000..b61bd75 --- /dev/null +++ b/HiveDeps/poco/Poco.props @@ -0,0 +1,17 @@ + + + + + + + + $(MSBuildThisFileDirectory)Foundation\include;$(MSBuildThisFileDirectory)Net\include;$(MSBuildThisFileDirectory)Util\include;$(MSBuildThisFileDirectory)XML\include;$(MSBuildThisFileDirectory)Zip\include;%(AdditionalIncludeDirectories) + POCO_NO_UNWINDOWS;POCO_STATIC;%(PreprocessorDefinitions) + 4250;%(DisableSpecificWarnings) + + + $(MSBuildThisFileDirectory)lib;%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/poco/StaticLib.props b/HiveDeps/poco/StaticLib.props new file mode 100644 index 0000000..ed0499e --- /dev/null +++ b/HiveDeps/poco/StaticLib.props @@ -0,0 +1,19 @@ + + + + + + + + $(MSBuildThisFileDirectory)lib\ + + + + $(TargetDir)$(TargetName).pdb + + + $(OutDir);%(AdditionalLibraryDirectories) + + + + \ No newline at end of file diff --git a/HiveDeps/poco/TestExe.props b/HiveDeps/poco/TestExe.props new file mode 100644 index 0000000..2385377 --- /dev/null +++ b/HiveDeps/poco/TestExe.props @@ -0,0 +1,25 @@ + + + + + + + + + + + static_md\ + static_md\ + static_mt\ + static_mt\ + + + bin\$(Platform)\$(PlatformToolset)\$(OutSuffix) + + + + $(TargetDir)$(TargetName).lib + + + + \ No newline at end of file diff --git a/HiveDeps/readme.md b/HiveDeps/readme.md new file mode 100644 index 0000000..21b87a2 --- /dev/null +++ b/HiveDeps/readme.md @@ -0,0 +1 @@ +PLACE THE HiveDeps FOLDER IN YOUR C:\ DRIVE ROOT \ No newline at end of file diff --git a/README b/README.old similarity index 100% rename from README rename to README.old diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..0d5c1f6 --- /dev/null +++ b/readme.md @@ -0,0 +1,111 @@ +# Dependencies +* The instructions for buiulding Dependencies are based on VS 2017, modify MSVC versions according to your VS version +* Unless otherwise noted this guide is performed from the VS tools command prompt +* This project reuires visual studio to be run as an administrator! +1. Copy the HiveDeps folder into your C:\ drive + +2. Install Python (any version works, use latest 3.x), and check add to PATH. click disable PATH limit then close installer https://www.python.org/downloads/ + +3. Download and build boost http://www.boost.org/ in the HiveDeps folder (We need the libs, prebuilt packages are not acceptable) + * download the latest version of boost (this guide was made using 1.63) + * Extract the files (not the root folder) to your C:\HiveDeps\boost directory + + #### Building Boost + 1. open up your visual studio command prompt + 2. ```CD C:\HiveDeps\boost``` + 3. ```bootstrap.bat``` + 4. ```b2.exe toolset=msvc-14.0 --build-type=complete variant=release,debug runtime-link=shared,static link=static threading=multi address-model=32 --without-log --stagedir=lib\x86\v141 --build-dir=out\x86\v141``` + * NOTE: boost 1.63 has no build out of the box for VS2017, you must edit project-config.jam + ```using msvc ;``` -----> ```using msvc : 14.0 : "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.24728\bin\HostX64\x64\cl.exe";``` + +#### Building POCO +1. Download Poco here (We use 1.7.8): https://pocoproject.org/download/index.html and extract files to C:\HiveDeps\poco +2. POCO requires OpenSSL, MySQL Connector and ODBC (part of Windows SDK) +3. install Windows 8.1 SDK from this link if building fails https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk +4. download OpenSSL https://www.openssl.org/source/ and extract to C;\HiveDeps\openssl, rename openssl-VER to openssl, we need to configure OpenSSL + * Download and install NASM http://www.nasm.us/ + * download and install PERL for windows, I used Strawberry PERL http://strawberryperl.com/releases.html + * We need to build both MT and MD libraries + * ```@set path=C:\Users\Nick-PC\AppData\Local\NASM;%path%``` + * ```@set path=C:\Strawberry\perl\bin;%path%``` + * ```CD C:\openssl``` + * ```perl Configure VC-WIN32``` + * ```nmake``` + * ```nmake test``` + * We use a buiuld script from https://www.npcglib.org/~stathis/blog/precompiled-openssl/ to build both static and dynamic (MT/MD) libraries for POCO. + * alternatively you may just want to download the compiled version and copy over the libs, but there isn't a precompiled MSVC 2017 version yet + * Download and install CygWin https://www.cygwin.com/ we need DOS2UNIX, PATCH, and 7Z (use view: FULL and search feature) + * Download the applicable version of the openssl build script, I used build-openssl-1.1.0e.bat AND PATCH openssl-1.1.0e.patch then place in your C:\openssl folder + * Download perlEnv.bat here: https://www.npcglib.org/~stathis/downloads/perlenv.bat and place in your perl root director + * edit the build script, find and replace D:\ with C:\ or your applicable drive. Edit \opensource\ -> \ and in the buildpath variable remove ```-!PROJECT_VERSION!``` be sure to verify your CygWin and PERL paths! + * Edit VS_VERSION to your version, and VISUAL_STUDIO_VC to the correct path where your VS install has vcvarsall.bat i.e. mine is ```C:\Program Files (x86)\Microsoft Visual Studio\!VS_VERSION!\Community\VC\Auxiliary\Build``` + * ```CD C:\openssl``` + * ```build-openssl-1.1.0e.bat patch build x86 static release``` + * ```build-openssl-1.1.0e.bat build all``` + * applicable files will be in the C:\Openssl-build-VER-VER and C:\Openssl-dist-VER-VER folders MD Release (C:\openssl-VER-VER\openssl-x86-shared-release-VER) MT Release (C:\openssl-VER-VER\openssl-x86-static-release-VER) + * find libsslmd.lib and create a copy, rename to ssleay32, and libcrypto -> libeay32. same again for the .exp files (do the same for both MT and MD files) BE SURE TO CHANGE MT AND MD TO LOWERCASE! + * Copy .lib and .exp files from the openssl folder to C:\openssl\include\lib (you may need to make the lib folder) +5. Download and build the MySQL client connector in the C:\HiveDeps\MySQL folder +[REQUIRES CMAKE] + * https://dev.mysql.com/downloads/connector/c/ download the source code OS + * Edit the Poco buildwin.cmd file to set MYSQL_DIR=C:\HiveDeps\MySQL + * To build: + * (if your CMake path is not set) @set path=C:\Program Files (x86)\CMake\bin;%path% + * ```CD C:\HiveDeps\MySQL``` + * ```cmake``` + * Open ALL_BUILD.vcxproj and build the RELEASE VERSION of the solution + * Copy the files in C:\HiveDeps\MySQL\libmysql\Release to your C:\HiveDeps\poco\lib folder + * in the C:\HiveDeps\MySQL folder create a new lib folder + * Copy the files in the following directors to C:\HiveDeps\MySQL\ + 1. C:\HiveDeps\MySQL\libmysql\Release + C:\HiveDeps\MySQL\libmysql\Debug + * download this repo, https://github.com/rajkosto/deps-mysql and merge the include directories. DO NOT OVERWRITE ANY FILES + * NOTE you need to clean and rebuild a Dynamically linked version of MySQL for the hive AFTER building poco! This is not covered, since it's actually not necessary unless you change the DatabaseMySQL.dll code + 3. ```CD C:\HiveDeps\poco``` + 4. ```buildwin 150 build all both Win32 samples``` + 4a. Replace 150 with your VS MSVC version + +#### Building intel TBB +1. download from https://www.threadingbuildingblocks.org/download#stable-releases (guide is using 4.4 u5) +2. Extract to C:\HiveDeps\TBB +3. open C:\HiveDeps\TBB\build\vs2012\makefile.sln and update the solutions versions if prompted +4. Save all and close visual studio +5. CD C:\HiveDeps\TBB +6. gmake +7. Your output will be: C:\HiveDeps\TBB\build\windows_ia32_cl_vc14_release + +#### Building detours +1. download the latest version of Microsoft Detours https://www.microsoft.com/en-us/download/details.aspx?id=52586 (extract to C:\kfw-2.6.5), +2. Extract files to the C:\HiveDeps\Detours folder +3. CD C:\HiveDeps\Detours\src +4. Overwrite your Makefile with the one in the root of the Detours folder in this Github (LINK) +4. Unset the Read Only property on MAKEFILE and edit the CFLAGS line to read ```CFLAGS=/W4 /WX /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=$(DETOURS_BITS)``` +5. ```nmake``` + +#### Building PostgreSQL +** PostgreSQL compilation is not covered in this tutorial as many users do not use it. You may use Rajkosto's Poco-Deps repository on Github** +** IN VS Right click on the PostgreSQL project and unload it ** + +#### Finally building the Hive +1. resolve your lib and include paths + * if you are using the windows tooal and apps SDK version 10 you will need to add an include path ```$(UniversalCRT_IncludePath)``` to all projects + * right click each project > properties > C/C++ > General > add ```$(UniversalCRT_IncludePath)``` to your additional includes directory (replace [VER] with your SDK version path) + * replace text in the additional includes field with: ```%(AdditionalIncludeDirectories)$(UniversalCRT_IncludePath)C:\HiveDeps\boost;C:\Program Files (x86)\Windows Kits\10\Include\[VER]\ucrt``` + 1. you need to edit the boost lib directory to the Library Directories field of project properties -> VC++ Directories. where VER is your MSVC VER + * AND Add the ucrt libs directory to the field if you are using 10 SDK + * add first to the input field, keep any text already in the box ```C:\HiveDeps\boost\lib\x86\VER\lib;``` + * FOR SDK 10 USERS ONLY! ```C:\HiveDeps\boost\lib\x86\VER\lib;C:\Program Files (x86)\Windows Kits\10\Lib\VER\ucrt\x86;``` + 2. Edit TBB.props file if it does not reflect you current TBB lib path + * ```$(MSBuildThisFileDirectory)build\windows_ia32_cl_vc14_release;``` ----> ```$(MSBuildThisFileDirectory)build\windows_ia32_cl_[YOUR VERSION]_release;``` +2. if you recieve any missing include errors, google them, chances are the VS installation requires additional components + +# Common Errors +1. Double check your include and library paths if you are missing any .lib .h files, or links. You need to change paths in this guide to YOUR actual path and version after building the Dependencies + * Also make sure your .props files are in the correct places and are up to date +2. ```:VCEnd exited with error code #``` + * Run VS as administrator, make sure you have python! Clean solution and rebuild + * Ensure git is part of your environment variables (this project requires the git command for versioning) see the instructions here for directions: http://stackoverflow.com/questions/26620312/installing-git-in-path-with-github-client-for-windows + * Environment variable edits require application restart! + * You must be working out of a cloned repository using the github app for windows + * The file ./source/HiveLib/version_gen.sh and version_gen.py may need to be edited ```gitVer=`git rev-list HEAD | head -n 1``` ---> ```gitVer=`git rev-list HEAD ^origin | head -n 1``` +3. If you are building a debug build, you will need to change all of the static paths to the debug libraries, since I linked to the release libs in the props, and guide above +4. If your build is failing despite following the directions, ensure you select the release|Win32 Active config setting \ No newline at end of file