void Vehicle::AddPassenger(Player * player, int8 seat) { if (!player->IsInWorld()) return; if (seat == -1) //choose a seat for us { for (uint8 i= 0; i < GetOccupancyLimit(); i++) if (m_passengers[i] == NULL) { seat = i; break; } if (seat == -1) //can't find a seat return; seat = 0; } else { if (seat >= GetOccupancyLimit() || m_passengers[seat] != NULL) return; } sLog.outDebug("AddPassenger"); m_passengers[seat] = player; // Set this vehicle and seat to player player->SetVehicle(this, seat); // Time to move into the unit... //player->Root(); SendFarsightPacket(player, true); RelocateToVehicle(player); if (seat == 0) //todo: what if its uncontrollable (skybreaker flightpath, rocket mount from k3) { //give control to player WorldPacket data; data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << uint8(1); player->SendPacket(&data); m_controller = player; player->SetCharmedUnitGUID(GetGUID()); SetCharmedByGUID(player->GetGUID()); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE); //set active mover player->GetSession()->SetActiveMover(GetNewGUID()); // Show the vehicle action bar ??? SendRideSpellPacket(player); } }
BOOL CHttpDownloadMgr::Init( void ) { #if DBG_LOG_OUTPUTSTRING_DWONLOAD ZTools::WriteZToolsLog( " CHttpDownloadMgr::Init \n" ); #endif if ( m_dwControlThreadId != 0 ) return FALSE; m_llMaxBufferSizeForDownload = CURL_MAX_WRITE_SIZE; curl_global_init( CURL_GLOBAL_ALL ); InitializeCriticalSection( &m_csTask ); //创建控制线程 m_hControlThread = ::CreateThread( NULL , 0 , CHttpDownloadMgr::_ControlThread , (LPVOID)this , CREATE_SUSPENDED , &m_dwControlThreadId); if (m_hControlThread == NULL || m_dwControlThreadId == 0) { AfxMessageBox("创建线程失败,CHttpDownloadMgr::_ControlThread"); ClearControlThread(); return FALSE; } m_hControlStartEvent = CreateEvent( NULL, TRUE, FALSE, GetNewGUID() ); if ( !m_hControlStartEvent ) { AfxMessageBox( "管理类初始化创建启动事件失败"); return FALSE; } m_hControlExitEvent = CreateEvent( NULL, TRUE, FALSE, GetNewGUID() ); if ( !m_hControlExitEvent ) { AfxMessageBox( "管理类初始化创建退出事件失败"); return FALSE; } ResumeThread( m_hControlThread ); if ( WaitForSingleObject( m_hControlStartEvent, TIMEOUT_PERSIST_DOWNLOAD_THREAD_INIT_TIME ) != WAIT_OBJECT_0 ) { AfxMessageBox( "控制线程启动超时" ); return FALSE; } #if DBG_LOG_OUTPUTSTRING_DWONLOAD ZTools::WriteZToolsLog( "CHttpDownloadMgr::Init Finished \n" ); #endif return TRUE; }
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO) { if(!this) return; uint32 guid; m_transportGuidGen.Acquire(); guid = ++m_transportGuidMax; m_transportGuidGen.Release(); CreatureInfo * inf = CreatureNameStorage.LookupEntry(Entry); CreatureProto * proto = CreatureProtoStorage.LookupEntry(Entry); if(inf == NULL || proto == NULL) return; Creature* pCreature(new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | guid)); pCreature->Init(); pCreature->Load(proto, offsetX, offsetY, offsetZ, offsetO); pCreature->m_TransporterUnk = UNIXTIME; pCreature->m_transportPosition = new LocationVector(offsetX, offsetY, offsetZ, offsetO); pCreature->m_TransporterGUID = GetGUID(); pCreature->m_transportNewGuid = GetNewGUID(); m_npcs.insert(make_pair(guid,pCreature)); }
void Vehicle::RemovePassenger(Player * player) { if (player == NULL || player->GetVehicle() != this || player->GetVehicleSeat() >= GetPassengerCount() || m_passengers[player->GetVehicleSeat()] != player) return; SendFarsightPacket(player, false); RelocateToVehicle(player); if (player == m_controller) { WorldPacket data; m_controller = NULL; SetCharmedByGUID( 0); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE); player->GetSession()->SetActiveMover(player->GetNewGUID()); data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << uint8(0); player->GetSession()->SendPacket(&data); } //clear refs uint8 seat = player->GetVehicleSeat(); player->ResetVehicleSettings(); m_passengers[seat] = NULL; }
COpenFileTask::COpenFileTask(const CFileInfo & info,LPCTSTR strLocalFile) { m_bFlag = TRUE; m_strErrMsg.Empty(); m_strOperation = "OpenFile"; m_FileInfo = info; m_strLocalFile = strLocalFile==NULL ? "":strLocalFile; m_strOpenTaskId = GetNewGUID().c_str(); }
// Destructable Buildings void GameObject::TakeDamage(uint32 amount, Object* mcaster, Object* pcaster, uint32 spellid) { printf("Gameobject Target Found\n"); if(pInfo->Type != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) return; if(HasFlag(GAMEOBJECT_FLAGS,GO_FLAG_DAMAGED)) // Already destroyed return; if(Health > amount) Health -= amount; else Health = 0; if(HasFlag(GAMEOBJECT_FLAGS,GO_FLAG_DAMAGED)) { if(Health == 0) { RemoveFlag(GAMEOBJECT_FLAGS,GO_FLAG_DAMAGED); SetFlag(GAMEOBJECT_FLAGS,GO_FLAG_DESTROYED); DestructibleModelDataEntry * display = dbcDestructibleModelDataEntry.LookupEntry( pInfo->Unknown9 ); SetUInt32Value(GAMEOBJECT_DISPLAYID,display->GetDisplayId(3)); sHookInterface.OnDestroyBuilding(TO_GAMEOBJECT(this)); } } else if(!HasFlag(GAMEOBJECT_FLAGS,GO_FLAG_DAMAGED)) { if(Health <= pInfo->sound5) { if(Health == 0) Health = 1; SetFlag(GAMEOBJECT_FLAGS,GO_FLAG_DAMAGED); DestructibleModelDataEntry * display = dbcDestructibleModelDataEntry.LookupEntry( pInfo->Unknown9 ); SetUInt32Value(GAMEOBJECT_DISPLAYID,display->GetDisplayId(1)); sHookInterface.OnDamageBuilding(TO_GAMEOBJECT(this)); } } WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 20); data << GetNewGUID(); data << mcaster->GetNewGUID(); data << pcaster->GetNewGUID(); data << uint32(amount) << spellid; mcaster->SendMessageToSet(&data, (mcaster->IsPlayer() ? true : false)); SetByte(GAMEOBJECT_BYTES_1, 3, Health); }
void Vehicle::AddPassenger(Unit * passenger, int8 seat) { if( HasAllProtoAvailable() == false ) return; ASSERT( passenger ); if( !passenger->IsInWorld() ) return; if(GetPassengerCount() + 1 > GetOccupancyLimit()) // Check if there is place left for us { return; } // Check if we're a vehicle trying to mount a non-player seat position if( seat == VEHICLE_PASSENGER_SLOT_INVALID || seat >= MAX_PASSENGERS || seat >= GetOccupancyLimit() || m_passengers[seat] != NULL) { return; } //right now mount owners are using seat 0 with is not actually a seat. In case there are crash reports we should check if picked seat is also valid in DBC // if( m_vehicleEntry->m_seatID[ seat ] == 0 ) return; m_passengers[seat] = passenger; // Set this vehicle and seat to player passenger->SetVehicle(this, seat); //set controler if( m_controller == NULL ) { m_controller = passenger; if( IsMount == false ) { //should not posses self ? if( m_controller != m_owner && passenger->IsPlayer() ) SafePlayerCast( passenger )->Possess( m_owner ); // passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); } } if( passenger->IsPlayer() ) { Player * player = SafePlayerCast(passenger); if( passenger != m_owner ) { if( IsMount == false ) SendFarsightPacket(player, true); //focus on vehicle instead us ? But why ? player->GetSession()->SetActiveMover( GetNewGUID() ); //loose movement control ? } if( IsMount == false ) player->m_noFallDamage = true; // Show the vehicle action bar. Is this to owner or to seat ? SendVehicleActionBar( player ); if( passenger != m_owner ) SendRidePacket( passenger, GetSeatData()->seat[seat] ); //seems like this is a mount if( passenger == m_owner ) { // Send others that we now have a vehicle sStackWolrdPacket( data, SMSG_CONVERT_VEHICLE, 9+4); data << passenger->GetNewGUID() ; data << uint32( proto->vehicleId ); player->SendMessageToSet(&data,true); //is this for all players or only the real vehicle controller data.Initialize(SMSG_CONTROL_VECHICLE); player->GetSession()->SendPacket(&data); } } // Remove shapeshift auras passenger->RemoveAllAuraType(SPELL_AURA_MOD_SHAPESHIFT); passenger->RemoveAllAuraType(SPELL_AURA_TRANSFORM); if( passenger != m_owner ) { passenger->Root(); passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } else if( passenger == m_owner ) m_owner->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VEHICLE); if(m_vehicledata->flags & VEHICLE_FLAG_DISABLE_AI_ON_ENTER) m_owner->DisableAI(); // Check if we exceeded maximum passenger capacity if( GetPassengerCount() >= GetOccupancyLimit() ) m_owner->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); m_passengerCount++; // Count the passenger as inside the vehicle }
void Vehicle::_AddToSlot(Unit* pPassenger, uint8 slot) { assert( slot < m_seatSlotMax ); if(pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_CurrentCharm) return; if(pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_isGmInvisible) { sChatHandler.GreenSystemMessage(TO_PLAYER(pPassenger)->GetSession(), "Please turn off invis before entering vehicle."); return; } CreatureProtoVehicle* vehicleproto = CreatureProtoVehicleStorage.LookupEntry(GetEntry()); m_passengers[slot] = pPassenger; LocationVector v; v.x = m_vehicleSeats[slot]->m_attachmentOffsetX; /* pPassenger->m_TransporterX = */ v.y = m_vehicleSeats[slot]->m_attachmentOffsetY; /* pPassenger->m_TransporterY = */ v.z = m_vehicleSeats[slot]->m_attachmentOffsetZ; /* pPassenger->m_TransporterZ = */ v.o = 0; /* pPassenger->m_TransporterO = */ //pPassenger->m_transportPosition =& v; // This is handled elsewhere, do not initialize here. pPassenger->movement_info.flags |= MOVEFLAG_TAXI; pPassenger->movement_info.transX = v.x; pPassenger->movement_info.transY = v.y; pPassenger->movement_info.transZ = v.z; pPassenger->movement_info.transO = GetOrientation(); pPassenger->movement_info.transSeat = slot; pPassenger->movement_info.transGuid = WoWGuid(GetGUID()); pPassenger->SetSeatID(slot); pPassenger->m_TransporterGUID = GetGUID(); if( m_CastSpellOnMount ) pPassenger->CastSpell( pPassenger, m_CastSpellOnMount, true ); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SELF_RES); // This is where the real magic happens if( pPassenger->IsPlayer() ) { Player* pPlayer = TO_PLAYER(pPassenger); //pPlayer->Root(); //Dismount if(pPlayer->m_MountSpellId && pPlayer->m_MountSpellId != m_mountSpell) pPlayer->RemoveAura(pPlayer->m_MountSpellId); //Remove morph spells if(pPlayer->GetUInt32Value(UNIT_FIELD_DISPLAYID) != pPlayer->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID)) { pPlayer->RemoveAllAurasOfType(SPELL_AURA_TRANSFORM); pPlayer->RemoveAllAurasOfType(SPELL_AURA_MOD_SHAPESHIFT); } //Dismiss any pets if(pPlayer->GetSummon()) { if(pPlayer->GetSummon()->GetUInt32Value(UNIT_CREATED_BY_SPELL) > 0) pPlayer->GetSummon()->Dismiss(false); // warlock summon -> dismiss else pPlayer->GetSummon()->Remove(false, true, true); // hunter pet -> just remove for later re-call } pPlayer->SetVehicle(this); pPlayer->SetUInt64Value(PLAYER_FARSIGHT, GetGUID()); pPlayer->SetPlayerStatus(TRANSFER_PENDING); sEventMgr.AddEvent(pPlayer, &Player::CheckPlayerStatus, (uint8)TRANSFER_PENDING, EVENT_PLAYER_CHECK_STATUS_Transfer, 5000, 0, 0); pPlayer->m_sentTeleportPosition.ChangeCoords(GetPositionX(), GetPositionY(), GetPositionZ()); WorldPacket data(SMSG_MONSTER_MOVE_TRANSPORT, 100); data << pPlayer->GetNewGUID(); // Passengerguid data << GetNewGUID(); // Transporterguid (vehicleguid) data << uint8(slot); // Vehicle Seat ID data << uint8(0); // Unknown data << GetPositionX() - pPlayer->GetPositionX(); // OffsetTransporterX data << GetPositionY() - pPlayer->GetPositionY(); // OffsetTransporterY data << GetPositionZ() - pPlayer->GetPositionZ(); // OffsetTransporterZ data << getMSTime(); // Timestamp data << uint8(0x04); // Flags data << float(0); // Orientation Offset data << uint32(MOVEFLAG_TB_MOVED); // MovementFlags data << uint32(0); // MoveTime data << uint32(1); // Points data << v.x; // GetTransOffsetX(); data << v.y; // GetTransOffsetY(); data << v.z; // GetTransOffsetZ(); SendMessageToSet(&data, true); if(vehicleproto) { // We have proto, no accessory in slot, and slot sets unselectable, unlike some seats if(!vehicleproto->seats[slot].accessoryentry && vehicleproto->seats[slot].unselectableaccessory) pPlayer->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE)); } else pPlayer->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE)); if(slot == 0) { if(m_vehicleSeats[slot]->IsControllable()) { m_redirectSpellPackets = pPlayer; SetSpeed(RUN, m_runSpeed); SetSpeed(FLY, m_flySpeed); // send "switch mover" packet data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << uint8(1); pPlayer->GetSession()->SendPacket(&data); pPlayer->m_CurrentCharm = TO_UNIT(this); pPlayer->SetUInt64Value(UNIT_FIELD_CHARM, GetGUID()); SetUInt64Value(UNIT_FIELD_CHARMEDBY, pPlayer->GetGUID()); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE); if(!m_faction || m_faction->ID == 35 || m_faction->ID == 2105) { SetCharmTempVal(pPlayer->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE)); SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, pPlayer->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE)); } if(vehicleproto && vehicleproto->healthfromdriver) { uint32 health = GetUInt32Value(UNIT_FIELD_HEALTH); uint32 maxhealth = GetUInt32Value(UNIT_FIELD_MAXHEALTH); uint32 healthdiff = maxhealth - health; SetUInt32Value(UNIT_FIELD_MAXHEALTH, (maxhealth+((pPlayer->GetTotalItemLevel())*(vehicleproto->healthunitfromitemlev)))); SetUInt32Value(UNIT_FIELD_HEALTH, (health+((pPlayer->GetTotalItemLevel())*(vehicleproto->healthunitfromitemlev))) - healthdiff); } SendSpells(GetEntry(), pPlayer); if(pPlayer->HasAura(62064)) { uint32 stack = pPlayer->FindActiveAura(62064)->stackSize; AddAura(new Aura(dbcSpell.LookupEntry(62064),-1,this,this)); FindActiveAura(62064)->ModStackSize(stack); } } } else { data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << uint8(0); pPlayer->GetSession()->SendPacket(&data); } data.Initialize(SMSG_PET_DISMISS_SOUND); data << uint32(m_vehicleSeats[slot]->m_enterUISoundID); data << pPlayer->GetPosition(); pPlayer->GetSession()->SendPacket(&data); ++m_ppassengerCount; } else { pPassenger->SetVehicle(this); if(vehicleproto != NULL) if(vehicleproto->seats[slot].accessoryentry == pPassenger->GetEntry()) if(vehicleproto->seats[slot].unselectableaccessory == true) pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE)); else pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION)); else pPassenger->SetFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE)); pPassenger->SetPosition(GetPositionX()+v.x, GetPositionY()+v.y, GetPositionZ()+v.z, GetOrientation()); } SendHeartBeatMsg(false); if(IsFull()) RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); if(canFly()) EnableFlight(); _setFaction(); }
void Vehicle::RemovePassenger(Unit* pPassenger) { if(pPassenger == NULL) // We have enough problems that we need to do this :( return; uint8 slot = pPassenger->GetSeatID(); pPassenger->SetVehicle(NULL); pPassenger->SetSeatID(NULL); pPassenger->RemoveFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_UNKNOWN_5 | UNIT_FLAG_PREPARATION | UNIT_FLAG_NOT_SELECTABLE)); if( pPassenger->IsPlayer() && TO_PLAYER(pPassenger)->m_MountSpellId != m_mountSpell ) pPassenger->RemoveAura(TO_PLAYER(pPassenger)->m_MountSpellId); if( m_mountSpell ) pPassenger->RemoveAura( m_mountSpell ); if( m_CastSpellOnMount ) pPassenger->RemoveAura( m_CastSpellOnMount ); WorldPacket data(SMSG_MONSTER_MOVE, 85); data << pPassenger->GetNewGUID(); // PlayerGUID data << uint8(0x40); // Unk - blizz uses 0x40 data << pPassenger->GetPosition(); // Player Position xyz data << getMSTime(); // Timestamp data << uint8(0x4); // Flags data << pPassenger->GetOrientation(); // Orientation data << uint32(MOVEFLAG_AIR_SUSPENSION); // MovementFlags data << uint32(0); // MovementTime data << uint32(1); // Pointcount data << GetPosition(); // Vehicle Position xyz SendMessageToSet(&data, false); pPassenger->movement_info.flags &= ~MOVEFLAG_TAXI; pPassenger->movement_info.transX = 0; pPassenger->movement_info.transY = 0; pPassenger->movement_info.transZ = 0; pPassenger->movement_info.transO = 0; pPassenger->movement_info.transTime = 0; pPassenger->movement_info.transSeat = 0; pPassenger->movement_info.transGuid = WoWGuid(uint64(NULL)); if(pPassenger->IsPlayer()) { Player* plr = TO_PLAYER(pPassenger); if(plr == GetControllingUnit()) { plr->m_CurrentCharm = NULL; data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << (uint8)0; plr->GetSession()->SendPacket(&data); } RemoveFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_PLAYER_CONTROLLED_CREATURE | UNIT_FLAG_PLAYER_CONTROLLED)); plr->SetPlayerStatus(TRANSFER_PENDING); // We get an ack later, if we don't set this now, we get disconnected. sEventMgr.AddEvent(plr, &Player::CheckPlayerStatus, (uint8)TRANSFER_PENDING, EVENT_PLAYER_CHECK_STATUS_Transfer, 5000, 0, 0); plr->m_sentTeleportPosition.ChangeCoords(GetPositionX(), GetPositionY(), GetPositionZ()); plr->SetPosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); data.Initialize(MSG_MOVE_TELEPORT_ACK); data << plr->GetNewGUID(); data << plr->m_teleportAckCounter; plr->m_teleportAckCounter++; data << uint32(MOVEFLAG_FLYING); data << uint16(0x40); data << getMSTime(); data << GetPositionX(); data << GetPositionY(); data << GetPositionZ(); data << GetOrientation(); data << uint32(0); plr->GetSession()->SendPacket(&data); plr->SetUInt64Value( PLAYER_FARSIGHT, 0 ); data.Initialize(SMSG_PET_DISMISS_SOUND); data << uint32(m_vehicleSeats[slot]->m_exitUISoundID); data << plr->GetPosition(); plr->GetSession()->SendPacket(&data); data.Initialize(SMSG_PET_SPELLS); data << uint64(0); data << uint32(0); plr->GetSession()->SendPacket(&data); CreatureProtoVehicle* vehicleproto = CreatureProtoVehicleStorage.LookupEntry(GetEntry()); if(vehicleproto && vehicleproto->healthfromdriver) { if(slot == 0) { uint32 health = GetUInt32Value(UNIT_FIELD_HEALTH); uint32 maxhealth = GetUInt32Value(UNIT_FIELD_MAXHEALTH); uint32 protomaxhealth = GetProto()->MaxHealth; uint32 healthdiff = maxhealth - health; uint32 plritemlevel = plr->GetTotalItemLevel(); uint32 convrate = vehicleproto->healthunitfromitemlev; if(plritemlevel != 0 && convrate != 0) { uint32 healthloss = healthdiff+plritemlevel*convrate; SetUInt32Value(UNIT_FIELD_HEALTH, GetProto()->MaxHealth - healthloss); } else if(protomaxhealth > healthdiff) SetUInt32Value(UNIT_FIELD_HEALTH, protomaxhealth-healthdiff); else SetUInt32Value(UNIT_FIELD_HEALTH, 1); SetUInt32Value(UNIT_FIELD_MAXHEALTH, protomaxhealth); } } } if(slot == 0) { m_redirectSpellPackets = NULLPLR; CombatStatus.Vanished(); pPassenger->SetUInt64Value( UNIT_FIELD_CHARM, 0 ); SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0); if(!m_faction || m_faction->ID == 35 || m_faction->ID == 2105) SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetCharmTempVal()); RemoveAura(62064); } SendHeartBeatMsg(false); m_passengers[slot] = NULL; pPassenger->m_TransporterGUID = NULL; // We need to null this out if(pPassenger->IsPlayer()) --m_ppassengerCount; //note: this is not blizz like we should despawn //and respawn at spawn point. //Well actually this is how blizz wanted it //but they couldnt get it to work xD bool haspassengers = false; for(uint8 i = 0; i < m_seatSlotMax; i++) { if(m_passengers[i] != NULL && m_passengers[i]->IsPlayer()) { haspassengers = true; break; } } if(!haspassengers && !GetVehicle()) // Passenger and accessory checks. { if( m_spawn == NULL ) SafeDelete(); } if(!IsFull()) SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); if(canFly()) DisableFlight(); _setFaction(); }
std::string CallHprose::UploadFileObject() { if (dataFileObject.CheckInfo() == FALSE) { m_bUploadErr = true; return ""; } if (m_TaskStatus == Upload_PAUSE || m_TaskStatus == Upload_STOP || m_TaskStatus == Upload_DELET) { ZTools::WriteZToolsFormatLog("CheckInfo完成,用户:%s",GetStatusMsg(m_TaskStatus)); return ""; } ZTools::WriteZToolsFormatLog("单个文件上传前"); dataFileObject.m_strFileId = ""; if(m_bCreateIndexForFileInfo) { CString strTmp = GetNewGUID(); strTmp.TrimLeft("{"); strTmp.TrimRight("}"); dataFileObject.m_strIndex = strTmp; ZTools::WriteZToolsFormatLog("创建新的GUID:%s",dataFileObject.m_strIndex.c_str()); } DataFiles oFiles; DataFile oFile; oFile.name = dataFileObject.m_strFileName; oFile.size = ZTools::FormatString("%lld", dataFileObject.m_nFileSize); // 大文件需用long long ,匹配时用lld oFile.lastModified = dataFileObject.m_strLastModifyTime; oFile.md5 = dataFileObject.m_strMd5; oFile.index = m_strNetDiskFileID; // 这个值在续传的时候不会变 oFiles.files.push_back(oFile); ZTools::WriteZToolsFormatLog("上传文件[%s]\nMD5值[%s]\n文件大小[%s]\nIndex值[%s]\n最后更新时间[%s]", oFile.name.c_str(),oFile.md5.c_str(),oFile.size.c_str(),oFile.index.c_str(),oFile.lastModified.c_str()); std::vector<hprose::any> vecAny; vecAny.clear(); vecAny.push_back(oFiles.ToJson()); if (!init(dataFileObject.m_strHproseRpc, vecAny)) { m_bUploadErr = true; ZTools::WriteZToolsLog(dataFileObject.m_strMsg); return ""; } if (m_TaskStatus == Upload_PAUSE || m_TaskStatus == Upload_STOP || m_TaskStatus == Upload_DELET) { ZTools::WriteZToolsFormatLog("init成功,用户:%s",GetStatusMsg(m_TaskStatus)); return ""; } if (m_bCreateIndexForFileInfo == FALSE) oFile.index = dataFileObject.m_strIndex; // 使用init后返回的新的index //文件大小为0或者文件MD5在数据库中找到重复的,init方法会直接返回fileId,不用走cwrite逻辑 if (!dataFileObject.m_strFileId.empty()) { ZTools::WriteZToolsFormatLog("单个文件秒传完成,%s",dataFileObject.m_strFileId.c_str()); dataFileObject.m_nFileSizeUploaded = dataFileObject.m_nFileSize; return dataFileObject.m_strFileId; } std::wstring wstrFilePath = s2ws_1(dataFileObject.m_strFilePath); std::ifstream fIn(wstrFilePath, std::ios::binary); if (fIn == NULL || fIn.is_open() == false) { dataFileObject.m_strMsg = ZTools::FormatString("read file error: %s", dataFileObject.m_strFilePath.c_str()); ZTools::WriteZToolsLog(dataFileObject.m_strMsg); m_bUploadErr = true; return ""; } if(dataFileObject.m_nFileSizeUploaded > 0) fIn.seekg(dataFileObject.m_nFileSizeUploaded,std::ios::beg); //断点续传 int nBlockSize = 256 * 1024; std::vector<char> vchar; vchar.resize(nBlockSize, '\0'); std::streamsize nBlockRead = 0; //dataFileObject.m_nFileSizeUploaded = 0; ZTools::WriteZToolsLog("开始执行cwrite循环..."); ZTools::WriteZToolsFormatLog("cwrite使用的Index值为:%s",oFile.index.c_str()); while (true) { nBlockRead = fIn.read(reinterpret_cast<char*>(&vchar[0]), 256*1024).gcount(); if (nBlockRead == 0) { break; } if (m_TaskStatus == Upload_PAUSE || m_TaskStatus == Upload_STOP || m_TaskStatus == Upload_DELET) { dataFileObject.m_strMsg = (LPCTSTR)GetStatusMsg(m_TaskStatus); ZTools::WriteZToolsFormatLog("cwrite循环中,用户:%s",dataFileObject.m_strMsg.c_str()); break; } vecAny.clear(); vecAny.push_back(oFile.index); vecAny.push_back(vchar); vecAny.push_back(nBlockRead); if (!cwrite(dataFileObject.m_strHproseRpc, vecAny)) { if (dataFileObject.m_strMsg.empty()) dataFileObject.m_strMsg = "上传出错!"; ZTools::WriteZToolsLog(dataFileObject.m_strMsg); //MessageBox(NULL,dataFileObject.m_strMsg.c_str(),"错误",MB_OK|MB_ICONERROR); m_bUploadErr = true; return ""; } dataFileObject.m_nFileSizeUploaded += nBlockRead; } if (dataFileObject.m_strFileId.empty()) { if (dataFileObject.m_strMsg.empty()) dataFileObject.m_strMsg = "unkown error"; if (m_TaskStatus == Upload_Runing) m_bUploadErr = true; ZTools::WriteZToolsLog(dataFileObject.m_strMsg); return ""; } ZTools::WriteZToolsFormatLog("单个文件上传完成,%s",dataFileObject.m_strFileId.c_str()); dataFileObject.m_nFileSizeUploaded = dataFileObject.m_nFileSize; return dataFileObject.m_strFileId; }