diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 36cb3f2df..074963e7e 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -18659,6 +18659,14 @@ void Player::InitGlyphsForLevel() void Player::EnterVehicle(Vehicle *vehicle) { + VehicleEntry const *ve = sVehicleStore.LookupEntry(vehicle->GetVehicleId()); + if(!ve) + return; + + VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(ve->m_seatID[0]); + if(!veSeat) + return; + vehicle->SetCharmerGUID(GetGUID()); vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); @@ -18684,9 +18692,9 @@ void Player::EnterVehicle(Vehicle *vehicle) data << vehicle->GetOrientation(); // o // transport part, TODO: load/calculate seat offsets data << uint64(vehicle->GetGUID()); // transport guid - data << float(0); // transport offsetX - data << float(0); // transport offsetY - data << float(3); // transport offsetZ + data << float(veSeat->m_attachmentOffsetX); // transport offsetX + data << float(veSeat->m_attachmentOffsetY); // transport offsetY + data << float(veSeat->m_attachmentOffsetZ); // transport offsetZ data << float(0); // transport orientation data << uint32(getMSTime()); // transport time data << uint8(0); // seat @@ -18694,9 +18702,6 @@ void Player::EnterVehicle(Vehicle *vehicle) data << uint32(0); // fall time GetSession()->SendPacket(&data); - vehicle->SetSpeed(MOVE_RUN, vehicle->GetCreatureInfo()->speed, true); - vehicle->SetSpeed(MOVE_FLIGHT, vehicle->GetCreatureInfo()->speed, true); - data.Initialize(SMSG_PET_SPELLS, 8+4+4+4+4*10+1+1); data << uint64(vehicle->GetGUID()); data << uint32(0x00000000); diff --git a/src/game/Unit.h b/src/game/Unit.h index 99bbf62ab..289317472 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -167,7 +167,7 @@ enum UnitBytes2_Flags UNIT_BYTE2_FLAG_UNK1 = 0x02, UNIT_BYTE2_FLAG_FFA_PVP = 0x04, UNIT_BYTE2_FLAG_SANCTUARY = 0x08, - UNIT_BYTE2_FLAG_AURAS = 0x10, // show positive auras as positive, and allow its dispel + UNIT_BYTE2_FLAG_UNK4 = 0x10, UNIT_BYTE2_FLAG_UNK5 = 0x20, UNIT_BYTE2_FLAG_UNK6 = 0x40, UNIT_BYTE2_FLAG_UNK7 = 0x80 @@ -1149,7 +1149,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject AuraList const& GetSingleCastAuras() const { return m_scAuras; } SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; - // Threat related methodes + // Threat related methods bool CanHaveThreatList() const; void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL); float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL); diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index e70d7c75f..4e1153a16 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -82,8 +82,6 @@ bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, u SetVehicleId(vehicleId); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - //SetUInt32Value(UNIT_FIELD_BYTES_1, 0x02000001); - //SetUInt32Value(UNIT_FIELD_BYTES_2, 0x00000001); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); CreatureInfo const *ci = GetCreatureInfo(); diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index fe6b88760..41d74b2d8 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -534,7 +534,15 @@ bool ChatHandler::HandleSpawnVehicle(const char* args) uint32 entry = (uint32)atoi(e); uint32 id = (uint32)atoi(i); - // TODO: check entry, id... + CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry); + + if(!ci) + return false; + + VehicleEntry const *ve = sVehicleStore.LookupEntry(id); + + if(!ve) + return false; Vehicle *v = new Vehicle; Map *map = m_session->GetPlayer()->GetMap(); diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index cc817014c..c8cce9da6 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -132,6 +132,8 @@ TaxiPathNodesByPath sTaxiPathNodesByPath; static DBCStorage sTaxiPathNodeStore(TaxiPathNodeEntryfmt); DBCStorage sTotemCategoryStore(TotemCategoryEntryfmt); +DBCStorage sVehicleStore(VehicleEntryfmt); +DBCStorage sVehicleSeatStore(VehicleSeatEntryfmt); DBCStorage sWorldMapAreaStore(WorldMapAreaEntryfmt); DBCStorage sWorldSafeLocsStore(WorldSafeLocsEntryfmt); @@ -437,6 +439,8 @@ void LoadDBCStores(std::string dataPath) sTaxiPathNodeStore.Clear(); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore, dbcPath,"TotemCategory.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc"); diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index b5c268258..3478b3d14 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -200,6 +200,8 @@ extern TaxiMask sTaxiNodesMask; extern TaxiPathSetBySource sTaxiPathSetBySource; extern TaxiPathNodesByPath sTaxiPathNodesByPath; extern DBCStorage sTotemCategoryStore; +extern DBCStorage sVehicleStore; +extern DBCStorage sVehicleSeatStore; //extern DBCStorage sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates extern DBCStorage sWorldSafeLocsStore; diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index 679e36d54..fd7e28b01 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -84,5 +84,7 @@ const char TaxiNodesEntryfmt[]="nifffxxxxxxxxxxxxxxxxxii"; const char TaxiPathEntryfmt[]="niii"; const char TaxiPathNodeEntryfmt[]="diiifffiixx"; const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii"; +const char VehicleEntryfmt[]="niffffiiiiiiiiffffiiiiiifffffffffffssssfifi"; +const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiii"; const char WorldMapAreaEntryfmt[]="xinxffffix"; const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx"; diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp index 86e017c96..a93f2a827 100644 --- a/src/shared/vmap/VMapManager.cpp +++ b/src/shared/vmap/VMapManager.cpp @@ -275,10 +275,12 @@ namespace VMAP { dirFileName = getDirFileName(pMapId); } - size_t len = pBasePath.length() + dirFileName.length(); - char *filenameBuffer = new char[len+1]; - sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str()); - FILE* df = fopen(filenameBuffer, "rb"); + //size_t len = pBasePath.length() + dirFileName.length(); + //char *filenameBuffer = new char[len+1]; + //sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str()); + std::string fb = pBasePath + dirFileName; + //FILE* df = fopen(filenameBuffer, "rb"); + FILE* df = fopen(fb.c_str(), "rb"); if(df) { char lineBuffer[FILENAMEBUFFER_SIZE]; @@ -288,8 +290,12 @@ namespace VMAP chomp(name); if(name.length() >1) { - sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), name.c_str()); - FILE* df2 = fopen(filenameBuffer, "rb"); + //size_t len2 = pBasePath.length() + name.length(); + //char *filenameBuffer2 = new char[len2+1]; + //sprintf(filenameBuffer2, "%s%s", pBasePath.c_str(), name.c_str()); + std::string fb2 = pBasePath + name; + //FILE* df2 = fopen(filenameBuffer2, "rb"); + FILE* df2 = fopen(fb2.c_str(), "rb"); if(df2) { char magic[8]; @@ -298,11 +304,12 @@ namespace VMAP result = true; fclose(df2); } + //delete[] filenameBuffer2; } } fclose(df); } - delete[] filenameBuffer; + //delete[] filenameBuffer; return result; } @@ -659,14 +666,16 @@ namespace VMAP bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent) { bool result = true; - size_t len = iBasePath.length() + pDirFileName.length(); - char *filenameBuffer = new char[len+1]; + //size_t len = iBasePath.length() + pDirFileName.length(); + //char *filenameBuffer = new char[len+1]; if(!hasDirFile(pDirFileName)) { FilesInDir filesInDir; result = false; - sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str()); - FILE* df = fopen(filenameBuffer, "rb"); + std::string fb = iBasePath + pDirFileName; + //sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str()); + //FILE* df = fopen(filenameBuffer, "rb"); + FILE* df = fopen(fb.c_str(), "rb"); if(df) { char lineBuffer[FILENAMEBUFFER_SIZE]; @@ -726,7 +735,7 @@ namespace VMAP filesInDir.incRefCount(); } } - delete [] filenameBuffer; + //delete [] filenameBuffer; return (result); }