PSpawnedVehicle* PVehicles::SpawnVehicle( u32 nVehicleId, u32 nLocation, PVhcCoordinates const* nVhcPos ) { PSpawnedVehicle* newVhc = NULL; PWorld* cWorld; PVehicleInformation nVhcInfo; if (( nLocation != PWorlds::mNcSubwayWorldId ) && IsValidVehicle( nVehicleId ) && !IsSpawned( nVehicleId ) ) { cWorld = Worlds->LeaseWorld( nLocation ); if ( cWorld && GetVehicleInfo( nVehicleId, &nVhcInfo ) ) { newVhc = cWorld->GetSpawnedVehicules()->SpawnVehicle( &nVhcInfo, nVhcPos ); if ( newVhc ) { if ( !RegisterSpawnedVehicle( newVhc ) ) { Console->Print( RED, BLACK, "[Error] PVehicles::SpawnVehicle : Could not register spawned vhc" ); } if( gDevDebug ) Console->Print( "%d Spawned vhc %d (local 0x%04x) type %d (requested: %d)", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), newVhc->GetVehicleId(), newVhc->GetLocalId(), newVhc->GetInformation().GetVehicleType(), nVhcInfo.GetVehicleType() ); } else Console->Print( RED, BLACK, "[Error] PVehicles::SpawnVehicle : Could not create vhc" ); } Worlds->ReleaseWorld( nLocation ); } return newVhc; }
bool PVehicles::UnspawnVehicle( u32 nVehicleId ) { PWorld* cWorld; bool Result = false; PSpawnedVhcMap::iterator it = mSpawnedVehicles.find( nVehicleId ); if ( it != mSpawnedVehicles.end() ) { cWorld = Worlds->LeaseWorld( it->second->GetLocation() ); if ( cWorld ) { if ( !it->second->Save() ) { Console->Print( RED, BLACK, "[Error] PVehicles::UnspawnVehicle : Could not save vhc %d", nVehicleId ); } Result = cWorld->GetSpawnedVehicules()->UnspawnVehicle( it->second->GetLocalId() ); if ( Result ) { if ( !UnregisterSpawnedVehicle( nVehicleId ) ) { Console->Print( RED, BLACK, "[Error] PVehicles::UnspawnVehicle : Could not unregister vhc %d", nVehicleId ); } } } Worlds->ReleaseWorld( it->second->GetLocation() ); } return Result; }
bool PUdpHeldItemLaunchingAction::DoAction() { PClient* nClient = mDecodeData->mClient; PChar* tChar = nClient->GetChar(); PWorld* CurrentWorld = Worlds->GetWorld( tChar->GetLocation() ); const PFurnitureItemTemplate* tFurnitureTemplate = NULL; const PDefWorldModel* tFurnitureModel = NULL; u32 mRawItemID = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 24 ); //if(gDevDebug) Console->Print("Client %d wants to hack itemID %d ***not managed yet***", mDecodeData->mClient->GetID(), mRawItemID); // First try to find out if we're hacking an dynamic actor if ( WorldActors->IsDynamicActor( mRawItemID ) == true ) { // Now get the get the function value: (What kind of hackable object) int tFunctionVal = WorldActors->GetWorldActorFunctionID( mRawItemID ); // Then get the FUNCTION VALUE as furniture model so we can access its subvalues etc. Here: Hack difficult tFurnitureModel = GameDefs->WorldModels()->GetDef( tFunctionVal ); } else { // Dat files have smaller IDs u32 ItemID = mRawItemID / 1024 - 1; // Now grab the template from .dat file tFurnitureTemplate = CurrentWorld->GetFurnitureItemTemplate( ItemID ); // Then get the FUNCTION VALUE as furniture model so we can access its subvalues etc tFurnitureModel = CurrentWorld->GetFurnitureItemModel( ItemID ); } if ( tFurnitureModel ) // We have an valid worldobject? Fine. Then start the hackgame { u8 tHackDifficult = tFurnitureModel->GetHackDifficulty(); u8 tHackPenalty = tFurnitureModel->GetHackPenalty(); // Print it! if(tHackDifficult) { //if (gDevDebug) Console->Print( "%s Client trying to hack itemID %d. Hack difficult: %d Hack penalty %d", Console->ColorText( CYAN, BLACK, "[DEBUG]" ), mRawItemID, tHackDifficult, tHackPenalty ); PMessage* tmpMsg = MsgBuilder->BuildStartHackGameMsg( nClient, mRawItemID, tHackDifficult ); nClient->SendUDPMessage( tmpMsg ); tmpMsg = NULL; } } mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; return true; }
WorldViewer::WorldViewer(PWorld world, EntityRef spectator) :m_world(world), m_spectator(spectator), m_occluder_config(world->tileMap().occluderMap()), m_see_all(false) { DASSERT(m_world); }
bool PUdpSync2::DoAction() { if (( mDecodeData->mState & DECODE_ACTION_READY ) && ( mDecodeData->mClientState->UDP.mState == PGameState::UDP::GUS_SYNC2 ) ) { PClient* nClient = mDecodeData->mClient; // Baseline message chunking & sending PMessage* BaselineMsg = MsgBuilder->BuildBaselineMsg( nClient ); nClient->FragmentAndSendUDPMessage( BaselineMsg, 0x19 ); // Sending "CharInfo3/Zoning2Msg" message // Removed because same as Zoning2Msg PMessage* Zoning2Msg = MsgBuilder->BuildZoning2Msg( nClient, mClientTime ); nClient->SendUDPMessage( Zoning2Msg ); mDecodeData->mClientState->UDP.mState = PGameState::UDP::GUS_SYNC3; nClient->SetZoning( false ); // If char is sitting (vhz zoning), send it now to client u32 nSeatableObjectId; u8 nSeatId; if( nClient->GetChar()->GetSeatInUse(&nSeatableObjectId, &nSeatId) ) { if( gDevDebug ) Console->Print( YELLOW, BLACK, "[DEBUG] PUdpSync2::DoAction : Char %d sitting on vhc id %d, seat %d", nClient->GetLocalID(), nSeatableObjectId, nSeatId ); PMessage* SittingMsg = MsgBuilder->BuildCharUseSeatMsg( nClient, nSeatableObjectId, nSeatId ); nClient->FillInUDP_ID(SittingMsg); nClient->SendUDPMessage( SittingMsg ); } //Temp: send Subway to client if in subway if ( nClient->GetChar()->GetLocation() == PWorlds::mNcSubwayWorldId ) { PMessage* SubwayMsg = MsgBuilder->BuildSubwaySpawnMsg( nClient, false ); nClient->SendUDPMessage( SubwayMsg ); SubwayMsg = MsgBuilder->BuildSubwaySpawnMsg( nClient, true ); nClient->SendUDPMessage( SubwayMsg ); } // Send spawned vehicles PWorld* CurrentWorld = Worlds->GetWorld( nClient->GetChar()->GetLocation() ); if ( CurrentWorld ) { PSpawnedVhcList* VhcList = CurrentWorld->GetSpawnedVehicules()->GetSpawnedVehicles(); PSpawnedVehicle* VhcEntry; PMessage* VhcMsg; while ( ! VhcList->empty() ) { VhcEntry = VhcList->front(); VhcList->pop(); if( gDevDebug ) Console->Print( YELLOW, BLACK, "[DEBUG] PUdpSync2::DoAction : Send info for vhc id %d", VhcEntry->GetLocalId() ); VhcMsg = MsgBuilder->BuildVhcPosUpdateMsg( VhcEntry ); nClient->FillInUDP_ID( VhcMsg ); nClient->SendUDPMessage( VhcMsg ); VhcMsg = MsgBuilder->BuildVhcInfoMsg( nClient, VhcEntry ); nClient->SendUDPMessage( VhcMsg ); } } // Dispatching info to & from other chars in zone int nbSent; nbSent = ClientManager->SendUDPZoneWelcomeToClient( nClient ); //Console->Print(GREEN, BLACK, " %d Welcome message were sent to client %d", nbSent, Client->GetIndex()); PMessage* HelloMsg = MsgBuilder->BuildCharHelloMsg( nClient ); nbSent = ClientManager->UDPBroadcast( HelloMsg, nClient ); //Console->Print(GREEN, BLACK, "Client %d: Hello message sent to %d chars", Client->GetIndex(), nbSent); // Send worldactors to client WorldActors->InitWorld( nClient ); // Send NPC information to client NPCManager->InitPlayer( nClient ); //Console->Print("OP Data inc"); Outposts->SendOPAreaData( nClient ); mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED; return true; } else return false; }