Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rts/Rendering/Env/NanoParticles/NanoParticleEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CBuilder;
class CFactory;
class CUnit;
struct float3;
class float3;

namespace NanoParticles {

Expand Down
2 changes: 2 additions & 0 deletions rts/Sim/Misc/InterceptHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void CInterceptHandler::Update(bool forced) {
for (CWeaponProjectile* p: interceptables) {
if (!p->CanBeInterceptedBy(wDef))
continue;
if (wDef->interceptSolo && p->IsBeingIntercepted())
continue;
if (w->HasIncomingProjectile(p->id))
continue;

Expand Down
28 changes: 24 additions & 4 deletions rts/Sim/Weapons/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ void CWeapon::Update()
if (!HaveTarget() && owner->curTarget.type != Target_None)
Attack(owner->curTarget);

if (salvoLeft == 0 && HaveDeniedInterceptTarget())
UpdateInterceptTarget();

currentTargetPos = GetLeadTargetPos(currentTarget);

if (!UpdateStockpile())
Expand Down Expand Up @@ -663,6 +666,12 @@ void CWeapon::DropCurrentTarget()
}


bool CWeapon::HaveDeniedInterceptTarget() const
{
return (currentTarget.type == Target_Intercept && weaponDef->interceptSolo && currentTarget.intercept->IsBeingIntercepted());
}


bool CWeapon::AllowWeaponAutoTarget() const
{
RECOIL_DETAILED_TRACY_ZONE;
Expand Down Expand Up @@ -1288,6 +1297,21 @@ void CWeapon::UpdateInterceptTarget()
CWeaponProjectile* newTarget = nullptr;
float minInterceptTargetDistSq = std::numeric_limits<float>::max();

if (weaponDef->interceptSolo) {
if (HaveDeniedInterceptTarget())
DropCurrentTarget();

spring::VectorEraseIfAll(incomingProjectileIDs, [this](const int projID) {
CWeaponProjectile* wp = static_cast<CWeaponProjectile*>(projectileHandler.GetProjectileBySyncedID(projID));

if (!wp->IsBeingIntercepted())
return false;

DeleteDeathDependence(wp, DEPENDENCE_INTERCEPT);
return true;
});
}

if (currentTarget.type == Target_Intercept)
minInterceptTargetDistSq = aimFromPos.SqDistance(currentTarget.intercept->pos);

Expand All @@ -1297,10 +1321,6 @@ void CWeapon::UpdateInterceptTarget()

const float curInterceptTargetDistSq = aimFromPos.SqDistance(wp->pos);

// set by CWeaponProjectile's ctor when the interceptor fires
if (weaponDef->interceptSolo && wp->IsBeingIntercepted()) //FIXME add bad target?
continue;

if (curInterceptTargetDistSq >= minInterceptTargetDistSq)
continue;

Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Weapons/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CWeapon : public CObject
bool HaveTarget() const { return (currentTarget.type != Target_None); }
bool HaveUnitTarget() const { return (currentTarget.type == Target_Unit); }
bool HavePosTarget() const { return (currentTarget.type == Target_Pos); }
bool HaveDeniedInterceptTarget() const;

const SWeaponTarget& GetCurrentTarget() const { return currentTarget; }
const float3& GetCurrentTargetPos() const { return currentTargetPos; }
Expand Down
2 changes: 1 addition & 1 deletion rts/build/cmake/OverrideFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(MSVC)
set(MSVC_EXTRA_DEFINES "/DWINDOWS /D_CRT_SECURE_NO_WARNINGS")
set(MSVC_EXTRA_FLAGS "/wd4244 /wd4018 /wd4800 /wd4305 /wd4514 /wd4996 /wd4710 /wd4820")

set(CMAKE_CXX_FLAGS_INIT "${MSVC_EXTRA_DEFINES} ${MSVC_EXTRA_FLAGS} /DWIN32 /D_WINDOWS /W3 /EHa /GR")
set(CMAKE_CXX_FLAGS_INIT "${MSVC_EXTRA_DEFINES} ${MSVC_EXTRA_FLAGS} /DWIN32 /D_WINDOWS /W3 /EHsc /GR")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
Expand Down
1 change: 1 addition & 0 deletions rts/build/cmake/Util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ macro (create_install_target targetName var_list_depends var_list_instDirs)
endif (NOT EXISTS "${CMAKE_SOURCE_DIR}/${instDir}/CMakeLists.txt")
set(installCmds ${installCmds}
COMMAND "${CMAKE_COMMAND}"
"-DBUILD_TYPE=$<CONFIG>"
"-P" "${CMAKE_BINARY_DIR}/${instDir}/cmake_install.cmake"
# NOTE: The following does not work in CMake 2.6.4
#"-DCMAKE_INSTALL_COMPONENT=${targetName}"
Expand Down