This commit is contained in:
jarod42 2004-06-26 12:51:17 +00:00
parent 7344d1003a
commit a6fc8c2375
8 changed files with 729 additions and 734 deletions

View file

@ -31,7 +31,7 @@
//@{
/*----------------------------------------------------------------------------
-- Includes
-- Includes
----------------------------------------------------------------------------*/
#include <string.h>
@ -168,7 +168,7 @@ void CclParseOrder(lua_State* l, Order* order)
int j;
//
// Parse the list: (still everything could be changed!)
// Parse the list: (still everything could be changed!)
//
args = luaL_getn(l, -1);
for (j = 0; j < args; ++j) {
@ -632,7 +632,7 @@ static int CclUnit(lua_State* l)
i = 0;
//
// Parse the list: (still everything could be changed!)
// Parse the list: (still everything could be changed!)
//
for (; j < args; ++j) {
value = LuaToString(l, j + 1);
@ -661,7 +661,7 @@ static int CclUnit(lua_State* l)
unit->Seen.Type = seentype;
unit->Active = 0;
unit->Removed = 0;
unit->Reset = 0; // JOHNS ????
unit->Reset = 0; // JOHNS ????
Assert(unit->Slot == slot);
} else if (!strcmp(value, "next")) {
unit->Next = UnitSlots[(int)LuaToNumber(l, j + 1)];
@ -930,7 +930,7 @@ static int CclUnit(lua_State* l)
MapMarkUnitSight(unit);
}
// Place on map
// Place on map
if (!unit->Removed && !unit->Destroyed && !unit->Type->Vanishes) {
unit->Removed = 1;
PlaceUnit(unit, unit->X, unit->Y);
@ -947,14 +947,14 @@ static int CclUnit(lua_State* l)
MapMarkUnitSight(unit);
}
/* if (unit->Moving) {
/* if (unit->Moving) {
NewResetPath(unit);
}*/
// Fix Colors for rescued units.
if (unit->RescuedFrom) {
unit->Colors = &unit->RescuedFrom->UnitColors;
}
return 0;
}
@ -1340,7 +1340,7 @@ static int CclGetUnitMana(lua_State* l)
**
** @param l Lua state.
**
** @return The new mana of the unit.
** @return The new mana of the unit.
*/
static int CclSetUnitMana(lua_State* l)
{
@ -1465,8 +1465,8 @@ static int CclSlotUsage(lua_State* l)
}
/**
** Load the unit allocator state.
** We need to do this in order to make sure that the game allocates units
** Load the unit allocator state.
** We need to do this in order to make sure that the game allocates units
** in the exact same way.
**
** @param l Lua state.

View file

@ -55,13 +55,13 @@
----------------------------------------------------------------------------*/
#ifdef DEBUG
extern int NoWarningUnitType; /// quiet ident lookup.
extern int NoWarningUnitType; ///< quiet ident lookup.
#endif
_AnimationsHash AnimationsHash; /// Animations hash table
_AnimationsHash AnimationsHash; ///< Animations hash table
char** BoolFlagName; /// Name of user defined flag
int NumberBoolFlag; /// Number of defined flags.
char** BoolFlagName; ///< Name of user defined flag
int NumberBoolFlag; ///< Number of defined flags.
/*----------------------------------------------------------------------------
-- Functions
@ -598,8 +598,8 @@ static int CclDefineUnitType(lua_State* l)
LuaError(l, "incorrect argument");
}
//
// Warning: can-cast-spell should only be used AFTER all spells
// have been defined. FIXME: MaxSpellType=500 or something?
// Warning: can-cast-spell should only be used AFTER all spells
// have been defined. FIXME: MaxSpellType=500 or something?
//
if (!type->CanCastSpell) {
type->CanCastSpell = malloc(SpellTypeCount);
@ -658,8 +658,8 @@ static int CclDefineUnitType(lua_State* l)
}
} else if (!strcmp(value, "CanTargetFlag")) {
//
// Warning: can-target-flag should only be used AFTER all bool flags
// have been defined.
// Warning: can-target-flag should only be used AFTER all bool flags
// have been defined.
//
if (!lua_istable(l, -1)) {
LuaError(l, "incorrect argument");
@ -826,7 +826,7 @@ static int CclDefineUnitStats(lua_State* l)
stats = &type->Stats[i];
//
// Parse the list: (still everything could be changed!)
// Parse the list: (still everything could be changed!)
//
for (; j < args; ++j) {
@ -1046,7 +1046,7 @@ static int CclDefineUnitTypeWcNames(lua_State* l)
int j;
char** cp;
if ((cp = UnitTypeWcNames)) { // Free all old names
if ((cp = UnitTypeWcNames)) { // Free all old names
while (*cp) {
free(*cp++);
}
@ -1054,7 +1054,7 @@ static int CclDefineUnitTypeWcNames(lua_State* l)
}
//
// Get new table.
// Get new table.
//
i = lua_gettop(l);
UnitTypeWcNames = cp = malloc((i + 1) * sizeof(char*));
@ -1140,7 +1140,7 @@ static int CclDefineAnimations(lua_State* l)
++t;
lua_pop(l, 1);
}
t[-1].Flags |= 0x80; // Marks end of list
t[-1].Flags |= 0x80; // Marks end of list
if (!strcmp(id, "still")) {
if (anims->Still) {

File diff suppressed because it is too large Load diff

View file

@ -26,16 +26,16 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// $Id$
// $Id$
//@{
/*----------------------------------------------------------------------------
-- Includes
-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
@ -170,9 +170,9 @@ int UnitCacheSelect(int x1, int y1, int x2, int y2, Unit** table)
listitem = TheMap.Fields[i * TheMap.Width + j].UnitCache;
for (; listitem; listitem = listitem->Next) {
//
// To avoid getting an unit in multiple times we use a cache lock.
// It should only be used in here, unless you somehow want the unit
// to be out of cache.
// To avoid getting an unit in multiple times we use a cache lock.
// It should only be used in here, unless you somehow want the unit
// to be out of cache.
//
if (!listitem->Unit->CacheLock) {
listitem->Unit->CacheLock = 1;
@ -183,7 +183,7 @@ int UnitCacheSelect(int x1, int y1, int x2, int y2, Unit** table)
}
//
// Clean the cache locks, restore to original situation.
// Clean the cache locks, restore to original situation.
//
for (i = 0; i < n; ++i) {
table[i]->CacheLock = 0;
@ -207,8 +207,8 @@ int UnitCacheOnTile(int x, int y, Unit** table)
int n;
//
// Unlike in UnitCacheSelect, there's no way an unit can show up twice,
// so there is no need for Cache Locks.
// Unlike in UnitCacheSelect, there's no way an unit can show up twice,
// so there is no need for Cache Locks.
//
n = 0;
listitem = TheMap.Fields[y * TheMap.Width + x].UnitCache;

View file

@ -78,59 +78,54 @@ static inline max(int a, int b) { return a > b ? a : b; }
/*----------------------------------------------------------------------------
-- Variables
-- Variables
----------------------------------------------------------------------------*/
int ShowHealthBar; /// Flag: show health bar
int ShowHealthDot; /// Flag: show health dot
int ShowManaBar; /// Flag: show mana bar
int ShowManaDot; /// Flag: show mana dot
int ShowNoFull; /// Flag: show no full health or mana
int DecorationOnTop; /// Flag: show health and mana on top
int ShowSightRange; /// Flag: show right range
int ShowReactionRange; /// Flag: show reaction range
int ShowAttackRange; /// Flag: show attack range
int ShowOrders; /// Flag: show orders of unit on map
unsigned long ShowOrdersCount; /// Show orders for some time
/// Flag: health horizontal instead of vertical
int ShowHealthHorizontal;
/// Flag: health horizontal instead of vertical
int ShowManaHorizontal;
/// Flag: show bars and dot energy only for selected
int ShowEnergySelectedOnly;
/// Flag: show the health background long
int ShowHealthBackgroundLong;
/// Flag: show the mana background long
int ShowManaBackgroundLong;
int ShowHealthBar; ///< Flag: show health bar
int ShowHealthDot; ///< Flag: show health dot
int ShowManaBar; ///< Flag: show mana bar
int ShowManaDot; ///< Flag: show mana dot
int ShowNoFull; ///< Flag: show no full health or mana
int DecorationOnTop; ///< Flag: show health and mana on top
int ShowSightRange; ///< Flag: show right range
int ShowReactionRange; ///< Flag: show reaction range
int ShowAttackRange; ///< Flag: show attack range
int ShowOrders; ///< Flag: show orders of unit on map
unsigned long ShowOrdersCount; ///< Show orders for some time
int ShowHealthHorizontal; ///< Flag: health horizontal instead of vertical
int ShowManaHorizontal; ///< Flag: health horizontal instead of vertical
int ShowEnergySelectedOnly; ///< Flag: show bars and dot energy only for selected
int ShowHealthBackgroundLong; ///< Flag: show the health background long
int ShowManaBackgroundLong; ///< Flag: show the mana background long
// FIXME: not all variables of this file are here
// FIXME: perhaps split this file into two or three parts?
/**
** Show that units are selected.
** Show that units are selected.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color FIXME
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void (*DrawSelection)(Uint32 color, int x1, int y1,
int x2, int y2) = DrawSelectionNone;
/*----------------------------------------------------------------------------
-- Functions
-- Functions
----------------------------------------------------------------------------*/
// FIXME: clean split screen support
// FIXME: integrate this with global versions of these functions in map.c
const Viewport* CurrentViewport; /// FIXME: quick hack for split screen
const Viewport* CurrentViewport; ///< FIXME: quick hack for split screen
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/**
** Show selection marker around an unit.
** Show selection marker around an unit.
**
** @param unit Pointer to unit.
** @param unit Pointer to unit.
*/
void DrawUnitSelection(const Unit* unit)
{
@ -169,7 +164,7 @@ void DrawUnitSelection(const Unit* unit)
color = Players[i].Color;
}
}
} else if (CursorBuilding && unit->Type->Building &&
} else if (CursorBuilding && unit->Type->Building &&
(unit->Player == ThisPlayer ||
PlayersTeamed(ThisPlayer->Player, unit->Player->Player))) {
// If building mark all own buildings
@ -188,11 +183,11 @@ void DrawUnitSelection(const Unit* unit)
}
/**
** Don't show selected units.
** Don't show selected units.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionNone(Uint32 color, int x1, int y1,
int x2, int y2)
@ -200,11 +195,11 @@ void DrawSelectionNone(Uint32 color, int x1, int y1,
}
/**
** Show selected units with circle.
** Show selected units with circle.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionCircle(Uint32 color, int x1, int x2,
int y1, int y2)
@ -216,11 +211,11 @@ void DrawSelectionCircle(Uint32 color, int x1, int x2,
}
/**
** Show selected units with circle.
** Show selected units with circle.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionCircleWithTrans(Uint32 color, int x1, int y1,
int x2, int y2)
@ -232,11 +227,11 @@ void DrawSelectionCircleWithTrans(Uint32 color, int x1, int y1,
}
/**
** Draw selected rectangle around the unit.
** Draw selected rectangle around the unit.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionRectangle(Uint32 color, int x1, int y1,
int x2, int y2)
@ -245,11 +240,11 @@ void DrawSelectionRectangle(Uint32 color, int x1, int y1,
}
/**
** Draw selected rectangle around the unit.
** Draw selected rectangle around the unit.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionRectangleWithTrans(Uint32 color, int x1, int y1,
int x2, int y2)
@ -260,11 +255,11 @@ void DrawSelectionRectangleWithTrans(Uint32 color, int x1, int y1,
}
/**
** Draw selected corners around the unit.
** Draw selected corners around the unit.
**
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
** @param color
** @param x1,y1 Coordinates of the top left corner.
** @param x2,y2 Coordinates of the bottom right corner.
*/
void DrawSelectionCorners(Uint32 color, int x1, int y1,
int x2, int y2)
@ -285,17 +280,17 @@ void DrawSelectionCorners(Uint32 color, int x1, int y1,
}
/**
** Decoration: health, mana.
** Decoration: health, mana.
*/
typedef struct _decoration_ {
char* File; /// File containing the graphics data
int HotX; /// X drawing position (relative)
int HotY; /// Y drawing position (relative)
int Width; /// width of the decoration
int Height; /// height of the decoration
char* File; ///< File containing the graphics data
int HotX; ///< X drawing position (relative)
int HotY; ///< Y drawing position (relative)
int Width; ///< width of the decoration
int Height; ///< height of the decoration
// --- FILLED UP ---
Graphic* Sprite; /// loaded sprite images
Graphic* Sprite; ///< loaded sprite images
} Decoration;
/**
@ -751,7 +746,7 @@ static void DrawManaBar(int x, int y, const UnitType* type, int full, int ready)
2, (f * type->BoxHeight) / 100);
} else {
//
// Draw the black rectangle in full size?
// Draw the black rectangle in full size?
//
if (ShowManaBackgroundLong) {
VideoFillRectangleClip(ColorBlack,
@ -797,20 +792,20 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
#ifdef REFS_DEBUG
//
// Show the number of references.
// Show the number of references.
//
VideoDrawNumberClip(x + 1, y + 1, GameFont, unit->Refs);
#endif
//
// Only for selected units?
// Only for selected units?
//
if (ShowEnergySelectedOnly && !unit->Selected) {
return;
}
//
// Health bar on left side of unit.
// Health bar on left side of unit.
//
stats = unit->Stats;
// Why remove the neutral race?
@ -828,7 +823,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
if (ShowHealthHorizontal) {
//
// Draw the black rectangle in full size?
// Draw the black rectangle in full size?
//
if (ShowHealthBackgroundLong) {
#ifdef DEBUG
@ -882,7 +877,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
//
// Health dot on left side of unit.
// Health dot on left side of unit.
// Why skip the neutral units?
//
if ((unit->Player->Type != PlayerNeutral) && ShowHealthDot) {
@ -926,24 +921,24 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
//
// Mana bar on right side of unit. FIXME: combine bar and sprite
// Mana bar on right side of unit. FIXME: combine bar and sprite
//
if (ShowManaBar) {
if (type->CanCastSpell &&
!(ShowNoFull && unit->Mana == unit->Type->_MaxMana)) {
// s0m3body: mana bar should display mana proportionally
// to unit's max mana (unit->Type->_MaxMana)
// to unit's max mana (unit->Type->_MaxMana)
DrawManaBar(x, y, type, unit->Type->_MaxMana, unit->Mana);
} else if (type->GivesResource) {
DrawManaBar(x, y, type, 655350, unit->Value);
}
//
// Show working of units.
// Show working of units.
//
if (unit->Player == ThisPlayer) {
//
// Building under constuction.
// Building under constuction.
//
/*
if (unit->Orders[0].Action == UnitActionBuilded) {
@ -952,7 +947,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
*/
//
// Building training units.
// Building training units.
//
if (unit->Orders[0].Action == UnitActionTrain) {
DrawManaBar(x, y, type, unit->Data.Train.What[0]->Stats[
@ -960,7 +955,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Data.Train.Ticks);
//
// Building upgrading to better type.
// Building upgrading to better type.
//
} else if (unit->Orders[0].Action == UnitActionUpgradeTo) {
DrawManaBar(x, y, type, unit->Orders[0].Type->Stats[
@ -968,8 +963,8 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Data.UpgradeTo.Ticks);
//
// Carry resource.
// Don't display if empty.
// Carry resource.
// Don't display if empty.
//
} else if (unit->Type->Harvester && unit->CurrentResource && unit->Value > 0 &&
!(ShowNoFull && unit->Value == unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity)) {
@ -978,7 +973,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Value);
//
// Building research new technologie.
// Building research new technologie.
//
} else if (unit->Orders[0].Action == UnitActionResearch) {
DrawManaBar(x, y, type,
@ -986,7 +981,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Player->UpgradeTimers.Upgrades[
unit->Data.Research.Upgrade - Upgrades]);
//
// Transporter with units on board.
// Transporter with units on board.
//
} else if (unit->Type->Transporter) {
DrawManaBar(x, y, type, unit->Type->MaxOnBoard, unit->BoardCount);
@ -995,11 +990,11 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
//
// Mana dot on right side of unit.
// Mana dot on right side of unit.
//
if (ShowManaDot) {
// s0m3body: MaxMana can vary for each unit,
// it is stored in unit->Type->_MaxMana
// it is stored in unit->Type->_MaxMana
if (type->CanCastSpell &&
!(ShowNoFull && unit->Mana == unit->Type->_MaxMana)) {
DrawManaSprite(x, y, type,unit->Type->_MaxMana, unit->Mana);
@ -1007,12 +1002,12 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
DrawManaSprite(x, y, type, 655350, unit->Value);
}
//
// Show working of units.
// Show working of units.
//
if (unit->Player == ThisPlayer) {
//
// Building under constuction.
// Building under constuction.
//
/*
if (unit->Orders[0].Action == UnitActionBuilded) {
@ -1021,7 +1016,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
*/
//
// Building training units.
// Building training units.
//
if (unit->Orders[0].Action == UnitActionTrain) {
DrawManaSprite(x, y, type, unit->Data.Train.What[0]->Stats[
@ -1029,7 +1024,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Data.Train.Ticks);
//
// Building upgrading to better type.
// Building upgrading to better type.
//
} else if (unit->Orders[0].Action == UnitActionUpgradeTo) {
DrawManaSprite(x,y,type,unit->Orders[0].Type->Stats[
@ -1037,7 +1032,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Data.UpgradeTo.Ticks);
//
// Carry resource.
// Carry resource.
//
} else if (unit->Type->Harvester && unit->CurrentResource && unit->Value > 0 &&
!(ShowNoFull && unit->Value == unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity)) {
@ -1046,7 +1041,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Value);
//
// Building research new technologie.
// Building research new technologie.
//
} else if (unit->Orders[0].Action == UnitActionResearch) {
DrawManaSprite(x, y, type,
@ -1054,7 +1049,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
unit->Player->UpgradeTimers.Upgrades[
unit->Data.Research.Upgrade-Upgrades]);
//
// Transporter with units on board.
// Transporter with units on board.
//
} else if (unit->Type->Transporter) {
DrawManaSprite(x, y, type, unit->Type->MaxOnBoard, unit->BoardCount);
@ -1063,7 +1058,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
// FIXME: Johns there is 100% a way to remove this calculation from
// runtime.
// runtime.
x1 = x;
y1 = y;
if (SpellSprite.HotX < 0) {
@ -1091,10 +1086,10 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
if (unit->Bloodlust) {
VideoDrawClip(SpellSprite.Sprite, 0, x1, y1);
}
if (unit->Haste) { // same slot as slow
if (unit->Haste) { // same slot as slow
VideoDrawClip(SpellSprite.Sprite, 1, x1 + 16, y1);
}
if (unit->Slow) { // same slot as haste
if (unit->Slow) { // same slot as haste
VideoDrawClip(SpellSprite.Sprite, 2, x1 + 16, y1);
}
if (unit->Invisible) {
@ -1105,7 +1100,7 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
}
//
// Draw group number
// Draw group number
//
if (unit->Selected && unit->GroupId != 0) {
char buf[2];
@ -1264,13 +1259,13 @@ void DrawPath(const Unit* unit)
y2 = unit->Orders[0].Y;
}
if (y1 > y2) { // exchange coordinates
if (y1 > y2) { // exchange coordinates
x1 ^= x2;
x2 ^= x1;
x1 ^= x2;
y1 ^= y2;
y2 ^= y1;
y1 ^= y2; // NOTE: ^= swap(x1,x2), swap(y1,y2)
y1 ^= y2; // NOTE: ^= swap(x1,x2), swap(y1,y2)
}
dy = y2 - y1;
dx = x2 - x1;
@ -1281,7 +1276,7 @@ void DrawPath(const Unit* unit)
xstep = 1;
}
if (dy == 0) { // horizontal line
if (dy == 0) { // horizontal line
if (dx == 0) {
return;
}
@ -1298,7 +1293,7 @@ void DrawPath(const Unit* unit)
return;
}
if (dx == 0) { // vertical line
if (dx == 0) { // vertical line
// CLIPPING
VideoDrawRectangleClip(ColorGray,
Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
@ -1316,7 +1311,7 @@ void DrawPath(const Unit* unit)
Map2ViewportX(CurrentViewport, x1) + TileSizeX / 2 - 3,
Map2ViewportY(CurrentViewport, y1) + TileSizeY / 2 - 3, 6, 6);
if (dx < dy) { // step in vertical direction
if (dx < dy) { // step in vertical direction
d = dy - 1;
dx += dx;
dy += dy;
@ -1334,7 +1329,7 @@ void DrawPath(const Unit* unit)
return;
}
if (dx > dy) { // step in horizontal direction
if (dx > dy) { // step in horizontal direction
d = dx - 1;
dx += dx;
dy += dy;
@ -1460,7 +1455,7 @@ static void ShowSingleOrder(const Unit* unit, int x1, int y1, const Order* order
y2 = Map2ViewportY(CurrentViewport, order->Y) + TileSizeY / 2;
// FALL THROUGH
case UnitActionAttack:
if (unit->SubAction & 2) { // Show weak targets.
if (unit->SubAction & 2) { // Show weak targets.
e_color = ColorBlue;
} else {
e_color = ColorRed;
@ -1595,7 +1590,7 @@ static void DrawInformations(const Unit* unit, const UnitType* type, int x, int
stats = unit->Stats;
//
// For debug draw sight, react and attack range!
// For debug draw sight, react and attack range!
//
if (NumSelected == 1 && unit->Selected) {
if (ShowSightRange) {
@ -1736,8 +1731,8 @@ static void DrawConstructionShadow(const Unit* unit, int frame, int x, int y)
if (unit->Type->Construction->ShadowSprite) {
x -= (unit->Type->Construction->Width - unit->Type->TileWidth * TileSizeX) / 2;
y -= (unit->Type->Construction->Height - unit->Type->TileHeight * TileSizeY )/ 2;
// x += type->ShadowOffsetX;
// y += type->ShadowOffsetY;
// x += type->ShadowOffsetX;
// y += type->ShadowOffsetY;
if (unit->Type->Flip) {
if (frame < 0) {
VideoDrawClipX(unit->Type->Construction->ShadowSprite,
@ -1846,8 +1841,8 @@ void DrawUnit(const Unit* unit)
ResourceInfo* resinfo;
ConstructionFrame* cframe;
UnitType* type;
if (unit->Type->Revealer) { // Revealers are not drawn
if (unit->Type->Revealer) { // Revealers are not drawn
return;
}
@ -1900,14 +1895,14 @@ void DrawUnit(const Unit* unit)
}
//
// Show that the unit is selected
// Show that the unit is selected
//
DrawUnitSelection(unit);
GraphicUnitPixels(unit, type->Sprite);
//
// Adjust sprite for Harvesters.
// Adjust sprite for Harvesters.
//
sprite = type->Sprite;
#ifdef USE_OPENGL
@ -1935,8 +1930,8 @@ void DrawUnit(const Unit* unit)
}
//
// Now draw!
// Buildings under construction/upgrade/ready.
// Now draw!
// Buildings under construction/upgrade/ready.
//
if (state == 1) {
if (constructed) {
@ -1945,7 +1940,7 @@ void DrawUnit(const Unit* unit)
y + (type->TileHeight * TileSizeY) / 2);
}
//
// Draw the future unit type, if upgrading to it.
// Draw the future unit type, if upgrading to it.
//
} else if (state == 2) {
// FIXME: this frame is hardcoded!!!

View file

@ -5,12 +5,12 @@
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// 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 unit_find.c - The find/select for units. */
/**@name unit_find.c - The find/select for units. */
//
// (c) Copyright 1998-2003 by Lutz Sammer and Jimmy Salmon
// (c) Copyright 1998-2003 by Lutz Sammer and Jimmy Salmon
//
// 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
@ -26,12 +26,12 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// $Id$
// $Id$
//@{
/*----------------------------------------------------------------------------
-- Includes
-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
@ -54,35 +54,35 @@
#include "pathfinder.h"
/*----------------------------------------------------------------------------
-- Defines
-- Defines
----------------------------------------------------------------------------*/
/*
** Configuration of the small (unit) AI.
** Configuration of the small (unit) AI.
*/
#define PRIORITY_FACTOR 0x00010000
#define HEALTH_FACTOR 0x00000001
#define DISTANCE_FACTOR 0x00100000
#define INRANGE_FACTOR 0x00010000
#define INRANGE_BONUS 0x01000000
#define CANATTACK_BONUS 0x00100000
#define PRIORITY_FACTOR 0x00010000
#define HEALTH_FACTOR 0x00000001
#define DISTANCE_FACTOR 0x00100000
#define INRANGE_FACTOR 0x00010000
#define INRANGE_BONUS 0x01000000
#define CANATTACK_BONUS 0x00100000
/*----------------------------------------------------------------------------
-- Local Data
-- Local Data
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Functions
-- Functions
----------------------------------------------------------------------------*/
/**
** Select unit on X,Y of type naval,fly,land.
** Select unit on X,Y of type naval,fly,land.
**
** @param x Map X tile position.
** @param y Map Y tile position.
** @param type UnitType::UnitType, naval,fly,land.
** @param x Map X tile position.
** @param y Map Y tile position.
** @param type UnitType::UnitType, naval,fly,land.
**
** @return Unit, if an unit of correct type is on the field.
** @return Unit, if an unit of correct type is on the field.
*/
Unit* UnitCacheOnXY(int x, int y, unsigned type)
{
@ -103,12 +103,12 @@ Unit* UnitCacheOnXY(int x, int y, unsigned type)
}
/**
** Find all units of type.
** Find all units of type.
**
** @param type type of unit requested
** @param table table in which we have to store the units
** @param type type of unit requested
** @param table table in which we have to store the units
**
** @return Returns the number of units found.
** @return Returns the number of units found.
*/
int FindUnitsByType(const UnitType* type, Unit** table)
{
@ -126,13 +126,13 @@ int FindUnitsByType(const UnitType* type, Unit** table)
}
/**
** Find all units of type.
** Find all units of type.
**
** @param player we're looking for the units of this player
** @param type type of unit requested
** @param table table in which we have to store the units
** @param player we're looking for the units of this player
** @param type type of unit requested
** @param table table in which we have to store the units
**
** @return Returns the number of units found.
** @return Returns the number of units found.
*/
int FindPlayerUnitsByType(const Player* player,const UnitType* type,
Unit** table)
@ -160,12 +160,12 @@ int FindPlayerUnitsByType(const Player* player,const UnitType* type,
}
/**
** Unit on map tile, no special prefered.
** Unit on map tile, no special prefered.
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
**
** @return Returns first found unit on tile.
** @return Returns first found unit on tile.
*/
Unit* UnitOnMapTile(int tx, int ty)
{
@ -187,12 +187,12 @@ Unit* UnitOnMapTile(int tx, int ty)
}
/**
** Repairable unit on map tile.
** Repairable unit on map tile.
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
**
** @return Returns repairable unit found on tile.
** @return Returns repairable unit found on tile.
*/
Unit* RepairableOnMapTile(int tx, int ty)
{
@ -211,13 +211,13 @@ Unit* RepairableOnMapTile(int tx, int ty)
}
/**
** Choose targe on a map
** Choose targe on a map
**
** @param source Unit which wants to attack.
** @param tx X position to attack.
** @param ty Y position to attack.
** @param source Unit which wants to attack.
** @param tx X position to attack.
** @param ty Y position to attack.
**
** @return Returns ideal target on map tile.
** @return Returns ideal target on map tile.
*/
Unit* TargetOnMapTile(const Unit* source, int tx, int ty)
{
@ -246,7 +246,7 @@ Unit* TargetOnMapTile(const Unit* source, int tx, int ty)
continue;
}
//
// Choose the best target.
// Choose the best target.
//
if (!best || best->Type->Priority < unit->Type->Priority) {
best = unit;
@ -256,15 +256,15 @@ Unit* TargetOnMapTile(const Unit* source, int tx, int ty)
}
/**
** Choose target on map area.
** Choose target on map area.
**
** @param source Unit which want to attack.
** @param x1 X position on map, tile-based.
** @param y1 Y position on map, tile-based.
** @param x2 X position on map, tile-based.
** @param y2 Y position on map, tile-based.
** @param source Unit which want to attack.
** @param x1 X position on map, tile-based.
** @param y1 Y position on map, tile-based.
** @param x2 X position on map, tile-based.
** @param y2 Y position on map, tile-based.
**
** @return Returns ideal target on map tile.
** @return Returns ideal target on map tile.
*/
Unit* TargetOnMap(const Unit* source, int x1, int y1, int x2, int y2)
{
@ -292,7 +292,7 @@ Unit* TargetOnMap(const Unit* source, int x1, int y1, int x2, int y2)
}
//
// Choose the best target.
// Choose the best target.
//
if (!best || best->Type->Priority < unit->Type->Priority) {
best = unit;
@ -302,12 +302,12 @@ Unit* TargetOnMap(const Unit* source, int x1, int y1, int x2, int y2)
}
/**
** Transporter unit on map tile.
** Transporter unit on map tile.
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
**
** @return Returns transporter unit found on tile.
** @return Returns transporter unit found on tile.
*/
Unit* TransporterOnMapTile(int tx, int ty)
{
@ -326,19 +326,19 @@ Unit* TransporterOnMapTile(int tx, int ty)
#if 0
/**
** Returns true if screen map position (x,y) is inside of
** the rectangle where the unit's sprite is drawn.
** Returns true if screen map position (x,y) is inside of
** the rectangle where the unit's sprite is drawn.
**
** @param unit Pointer to unit whose sprite is to be tested
** @param x X position on screen map, pixel-based
** @param y Y position on screen map, pixel-based
** @param unit Pointer to unit whose sprite is to be tested
** @param x X position on screen map, pixel-based
** @param y Y position on screen map, pixel-based
**
** @return true if (x,y) is inside the unit's sprite
** @return true if (x,y) is inside the unit's sprite
*/
static int InsideUnitSprite(const Unit* unit, int x, int y)
{
int ux;
int uy; // position at which unit's sprite is currently drawn
int uy; // position at which unit's sprite is currently drawn
const UnitType* type;
type = unit->Type;
@ -357,17 +357,17 @@ static int InsideUnitSprite(const Unit* unit, int x, int y)
#endif
/*----------------------------------------------------------------------------
-- Finding special units
-- Finding special units
----------------------------------------------------------------------------*/
/**
** Find a unit on a map tile with a specific type
** Find a unit on a map tile with a specific type
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param type Unit Type to Find
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param type Unit Type to Find
**
** @return Returns the unit if found, or NoUnitP.
** @return Returns the unit if found, or NoUnitP.
*/
Unit* UnitTypeOnMap(int tx, int ty, UnitType* type)
{
@ -385,13 +385,13 @@ Unit* UnitTypeOnMap(int tx, int ty, UnitType* type)
}
/**
** Resource on map tile
** Resource on map tile
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param resource resource type.
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param resource resource type.
**
** @return Returns the deposit if found, or NoUnitP.
** @return Returns the deposit if found, or NoUnitP.
*/
Unit* ResourceOnMap(int tx, int ty, int resource)
{
@ -413,13 +413,13 @@ Unit* ResourceOnMap(int tx, int ty, int resource)
}
/**
** Resource deposit on map tile
** Resource deposit on map tile
**
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param resource resource type.
** @param tx X position on map, tile-based.
** @param ty Y position on map, tile-based.
** @param resource resource type.
**
** @return Returns the deposit if found, or NoUnitP.
** @return Returns the deposit if found, or NoUnitP.
*/
Unit* ResourceDepositOnMap(int tx, int ty, int resource)
{
@ -440,23 +440,23 @@ Unit* ResourceDepositOnMap(int tx, int ty, int resource)
}
/*----------------------------------------------------------------------------
-- Finding units for attack
-- Finding units for attack
----------------------------------------------------------------------------*/
/**
** Attack units in distance, with large missile
** Attack units in distance, with large missile
**
** Choose the best target, that can be attacked. It takes into
** account allied unit which could be hit by the missile
** Choose the best target, that can be attacked. It takes into
** account allied unit which could be hit by the missile
**
** @param u Find in distance for this unit.
** @param range Distance range to look.
** @param u Find in distance for this unit.
** @param range Distance range to look.
**
** @return Unit to be attacked.
** @return Unit to be attacked.
**
** @note This could be improved, for better performance / better trade.
** @note Limited to attack range smaller than 16.
** @note Will be moved to unit_ai.c soon.
** @note This could be improved, for better performance / better trade.
** @note Limited to attack range smaller than 16.
** @note Will be moved to unit_ai.c soon.
*/
static Unit* FindRangeAttack(Unit* u, int range)
{
@ -491,7 +491,7 @@ static Unit* FindRangeAttack(Unit* u, int range)
player = u->Player;
// If catapult, count units near the target...
// FIXME : make it configurable
// FIXME : make it configurable
//
missile_range = type->Missile.Missile->Range + range - 1;
@ -507,13 +507,13 @@ static Unit* FindRangeAttack(Unit* u, int range)
x = u->Container->X;
y = u->Container->Y;
n = UnitCacheSelect(x - missile_range, y - missile_range,
x + missile_range + u->Container->Type->TileWidth,
x + missile_range + u->Container->Type->TileWidth,
y + missile_range + u->Container->Type->TileHeight, table);
} else {
x = u->X;
y = u->Y;
n = UnitCacheSelect(x - missile_range, y - missile_range,
x + missile_range + u->Type->TileWidth,
x + missile_range + u->Type->TileWidth,
y + missile_range + u->Type->TileHeight, table);
}
@ -539,12 +539,12 @@ static Unit* FindRangeAttack(Unit* u, int range)
}
// won't be a target...
if (!CanTarget(type, dtype)) { // can't be attacked.
if (!CanTarget(type, dtype)) { // can't be attacked.
table[i] = 0;
continue;
}
if (!IsEnemy(player, dest)) { // a friend or neutral
if (!IsEnemy(player, dest)) { // a friend or neutral
table[i] = 0;
// Calc a negative cost
@ -685,7 +685,7 @@ static Unit* FindRangeAttack(Unit* u, int range)
y = u->Y;
}
// Make x,y relative to u->x...
// Make x,y relative to u->x...
x = x - u->X + missile_range + 1;
y = y - u->Y + missile_range + 1;
@ -725,15 +725,15 @@ static Unit* FindRangeAttack(Unit* u, int range)
}
/**
** Attack units in distance.
** Attack units in distance.
**
** If the unit can attack must be handled by caller.
** Choose the best target, that can be attacked.
** If the unit can attack must be handled by caller.
** Choose the best target, that can be attacked.
**
** @param unit Find in distance for this unit.
** @param range Distance range to look.
** @param unit Find in distance for this unit.
** @param range Distance range to look.
**
** @return Unit to be attacked.
** @return Unit to be attacked.
**
*/
Unit* AttackUnitsInDistance(Unit* unit, int range)
@ -760,7 +760,7 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
}
//
// Select all units in range.
// Select all units in range.
//
x = unit->X;
y = unit->Y;
@ -775,7 +775,7 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
attackrange = unit->Stats->AttackRange;
//
// Find the best unit to attack
// Find the best unit to attack
//
for (i = 0; i < n; ++i) {
@ -785,30 +785,30 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
continue;
}
if (!IsEnemy(player, dest)) { // a friend or neutral
if (!IsEnemy(player, dest)) { // a friend or neutral
continue;
}
dtype = dest->Type;
if (!CanTarget(type, dtype)) { // can't be attacked.
if (!CanTarget(type, dtype)) { // can't be attacked.
continue;
}
//
// Calculate the costs to attack the unit.
// Unit with the smallest attack costs will be taken.
// Calculate the costs to attack the unit.
// Unit with the smallest attack costs will be taken.
//
cost = 0;
//
// Priority 0-255
// Priority 0-255
//
cost -= dtype->Priority * PRIORITY_FACTOR;
//
// Remaining HP (Health) 0-65535
// Remaining HP (Health) 0-65535
//
cost += dest->HP * HEALTH_FACTOR;
//
// Unit in attack range?
// Unit in attack range?
//
d = MapDistanceBetweenUnits(unit, dest);
@ -823,14 +823,14 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
cost += d * DISTANCE_FACTOR;
}
//
// Unit can attack back.
// Unit can attack back.
//
if (CanTarget(dtype, type)) {
cost -= CANATTACK_BONUS;
}
//
// Take this target?
// Take this target?
//
if (cost < best_cost && (d < attackrange ||
UnitReachable(unit, dest, attackrange))) {
@ -843,16 +843,16 @@ Unit* AttackUnitsInDistance(Unit* unit, int range)
}
/**
** Attack units in attack range.
** Attack units in attack range.
**
** @param unit Find unit in attack range for this unit.
** @param unit Find unit in attack range for this unit.
**
** @return Pointer to unit which should be attacked.
** @return Pointer to unit which should be attacked.
*/
Unit* AttackUnitsInRange(Unit* unit)
{
//
// Only units which can attack.
// Only units which can attack.
//
#ifdef DEBUG
if (!unit->Type->CanAttack) {
@ -866,11 +866,11 @@ Unit* AttackUnitsInRange(Unit* unit)
}
/**
** Attack units in reaction range.
** Attack units in reaction range.
**
** @param unit Find unit in reaction range for this unit.
** @param unit Find unit in reaction range for this unit.
**
** @return Pointer to unit which should be attacked.
** @return Pointer to unit which should be attacked.
*/
Unit* AttackUnitsInReactRange(Unit* unit)
{
@ -878,7 +878,7 @@ Unit* AttackUnitsInReactRange(Unit* unit)
const UnitType* type;
//
// Only units which can attack.
// Only units which can attack.
//
type = unit->Type;
#ifdef DEBUG

View file

@ -66,19 +66,19 @@
const char UnitTypeType[] = "unit-type";
#ifdef DEBUG
int NoWarningUnitType; /// quiet ident lookup
int NoWarningUnitType; ///< quiet ident lookup
#endif
UnitType* UnitTypes[UnitTypeMax]; /// unit-types definition
int NumUnitTypes; /// number of unit-types made
UnitType* UnitTypes[UnitTypeMax]; ///< unit-types definition
int NumUnitTypes; ///< number of unit-types made
/*
/**
** Next unit type are used hardcoded in the source.
**
** @todo find a way to make it configurable!
*/
UnitType* UnitTypeHumanWall; /// Human wall
UnitType* UnitTypeOrcWall; /// Orc wall
UnitType* UnitTypeHumanWall; ///< Human wall
UnitType* UnitTypeOrcWall; ///< Orc wall
/**
** Mapping of W*rCr*ft number to our internal unit-type symbol.
@ -308,9 +308,9 @@ void ParsePudUDTA(const char* udta, int length __attribute__((unused)))
unittype->_HitPoints = v;
}
for (i = 0; i < 110; ++i) { // Flag if unit is magic
// unittype = UnitTypeByWcNum(i);
// v = Fetch8(udta);
// unittype->Magic = v;
// unittype = UnitTypeByWcNum(i);
// v = Fetch8(udta);
// unittype->Magic = v;
++udta;
}
for (i = 0; i < 110; ++i) { // Build time * 6 = one second FRAMES
@ -485,16 +485,16 @@ void ParsePudUDTA(const char* udta, int length __attribute__((unused)))
unittype->CanStore[GoldCost] = BIT(12, v);
unittype->Vanishes = BIT(13, v);
unittype->GroundAttack = BIT(14, v);
// No idea on what do about commented stuff.
// unittype->IsUndead = BIT(15, v);
// No idea on what do about commented stuff.
// unittype->IsUndead = BIT(15, v);
unittype->ShoreBuilding = BIT(16, v);
// unittype->CanCastSpell = BIT(17,v);
// unittype->CanCastSpell = BIT(17,v);
unittype->CanStore[WoodCost] = BIT(18, v);
unittype->CanAttack = BIT(19, v);
// unittype->Hero = BIT(23, v);
// unittype->Hero = BIT(23, v);
unittype->CanStore[OilCost] = BIT(24, v);
// unittype->Volatile = BIT(25, v);
// unittype->Organic = BIT(27, v);
// unittype->Volatile = BIT(25, v);
// unittype->Organic = BIT(27, v);
if (BIT(11, v) || BIT(21, v)) {
unittype->GivesResource = OilCost;
@ -583,7 +583,7 @@ void SaveUnitTypes(CLFile* file)
{
int i;
int j;
// char** sp;
// char** sp;
CLprintf(file, "\n--- -----------------------------------------\n");
CLprintf(file, "--- MODULE: unittypes $Id$\n\n");

View file

@ -70,20 +70,20 @@ static void AllowUpgradeId(Player* player, int id, char af);
*/
const char UpgradeType[] = "upgrade";
Upgrade Upgrades[UpgradeMax]; /// The main user useable upgrades
static int NumUpgrades; /// Number of upgrades used
Upgrade Upgrades[UpgradeMax]; ///< The main user useable upgrades
static int NumUpgrades; ///< Number of upgrades used
/// How many upgrades modifiers supported
#define UPGRADE_MODIFIERS_MAX (UpgradeMax * 4)
#define UPGRADE_MODIFIERS_MAX (UpgradeMax * 4)
/// Upgrades modifiers
static UpgradeModifier* UpgradeModifiers[UPGRADE_MODIFIERS_MAX];
/// Number of upgrades modifiers used
static int NumUpgradeModifiers;
#ifdef DOXYGEN // no real code, only for documentation
static Upgrade* UpgradeHash[61]; /// lookup table for upgrade names
static Upgrade* UpgradeHash[61]; ///< lookup table for upgrade names
#else
static hashtable(Upgrade*, 61) UpgradeHash; /// lookup table for upgrade names
static hashtable(Upgrade*, 61) UpgradeHash; ///< lookup table for upgrade names
#endif
/**
@ -233,120 +233,120 @@ void CleanUpgrades(void)
}
/**
** Parse ALOW area from puds.
** Parse ALOW area from puds.
**
** @param alow Pointer to alow area.
** @param length length of alow area.
** @param alow Pointer to alow area.
** @param length length of alow area.
**
** @note Only included for compatibility, for new levels use
** CCL (define-allow)
** @note Only included for compatibility, for new levels use
** CCL (define-allow)
*/
void ParsePudALOW(const char* alow, int length __attribute__((unused)))
{
// units allow bits -> wc2num -> internal names.
static char unit_for_bit[64] = {
0, 1, // unit-footman unit-grunt
2, 3, // unit-peasant unit-peon
4, 5, // unit-ballista unit-catapult
6, 7, // unit-knight unit-ogre
8, 9, // unit-archer unit-axethrower
10, 11, // unit-mage unit-death-knight
26, 27, // unit-human-oil-tanker unit-orc-oil-tanker
30, 31, // unit-elven-destroyer unit-troll-destroyer
28, 29, // unit-human-transport unit-orc-transport
32, 33, // unit-battleship unit-ogre-juggernaught
38, 39, // unit-gnomish-submarine unit-giant-turtle
40, 41, // unit-gnomish-flying-machine unit-goblin-zeppelin
42, 43, // unit-gryphon-rider unit-dragon
-1, -1, // unused
14, 15, // unit-dwarves unit-goblin-sappers
70, 71, // unit-gryphon-aviary unit-dragon-roost
58, 59, // unit-farm unit-pig-farm
60, 61, // unit-human-barracks unit-orc-barracks
76, 77, // unit-elven-lumber-mill unit-troll-lumber-mill
66, 67, // unit-stables unit-ogre-mound
80, 81, // unit-mage-tower unit-temple-of-the-damned
78, 79, // unit-human-foundry unit-orc-foundry
84, 85, // unit-human-refinery unit-orc-refinery
68, 69, // unit-gnomish-inventor unit-goblin-alchemist
62, 63, // unit-church unit-altar-of-storms
64, 65, // unit-human-watch-tower unit-orc-watch-tower
74, 75, // unit-town-hall unit-great-hall
88, 89, // unit-keep unit-stronghold
90, 91, // unit-castle unit-fortress
82, 83, // unit-human-blacksmith unit-orc-blacksmith
72, 73, // unit-human-shipyard unit-orc-shipyard
103,104,// unit-human-wall unit-orc-wall
0, 1, // unit-footman unit-grunt
2, 3, // unit-peasant unit-peon
4, 5, // unit-ballista unit-catapult
6, 7, // unit-knight unit-ogre
8, 9, // unit-archer unit-axethrower
10, 11, // unit-mage unit-death-knight
26, 27, // unit-human-oil-tanker unit-orc-oil-tanker
30, 31, // unit-elven-destroyer unit-troll-destroyer
28, 29, // unit-human-transport unit-orc-transport
32, 33, // unit-battleship unit-ogre-juggernaught
38, 39, // unit-gnomish-submarine unit-giant-turtle
40, 41, // unit-gnomish-flying-machine unit-goblin-zeppelin
42, 43, // unit-gryphon-rider unit-dragon
-1, -1, // unused
14, 15, // unit-dwarves unit-goblin-sappers
70, 71, // unit-gryphon-aviary unit-dragon-roost
58, 59, // unit-farm unit-pig-farm
60, 61, // unit-human-barracks unit-orc-barracks
76, 77, // unit-elven-lumber-mill unit-troll-lumber-mill
66, 67, // unit-stables unit-ogre-mound
80, 81, // unit-mage-tower unit-temple-of-the-damned
78, 79, // unit-human-foundry unit-orc-foundry
84, 85, // unit-human-refinery unit-orc-refinery
68, 69, // unit-gnomish-inventor unit-goblin-alchemist
62, 63, // unit-church unit-altar-of-storms
64, 65, // unit-human-watch-tower unit-orc-watch-tower
74, 75, // unit-town-hall unit-great-hall
88, 89, // unit-keep unit-stronghold
90, 91, // unit-castle unit-fortress
82, 83, // unit-human-blacksmith unit-orc-blacksmith
72, 73, // unit-human-shipyard unit-orc-shipyard
103,104,// unit-human-wall unit-orc-wall
};
// spells allow bits -> wc2num -> internal names.
static char spell_for_bit[32] = {
34, // upgrade-holy-vision
35, // upgrade-healing
-1, // not used
36, // upgrade-exorcism
37, // upgrade-flame-shield
38, // upgrade-fireball
39, // upgrade-slow
40, // upgrade-invisibility
41, // upgrade-polymorph
42, // upgrade-blizzard
43, // upgrade-eye-of-kilrogg
44, // upgrade-bloodlust
-1, // not used
45, // upgrade-raise-dead
46, // upgrade-death-coil
47, // upgrade-whirlwind
48, // upgrade-haste
49, // upgrade-unholy-armor
50, // upgrade-runes
51, // upgrade-death-and-decay
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
34, // upgrade-holy-vision
35, // upgrade-healing
-1, // not used
36, // upgrade-exorcism
37, // upgrade-flame-shield
38, // upgrade-fireball
39, // upgrade-slow
40, // upgrade-invisibility
41, // upgrade-polymorph
42, // upgrade-blizzard
43, // upgrade-eye-of-kilrogg
44, // upgrade-bloodlust
-1, // not used
45, // upgrade-raise-dead
46, // upgrade-death-coil
47, // upgrade-whirlwind
48, // upgrade-haste
49, // upgrade-unholy-armor
50, // upgrade-runes
51, // upgrade-death-and-decay
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
-1, // not used
};
// upgrades allow bits -> wc2num -> internal names.
static char upgrade_for_bit[64] = {
4, 6, // upgrade-arrow1 upgrade-throwing-axe1
5, 7, // upgrade-arrow2 upgrade-throwing-axe2
0, 2, // upgrade-sword1 upgrade-battle-axe1
1, 3, // upgrade-sword2 upgrade-battle-axe2
8,10, // upgrade-human-shield1 upgrade-orc-shield1
9,11, // upgrade-human-shield2 upgrade-orc-shield2
12,14, // upgrade-human-ship-cannon1 upgrade-orc-ship-cannon1
13,15, // upgrade-human-ship-cannon2 upgrade-orc-ship-cannon2
16,18, // upgrade-human-ship-armor1 upgrade-orc-ship-armor1
17,19, // upgrade-human-ship-armor2 upgrade-orc-ship-armor2
-1,-1, // unused
-1,-1, // unused
20,22, // upgrade-catapult1 upgrade-ballista1
21,23, // upgrade-catapult2 upgrade-ballista2
-1,-1, // unused
-1,-1, // unused
24,28, // upgrade-ranger upgrade-berserker
25,29, // upgrade-longbow upgrade-light-axes
26,30, // upgrade-ranger-scouting upgrade-berserker-scouting
27,31, // upgrade-ranger-marksmanship upgrade-berserker-regeneration
33,32, // upgrade-paladin upgrade-ogre-mage
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
4, 6, // upgrade-arrow1 upgrade-throwing-axe1
5, 7, // upgrade-arrow2 upgrade-throwing-axe2
0, 2, // upgrade-sword1 upgrade-battle-axe1
1, 3, // upgrade-sword2 upgrade-battle-axe2
8,10, // upgrade-human-shield1 upgrade-orc-shield1
9,11, // upgrade-human-shield2 upgrade-orc-shield2
12,14, // upgrade-human-ship-cannon1 upgrade-orc-ship-cannon1
13,15, // upgrade-human-ship-cannon2 upgrade-orc-ship-cannon2
16,18, // upgrade-human-ship-armor1 upgrade-orc-ship-armor1
17,19, // upgrade-human-ship-armor2 upgrade-orc-ship-armor2
-1,-1, // unused
-1,-1, // unused
20,22, // upgrade-catapult1 upgrade-ballista1
21,23, // upgrade-catapult2 upgrade-ballista2
-1,-1, // unused
-1,-1, // unused
24,28, // upgrade-ranger upgrade-berserker
25,29, // upgrade-longbow upgrade-light-axes
26,30, // upgrade-ranger-scouting upgrade-berserker-scouting
27,31, // upgrade-ranger-marksmanship upgrade-berserker-regeneration
33,32, // upgrade-paladin upgrade-ogre-mage
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
-1,-1, // unused
};
int i;
int b;
@ -355,10 +355,10 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
DebugPrint(" Length %d FIXME: constant must be moved to ccl\n" _C_ length);
//
// Allow units
// Allow units
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) { // 4 bytes endian save
for (i = 0; i < 4; ++i) { // 4 bytes endian save
int v;
v = (*alow++) & 0xFF;
@ -385,7 +385,7 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
//
// Spells start with
// Spells start with
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) {
@ -407,7 +407,7 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
//
// Spells allowed
// Spells allowed
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) {
@ -427,8 +427,8 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
//
// Spells researching
// FIXME: not useful.
// Spells researching
// FIXME: not useful.
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) {
@ -448,7 +448,7 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
//
// Upgrades allowed
// Upgrades allowed
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) {
@ -471,7 +471,7 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
//
// Upgrades acquired
// Upgrades acquired
//
for (player = Players; player < Players + 16; ++player) {
for (i = 0; i < 4; ++i) {
@ -495,10 +495,10 @@ void ParsePudALOW(const char* alow, int length __attribute__((unused)))
}
/**
** Parse UGRD area from puds.
** Parse UGRD area from puds.
**
** @param ugrd Pointer to ugrd area.
** @param length length of ugrd area.
** @param ugrd Pointer to ugrd area.
** @param length length of ugrd area.
*/
void ParsePudUGRD(const char* ugrd, int length __attribute__((unused)))
{
@ -516,12 +516,12 @@ void ParsePudUGRD(const char* ugrd, int length __attribute__((unused)))
for (i = 0; i < 52; ++i) {
time = ((unsigned char*)ugrd)[i];
gold = AccessLE16( ugrd + 52 + (i) * 2);
lumber = AccessLE16( ugrd + 52 + (i + 52) * 2);
oil = AccessLE16( ugrd + 52 + (i + 52 + 52) * 2);
icon = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52) * 2);
group = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52 + 52) * 2);
flags = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52 + 52 + 52) * 2);
gold = AccessLE16(ugrd + 52 + (i) * 2);
lumber = AccessLE16(ugrd + 52 + (i + 52) * 2);
oil = AccessLE16(ugrd + 52 + (i + 52 + 52) * 2);
icon = AccessLE16(ugrd + 52 + (i + 52 + 52 + 52) * 2);
group = AccessLE16(ugrd + 52 + (i + 52 + 52 + 52 + 52) * 2);
flags = AccessLE16(ugrd + 52 + (i + 52 + 52 + 52 + 52 + 52) * 2);
memset(costs, 0, sizeof(costs));
costs[TimeCost] = time;
@ -983,8 +983,8 @@ static int AddUpgradeModifierBase(int uid, int attack_range, int sight_range,
#if 0
/**
** returns upgrade modifier id or -1 for error (actually this id is
** useless, just error checking)
** returns upgrade modifier id or -1 for error (actually this id is
** useless, just error checking)
*/
static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
int basic_damage, int piercing_damage, int armor, int speed,
@ -992,7 +992,7 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
const int units[UnitTypeMax],
// following are comma separated list of required string id's
const char* af_upgrades,
const char* apply_to // "unit-peon,unit-peasant"
const char* apply_to // "unit-peon,unit-peasant"
)
{
char* s1;
@ -1026,7 +1026,7 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
memcpy(um->ChangeUnits, units, sizeof(um->ChangeUnits));
memset(um->ChangeUpgrades, '?', sizeof(um->ChangeUpgrades));
memset(um->ApplyTo, '?', sizeof(um->ApplyTo));
memset(um->ApplyTo, '?', sizeof(um->ApplyTo));
//
// get allow/forbid's for upgrades
@ -1039,7 +1039,7 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
Assert(s2[1] == ':');
id = UpgradeIdByIdent(s2 + 2);
if (id == -1) {
continue; // should we cancel all and return error?!
continue; // should we cancel all and return error?!
}
um->ChangeUpgrades[id] = s2[0];
}
@ -1055,9 +1055,9 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
id = UnitTypeIdByIdent(s2);
if (id == -1) {
break; // cade: should we cancel all and return error?!
break; // cade: should we cancel all and return error?!
}
um->ApplyTo[id] = 'X'; // something other than '?'
um->ApplyTo[id] = 'X'; // something other than '?'
}
free(s1);
@ -1069,7 +1069,7 @@ static int AddUpgradeModifier(int uid, int attack_range, int sight_range,
#endif
/*----------------------------------------------------------------------------
-- General/Map functions
-- General/Map functions
----------------------------------------------------------------------------*/
// AllowStruct and UpgradeTimers will be static in the player so will be
@ -1111,7 +1111,7 @@ int UpgradeIdByIdent(const char* ident)
}
/*----------------------------------------------------------------------------
-- Upgrades
-- Upgrades
----------------------------------------------------------------------------*/
/**