void CFSShip::ShipStatusWarped(IwarpIGC* pwarp) { SectorID sectorID = pwarp->GetDestination()->GetCluster()->GetObjectID(); for (SideLinkIGC* psl = GetMission()->GetIGCMission()->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); if ((GetIGCShip()->SeenBySide(pside)) && (pwarp->SeenBySide(pside))) { SideID sideID = pside->GetObjectID(); m_rgShipStatus[sideID].SetSectorID(sectorID); //Adjust the ship status for all of the children as well { for (ShipLinkIGC* psl = GetIGCShip()->GetChildShips()->first(); (psl != NULL); psl = psl->next()) { IshipIGC* pship = psl->data(); ShipStatus* pss = ((CFSShip*)(pship->GetPrivateData()))->GetShipStatus(sideID); pss->SetSectorID(sectorID); } } } } }
CFSPlayer::~CFSPlayer() { /* People get removed from the groups automatically when the player is destroyed ZSucceeded(g.pDirectPlay->DeletePlayerFromGroup(g.dpidEveryone, m_dpid)); if (NA == GetSide()) ZSucceeded(g.pDirectPlay->DeletePlayerFromGroup(g.dpidLobby, m_dpid)); else ZSucceeded(g.pDirectPlay->DeletePlayerFromGroup(g.rgdpidSides[GetSide()], m_dpid)); if (m_dpidGroup) ZSucceeded(g.pDirectPlay->DeletePlayerFromGroup(m_dpidGroup, m_dpid)); // NYI: They might be in sector overview too */ m_pcnxn->SetPrivateData(0); // disconnect two-way link between connection and this LPCSTR pszContext = GetIGCShip() ? GetIGCShip()->GetMission()->GetContextName() : NULL; _AGCModule.TriggerContextEvent(NULL, EventID_LogoutServer, pszContext, GetName(), GetConnection()->GetID(), -1, -1, 1, "User", VT_I4, GetConnection()->GetID()); ShipID shipID = GetShipID(); if (NULL != g.pServerCounters) g.pServerCounters->cPlayersOnline--; if (GetMission()) GetMission()->RemovePlayerFromMission(this, QSR_LinkDead); // Get rid of all the PersistPlayerScoreObjects PersistPlayerScoreObjectLink * pperplrscoLink = NULL; while (pperplrscoLink = m_perplrscoreList.first()) { delete pperplrscoLink->data(); delete pperplrscoLink; } // Too risky, dplay may block-- g.fm.GetDPlay()->DestroyPlayer(m_dpid); }
void CFSShip::ShipStatusDocked(IstationIGC* pstation) { StationID stationID = pstation->GetObjectID(); SectorID sectorID = pstation->GetCluster()->GetObjectID(); HullID hullID; { IhullTypeIGC* pht = GetIGCShip()->GetBaseHullType(); hullID = pht ? pht->GetObjectID() : NA; } IsideIGC* psideMe = GetIGCShip()->GetSide(); for (SideLinkIGC* psl = GetMission()->GetIGCMission()->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); if ((pside == psideMe || pside->AlliedSides(pside,psideMe)) || // #ALLY Imago 7/8/09 VISIBILITY? (GetIGCShip()->SeenBySide(pside) && pstation->SeenBySide(pside))) { SideID sideID = pside->GetObjectID(); ShipStatus* pss = &(m_rgShipStatus[sideID]); pss->SetStateTime(g.timeNow.clock()); pss->SetState(c_ssDocked); pss->SetParentID(NA); pss->SetStationID(stationID); pss->SetSectorID(sectorID); pss->SetHullID(hullID); //Adjust the ship status for all of the children as well { for (ShipLinkIGC* psl = GetIGCShip()->GetChildShips()->first(); (psl != NULL); psl = psl->next()) { IshipIGC* pship = psl->data(); ShipStatus* pss = ((CFSShip*)(pship->GetPrivateData()))->GetShipStatus(sideID); assert ((pship->GetTurretID() == NA) ? (pss->GetState() == c_ssObserver) : (pss->GetState() == c_ssTurret)); assert (pss->GetParentID() == GetIGCShip()->GetObjectID()); assert (pss->GetHullID() == NA); pss->SetStationID(stationID); pss->SetSectorID(sectorID); } } } } }
/****************************************************************** CFSDrone ******************************************************************/ CFSDrone::CFSDrone(IshipIGC* pship) : CFSShip(pship, false) { if (GetMission()->GetStage() == STAGE_STARTED) { //Hook the drone's side/score information up (since drones live only on a single side for their entire lifespan). IsideIGC* pside = pship->GetSide(); assert (pside); CFSSide* pfsside = CFSSide::FromIGC(pside); assert (pfsside); GetPlayerScoreObject()->Connect(g.timeNow); } }
void CFSShip::ShipStatusHullChange(IhullTypeIGC* pht) { IsideIGC* psideMe = GetIGCShip()->GetSide(); HullID hid = pht->GetObjectID(); for (SideLinkIGC* psl = GetMission()->GetIGCMission()->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); if ((psideMe == pside || psideMe->AlliedSides(psideMe,pside)) || GetIGCShip()->SeenBySide(pside)) // #ALLY Imago 7/23/09 VISIBILITY? { m_rgShipStatus[pside->GetObjectID()].SetHullID(hid); } } }
void MavLinkSendMissionItem(uint8_t currentMissionIndex) { Mission m; uint8_t result; GetMission(currentMissionIndex, &m, &result); if (result) { mavlink_message_t msg; int8_t missionManagerCurrentIndex; GetCurrentMission(&missionManagerCurrentIndex); mavlink_msg_mission_item_pack(mavlink_system.sysid, mavlink_system.compid, &msg, groundStationSystemId, groundStationComponentId, currentMissionIndex, m.refFrame, m.action, (currentMissionIndex == (uint8_t)missionManagerCurrentIndex), m.autocontinue, m.parameters[0], m.parameters[1], m.parameters[2], m.parameters[3], m.coordinates[0], m.coordinates[1], m.coordinates[2]); len = mavlink_msg_to_send_buffer(buf, &msg); uart1EnqueueData(buf, (uint8_t)len); } }
void CdispenserIGC::Update(Time now) { assert (m_ship); if (m_mountedFraction < 1.0f) { float dt = now - m_ship->GetLastUpdate(); assert (dt >= 0.0f); m_mountedFraction += dt * m_pMission->GetFloatConstant(c_fcidMountRate); if (m_mountedFraction < 1.0f) return; IIgcSite* pigc = GetMission()->GetIgcSite(); pigc->PlayNotificationSound(mountedSound, m_ship); pigc->PostNotificationText(m_ship, false, "%s ready.", GetPartType()->GetName()); m_mountedFraction = 1.0f; } if ((m_timeLoaded < now) && (m_amount > 0)) { static const int c_maskFire[ET_MAX] = { chaffFireIGC, 0, 0, mineFireIGC, 0, 0, 0, 0 }; assert (c_maskFire[ET_ChaffLauncher] == chaffFireIGC); assert (c_maskFire[ET_Dispenser] == mineFireIGC); EquipmentType et = m_expendableType->GetEquipmentType(); if ((m_ship->GetStateM() & c_maskFire[et]) && ((et == ET_ChaffLauncher) || (m_ship->GetRipcordModel() == NULL))) { m_timeLoaded = now + m_expendableType->GetLoadTime(); m_pMission->GetIgcSite()->FireExpendable(m_ship, this, now); } } }
void CFSShip::ShipStatusRestart(IstationIGC* pstation) { IsideIGC* psideShip = GetIGCShip()->GetSide(); for (SideLinkIGC* psl = GetMission()->GetIGCMission()->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); if ((pside == psideShip || pside->AlliedSides(pside,psideShip)) || (GetIGCShip()->SeenBySide(pside))) //ALLY imago 7/23/09 { ShipStatus* pss = &(m_rgShipStatus[pside->GetObjectID()]); pss->SetStateTime(g.timeNow.clock()); pss->SetState(c_ssDead); pss->SetParentID(NA); pss->SetHullID(NA); pss->SetSectorID(NA); } } }
void CFSShip::ShipStatusRecalculate(void) { IsideIGC* psideMe = GetIGCShip()->GetSide(); IclusterIGC* pcluster = GetIGCShip()->GetCluster(); if (pcluster) { for (SideLinkIGC* psl = GetMission()->GetIGCMission()->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); SideID sid = pside->GetObjectID(); if ((pside == psideMe || pside->AlliedSides(pside,psideMe)) || (m_rgShipStatus[sid].GetState() >= c_ssFlying)) //ALLY IMAGO 7/23/09 ShipStatusSpotted(pside); } } else { ShipStatusSpotted(psideMe); } }
void GetPlayerMissions(std::list<Mission> &missions) { for(std::list<std::string>::const_iterator i = s_modules.begin(); i!=s_modules.end(); ++i) { LUA_DEBUG_START(L) lua_getglobal(L, (*i).c_str()); lua_pushcfunction(L, mylua_panic); lua_getfield(L, -2, "GetPlayerMissions"); if (!lua_isnil(L, -1)) { lua_pushvalue(L, -3); // push self lua_pcall(L, 1, 1, -3); // -1 is table of missions lua_pushnil(L); /* first key */ while (lua_next(L, -2) != 0) { /* 'key' (at index -2) and 'value' (at index -1) */ GetMission(missions); /* removes 'value'; keeps 'key' for next iteration */ lua_pop(L, 1); } } lua_pop(L, 3); LUA_DEBUG_END(L, 0) } }
void CclusterIGC::Update(Time now) { if (now > m_lastUpdate) { float dt = now - m_lastUpdate; bool bStarted = m_pMission->GetMissionStage() == STAGE_STARTED; if (bStarted) { { //Have any stations launch docked drones for (StationLinkIGC* l = m_stations.first(); (l != NULL); l = l->next()) { IstationIGC* pstation = l->data(); ShipLinkIGC* pslNext; for (ShipLinkIGC* psl = pstation->GetShips()->first(); (psl != NULL); psl = pslNext) { IshipIGC* pship = psl->data(); pslNext = psl->next(); //Get the next link now since the ship may launch // const MissionParams* pmp = m_pMission->GetMissionParams(); 04/08 commented out as not needed // mmf 10/07 added so we can get at bExperimental game type if (pship->GetAutopilot() && (pship->GetPilotType() < c_ptPlayer)) { //Docked non-players on autopilot never are observers/parents assert (pship->GetParentShip() == NULL); assert (pship->GetChildShips()->n() == 0); // mmf/yp 10/07 added this so drones launch when ordered to even if OkToLaunch might be false // intentionally left c_cidMine out of the list otherwise miners would launch with their AI // 'order' to mine if (pship->OkToLaunch(now) || (pship->GetCommandID(c_cmdAccepted) == c_cidGoto) || (pship->GetCommandID(c_cmdAccepted) == c_cidBuild) ) pship->SetStation(NULL); // if (pship->OkToLaunch(now)) // mmf orig code // pship->SetStation(NULL); } } //Are any ships buzzing around the stations that a side has yet to eye? #121 #120 Imago 8/10 if (GetShips()->n() > 0 && pstation->GetRoidID() != NA) { Vector pos = pstation->GetRoidPos(); float Sig = pstation->GetRoidSig(); float Radius = pstation->GetRoidRadius(); if (Sig != 0.0f && Radius != 0.0f) { //check if they have a ship eying where the rock would be for (ShipLinkIGC* psl1 = GetShips()->first(); (psl1 != NULL); psl1 = psl1->next()) { IshipIGC* pship = psl1->data(); if (pship->GetParentShip() || pship->GetSide()->GetObjectID() == pstation->GetSide()->GetObjectID() || pstation->SeenBySide(pship->GetSide()) || !pstation->GetRoidSide(pship->GetSide()->GetObjectID())) continue; bool bEye = bSimpleEye(pship->GetHullType()->GetScannerRange(),GetMission()->GetModel(OT_ship,pship->GetObjectID()),Sig,pstation->GetSide()->GetGlobalAttributeSet().GetAttribute(c_gaSignature),Radius,pos); if (bEye) { //Turkey 3/13 #353: kill asteroids for all sides in that alliance. IsideIGC* pside1 = pship->GetSide(); for (SideLinkIGC* sl = m_pMission->GetSides()->first(); sl != NULL; sl = sl->next()) { IsideIGC* pside2 = sl->data(); if (pside1->AlliedSides(pside1, pside2)) { pstation->SetRoidSide(pside2->GetObjectID(),false); GetMission()->GetIgcSite()->KillAsteroidEvent(pstation->GetRoidID(),GetObjectID(),pside2); } } } } } } } } { m_fCost = m_pMission->GetFloatConstant(c_fcidBaseClusterCost); float costLifepod = m_pMission->GetFloatConstant(c_fcidLifepodCost); float costTurret = m_pMission->GetFloatConstant(c_fcidTurretCost); float costPlayer = m_pMission->GetFloatConstant(c_fcidPlayerCost); float costDrone = m_pMission->GetFloatConstant(c_fcidDroneCost); //Have miners and builders do any pre-plotted moves. Allow ships to suicide. ShipLinkIGC* lNext; for (ShipLinkIGC* l = m_ships.first(); (l != NULL); l = lNext) { IshipIGC* s = l->data(); lNext = l->next(); if (s->GetPilotType() < c_ptPlayer) m_fCost += costDrone; else if (s->GetParentShip() != NULL) m_fCost += costTurret; else { IhullTypeIGC* pht = s->GetBaseHullType(); assert (pht); m_fCost += pht->HasCapability(c_habmLifepod) ? costLifepod : costPlayer; } s->PreplotShipMove(now); } if (m_fCost > 0.0f) { m_fCost *= dt / m_pMission->GetFloatConstant(c_fcidClusterDivisor); } { //Have all ships on autopilot plot their moves. Allow ships to suicide. ShipLinkIGC* lNext; for (ShipLinkIGC* l = m_ships.first(); (l != NULL); l = lNext) { IshipIGC* s = l->data(); lNext = l->next(); s->PlotShipMove(now); } } } { //Have all ships execute their moves for (ShipLinkIGC* l = m_ships.first(); (l != NULL); l = l->next()) { IshipIGC* s = l->data(); if (s->GetParentShip() == NULL) { s->ExecuteShipMove(now); } } } } else m_fCost = 0.0f; { //Call the update method on all the contained models //models might self-terminate in the update and nuke earlier models in the update loop //NYI debugging variables //ObjectType oldObjectType = NA; //ObjectType newObjectType = NA; ModelLinkIGC* lNext; for (ModelLinkIGC* l = m_models.first(); (l != NULL); l = lNext) { //oldObjectType = newObjectType; //newObjectType = l->data()->GetObjectType(); lNext = l->next(); l->data()->Update(now); } } if (m_data.activeF && bStarted) { { //Update the bounding boxes for all moving objects & projectiles for (ModelLinkIGC* l = m_models.first(); (l != NULL); l = l->next()) { l->data()->SetBB(m_lastUpdate, now, dt); } m_tMax = dt; } m_kdrStatic.update(); m_kdrMoving.update(); { //Cast rays through the KD tree for each object for (ModelLinkIGC* l = m_modelsCastRay.first(); (l != NULL); l = l->next()) { ImodelIGC* m = l->data(); HitTest* ht = m->GetHitTest(); if (!ht->GetDeadF()) { m_kdrStatic.test(ht, &m_collisions); m_kdrMoving.test(ht, &m_collisions); } } } //Sort the collisions by the time they occur m_collisions.sort(0); //Process each collision (in order) { m_tOffset = 0.0f; for (m_collisionID = 0; (m_collisionID < m_collisions.n()); m_collisionID++) { const CollisionEntry& entry = m_collisions[m_collisionID]; if (!(entry.m_pHitTest1->GetDeadF() || entry.m_pHitTest2->GetDeadF())) { Time timeCollision = m_lastUpdate + (m_tOffset + entry.m_tCollision); ImodelIGC* pModelHitTest1 = (ImodelIGC*)(entry.m_pHitTest1->GetData()); assert (pModelHitTest1); ImodelIGC* pModelHitTest2 = (ImodelIGC*)(entry.m_pHitTest2->GetData()); assert (pModelHitTest2); //Give each participant in the collision a chance to handle the collision //but give the "1st" model first dibs. if ((pModelHitTest1->GetCluster() == this) && (pModelHitTest2->GetCluster() == this)) { pModelHitTest1->HandleCollision(timeCollision, entry.m_tCollision, entry, pModelHitTest2); } } } m_collisions.purge(); } { //Apply any damage from mines //Kids always follow parents in the ship list, so go from back to front //so that the killing a parent doesn't mean hitting dead elements in the list ShipLinkIGC* lTxen; for (ShipLinkIGC* l = m_ships.last(); (l != NULL); l = lTxen) { IshipIGC* s = l->data(); lTxen = l->txen(); s->ApplyMineDamage(); } } //Move each object & projectile { for (ModelLinkIGC* l = m_models.first(); (l != NULL); l = l->next()) { l->data()->Move(); } } if ((m_nPass++) % c_nPassesPerUpdate == 0) { for (ModelLinkIGC* l = m_models.first(); (l != NULL); l = l->next()) { l->data()->UpdateSeenBySide(); } m_pMission->GetIgcSite()->ClusterUpdateEvent(this); } } //Draw and resolve any explosions if (m_nExplosions != 0) { const int c_maxDmgs = 500; IdamageIGC* pdmgs[c_maxDmgs]; int nDmgs = 0; //Copy the list of models in the sector that can be damaged into for (ModelLinkIGC* l = m_modelsPickable.first(); (l != NULL); l = l->next()) { ImodelIGC* pmodel = l->data(); ObjectType type = pmodel->GetObjectType(); //Not everything that can take damage can be affected by an explosion. if ((type == OT_ship) || (type == OT_asteroid) || (type == OT_station) || (type == OT_missile) || (type == OT_probe)) { pmodel->AddRef(); pdmgs[nDmgs++] = (IdamageIGC*)pmodel; if (nDmgs == c_maxDmgs) break; } } ImineIGC* pmines[c_maxDmgs]; int nMines = 0; { for (MineLinkIGC* l = m_mines.first(); (l != NULL); l = l->next()) { ImineIGC* pm = l->data(); pm->AddRef(); pmines[nMines++] = pm; if (nMines == c_maxDmgs) break; } } int i = 0; do { ExplosionData& e = m_explosions[i]; m_pClusterSite->AddExplosion(e.position, e.radius, e.explosionType); float dt = (e.time - m_lastUpdate) - m_tOffset; //Now, the painful part: applying damage to everything in the sector that could be hit { for (int j = 0; (j < nDmgs); j++) { IdamageIGC* pTarget = pdmgs[j]; if (pTarget->GetCluster() == this) //Make sure it wasn't already destroyed { //The target is still around Vector p = pTarget->GetPosition() + dt * pTarget->GetVelocity(); float d = (e.position - p).Length() - pTarget->GetRadius(); if (d < e.radius) { float amount = e.amount; if (d > 0.0f) { float f = 1.0f - (d / e.radius); amount *= f * f; } pTarget->ReceiveDamage(e.damageType | c_dmgidNoWarn | c_dmgidNoDebris, amount, e.time, p, e.position, e.launcher); } } } } { for (int j = 0; (j < nMines); j++) { ImineIGC* pTarget = pmines[j]; if (pTarget->GetCluster() == this) //Make sure it wasn't already destroyed { //The target is still around const Vector& p = pTarget->GetPosition(); float d = (e.position - p).Length() - pTarget->GetRadius(); if (d < e.radius) { float amount = e.amount; if (d > 0.0f) { float f = 1.0f - (d / e.radius); amount *= f * f; } pTarget->ReduceStrength(amount); } } } } if (e.launcher) e.launcher->Release(); } while (++i < m_nExplosions); //Release all the cached pointers { while (--nDmgs >= 0) pdmgs[nDmgs]->Release(); } { while (--nMines >= 0) pmines[nMines]->Release(); } m_nExplosions = 0; } m_lastUpdate = now; } }
/*------------------------------------------------------------------------- * CaptureStation *------------------------------------------------------------------------- * Purpose: * Handle a station being captured by a ship */ void CFSShip::CaptureStation(IstationIGC * pstation) { { //Fudge the hitpoints of the station //All those guns inside damage the hull pstation->SetFraction(pstation->GetFraction() * 0.5f); //But the heroic engineer's get the shields up. pstation->SetShieldFraction(0.8f); //pstation->GetShieldFraction() + 0.5f); } { GetPlayerScoreObject()->CaptureBase(true); for (ShipLinkIGC* psl = GetIGCShip()->GetChildShips()->first(); (psl != NULL); psl = psl->next()) { CFSShip* ps = (CFSShip*)(psl->data()->GetPrivateData()); ps->GetPlayerScoreObject()->CaptureBase(false); } } IsideIGC * pside = GetSide(); pside->AddBaseCapture(); SideID iSide = pside->GetObjectID(); IsideIGC* psideOld = pstation->GetSide(); StationID stationID = pstation->GetObjectID(); BEGIN_PFM_CREATE(g.fm, pfmStationCapture, S, STATION_CAPTURE) END_PFM_CREATE pfmStationCapture->stationID = stationID; pfmStationCapture->sidOld = psideOld->GetObjectID(); pfmStationCapture->sidNew = iSide; pfmStationCapture->shipIDCredit = GetIGCShip()->GetObjectID(); g.fm.SendMessages(GetMission()->GetGroupRealSides(), FM_GUARANTEED, FM_FLUSH); pstation->SetSide(pside); // TE: Fire AGCEvent when base is captured CFSMission * pfsMission = this->GetMission(); LPCSTR pszContext = pfsMission->GetIGCMission() ? pfsMission->GetIGCMission()->GetContextName() : NULL; _AGCModule.TriggerContextEvent(NULL, EventID_StationChangesSides, pszContext, GetName(), GetShipID(), pside->GetUniqueID(), -1, 4, "GameID" , VT_I4 , pfsMission->GetMissionID(), "OldTeam" , VT_I4 , psideOld->GetUniqueID(), "OldTeamName", VT_LPSTR, psideOld->GetName(), "StationName", VT_LPSTR, pstation->GetName()); // TE end // yp: Add event for players who were involved in the capture of an enemy base. // mmf commented this out for now pending additional testing #if 0 ZString pszPlayerList = ""; // this creates a new ZString object and set its value to "", it's not a pointer to "" if(m_pfsMission->GetIGCMission() && m_pfsMission->GetIGCMission()->GetShips()) { ShipLinkIGC * pShiplink = m_pfsMission->GetIGCMission()->GetShips()->first(); while (pShiplink) { CFSShip * pfsShip = (CFSShip *) pShiplink->data()->GetPrivateData(); if (pfsShip && pfsShip->IsPlayer()) { // this logic might need to be tweeked to include the ship that did the capture if its if(pfsShip->GetSide() && pfsShip->GetSide()->GetObjectID() == iSide && // if they are on the side that did the Capture. and.. pfsShip->GetPlayer()->GetIGCShip()->GetObjectID() == GetIGCShip()->GetObjectID() || // they are the ship that did the caputure. or pfsShip->GetCluster() && pstation->GetCluster() && pfsShip->GetCluster()->GetObjectID() == pstation->GetCluster()->GetObjectID()) // they are in this sector { pszPlayerList = pszPlayerList + ";" + ZString(pfsShip->GetPlayer()->GetName()); // players name // The distance the player is from the station that was destroyed. if(pfsShip->GetPlayer()->GetIGCShip() ) { pszPlayerList = pszPlayerList + ":" + ZString( (pstation->GetPosition() - pfsShip->GetPlayer()->GetIGCShip()->GetPosition()).Length()); // the distance } } } pShiplink = pShiplink->next(); } } // Fire AGCEvent listing players in the sector // TODO: Might want to add into the event weither or not this was a VICTORY capture.. should we track that as well? _AGCModule.TriggerContextEvent(NULL, EventID_StationChangesSides, pszContext, GetName(), GetShipID(), pside->GetUniqueID(), -1, 4, "GameID" , VT_I4 , pfsMission->GetMissionID(), "OldTeam" , VT_I4 , psideOld->GetUniqueID(), "OldTeamName", VT_LPSTR, psideOld->GetName(), "zPlayerList", VT_LPSTR, pszPlayerList); // pszPlayerList should look like ";player@squad:1500;player2@squad:500" // yp:end #endif //Possibly the built themselves to a victory IsideIGC* psideWin = m_pfsMission->CheckForVictoryByStationCapture(pside, psideOld); if (psideWin) { static char szReason[100]; //Make this static so we only need to keep a pointer to it around sprintf(szReason, "%s won because %s captured %s", psideWin->GetName(), GetIGCShip()->GetName(), pstation->GetName()); m_pfsMission->GameOver(psideWin, szReason); } else if (psideOld->GetActiveF()) //RESET OUR EYE HERE? IMAGO CAPTURE EYE BUG FIX? REVIEW 7/23/09 m_pfsMission->VacateStation(pstation); }
bool CFSPlayer::IsMissionOwner() { return this == GetMission()->GetOwner(); }
void CFSPlayer::SetReady(bool fReady) { m_fReady = fReady; GetMission()->PlayerReadyChange(this); }
//---------------------------------------- int32_t CMission::LoadRefMission(bool searchByID /* = true */ ) { int32_t result = BRATHL_SUCCESS; const uint32_t MAX_LINE_LEN = 255; char line[MAX_LINE_LEN+1]; brathl_mission id = 0; char name[CMission::m_maxLenName+1]; int32_t cycle = 0; int32_t pass = 0; double julian = 0.0; double repeat = 0.0; int32_t nbPass = 0; bool bFoundInFile = false; CMission missionSave = *this; std::string refFilePathName = CTools::FindDataFile( CMission::m_refFileName ); if (refFilePathName == "") { if (m_printWarnings) { printf( "\nWARNING - CMission::LoadRefMission - Unabled to open file '%s' " "\nCheck directory '%s'\n", CMission::m_refFileName, CTools::GetInternalDataDir().c_str()); } return BRATHL_WARNING_OPEN_FILE_REF_FILE; } // reads file contains conversion parameters CFile fileRef(refFilePathName, CFile::modeRead); if (fileRef.IsOpen() == false) { if (m_printWarnings) { printf( "\nWARNING - CMission::LoadRefMission - Unabled to open file '%s'\n", refFilePathName.c_str() ); } return BRATHL_WARNING_OPEN_FILE_REF_FILE; } int32_t nbFields = EOF; int32_t lineNb = 0; int32_t size = fileRef.ReadLineData(line, MAX_LINE_LEN); while (size > 0) { ++lineNb; nbFields = sscanf ( line, "%d %s %d %d %lf %lf %d", &id, name, &cycle, &pass, &julian, &repeat, &nbPass ); if ( nbFields < 7 ) { if (m_printWarnings) { printf( "\nWARNING - CMission::LoadRefMission - Invalid reference mission file format - line: %d of file: %s \n", lineNb, refFilePathName.c_str() ); } return BRATHL_WARNING_INVALID_REF_FILE_FIELD; } /*printf("id %d, name %s, cycle %d, pass %d, julian %lf, repead %lf, nbpass %d \n", id, name, cycle, pass, julian, repeat, nbPass);*/ if ( searchByID ) bFoundInFile = ( id == GetMission() ); else { std::string product_type ( GetName() ); // product type/label std::string name_read( name ); // mission name at reference file product_type = CTools::StringToLower(product_type).substr(0, name_read.size()); name_read = CTools::StringToLower(name_read); bFoundInFile = ( product_type == name_read ); } if ( bFoundInFile ) { missionSave = *this; // Assign mission conversion parameters m_mission = id; m_missionName = name; m_cycleRef = cycle; m_passRef = pass; m_repeat = repeat; m_nbPass = nbPass; result = m_dateRef.SetDateJulian(julian); if (result != BRATHL_SUCCESS) { if (m_printWarnings) { printf( "\nWARNING - CMission::LoadRefMission - Invalid reference date - file name %s \n" "mission %s, cycle %d, pass %d, julian %lf, repeat %lf, nb passes %d\n", refFilePathName.c_str(), name, cycle, pass, julian, repeat, nbPass ); } *this = missionSave; result = BRATHL_WARNING_INVALID_REF_FILE_FIELDDATE; } } // Breaks while loop if mission was found if ( bFoundInFile ) { break; } else { size = fileRef.ReadLineData(line, MAX_LINE_LEN); } // reads next line } if ( bFoundInFile == false ) { if ( m_printWarnings ) { if (searchByID) printf("\nWARNING - CMission::LoadRefMission - no mission ID=%d found in file: %s \n", GetMission(), refFilePathName.c_str()); else printf("\nWARNING - CMission::LoadRefMission - no mission name='%s' found in file: %s \n", GetName(), refFilePathName.c_str()); } m_missionName = CMission::m_nameUnknown; result = BRATHL_ERROR_INVALID_MISSION; } fileRef.Close(); return result; }
void CafterburnerIGC::IncrementalUpdate(Time lastUpdate, Time now, bool bUseFuel) { assert (m_ship); assert (now >= lastUpdate); { #ifdef WIN float dt = now - lastUpdate; #else float dt = Seconds(now - lastUpdate).count(); #endif if (m_mountedFraction < 1.0f) { if (bUseFuel) m_mountedFraction += dt * m_pMission->GetFloatConstant(c_fcidMountRate); if (m_mountedFraction >= 1.0f) { IIgcSite* pigc = GetMission()->GetIgcSite(); pigc->PlayNotificationSound(mountedSound, m_ship); pigc->PostNotificationText(m_ship, false, "%s ready.", GetPartType()->GetName()); m_mountedFraction = 1.0f; } else return; } { float fuel = m_ship->GetFuel(); bool bActivated = (m_ship->GetStateM() & afterburnerButtonIGC) && (fuel != 0.0f || m_typeData->fuelConsumption == 0.0f); //Spunky - #271 if (bActivated) Activate(); if (m_fActive) { if (bActivated) { m_power += dt * m_typeData->onRate; if (m_power > 1.0f) m_power = 1.0f; } else { m_power -= dt * m_typeData->offRate; if (m_power <= 0.0f) Deactivate(); } if ((m_power != 0.0f) && bUseFuel) { float fuelUsed = m_power * m_typeData->fuelConsumption * m_typeData->maxThrust * dt; if (fuelUsed < fuel) m_ship->SetFuel(fuel - fuelUsed); else if (fuel != 0.0f) { //Out of gas m_ship->SetFuel(0.0f); Deactivate(); } } } } } }
void CFSPlayer::SetSide(CFSMission * pfsMission, IsideIGC * pside) { CFSMission * pfsmOld = GetMission(); IsideIGC* psideOld = GetSide(); CFSShip::SetSide(pfsMission, pside); // Their persist score now becomes their current score, and other stuff is reset if (pside) { PlayerScoreObject* ppso = GetPlayerScoreObject(); ppso->SetPersist(GetPersistPlayerScore(pside->GetCivilization()->GetObjectID())); memset(m_ptDesiredLoadout, 0, sizeof(m_ptDesiredLoadout)); } // can't guarantee success on group changes--dplay player may be already blown away if (pside != psideOld) { if (pfsmOld) g.fm.DeleteConnectionFromGroup(CFSSide::FromIGC(psideOld)->GetGroup(), GetConnection()); if (pfsMission) { bool fLobbySide = SIDE_TEAMLOBBY == pside->GetObjectID(); CFMGroup * pgrp = CFSSide::FromIGC(pside)->GetGroup(); g.fm.AddConnectionToGroup(pgrp, GetConnection()); if (fLobbySide) g.fm.DeleteConnectionFromGroup(pfsMission->GetGroupRealSides(), GetConnection()); else g.fm.AddConnectionToGroup(pfsMission->GetGroupRealSides(), GetConnection()); } } else assert (pfsmOld == pfsMission); if (!pside && m_pgrp) { g.fm.DeleteConnectionFromGroup(m_pgrp, GetConnection()); m_pgrp = NULL; } // // If the user just joined or left the game, consider firing an AGC event // if (pfsmOld != pfsMission) { if (pfsmOld) // if leaving a game { const char * szName = pfsmOld->GetIGCMission() && pfsmOld->GetIGCMission()->GetMissionParams() ? pfsmOld->GetIGCMission()->GetMissionParams()->strGameName : "?" ; int id = pfsmOld->GetIGCMission() ? pfsmOld->GetIGCMission()->GetMissionID() : -1; long idShip = (AGC_AdminUser << 16) | CAdminUser::DetermineID(this->GetPlayer()); LPCSTR pszContext = pfsmOld->GetIGCMission() ? pfsmOld->GetIGCMission()->GetContextName() : NULL; _AGCModule.TriggerContextEvent(NULL, EventID_LogoutGame, pszContext, GetName(), idShip, -1, -1, 2, "GameID", VT_I4, id, "GameName", VT_LPSTR, szName); } if (pfsMission) // if joining a game { const char * szName = pfsMission->GetIGCMission() && pfsMission->GetIGCMission()->GetMissionParams() ? pfsMission->GetIGCMission()->GetMissionParams()->strGameName : "?" ; int id = pfsMission->GetIGCMission() ? pfsMission->GetIGCMission()->GetMissionID() : -1; long idShip = (AGC_AdminUser << 16) | CAdminUser::DetermineID(this->GetPlayer()); LPCSTR pszContext = pfsMission->GetIGCMission() ? pfsMission->GetIGCMission()->GetContextName() : NULL; _AGCModule.TriggerContextEvent(NULL, EventID_LoginGame, pszContext, GetName(), idShip, -1, -1, 2, "GameID", VT_I4, id, "GameName", VT_LPSTR, szName); } } // // If the user just joined or left the team, consider firing an AGC event // if (psideOld != pside) { //Imago #169 if ( (psideOld && psideOld->GetObjectID() == SIDE_TEAMLOBBY) || (pside && pside->GetObjectID() == SIDE_TEAMLOBBY)) if (pfsMission) pfsMission->SetLobbyIsDirty(); long idShip = (AGC_AdminUser << 16) | CAdminUser::DetermineID(this->GetPlayer()); if (psideOld ) // if leaving a side { LPCSTR pszContext = GetIGCShip()->GetMission() ? GetIGCShip()->GetMission()->GetContextName() : NULL; // TE Modify LeaveTeam AGCEvent to include MissionID, and change UniqueID to ObjectID _AGCModule.TriggerContextEvent(NULL, EventID_LeaveTeam, pszContext, GetName(), idShip, psideOld->GetUniqueID(), -1, 3, // Changed UniqueID to ObjectID. Modified ParamCount to 3 "MissionID", VT_I4 , psideOld->GetMission()->GetMissionID(), // Added line MissionID as param "Team" , VT_I4 , psideOld->GetObjectID(), // Changed UniqueID to ObjectID "TeamName", VT_LPSTR, psideOld->GetName()); // old event //_AGCModule.TriggerContextEvent(NULL, EventID_LeaveTeam, pszContext, // GetName(), idShip, psideOld->GetUniqueID(), -1, 2, // "Team" , VT_I4 , psideOld->GetUniqueID(), // "TeamName", VT_LPSTR, psideOld->GetName()); } if (pside) // if joining a side { // TE Modify JoinTeam AGCEvent to include MissionID, and change UniqueID to ObjectID _AGCModule.TriggerEvent(NULL, EventID_JoinTeam, GetName(), idShip, pside->GetUniqueID(), -1, 3, // Changed UniqueID to ObjectID. Modified ParamCount to 3 "MissionID", VT_I4 , pfsMission->GetMissionID(), // Added line MissionID "Team" , VT_I4 , pside->GetObjectID(), // Changed UniqueID to ObjectID. "TeamName", VT_LPSTR, pside->GetName()); // old event //_AGCModule.TriggerEvent(NULL, EventID_JoinTeam, GetName(), idShip, //pside->GetUniqueID(), -1, 2, //"Team" , VT_I4 , pside->GetUniqueID(), //"TeamName", VT_LPSTR, pside->GetName()); } } }