nonstockpilecoverage.diff (2,937 bytes)
2008-10-26 05:11
Index: rts/Game/UI/GuiHandler.cpp
===================================================================
--- rts/Game/UI/GuiHandler.cpp (revision 6893)
+++ rts/Game/UI/GuiHandler.cpp (working copy)
@@ -3704,23 +3704,20 @@
DrawSensorRange(unitdef->sonarJamRadius, cmdColors.rangeSonarJammer, p);
}
// draw interceptor range
- const WeaponDef* wd = NULL;
- const CWeapon* w = NULL;
- if (enemyUnit) {
- wd = unitdef->stockpileWeaponDef;
- } else {
- w = unit->stockpileWeapon;
- if (w != NULL) {
- wd = w->weaponDef;
- }
- }
- if ((wd != NULL) && wd->interceptor) {
- if (enemyUnit || w->numStockpiled) {
+ if (unitdef->maxCoverage > 0.0f) {
+ const CWeapon* w = NULL; //will be checked if any missiles are ready
+ if (!enemyUnit) {
+ w = unit->stockpileWeapon;
+ if (w != NULL && !w->weaponDef->interceptor) {
+ w = NULL; //if this isn't the interceptor, then don't use it
+ }
+ } //shows as on if enemy, a non-stockpiled weapon, or if the stockpile has a missile
+ if (enemyUnit || (w == NULL) || w->numStockpiled) {
glColor4fv(cmdColors.rangeInterceptorOn);
} else {
glColor4fv(cmdColors.rangeInterceptorOff);
}
- glSurfaceCircle(unit->pos, wd->coverageRange, 40);
+ glSurfaceCircle(unit->pos, unitdef->maxCoverage, 40);
}
}
}
Index: rts/Lua/LuaUnitDefs.cpp
===================================================================
--- rts/Lua/LuaUnitDefs.cpp (revision 6893)
+++ rts/Lua/LuaUnitDefs.cpp (working copy)
@@ -754,6 +754,7 @@
ADD_FLOAT("slideTolerance", ud.slideTolerance);
ADD_FLOAT("maxWeaponRange", ud.maxWeaponRange);
+ ADD_FLOAT("maxCoverage", ud.maxCoverage);
ADD_BOOL( "buildRange3D", ud.buildRange3D);
ADD_FLOAT("buildDistance", ud.buildDistance);
Index: rts/Sim/Units/UnitDef.h
===================================================================
--- rts/Sim/Units/UnitDef.h (revision 6893)
+++ rts/Sim/Units/UnitDef.h (working copy)
@@ -221,6 +221,7 @@
const WeaponDef* shieldWeaponDef;
const WeaponDef* stockpileWeaponDef;
float maxWeaponRange;
+ float maxCoverage;
std::map<int, std::string> buildOptions;
Index: rts/Sim/Units/UnitDefHandler.cpp
===================================================================
--- rts/Sim/Units/UnitDefHandler.cpp (revision 6893)
+++ rts/Sim/Units/UnitDefHandler.cpp (working copy)
@@ -524,6 +524,7 @@
ud.stockpileWeaponDef = NULL;
ud.maxWeaponRange = 0.0f;
+ ud.maxCoverage = 0.0f;
const WeaponDef* noWeaponDef = weaponDefHandler->GetWeapon("NOWEAPON");
@@ -584,6 +585,9 @@
if (wd->range > ud.maxWeaponRange) {
ud.maxWeaponRange = wd->range;
}
+ if (wd->interceptor && wd->coverageRange > ud.maxCoverage) {
+ ud.maxCoverage = wd->coverageRange;
+ }
if (wd->isShield) {
if (!ud.shieldWeaponDef || // use the biggest shield
(ud.shieldWeaponDef->shieldRadius < wd->shieldRadius)) {