Fixed off by 1
This commit is contained in:
parent
7528ab19f0
commit
7d67e6ee94
7 changed files with 20 additions and 19 deletions
|
@ -201,7 +201,8 @@ int EnemyUnitsInDistance(const Unit* unit, unsigned range)
|
|||
//
|
||||
x = unit->X;
|
||||
y = unit->Y;
|
||||
n = UnitCacheSelect(x - range, y - range, x + range + 1, y + range + 1, table);
|
||||
n = UnitCacheSelect(x - range, y - range, x + range + unit->Type->TileWidth,
|
||||
y + range + unit->Type->TileHeight, table);
|
||||
|
||||
player = unit->Player;
|
||||
type = unit->Type;
|
||||
|
|
|
@ -1865,7 +1865,7 @@ void MissileActionDeathCoil(Missile* missile)
|
|||
x = missile->DX / TileSizeX;
|
||||
y = missile->DY / TileSizeY;
|
||||
|
||||
n = UnitCacheSelect(x - 2, y - 2, x + 2, y + 2, table);
|
||||
n = UnitCacheSelect(x - 2, y - 2, x + 2 + 1, y + 2 + 1, table);
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ static int CclChangeUnitsOwner(lua_State* l)
|
|||
y2 = LuaToNumber(l, -1);
|
||||
lua_pop(l, 1);
|
||||
|
||||
n = UnitCacheSelect(x1, y1, x2, y2, table);
|
||||
n = UnitCacheSelect(x1, y1, x2 + 1, y2 + 1, table);
|
||||
oldp = LuaToNumber(l, 3);
|
||||
newp = LuaToNumber(l, 4);
|
||||
while (n) {
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name spells.c - The spell cast action. */
|
||||
//
|
||||
// (c) Copyright 1998-2003 by Vladi Belperchinov-Shabanski, Lutz Sammer,
|
||||
// Jimmy Salmon and Joris DAUPHIN
|
||||
// (c) Copyright 1998-2004 by Vladi Belperchinov-Shabanski, Lutz Sammer,
|
||||
// Jimmy Salmon and Joris DAUPHIN
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -154,7 +154,7 @@ int CastDemolish(Unit* caster, const SpellType* spell __attribute__((unused)),
|
|||
// Effect of the explosion on units. Don't bother if damage is 0
|
||||
//
|
||||
if (action->Data.Demolish.Damage) {
|
||||
n = UnitCacheSelect(xmin, ymin, xmax, ymax, table);
|
||||
n = UnitCacheSelect(xmin, ymin, xmax + 1, ymax + 1, table);
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (table[i]->Type->UnitType != UnitTypeFly && table[i]->HP &&
|
||||
MapDistanceToUnit(x, y, table[i]) <= action->Data.Demolish.Range) {
|
||||
|
|
|
@ -1142,7 +1142,7 @@ static int CclOrderUnit(lua_State* l)
|
|||
} else if (!strcmp(order, "attack")) {
|
||||
Unit* attack;
|
||||
|
||||
attack=TargetOnMap(unit, dx1, dy1, dx2, dy2);
|
||||
attack = TargetOnMap(unit, dx1, dy1, dx2 + 1, dy2 + 1);
|
||||
CommandAttack(unit, (dx1 + dx2) / 2, (dy1 + dy2) / 2, attack, 1);
|
||||
} else if (!strcmp(order, "patrol")) {
|
||||
CommandPatrolUnit(unit, (dx1 + dx2) / 2, (dy1 + dy2) / 2, 1);
|
||||
|
|
|
@ -2109,24 +2109,24 @@ Unit* CanBuildHere(const Unit* unit, const UnitType* type, int x, int y)
|
|||
// Run Distance Checking
|
||||
if (b->RestrictType == RestrictDistance) {
|
||||
if (b->Data.Distance.DistanceType == LessThanEqual ||
|
||||
b->Data.Distance.DistanceType == GreaterThan ||
|
||||
b->Data.Distance.DistanceType == Equal ||
|
||||
b->Data.Distance.DistanceType == NotEqual) {
|
||||
b->Data.Distance.DistanceType == GreaterThan ||
|
||||
b->Data.Distance.DistanceType == Equal ||
|
||||
b->Data.Distance.DistanceType == NotEqual) {
|
||||
x1 = x - b->Data.Distance.Distance > 0 ? x - b->Data.Distance.Distance : 0;
|
||||
y1 = y - b->Data.Distance.Distance > 0 ? y - b->Data.Distance.Distance : 0;
|
||||
x2 = x + type->TileWidth + b->Data.Distance.Distance < TheMap.Width ?
|
||||
x + type->TileWidth + b->Data.Distance.Distance : TheMap.Width - 1;
|
||||
x + type->TileWidth + b->Data.Distance.Distance : TheMap.Width;
|
||||
y2 = y + type->TileHeight + b->Data.Distance.Distance < TheMap.Height ?
|
||||
y + type->TileHeight + b->Data.Distance.Distance : TheMap.Height - 1;
|
||||
y + type->TileHeight + b->Data.Distance.Distance : TheMap.Height;
|
||||
distance = b->Data.Distance.Distance;
|
||||
} else if (b->Data.Distance.DistanceType == LessThan ||
|
||||
b->Data.Distance.DistanceType == GreaterThanEqual) {
|
||||
b->Data.Distance.DistanceType == GreaterThanEqual) {
|
||||
x1 = x - b->Data.Distance.Distance - 1 > 0 ? x - b->Data.Distance.Distance - 1 : 0;
|
||||
y1 = y - b->Data.Distance.Distance - 1 > 0 ? y - b->Data.Distance.Distance - 1 : 0;
|
||||
x2 = x + type->TileWidth + b->Data.Distance.Distance + 1 < TheMap.Width ?
|
||||
x + type->TileWidth + b->Data.Distance.Distance + 1 : TheMap.Width - 1;
|
||||
x + type->TileWidth + b->Data.Distance.Distance + 1 : TheMap.Width;
|
||||
y2 = y + type->TileHeight + b->Data.Distance.Distance + 1 < TheMap.Height ?
|
||||
y + type->TileHeight + b->Data.Distance.Distance + 1 : TheMap.Height - 1;
|
||||
y + type->TileHeight + b->Data.Distance.Distance + 1 : TheMap.Height;
|
||||
distance = b->Data.Distance.Distance - 1;
|
||||
}
|
||||
n = UnitCacheSelect(x1, y1, x2, y2, table);
|
||||
|
|
|
@ -765,8 +765,8 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
|
|||
x = unit->X;
|
||||
y = unit->Y;
|
||||
type = unit->Type;
|
||||
n = UnitCacheSelect(x - range, y - range, x + range + type->TileWidth - 1,
|
||||
y + range + type->TileHeight - 1, table);
|
||||
n = UnitCacheSelect(x - range, y - range, x + range + type->TileWidth,
|
||||
y + range + type->TileHeight, table);
|
||||
|
||||
best_unit = NoUnitP;
|
||||
best_cost = INT_MAX;
|
||||
|
|
Loading…
Add table
Reference in a new issue