Gcc Warnings

fixed a lot of gcc warnings while also extending the warnings flags
removed unused variables
fixed use of unitialized variables at a few places (e.g. graphic.cpp - j isn't initialized)
This commit is contained in:
Pali Rohár 2010-09-20 15:18:02 +02:00
parent b3097da7eb
commit d4ac7b3c5f
49 changed files with 357 additions and 379 deletions

View file

@ -21,7 +21,7 @@ PREFIX=@PREFIX@
PKGDATADIR=@PKGDATADIR@
CPPFLAGS=@DEFS@ @CPPFLAGS@ -DUSE_ZLIB -I$(TOPDIR) -I$(TOPDIR)/src/include -I$(TOPDIR)/src/guichan/include -DSTRATAGUS_LIB_PATH="\"@PKGDATADIR@\""
CPPFLAGS=@DEFS@ @CPPFLAGS@ -DUSE_ZLIB -I$(TOPDIR) -I$(TOPDIR)/src/include -I$(TOPDIR)/src/guichan/include -DSTRATAGUS_LIB_PATH="\"@PKGDATADIR@\"" -Wextra -Wno-long-long -pedantic
CXXFLAGS=@CXXFLAGS@
LDFLAGS=@LDFLAGS@ -lpng -lz -lm

View file

@ -146,15 +146,13 @@ static int CheckForTargetInRange(CUnit *unit)
}
COrderPtr order = unit->CurrentOrder();
int wall;
//
// No goal: if meeting enemy attack it.
//
wall = 0;
if (!order->HasGoal() &&
if (!order->HasGoal() &&
order->Action != UnitActionAttackGround &&
!(wall = Map.WallOnMap(order->X, order->Y))) {
!Map.WallOnMap(order->X, order->Y)) {
CUnit *goal = AttackUnitsInReactRange(unit);
if (goal) {
#ifdef DEBUG
@ -299,7 +297,7 @@ static void AttackTarget(CUnit *unit)
{
Assert(unit);
Assert(unit->CurrentOrder()->HasGoal() ||
Assert(unit->CurrentOrder()->HasGoal() ||
(unit->CurrentOrder()->X != -1 && unit->CurrentOrder()->Y != -1));
AnimateActionAttack(unit);

View file

@ -143,14 +143,12 @@ static void SpellMoveToTarget(CUnit *unit)
*/
void HandleActionSpellCast(CUnit *unit)
{
int flags;
if (unit->Wait) {
unit->Wait--;
return;
}
COrderPtr order = unit->CurrentOrder();
const SpellType *spell = order->Arg1.Spell;
const SpellType *spell = order->Arg1.Spell;
switch (unit->SubAction) {
case 0:
//
@ -196,7 +194,7 @@ void HandleActionSpellCast(CUnit *unit)
case 2: // Cast spell on the target.
// FIXME: should use AnimateActionSpellCast here
if (unit->Type->Animations->Attack && !spell->IsCasterOnly()) {
flags = UnitShowAnimation(unit, unit->Type->Animations->Attack);
UnitShowAnimation(unit, unit->Type->Animations->Attack);
if (unit->Anim.Unbreakable) { // end of animation
return;
}

View file

@ -81,7 +81,7 @@ static int AiCheckSurrounding(const CUnit *worker,
int dir;
int obstacle;
int y_offset;
x0 = x - 1;
y0 = y - 1;
x1 = x0 + type->TileWidth + 1;
@ -98,17 +98,17 @@ static int AiCheckSurrounding(const CUnit *worker,
(unsigned)y < (unsigned)Map.Info.MapHeight) {
if (worker && x == worker->X && y == worker->Y) {
surrounding[surroundingnb++] = 1;
} else if ( Map.CheckMask(x + y_offset,
} else if ( Map.CheckMask(x + y_offset,
(MapFieldUnpassable | MapFieldWall | MapFieldRocks |
MapFieldForest | MapFieldBuilding))
) {
surrounding[surroundingnb++] = 0;
} else{
// Can pass there
surrounding[surroundingnb++] = Map.CheckMask(x + y_offset,
(MapFieldWaterAllowed +
surrounding[surroundingnb++] = Map.CheckMask(x + y_offset,
(MapFieldWaterAllowed +
MapFieldCoastAllowed + MapFieldLandAllowed));
}
} else {
surrounding[surroundingnb++] = 0;
@ -197,10 +197,10 @@ static int AiFindBuildingPlace2(const CUnit *worker, const CUnitType *type,
backupy = y;
}
}
size = Map.Info.MapWidth * Map.Info.MapHeight / 4;
points = new p[size];
//
// Make movement matrix.
//
@ -319,8 +319,8 @@ static int AiFindBuildingPlace2(const CUnit *worker, const CUnitType *type,
*/
static int AiFindHallPlace(const CUnit *worker,
const CUnitType *type,
int nx, int ny,
int *dx, int *dy,
int nx, int ny,
int *dx, int *dy,
int resource = GoldCost)
{
static const int xoffset[] = { 0, -1, +1, 0, -1, +1, -1, +1 };
@ -344,11 +344,9 @@ static int AiFindHallPlace(const CUnit *worker,
unsigned char *morg;
unsigned char *matrix;
CUnit *mine;
int destx;
int desty;
destx = x = (nx != -1 ? nx : worker->X);
desty = y = (ny != -1 ? ny : worker->Y);
x = (nx != -1 ? nx : worker->X);
y = (ny != -1 ? ny : worker->Y);
size = Map.Info.MapWidth * Map.Info.MapHeight / 4;
points = new p[size];
@ -401,7 +399,7 @@ static int AiFindHallPlace(const CUnit *worker,
//
minx = mine->X - 5;
miny = mine->Y - 5;
maxx = mine->X + mine->Type->TileWidth + 5;
maxx = mine->X + mine->Type->TileWidth + 5;
maxy = mine->Y + mine->Type->TileHeight + 5;
Map.FixSelectionArea(minx, miny, maxx, maxy);
nunits = Map.SelectFixed(minx, miny, maxx, maxy, units);
@ -479,7 +477,7 @@ static int AiFindHallPlace(const CUnit *worker,
** @todo FIXME: This is slow really slow, using two flood
** fills, is not a perfect solution.
*/
static int AiFindLumberMillPlace(const CUnit *worker, const CUnitType *type,
static int AiFindLumberMillPlace(const CUnit *worker, const CUnitType *type,
int nx,int ny, int *dx, int *dy)
{
static const int xoffset[] = { 0, -1, +1, 0, -1, +1, -1, +1 };
@ -581,8 +579,8 @@ static int AiFindLumberMillPlace(const CUnit *worker, const CUnitType *type,
static int AiFindMiningPlace(const CUnit *worker,
const CUnitType *type,
int nx, int ny,
int *dx, int *dy,
int nx, int ny,
int *dx, int *dy,
int resource)
{
static const int xoffset[] = { 0, -1, +1, 0, -1, +1, -1, +1 };
@ -606,11 +604,9 @@ static int AiFindMiningPlace(const CUnit *worker,
unsigned char *morg;
unsigned char *matrix;
CUnit *mine;
int destx;
int desty;
destx = x = (nx != -1 ? nx : worker->X);
desty = y = (ny != -1 ? ny : worker->Y);
x = (nx != -1 ? nx : worker->X);
y = (ny != -1 ? ny : worker->Y);
size = Map.Info.MapWidth * Map.Info.MapHeight / 4;
points = new p[size];
@ -701,13 +697,13 @@ static int AiFindMiningPlace(const CUnit *worker,
** @todo Better and faster way to find building place of oil
** platforms Special routines for special buildings.
*/
int AiFindBuildingPlace(const CUnit *worker, const CUnitType *type,
int AiFindBuildingPlace(const CUnit *worker, const CUnitType *type,
int nx, int ny, int *dx, int *dy)
{
//
// Find a good place for a new hall
//
DebugPrint("%d: Want to build a %s(%s)\n" _C_ AiPlayer->Player->Index
DebugPrint("%d: Want to build a %s(%s)\n" _C_ AiPlayer->Player->Index
_C_ type->Ident.c_str() _C_ type->Name.c_str());
//Mines and Depots
@ -728,14 +724,14 @@ int AiFindBuildingPlace(const CUnit *worker, const CUnitType *type,
return AiFindMiningPlace(worker, type, nx, ny, dx, dy, i);
} else {
//Mine can be build without resource restrictions: solar panels, etc
return AiFindBuildingPlace2(worker, type,
return AiFindBuildingPlace2(worker, type,
(nx != -1 ? nx : worker->X),
(ny != -1 ? ny : worker->Y), dx, dy);
}
}
}
return AiFindBuildingPlace2(worker, type,
return AiFindBuildingPlace2(worker, type,
(nx != -1 ? nx : worker->X), (ny != -1 ? ny : worker->Y), dx, dy);
}

View file

@ -55,12 +55,12 @@
template <const bool IN_REACT_RANGE>
struct AiForceEnemyFinder {
const CUnit *enemy;
inline bool found(void) {
return enemy != NULL;
}
inline bool operator() (const CUnit *const unit)
inline bool operator() (const CUnit *const unit)
{
if(IN_REACT_RANGE) {
if (unit->Type->CanAttack)
@ -70,28 +70,28 @@ struct AiForceEnemyFinder {
enemy = AttackUnitsInDistance(unit, MaxMapWidth);
}
return enemy == NULL;
}
}
AiForceEnemyFinder(int force): enemy(NULL) {
AiPlayer->Force[force].Units.for_each_if(*this);
}
AiForceEnemyFinder(AiForce *force): enemy(NULL) {
force->Units.for_each_if(*this);
}
};
struct AiForceAttackSender {
int goalX;
int goalY;
int delta;
inline void operator() (CUnit *const unit) {
// this may be problem if units are in bunker and we want sent
// them to attack
if (unit->Container == NULL) {
// To avoid lot of CPU consuption, send them with a small time difference.
// To avoid lot of CPU consuption, send them with a small time difference.
unit->Wait = delta;
++delta;
if (unit->Type->CanTransport() && unit->BoardCount > 0) {
@ -102,7 +102,7 @@ struct AiForceAttackSender {
CommandMove(unit, goalX, goalY, FlushCommands);
}
}
}
}
//
// Send all units in the force to enemy at x,y.
@ -117,7 +117,7 @@ struct AiForceAttackSender {
AiForceAttackSender(AiForce *force, int x, int y):
goalX(x), goalY(y), delta(0) {
DebugPrint("%d: Attacking with force #%lu\n" _C_ AiPlayer->Player->Index
_C_ (long unsigned int)(force - &(AiPlayer->Force[0])));
force->Attacking = true;
@ -223,7 +223,6 @@ int AiFindAvailableUnitTypeEquiv(const CUnitType *unittype, int *usableTypes)
int i;
int j;
int tmp;
int playerid;
int bestlevel;
int curlevel;
@ -242,8 +241,6 @@ int AiFindAvailableUnitTypeEquiv(const CUnitType *unittype, int *usableTypes)
}
// 3 - Sort by level
playerid = AiPlayer->Player->Index;
// We won't have usableTypesCount>4, so simple sort should do it
for (i = 0; i < usableTypesCount - 1; ++i) {
bestlevel = UnitTypes[usableTypes[i]]->Priority;
@ -268,7 +265,7 @@ int AiFindAvailableUnitTypeEquiv(const CUnitType *unittype, int *usableTypes)
struct AiForceCounter {
unsigned int *data;//[UnitTypeMax + 1];
inline void operator() (CUnit *const unit) {
data[UnitTypeEquivs[unit->Type->Slot]]++;
}
@ -277,7 +274,7 @@ struct AiForceCounter {
{
memset(data, 0, len);
units.for_each(*this);
}
}
};
void AiForce::CountTypes(unsigned int *counter, const size_t len) {
@ -351,23 +348,23 @@ void AiForce::Clean(void) {
void AiForce::Attack(int goalX, int goalY)
{
Clean();
Attacking = false;
if (Units.size() > 0) {
Attacking = true;
if(goalX == -1 || goalY == -1) {
/* Search in entire map */
const CUnit *enemy = AiForceEnemyFinder<false>(this).enemy;
const CUnit *enemy = AiForceEnemyFinder<false>(this).enemy;
if (enemy) {
goalX = enemy->X;
goalY = enemy->Y;
}
}
GoalX = goalX;
GoalY = goalY;
if(goalX == -1 || goalY == -1) {
DebugPrint("%d: Need to plan an attack with transporter\n" _C_ AiPlayer->Player->Index);
if (State == AI_FORCE_STATE_WAITING && !PlanAttack()) {
@ -382,7 +379,7 @@ void AiForce::Attack(int goalX, int goalY)
//
AiForceAttackSender(this, goalX, goalY);
}
}
AiForceManager::AiForceManager() {
@ -432,7 +429,7 @@ bool AiForceManager::Assign(CUnit *unit)
// No troops for attacking force
if (force->IsAttacking()) {
continue;
}
}
if (unit->GroupId == 0 && force->IsBelongsTo(unit->Type)) {
force->Insert(unit);
unit->GroupId = i + 1;
@ -447,9 +444,9 @@ void AiForceManager::CheckUnits(int *counter)
int attacking[UnitTypeMax];
unsigned int i,j;
const int *unit_types_count = AiPlayer->Player->UnitTypesCount;
memset(attacking, 0, sizeof(attacking));
//
// Look through the forces what is missing.
//
@ -560,7 +557,7 @@ void AiAttackWithForceAt(unsigned int force, int x, int y)
DebugPrint("Force out of range: %d" _C_ force);
return ;
}
if (!Map.Info.IsPointOnMap(x,y)) {
DebugPrint("(%d, %d) not in the map(%d, %d)" _C_ x _C_ y
_C_ Map.Info.MapWidth _C_ Map.Info.MapHeight);
@ -602,7 +599,7 @@ void AiAttackWithForces(int *forces)
if (!AiPlayer->Force[force].Defending)
{
found = true;
//Fixme: this is triky but should work
AiPlayer->Force[f].Role = AiPlayer->Force[force].Role;
@ -711,9 +708,9 @@ void AiForce::Update(void)
Attacking = false;
if (!Defending && State > 0) {
DebugPrint("%d: Attack force #%lu was destroyed, giving up\n"
_C_ AiPlayer->Player->Index _C_ (long unsigned int)(this - &(AiPlayer->Force[0])));
_C_ AiPlayer->Player->Index _C_ (long unsigned int)(this - &(AiPlayer->Force[0])));
Reset(true);
}
}
return;
}
@ -728,7 +725,7 @@ void AiForce::Update(void)
if (Attacking == false) {
if (!Defending && State > 0) {
DebugPrint("%d: Attack force #%lu has lost all agresive units, giving up\n"
_C_ AiPlayer->Player->Index _C_ (long unsigned int)(this - &(AiPlayer->Force[0])));
_C_ AiPlayer->Player->Index _C_ (long unsigned int)(this - &(AiPlayer->Force[0])));
Reset(true);
}
return ;
@ -869,14 +866,14 @@ void AiForceManager::Update(void)
AiForce *force = &forces[f];
//
// Look if our defenders still have enemies in range.
//
//
if (force->Defending) {
force->Clean();
//
// Look if still enemies in attack range.
//
if(!AiForceEnemyFinder<true>(force).found()) {
DebugPrint("%d:FIXME: not written, should send force #%d home\n"
DebugPrint("%d:FIXME: not written, should send force #%d home\n"
_C_ AiPlayer->Player->Index _C_ f);
force->Defending = false;
force->Attacking = false;

View file

@ -98,7 +98,7 @@ public:
*/
enum AiForceRole {
AiForceRoleAttack = 0, /// Force should attack
AiForceRoleDefend, /// Force should defend
AiForceRoleDefend /// Force should defend
};
#define AI_FORCE_STATE_FREE -1

View file

@ -62,9 +62,6 @@ void AiCheckMagic(void)
CUnit **units;
CUnit *unit;
const CPlayer *player;
#ifdef DEBUG
int success;
#endif
n = AiPlayer->Player->TotalNumUnits;
units = AiPlayer->Player->Units;
@ -77,9 +74,6 @@ void AiCheckMagic(void)
// Check if we can cast this spell. SpellIsAvailable checks for upgrades.
if (unit->Type->CanCastSpell[j] && SpellIsAvailable(player, j) &&
(SpellTypeTable[j]->AutoCast || SpellTypeTable[j]->AICast)) {
#ifdef DEBUG
success = // Follow on next line (AutoCastSpell).
#endif
AutoCastSpell(unit, SpellTypeTable[j]);
}
}

View file

@ -191,7 +191,7 @@ static int AiCheckUnitTypeCosts(const CUnitType *type)
**
** @return Number of enemy units.
*/
int AiEnemyUnitsInDistance(const CPlayer *player,
int AiEnemyUnitsInDistance(const CPlayer *player,
const CUnitType *type, int x, int y, unsigned range)
{
const CUnit *dest;
@ -203,7 +203,7 @@ int AiEnemyUnitsInDistance(const CPlayer *player,
//
// Select all units in range.
//
n = Map.Select(x - range, y - range,
n = Map.Select(x - range, y - range,
x + range + (type ? type->TileWidth :0),
y + range + (type ? type->TileHeight:0), table);
@ -297,19 +297,19 @@ static int AiBuildBuilding(const CUnitType *type, CUnitType *building,
// No workers available to build
return 0;
}
if(num == 1) {
unit = table[0];
} else {
// Try one worker at random to save cpu
unit = table[SyncRand() % num];
}
// Find a place to build.
if (AiFindBuildingPlace(unit, building, near_x, near_y, &x, &y)) {
CommandBuildBuilding(unit, x, y, building, FlushCommands);
return 1;
}
}
else
//when first worker can't build then rest also won't be able (save CPU)
if (near_x != -1 && near_y != -1) {
@ -326,13 +326,13 @@ static int AiBuildBuilding(const CUnitType *type, CUnitType *building,
return 0;
}
static bool
static bool
AiRequestedTypeAllowed(const CPlayer *player, const CUnitType *type)
{
const int size = AiHelpers.Build[type->Slot].size();
for(int i = 0; i<size; ++i) {
CUnitType *builder = AiHelpers.Build[type->Slot][i];
if(player->UnitTypesCount[builder->Slot] > 0 &&
if(player->UnitTypesCount[builder->Slot] > 0 &&
CheckDependByType(player, type))
{
return true;
@ -353,12 +353,12 @@ static int cnode_cmp(const void*const t0,
int s0 = ((struct cnode*)t0)->unit_cost;
int s1 = ((struct cnode*)t1)->unit_cost;
if(s0 == s1) {
return 0;
return 0;
}
return s0 < s1 ? -1 : 1;
}
int
int
AiGetBuildRequestsCount(PlayerAi *pai, int counter[UnitTypeMax])
{
const int size = (int)pai->UnitTypeBuilt.size();
@ -370,18 +370,18 @@ AiGetBuildRequestsCount(PlayerAi *pai, int counter[UnitTypeMax])
return size;
}
extern CUnit *FindDepositNearLoc(CPlayer *p,
extern CUnit *FindDepositNearLoc(CPlayer *p,
int x, int y, int range, int resource);
void AiNewDepotRequest(CUnit *worker) {
/*
DebugPrint("%d: Worker %d report: Resource [%d] too far from depot, returning time [%d].\n"
_C_ worker->Player->Index _C_ worker->Slot
DebugPrint("%d: Worker %d report: Resource [%d] too far from depot, returning time [%d].\n"
_C_ worker->Player->Index _C_ worker->Slot
_C_ worker->CurrentResource
_C_ worker->Data.Move.Cycles
);
*/
*/
int i;
int n;
int c;
@ -389,13 +389,13 @@ void AiNewDepotRequest(CUnit *worker) {
CUnitType *best_type = NULL;
int cost, best_cost = 0;
//int best_mask = 0, needmask;
int PosX = -1;
int PosY = -1;
ResourceInfo *resinfo =
worker->Type->ResInfo[worker->CurrentResource];
ResourceInfo *resinfo =
worker->Type->ResInfo[worker->CurrentResource];
if(resinfo->TerrainHarvester) {
PosX = worker->CurrentOrder()->Arg1.Resource.Pos.X;
PosY = worker->CurrentOrder()->Arg1.Resource.Pos.Y;
@ -405,18 +405,18 @@ void AiNewDepotRequest(CUnit *worker) {
PosX = mine->X;
PosY = mine->Y;
}
}
}
if (PosX != -1 && NULL != FindDepositNearLoc(worker->Player,
if (PosX != -1 && NULL != FindDepositNearLoc(worker->Player,
PosX, PosY, 10, worker->CurrentResource)) {
/*
* New Depot has just be finished and worker just return to old depot
/*
* New Depot has just be finished and worker just return to old depot
* (far away) from new Deopt.
*/
return;
return;
}
int counter[UnitTypeMax];
//
// Count the already made build requests.
@ -427,36 +427,36 @@ void AiNewDepotRequest(CUnit *worker) {
for (i = 0; i < n; ++i) {
type = AiHelpers.Depots[worker->CurrentResource - 1][i];
if (counter[type->Slot]) { // Already ordered.
return;
}
}
if (!AiRequestedTypeAllowed(worker->Player, type)) {
continue;
}
//
// Check if resources available.
//
//needmask = AiCheckUnitTypeCosts(type);
cost = 0;
for (c = 1; c < MaxCosts; ++c) {
cost += type->Stats[worker->Player->Index].Costs[c];
}
if(best_type == NULL || (cost < best_cost)) {
best_type = type;
best_cost = cost;
//best_mask = needmask;
}
}
if(best_type) {
//if(!best_mask) {
AiBuildQueue queue;
queue.Type = best_type;
@ -466,9 +466,9 @@ void AiNewDepotRequest(CUnit *worker) {
queue.Y = PosY;
worker->Player->Ai->UnitTypeBuilt.push_back(queue);
DebugPrint("%d: Worker %d report: Requesting new depot near [%d,%d].\n"
_C_ worker->Player->Index _C_ worker->Slot
DebugPrint("%d: Worker %d report: Requesting new depot near [%d,%d].\n"
_C_ worker->Player->Index _C_ worker->Slot
_C_ queue.X _C_ queue.Y
);
@ -478,7 +478,7 @@ void AiNewDepotRequest(CUnit *worker) {
}
*/
}
}
/**
@ -501,14 +501,14 @@ static bool AiRequestSupply(void)
return true;
}
int counter[UnitTypeMax];
//
// Count the already made build requests.
//
AiGetBuildRequestsCount(AiPlayer, counter);
struct cnode cache[16];
int j;
memset(cache, 0, sizeof(cache));
//
@ -525,12 +525,12 @@ static bool AiRequestSupply(void)
_C_ AiPlayer->Player->Index _C_ type->Name.c_str());
#endif
return false;
}
}
if (!AiRequestedTypeAllowed(AiPlayer->Player, type)) {
continue;
}
//
// Check if resources available.
//
@ -547,7 +547,7 @@ static bool AiRequestSupply(void)
if(j > 1)
qsort(&cache, j, sizeof(struct cnode), cnode_cmp);
if(j) {
if(!cache[0].needmask) {
type = cache[0].type;
@ -567,7 +567,7 @@ static bool AiRequestSupply(void)
}
AiPlayer->NeededMask |= cache[0].needmask;
}
#if defined( DEBUG) && defined( DebugRequestSupply )
std::string needed("");
@ -659,7 +659,7 @@ int AiCountUnitBuilders(CUnitType *type)
const std::vector<CUnitType *> *table;
if (UnitIdAllowed(AiPlayer->Player, type->Slot) == 0) {
DebugPrint("%d: Can't build `%s' now\n" _C_ AiPlayer->Player->Index
DebugPrint("%d: Can't build `%s' now\n" _C_ AiPlayer->Player->Index
_C_ type->Ident.c_str());
return 0;
}
@ -674,13 +674,13 @@ int AiCountUnitBuilders(CUnitType *type)
tablep = &AiHelpers.Train;
}
if (type->Slot > n) { // Oops not known.
DebugPrint("%d: AiCountUnitBuilders I: Nothing known about `%s'\n" _C_ AiPlayer->Player->Index
DebugPrint("%d: AiCountUnitBuilders I: Nothing known about `%s'\n" _C_ AiPlayer->Player->Index
_C_ type->Ident.c_str());
return 0;
}
table = &(*tablep)[type->Slot];
if (!table->size()) { // Oops not known.
DebugPrint("%d: AiCountUnitBuilders II: Nothing known about `%s'\n" _C_ AiPlayer->Player->Index
DebugPrint("%d: AiCountUnitBuilders II: Nothing known about `%s'\n" _C_ AiPlayer->Player->Index
_C_ type->Ident.c_str());
return 0;
}
@ -736,13 +736,13 @@ static int AiMakeUnit(CUnitType *type, int near_x, int near_y)
tablep = &AiHelpers.Train;
}
if (type->Slot > n) { // Oops not known.
DebugPrint("%d: AiMakeUnit I: Nothing known about `%s'\n"
DebugPrint("%d: AiMakeUnit I: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
continue;
}
table = &(*tablep)[type->Slot];
if (!table->size()) { // Oops not known.
DebugPrint("%d: AiMakeUnit II: Nothing known about `%s'\n"
DebugPrint("%d: AiMakeUnit II: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
continue;
}
@ -837,13 +837,13 @@ void AiAddResearchRequest(CUpgrade *upgrade)
tablep = &AiHelpers.Research;
if (upgrade->ID > n) { // Oops not known.
DebugPrint("%d: AiAddResearchRequest I: Nothing known about `%s'\n"
DebugPrint("%d: AiAddResearchRequest I: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ upgrade->Ident.c_str());
return;
}
table = &(*tablep)[upgrade->ID];
if (!table->size()) { // Oops not known.
DebugPrint("%d: AiAddResearchRequest II: Nothing known about `%s'\n"
DebugPrint("%d: AiAddResearchRequest II: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ upgrade->Ident.c_str());
return;
}
@ -932,13 +932,13 @@ void AiAddUpgradeToRequest(CUnitType *type)
tablep = &AiHelpers.Upgrade;
if (type->Slot > n) { // Oops not known.
DebugPrint("%d: AiAddUpgradeToRequest I: Nothing known about `%s'\n"
DebugPrint("%d: AiAddUpgradeToRequest I: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
return;
}
table = &(*tablep)[type->Slot];
if (!table->size()) { // Oops not known.
DebugPrint("%d: AiAddUpgradeToRequest II: Nothing known about `%s'\n"
DebugPrint("%d: AiAddUpgradeToRequest II: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
return;
}
@ -1053,7 +1053,7 @@ static int AiAssignHarvester(CUnit *unit, int resource)
if (resinfo->TerrainHarvester) {
// These will hold the coordinates of the forest.
int forestx, foresty;
//
// Code for terrain harvesters. Search for piece of terrain to mine.
//
@ -1073,10 +1073,10 @@ static int AiAssignHarvester(CUnit *unit, int resource)
unit->X, unit->Y, 1000, resource, true);
if (dest) {
//FIXME: rb - when workers can speedup building then such assign may be ok.
//FIXME: rb - when workers can speedup building then such assign may be ok.
//if(dest->CurrentAction() == UnitActionBuilt)
//CommandBuildBuilding(unit, dest->X, dest->Y, dest->Type, FlushCommands);
//else
//else
CommandResource(unit, dest, FlushCommands);
return 1;
}
@ -1086,7 +1086,7 @@ static int AiAssignHarvester(CUnit *unit, int resource)
(dest = UnitFindMiningArea(unit, unit->X, unit->Y, 1000, resource))) {
int needmask;
//int counter[UnitTypeMax];
//
// Count the already made build requests.
//
@ -1096,16 +1096,16 @@ static int AiAssignHarvester(CUnit *unit, int resource)
CUnitType *type = AiHelpers.Refinery[resource - 1][i];
//if (counter[type->Slot]) { // Already ordered.
// return 0;
//}
//}
if (!AiRequestedTypeAllowed(AiPlayer->Player, type)) {
continue;
}
//
// Check if resources available.
//
needmask = AiCheckUnitTypeCosts(type);
needmask = AiCheckUnitTypeCosts(type);
if(!needmask && AiMakeUnit(type)) {
AiBuildQueue newqueue;
newqueue.Type = type;
@ -1117,9 +1117,9 @@ static int AiAssignHarvester(CUnit *unit, int resource)
AiPlayer->UnitTypeBuilt.begin(), newqueue);
return 0;
}
}
return 0;
}
#endif
@ -1153,7 +1153,7 @@ static int AiAssignHarvester(CUnit *unit, int resource)
static int CmpWorkers(const void *w0,const void *w1) {
const CUnit*const worker0 = (const CUnit*const)w0;
const CUnit*const worker1 = (const CUnit*const)w1;
return worker0->ResourcesHeld < worker1->ResourcesHeld ? 1 : -1;
}
@ -1171,7 +1171,6 @@ static void AiCollectResources(void)
int num_units_with_resource[MaxCosts];
int num_units_assigned[MaxCosts];
int num_units_unassigned[MaxCosts];
int total; // Total of workers
int c;
int src_c;
int i;
@ -1191,7 +1190,7 @@ static void AiCollectResources(void)
memset(num_units_with_resource, 0, sizeof(num_units_with_resource));
memset(num_units_unassigned, 0, sizeof(num_units_unassigned));
memset(num_units_assigned, 0, sizeof(num_units_assigned));
//
// Collect statistics about the current assignment
//
@ -1210,7 +1209,7 @@ static void AiCollectResources(void)
//
// See if it's assigned already
//
if (c && unit->OrderCount == 1 &&
if (c && unit->OrderCount == 1 &&
unit->CurrentAction() == UnitActionResource) {
units_assigned[c][num_units_assigned[c]++] = unit;
total_harvester++;
@ -1247,16 +1246,13 @@ static void AiCollectResources(void)
if(!total_harvester) {
return;
}
}
memset(wanted, 0, sizeof(wanted));
percent_total = 100;
total = 0;
for (c = 1; c < MaxCosts; ++c) {
percent[c] = AiPlayer->Collect[c];
//FIXME: rb- where is total used?
total += num_units_assigned[c] + num_units_with_resource[c];
if ((AiPlayer->NeededMask & (1 << c))) { // Double percent if needed
percent_total += percent[c];
percent[c] <<= 1;
@ -1268,12 +1264,12 @@ static void AiCollectResources(void)
//
for (c = 1; c < MaxCosts; ++c ) {
if(percent[c]) {
// Wanted needs to be representative.
// Wanted needs to be representative.
if (total_harvester < 5) {
wanted[c] = 1 + (percent[c] * 5) / percent_total;
} else {
wanted[c] = 1 + (percent[c] * total_harvester) / percent_total;
}
}
}
}
@ -1283,13 +1279,13 @@ static void AiCollectResources(void)
for (c = 0; c < MaxCosts; ++c) {
priority_resource[c] = c;
priority_needed[c] = wanted[c] - num_units_assigned[c] - num_units_with_resource[c];
if (c && num_units_assigned[c] > 1) {
//first should go workers with lower ResourcesHeld value
qsort(units_assigned[c], num_units_assigned[c],
sizeof(CUnit*), CmpWorkers);
}
}
}
do {
//
@ -1530,13 +1526,13 @@ static int AiRepairUnit(CUnit *unit)
tablep = &AiHelpers.Repair;
type = unit->Type;
if (type->Slot > n) { // Oops not known.
DebugPrint("%d: AiRepairUnit I: Nothing known about `%s'\n"
DebugPrint("%d: AiRepairUnit I: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
return 0;
}
table = &(*tablep)[type->Slot];
if (!table->size()) { // Oops not known.
DebugPrint("%d: AiRepairUnit II: Nothing known about `%s'\n"
DebugPrint("%d: AiRepairUnit II: Nothing known about `%s'\n"
_C_ AiPlayer->Player->Index _C_ type->Ident.c_str());
return 0;
}

View file

@ -108,7 +108,7 @@ enum _mode_buttons_ {
enum EditorActionType
{
EditorActionTypePlaceUnit,
EditorActionTypeRemoveUnit,
EditorActionTypeRemoveUnit
};
struct EditorAction
@ -651,7 +651,7 @@ static void DrawPlayers(void)
}
}
extern void DrawPopupUnitInfo(const CUnitType *type,
extern void DrawPopupUnitInfo(const CUnitType *type,
int player_index, CFont *font,
Uint32 backgroundColor, int buttonX, int buttonY);
@ -659,8 +659,8 @@ static void DrawPopup(void) {
if (Editor.State == EditorEditUnit && Editor.CursorUnitIndex != -1) {
std::string nc, rc;
GetDefaultTextColors(nc, rc);
DrawPopupUnitInfo(Editor.ShownUnitTypes[Editor.CursorUnitIndex],
Editor.SelectedPlayer, SmallFont,
DrawPopupUnitInfo(Editor.ShownUnitTypes[Editor.CursorUnitIndex],
Editor.SelectedPlayer, SmallFont,
Video.MapRGB(TheScreen->format, 38, 38, 78),
Editor.PopUpX, Editor.PopUpY);
SetDefaultTextColors(nc, rc);
@ -709,7 +709,7 @@ static void DrawUnitIcons(void)
Video.DrawRectangleClip(ColorWhite, x - 1, y - 1,
icon->G->Width + 2, icon->G->Height + 2);
Editor.PopUpX = x;
Editor.PopUpY = y;
Editor.PopUpY = y;
}
x += IconWidth + 8;
@ -823,10 +823,10 @@ static void DrawTileIcons(void)
TileSizeX-2, TileSizeY-2);
}
if (i == Editor.CursorTileIndex) {
Video.DrawRectangleClip(ColorWhite, x - 1, y - 1,
Video.DrawRectangleClip(ColorWhite, x - 1, y - 1,
TileSizeX+2, TileSizeY+2);
Editor.PopUpX = x;
Editor.PopUpY = y;
Editor.PopUpY = y;
}
x += TileSizeX + 8;
@ -1271,7 +1271,7 @@ static void EditorCallbackButtonDown(unsigned button)
editorUnitSlider->setVisible(false);
if (VisibleTileIcons < (int)Editor.ShownTileTypes.size()) {
editorSlider->setVisible(true);
}
}
return;
case StartButton:
Editor.State = EditorSetStartLocation;
@ -1352,7 +1352,7 @@ static void EditorCallbackButtonDown(unsigned button)
// Click on map area
//
if (CursorOn == CursorOnMap) {
if (MouseButtons & RightButton) {
if (Editor.State == EditorEditUnit &&
Editor.SelectedUnitIndex != -1) {
@ -1365,8 +1365,8 @@ static void EditorCallbackButtonDown(unsigned button)
CursorBuilding = NULL;
return;
}
}
}
CViewport *vp = GetViewport(CursorX, CursorY);
Assert(vp);
if ((MouseButtons & LeftButton) && UI.SelectedViewport != vp) {
@ -1376,11 +1376,11 @@ static void EditorCallbackButtonDown(unsigned button)
if (MouseButtons & LeftButton) {
int tileX = UI.MouseViewport->Viewport2MapX(CursorX);
int tileY = UI.MouseViewport->Viewport2MapY(CursorY);
int tileY = UI.MouseViewport->Viewport2MapY(CursorY);
if (Editor.State == EditorEditTile &&
Editor.SelectedTileIndex != -1) {
EditTiles(tileX, tileY,
EditTiles(tileX, tileY,
Editor.ShownTileTypes[Editor.SelectedTileIndex],
TileCursorSize);
} else if (Editor.State == EditorEditUnit) {
@ -1827,8 +1827,8 @@ static void EditorCallbackMouse(int x, int y)
}
++i;
by += 20;
}
}
i = Editor.TileIndex;
by = UI.ButtonPanel.Y + 24;
while (by < UI.ButtonPanel.Y + ButtonPanelHeight - TileSizeY) {
@ -1891,10 +1891,10 @@ static void EditorCallbackMouse(int x, int y)
return;
}
}
int StartUnitWidth = Editor.StartUnit ?
int StartUnitWidth = Editor.StartUnit ?
Editor.StartUnit->Icon.Icon->G->Width : TileSizeX + 7;
int StartUnitHeight = Editor.StartUnit ?
int StartUnitHeight = Editor.StartUnit ?
Editor.StartUnit->Icon.Icon->G->Height : TileSizeY + 7;
if (UI.InfoPanel.X + 4 + START_ICON_X < CursorX &&
CursorX < UI.InfoPanel.X + 4 + START_ICON_X + StartUnitWidth &&
@ -1983,9 +1983,9 @@ static void CreateTileIcons(void)
for(int i = 0; 0x10 + i < Map.Tileset.NumTiles; i+=16) {
TileInfo *info = &Map.Tileset.Tiles[0x10 + i];
if (info->BaseTerrain && !info->MixTerrain) {
Editor.ShownTileTypes.push_back(0x10 + i);
Editor.ShownTileTypes.push_back(0x10 + i);
}
}
}
}
/**
@ -2088,7 +2088,7 @@ void CEditor::Init(void)
CreateTileIcons();
VisibleTileIcons = CalculateVisibleIcons(true);
RecalculateShownUnits();
EditorUndoActions.clear();
@ -2181,7 +2181,7 @@ void EditorMainLoop(void)
editorUnitSlider->setSize(ButtonPanelWidth/*176*/, 16);
editorSlider->setSize(ButtonPanelWidth/*176*/, 16);
editorContainer->add(editorUnitSlider, UI.ButtonPanel.X + 2, UI.ButtonPanel.Y + 4);
editorContainer->add(editorSlider, UI.ButtonPanel.X + 2, UI.ButtonPanel.Y + 4);
editorContainer->add(editorSlider, UI.ButtonPanel.X + 2, UI.ButtonPanel.Y + 4);
}
//ProcessMenu("menu-editor-tips", 1);
InterfaceState = IfaceStateNormal;

View file

@ -44,7 +44,7 @@ enum _diplomacy_ {
DiplomacyAllied, /// Ally with opponent
DiplomacyNeutral, /// Don't attack be neutral
DiplomacyEnemy, /// Attack opponent
DiplomacyCrazy, /// Ally and attack opponent
DiplomacyCrazy /// Ally and attack opponent
}; /// Diplomacy states for CommandDiplomacy
class CUnit;

View file

@ -55,7 +55,7 @@ enum AnimationType {
AnimationUnbreakable,
AnimationLabel,
AnimationGoto,
AnimationRandomGoto,
AnimationRandomGoto
};
class CAnimation {
@ -141,7 +141,7 @@ public:
delete[] Harvest[i];
}
}
CAnimation *Start;
CAnimation *Still;
CAnimation *Death;

View file

@ -106,7 +106,7 @@ class CPlayerColorGraphic;
enum ConstructionFileType {
ConstructionFileConstruction,
ConstructionFileMain,
ConstructionFileMain
};
/// Construction frame

View file

@ -156,7 +156,7 @@ enum CursorStates {
CursorStatePoint, /// Normal cursor
CursorStateSelect, /// Select position
CursorStateRectangle, /// Rectangle selecting
CursorStatePieMenu, /// Displaying Pie Menu
CursorStatePieMenu /// Displaying Pie Menu
};
/*----------------------------------------------------------------------------

View file

@ -101,7 +101,7 @@ class CUpgrade;
enum {
DependRuleUnitType, /// Kind is an unit-type
DependRuleUpgrade, /// Kind is an upgrade
DependRuleUpgrade /// Kind is an upgrade
};
/// Dependency rule

View file

@ -48,7 +48,7 @@ enum EditorRunningType {
EditorNotRunning = 0, /// Not Running
EditorStarted = 1, /// Editor Enabled at all
EditorCommandLine = 2, /// Called from Command Line
EditorEditing = 4, /// Editor is fully running
EditorEditing = 4 /// Editor is fully running
};
enum EditorStateType {
@ -62,7 +62,7 @@ class CEditor {
public:
CEditor() : TerrainEditable(true),
StartUnit(NULL),
UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
TileIndex(0), CursorTileIndex(-1), SelectedTileIndex(-1),
CursorPlayer(-1), SelectedPlayer(PlayerNumNeutral),
MapLoaded(false), WriteCompressedMaps(true), PopUpX(-1), PopUpY(-1)
@ -91,7 +91,7 @@ public:
int TileIndex; /// tile icon draw index.
int CursorTileIndex; /// tile icon under cursor.
int SelectedTileIndex; /// tile type to draw.
int CursorPlayer; /// Player under the cursor.
int SelectedPlayer; /// Player selected for draw.
@ -101,10 +101,10 @@ public:
EditorRunningType Running; /// Editor is running
EditorStateType State; /// Current editor state
int PopUpX;
int PopUpY;
};
/*----------------------------------------------------------------------------

View file

@ -75,7 +75,7 @@ enum ButtonCmd {
ButtonCancel, /// cancel
ButtonCancelUpgrade, /// cancel upgrade
ButtonCancelTrain, /// cancel training
ButtonCancelBuild, /// cancel building
ButtonCancelBuild /// cancel building
};
class ButtonAction;
@ -109,20 +109,20 @@ enum _button_area_ {
ButtonAreaResearching, /// Researching button
ButtonAreaTransporting, /// Transporting button
ButtonAreaButton, /// Button panel button
ButtonAreaMenu, /// Menu button
ButtonAreaMenu /// Menu button
};
/// Menu button under cursor
enum _menu_button_under_ {
ButtonUnderMenu, /// Menu button
ButtonUnderNetworkMenu, /// Network menu button
ButtonUnderNetworkDiplomacy, /// Diplomacy button
ButtonUnderNetworkDiplomacy /// Diplomacy button
};
/// current interface state
enum _iface_state_ {
IfaceStateNormal, /// Normal Game state
IfaceStateMenu, /// Menu active
IfaceStateMenu /// Menu active
};
/// current key state
@ -168,7 +168,7 @@ enum _cursor_on_ {
CursorOnScrollLeftUp, /// in scroll left+up area
CursorOnScrollLeftDown, /// in scroll left+down area
CursorOnScrollRightUp, /// in scroll right+up area
CursorOnScrollRightDown, /// in scroll right+down area
CursorOnScrollRightDown /// in scroll right+down area
};
/// Are We Scrolling With the Keyboard ?

View file

@ -56,7 +56,7 @@ class CMapInfo;
/**
** Exception thrown by FileWriter objects.
**/
class FileException
class FileException
{
};
@ -131,7 +131,7 @@ enum {
CLF_TYPE_INVALID, /// invalid file handle
CLF_TYPE_PLAIN, /// plain text file handle
CLF_TYPE_GZIP, /// gzip file handle
CLF_TYPE_BZIP2, /// bzip2 file handle
CLF_TYPE_BZIP2 /// bzip2 file handle
};
#define CL_OPEN_READ 0x1

View file

@ -172,7 +172,7 @@ enum _ic_message_subtype_ {
ICMGo, /// Client is ready to run
ICMAYT, /// Server asks are you there
ICMIAH, /// Client answers I am here
ICMIAH /// Client answers I am here
};
/**
@ -196,7 +196,7 @@ enum _net_client_con_state_ {
ccs_goahead, /// Server wants to start game
ccs_started, /// Server has started game
ccs_incompatibleengine, /// Incompatible engine version
ccs_incompatiblenetwork, /// Incompatible netowrk version
ccs_incompatiblenetwork /// Incompatible netowrk version
};
/*----------------------------------------------------------------------------

View file

@ -109,7 +109,7 @@ enum _message_type_ {
*/
enum _extended_message_type_ {
ExtendedMessageDiplomacy, /// Change diplomacy
ExtendedMessageSharedVision, /// Change shared vision
ExtendedMessageSharedVision /// Change shared vision
};
/**

View file

@ -65,7 +65,7 @@ enum _move_return_ {
PF_UNREACHABLE = -2, /// Unreachable stop
PF_REACHED = -1, /// Reached goal stop
PF_WAIT = 0, /// Wait, no time or blocked
PF_MOVE = 1, /// On the way moving
PF_MOVE = 1 /// On the way moving
};
/**

View file

@ -441,7 +441,7 @@ public:
enum PlayerRacesOld {
PlayerRaceHuman = 0, /// belongs to human
PlayerRaceOrc = 1, /// belongs to orc
PlayerRaceOrc = 1 /// belongs to orc
};
/**
@ -488,7 +488,7 @@ enum PlayerTypes {
PlayerComputer = 4, /// computer player
PlayerPerson = 5, /// human player
PlayerRescuePassive = 6, /// rescued passive
PlayerRescueActive = 7, /// rescued active
PlayerRescueActive = 7 /// rescued active
};
#define PlayerNumNeutral (PlayerMax - 1) /// this is the neutral player slot
@ -499,7 +499,7 @@ enum PlayerTypes {
enum NotifyType {
NotifyRed, /// Red alram
NotifyYellow, /// Yellow alarm
NotifyGreen, /// Green alarm
NotifyGreen /// Green alarm
};
/*----------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@
enum ReplayType {
ReplayNone, /// No replay
ReplaySinglePlayer, /// Single player replay
ReplayMultiPlayer, /// Multi player replay
ReplayMultiPlayer /// Multi player replay
}; /// Replay types
class CFile;

View file

@ -62,7 +62,7 @@ typedef struct _lua_user_data_ {
enum {
LuaUnitType = 100,
LuaSoundType,
LuaSoundType
};
extern lua_State *Lua;
@ -156,7 +156,7 @@ typedef enum {
UnitRefInside, /// unit->Inside.
UnitRefContainer, /// Unit->Container.
UnitRefWorker, /// unit->Data.Built.Worker
UnitRefGoal, /// unit->Goal
UnitRefGoal /// unit->Goal
} EnumUnit;

View file

@ -98,7 +98,7 @@ enum GameTypes {
SettingsGameTypeTopVsBottom,
SettingsGameTypeLeftVsRight,
SettingsGameTypeManVsMachine,
SettingsGameTypeManTeamVsMachine,
SettingsGameTypeManTeamVsMachine
// Future game type ideas
#if 0
@ -108,7 +108,7 @@ enum GameTypes {
SettingsGameTypeSlaughter,
SettingsGameTypeSuddenDeath,
SettingsGameTypeTeamMelee,
SettingsGameTypeTeamCaptureTheFlag,
SettingsGameTypeTeamCaptureTheFlag
#endif
};

View file

@ -69,7 +69,7 @@ enum _play_audio_flags_ {
PlayAudioStream = 1, /// Stream the file from medium
PlayAudioPreLoad = 2, /// Load compressed in memory
PlayAudioLoadInMemory = 4, /// Preload file into memory
PlayAudioLoadOnDemand = 8, /// Load only if needed.
PlayAudioLoadOnDemand = 8 /// Load only if needed.
};
/*----------------------------------------------------------------------------

View file

@ -220,7 +220,7 @@ enum TileType {
TileTypeCoast, /// Any coast tile
TileTypeHumanWall, /// Any human wall tile
TileTypeOrcWall, /// Any orc wall tile
TileTypeWater, /// Any water tile
TileTypeWater /// Any water tile
};
/// Single tile definition
@ -307,7 +307,7 @@ public:
unsigned HumanWallTable[16]; /// Human wall placement table
unsigned OrcWallTable[16]; /// Orc wall placement table
bool IsSeenTile(unsigned short type, unsigned short seen) const
{
if(TileTypeTable) {
@ -322,7 +322,7 @@ public:
}
return false;
};
};
/*----------------------------------------------------------------------------

View file

@ -37,7 +37,7 @@
class CFont;
enum {
TitleFlagCenter = 1 << 0, /// Center Text
TitleFlagCenter = 1 << 0 /// Center Text
};
class TitleScreenLabel {

View file

@ -79,7 +79,7 @@ enum TextAlignment {
TextAlignUndefined,
TextAlignCenter,
TextAlignLeft,
TextAlignRight,
TextAlignRight
};
class ButtonStyleProperties {
@ -101,7 +101,7 @@ public:
int TextY; /// Text Y location
std::string TextNormalColor; /// Normal text color
std::string TextReverseColor; /// Reverse text color
} ;
};
class ButtonStyle {
public:
@ -168,7 +168,7 @@ public:
OffsetX(0), OffsetY(0), MapWidth(0), MapHeight(0), Unit(NULL),
Proxy(NULL) {}
~CViewport();
/// Check if X and Y pixels are within map area
bool IsInsideMapArea(int x, int y) const;
@ -429,9 +429,9 @@ class CFiller
struct bits_map {
bits_map() : Width(0), Height(0), bstore(NULL) {}
~bits_map();
void Init(CGraphic *g);
bool TransparentPixel(int x, int y)
{
if(bstore) {
@ -443,18 +443,18 @@ class CFiller
}
return false;
};
int Width;
int Height;
unsigned int *bstore;
unsigned int *bstore;
};
bits_map map;
public:
CFiller() : G(NULL), X(0), Y(0) {}
void Load(void);
bool OnGraphic(int x, int y) {
x -= X;
y -= Y;
@ -698,8 +698,8 @@ public:
CGraphic *DefeatBackgroundG; /// Defeat background graphic
};
/*
* Basic Shared Pointer for Current Selected Buttons
/*
* Basic Shared Pointer for Current Selected Buttons
* parallel drawing problems.
*/
class ButtonActionProxy {
@ -730,7 +730,7 @@ class ButtonActionProxy {
public:
ButtonActionProxy (): ptr(0), count(0) {}
ButtonActionProxy (const ButtonActionProxy& p)
: ptr(p.ptr), count(p.count)
{
@ -754,12 +754,12 @@ public:
ButtonAction &operator[](unsigned int index) {
return ptr[index];
}
bool IsValid(void)
{
return ptr != NULL;
}
};
extern ButtonActionProxy CurrentButtons; /// Current Selected Buttons

View file

@ -184,7 +184,7 @@
**
** Contains the binary angle (0-255) in which the direction the
** unit looks. 0, 32, 64, 128, 160, 192, 224, 256 corresponds to
** 0°, 45°, 90°, 135°, 180°, 225°, 270°, 315°, 360° or north,
** 0<EFBFBD>, 45<EFBFBD>, 90<EFBFBD>, 135<EFBFBD>, 180<EFBFBD>, 225<EFBFBD>, 270<EFBFBD>, 315<EFBFBD>, 360<EFBFBD> or north,
** north-east, east, south-east, south, south-west, west,
** north-west, north. Currently only 8 directions are used, this
** is more for the future.
@ -471,7 +471,7 @@ enum UnitVoiceGroup {
VoiceBuilding, /// only for building under construction
VoiceDocking, /// only for transport reaching coast
VoiceRepairing, /// repairing
VoiceHarvesting, /// harvesting
VoiceHarvesting /// harvesting
};
/**
@ -490,7 +490,7 @@ enum _directions_ {
LookingS = 4 * 32, /// Unit looking south
LookingSW = 5 * 32, /// Unit looking south west
LookingW = 6 * 32, /// Unit looking west
LookingNW = 7 * 32, /// Unit looking north west
LookingNW = 7 * 32 /// Unit looking north west
};
#define NextDirection 32 /// Next direction N->NE->E...
@ -506,7 +506,7 @@ public:
class COrder {
friend void CclParseOrder(lua_State *l, COrder *order);
CUnit *Goal; /// goal of the order (if any)
public:
COrder() : Goal(NULL), Range(0), MinRange(0), Width(0),
Height(0),Action(UnitActionNone), CurrentResource(0),
@ -520,9 +520,9 @@ public:
void Release(void);
COrder& operator=(const COrder &rhs);
bool CheckRange(void);
void Init() {
Assert(Action != UnitActionResource ||
Assert(Action != UnitActionResource ||
(Action == UnitActionResource && Arg1.Resource.Mine == NULL));
Action = UnitActionNone;
Range = 0;
@ -540,7 +540,7 @@ public:
unsigned char Width; /// Goal Width (used when Goal is not)
unsigned char Height; /// Goal Height (used when Goal is not)
unsigned char Action; /// global action
unsigned char CurrentResource; //used in UnitActionResource and
unsigned char CurrentResource; //used in UnitActionResource and
//UnitActionReturnGoods
int X; /// or X tile coordinate of destination
@ -594,7 +594,7 @@ public:
}
Goal = new_goal;
};
inline void ClearGoal(void)
{
if (Goal) {
@ -604,7 +604,7 @@ public:
};
};
CUnit() { Init(); }
void Init() {
@ -686,7 +686,7 @@ public:
CUnit *NextContained; /// Next unit in the container.
CUnit *PrevContained; /// Previous unit in the container.
CUnit *NextWorker; //pointer to next assigned worker to "Goal" resource.
int X; /// Map position X
int Y; /// Map position Y
unsigned int Offset;/// Map position as flat index offset (x + y * w)
@ -699,7 +699,7 @@ public:
// DISPLAY:
int Frame; /// Image frame: <0 is mirrored
CUnitColors *Colors; /// Player colors
signed char IX; /// X image displacement to map position
signed char IY; /// Y image displacement to map position
unsigned char Direction; //: 8; /// angle (0-255) unit looking
@ -718,7 +718,7 @@ public:
unsigned Destroyed : 1; /// unit is destroyed pending reference
unsigned Removed : 1; /// unit is removed (not on map)
unsigned Selected : 1; /// unit is selected
unsigned Constructed : 1; /// Unit is in construction
unsigned Active : 1; /// Unit is active for AI
@ -742,7 +742,7 @@ public:
unsigned Constructed : 1; /// Unit seen construction
unsigned State : 3; /// Unit seen build/upgrade state
unsigned Destroyed : PlayerMax; /// Unit seen destroyed or not
unsigned ByPlayer : PlayerMax; /// Track unit seen by player
unsigned ByPlayer : PlayerMax; /// Track unit seen by player
} Seen;
CVariable *Variable; /// array of User Defined variables.
@ -814,22 +814,22 @@ public:
inline COrder * CreateOrder(void) {
Orders.push_back(new COrder);
return Orders[(int)OrderCount++];
return Orders[(int)OrderCount++];
}
inline COrder *CurrentOrder() const
inline COrder *CurrentOrder() const
{
#if __GNUC__ < 4
return Orders[0];
#else
return *(Orders.data());
#endif
#endif
}
inline UnitAction CurrentAction() const
{
return (UnitAction)(CurrentOrder()->Action);
}
inline bool IsIdle() const {
return OrderCount == 1 && CurrentAction() == UnitActionStill;
}
@ -842,7 +842,7 @@ public:
}
}
inline int GetReactRange() const
inline int GetReactRange() const
{
return (Player->Type == PlayerPerson ?
Type->ReactRangePerson : Type->ReactRangeComputer);
@ -875,15 +875,15 @@ public:
void AssignWorkerToMine(CUnit *mine);
void DeAssignWorkerFromMine(CUnit *mine);
/// Release a unit
void Release(bool final = false);
bool RestoreOrder(void);
bool StoreOrder(void);
// Cowards and invisible units don't attack unless ordered.
bool IsAgressive(void) const
bool IsAgressive(void) const
{
return (Type->CanAttack && !Type->Coward &&
Variable[INVISIBLE_INDEX].Value == 0);
@ -946,7 +946,7 @@ public:
!(Seen.Destroyed & (1 << player->Index));
}
}
/**
** Returns true, if unit is visible for this player on the map.
** The unit has to be out of fog of war and alive
@ -958,17 +958,17 @@ public:
inline bool IsVisibleOnMap(const CPlayer *player) const
{
return IsAliveOnMap() && !IsInvisibile(player) && IsVisible(player);
}
}
/// Returns true if unit is visible on minimap. Only for ThisPlayer.
bool IsVisibleOnMinimap() const;
// Returns true if unit is visible under radar (By player, or by shared vision)
bool IsVisibleOnRadar(const CPlayer *pradar) const;
/// Returns true if unit is visible in an viewport. Only for ThisPlayer.
bool IsVisibleInViewport(const CViewport *vp) const;
/// Returns true, if unit is visible on current map view (any viewport).
bool IsVisibleOnScreen() const;
@ -987,7 +987,7 @@ public:
bool IsTeamed(const CUnit *x) const;
bool IsUnusable(bool ignore_built_state = false) const;
/**
** Returns the map distance between this unit and dst units.
**
@ -1000,7 +1000,7 @@ public:
return MapDistanceBetweenTypes(Type, X, Y,
dst->Type, dst->X, dst->Y);
}
/**
** Returns the map distance to unit.
**
@ -1025,13 +1025,13 @@ public:
{
return Type->CanMove();
}
int GetDrawLevel(void) const
{
return ((Type->CorpseType && CurrentAction() == UnitActionDie) ?
Type->CorpseType->DrawLevel : Type->DrawLevel);
}
};
typedef CUnit::COrder* COrderPtr;
@ -1047,7 +1047,7 @@ public:
unit = NULL;
}
CUnitPtr(): unit(NULL) {}
CUnitPtr(): unit(NULL) {}
CUnitPtr(CUnit *u): unit(u) {
if (unit) {
unit->RefsIncrease();
@ -1114,28 +1114,28 @@ public:
int X;
int Y;
int frame;
int TeamSelected; //unit->TeamSelected
int GroupId; //unit->GroupId
signed char IX;
int frame;
int TeamSelected; //unit->TeamSelected
int GroupId; //unit->GroupId
signed char IX;
signed char IY;
unsigned char CurrentResource;
unsigned char CurrentResource;
unsigned int IsAlive:1;
unsigned int Selected:1; //unit->Selected
unsigned int ResourcesHeld:1; /// isResources Held by a unit
unsigned int Selected:1; //unit->Selected
unsigned int ResourcesHeld:1; /// isResources Held by a unit
unsigned int state: 2;
unsigned int Blink: 3; //unit->Blink
const CConstructionFrame *cframe;
const CUnitType *Type;
const CPlayer *Player;
CVariable *Variable;
void operator=(const CUnit *unit);
void Draw(const CViewport *vp) const;
void Draw(const CViewport *vp) const;
};
//unit_find
@ -1154,7 +1154,7 @@ struct CUnitTypeFinder {
{
return cache.find(*this);
}
inline CUnit *Find(const CMapField *const mf) const
{
return mf->UnitCache.find(*this);
@ -1168,8 +1168,8 @@ struct CResourceFinder {
inline bool operator () (const CUnit *const unit) const
{
const CUnitType *const type = unit->Type;
return (type->GivesResource == resource
&& unit->ResourcesHeld != 0
return (type->GivesResource == resource
&& unit->ResourcesHeld != 0
&& (mine_on_top ? type->CanHarvest : !type->CanHarvest)
&& !unit->IsUnusable(true) //allow mines under construction
);
@ -1177,7 +1177,7 @@ struct CResourceFinder {
inline CUnit *Find(const CMapField *const mf) const
{
return mf->UnitCache.find(*this);
}
}
};
struct CResourceDepositFinder {
@ -1278,12 +1278,12 @@ extern void UnitGoesUnderFog(CUnit *unit, const CPlayer *player);
extern void UnitGoesOutOfFog(CUnit *unit, const CPlayer *player);
/// Marks a unit as seen
extern void UnitsOnTileMarkSeen(const CPlayer *player, int x, int y, int p);
extern void
extern void
UnitsOnTileMarkSeen(const CPlayer *player, const unsigned int index, int p);
/// Unmarks a unit as seen
extern void UnitsOnTileUnmarkSeen(const CPlayer *player, int x, int y, int p);
extern void
extern void
UnitsOnTileUnmarkSeen(const CPlayer *player, const unsigned int index, int p);
/// Does a recount for VisCount
@ -1319,7 +1319,7 @@ extern CUnit *CanBuildUnitType(const CUnit *unit, const CUnitType *type, int x,
extern CUnit *UnitFindResource(const CUnit *unit, int x, int y, int range,
int resource, bool check_usage = false, const CUnit *destu = NULL);
extern CUnit *UnitFindMiningArea(const CUnit *unit, int x, int y,
int range, int resource);
int range, int resource);
/// Find nearest deposit
extern CUnit *FindDeposit(const CUnit *unit, int range, int resource);
/// Find the next idle worker
@ -1407,7 +1407,7 @@ extern CUnit *UnitOnMapTile(int tx, int ty, unsigned int type);// = -1);
extern CUnit *TargetOnMap(const CUnit *unit, int x1, int y1, int x2, int y2);
/// Return resource, if on map tile
extern CUnit *ResourceOnMap(int tx, int ty, int resource,
extern CUnit *ResourceOnMap(int tx, int ty, int resource,
bool mine_on_top = true);
/// Return resource deposit, if on map tile
extern CUnit *ResourceDepositOnMap(int tx, int ty, int resource);
@ -1420,7 +1420,7 @@ extern CUnit *AttackUnitsInRange(const CUnit *unit);
extern CUnit *AttackUnitsInReactRange(const CUnit *unit);
extern CUnit *
AutoAttackUnitsInDistance(const CUnit *unit, int range,
AutoAttackUnitsInDistance(const CUnit *unit, int range,
CUnitCache &autotargets);
// in groups.c

View file

@ -564,7 +564,7 @@ class ResourceInfo {
public:
ResourceInfo() : WaitAtResource(0), ResourceStep(0),
ResourceCapacity(0), WaitAtDepot(0), ResourceId(0), FinalResource(0),
TerrainHarvester(0), LoseResources(0), HarvestFromOutside(0),
TerrainHarvester(0), LoseResources(0), HarvestFromOutside(0),
SpriteWhenLoaded(NULL), SpriteWhenEmpty(NULL)
{}
@ -579,7 +579,7 @@ public:
unsigned char TerrainHarvester; /// Unit will harvest terrain(wood only for now).
unsigned char LoseResources; /// The unit will lose it's resource when distracted.
unsigned char HarvestFromOutside; /// Unit harvests without entering the building.
unsigned char RefineryHarvester; /// Unit have to build Refinery buildings for harvesting.
unsigned char RefineryHarvester; /// Unit have to build Refinery buildings for harvesting.
// Runtime info:
CPlayerColorGraphic *SpriteWhenLoaded; /// The graphic corresponding to FileWhenLoaded.
CPlayerColorGraphic *SpriteWhenEmpty; /// The graphic corresponding to FileWhenEmpty
@ -740,7 +740,7 @@ class CDecoVarSpriteBar : public CDecoVar
public:
CDecoVarSpriteBar() : NSprite(-1) {};
/// function to draw the decorations.
virtual void Draw(int x, int y,
virtual void Draw(int x, int y,
const CUnitType *Type, const CVariable &Variable) const;
char NSprite; /// Index of number. (@see DefineSprites and @see GetSpriteIndex)
@ -763,7 +763,7 @@ public:
enum UnitTypeType {
UnitTypeLand, /// Unit lives on land
UnitTypeFly, /// Unit lives in air
UnitTypeNaval, /// Unit lives on water
UnitTypeNaval /// Unit lives on water
};
enum DistanceTypeType {
@ -772,7 +772,7 @@ enum DistanceTypeType {
LessThan,
LessThanEqual,
GreaterThan,
GreaterThanEqual,
GreaterThanEqual
};
@ -814,7 +814,7 @@ public:
class CBuildRestrictionAddOn : public CBuildRestriction {
struct functor {
const CUnitType *const Parent; /// building that is unit is an addon too.
const CUnitType *const Parent; /// building that is unit is an addon too.
const int x,y; //functor work position
functor(const CUnitType *type, int _x, int _y): Parent(type), x(_x), y(_y) {}
inline bool operator() (const CUnit *const unit) const;
@ -833,8 +833,8 @@ public:
class CBuildRestrictionOnTop : public CBuildRestriction {
struct functor {
CUnit *ontop; /// building that is unit is an addon too.
const CUnitType *const Parent; /// building that is unit is an addon too.
CUnit *ontop; /// building that is unit is an addon too.
const CUnitType *const Parent; /// building that is unit is an addon too.
const int x,y; //functor work position
functor(const CUnitType *type, int _x, int _y): ontop(0), Parent(type), x(_x), y(_y) {}
inline bool operator() (CUnit *const unit);
@ -970,10 +970,10 @@ public:
unsigned Indestructible : 1; /// Unit is indestructible (take no damage).
unsigned Teleporter : 1; /// Can teleport other units.
CVariable *Variable; /// Array of user defined variables.
CVariable *Variable; /// Array of user defined variables.
struct BoolFlags {
bool value; /// User defined flag. Used for (dis)allow target.
char CanTransport; /// Can transport units with this flag.
char CanTransport; /// Can transport units with this flag.
char CanTargetFlag; /// Flag needed to target with missile.
};
std::vector<BoolFlags> BoolFlag;
@ -1003,7 +1003,7 @@ public:
CGraphic *ShadowSprite; /// Shadow sprite image
/* API */
bool CheckUserBoolFlags(char *BoolFlags);
bool CanTransport(void) const
{
@ -1055,11 +1055,11 @@ public:
struct CKeys {
struct DataKey
{
static bool key_pred(const DataKey& lhs,
{
static bool key_pred(const DataKey& lhs,
const DataKey& rhs)
{
return ((lhs.keylen == rhs.keylen) ?
return ((lhs.keylen == rhs.keylen) ?
(strcmp(lhs.key, rhs.key) < 0) : (lhs.keylen < rhs.keylen));
}
int offset;
@ -1068,22 +1068,22 @@ public:
};
CKeys(): TotalKeys(SIZE) {}
DataKey buildin[SIZE];
std::map<std::string, int> user;
unsigned int TotalKeys;
void Init() {
std::sort(buildin, buildin+SIZE, DataKey::key_pred);
std::sort(buildin, buildin+SIZE, DataKey::key_pred);
}
const char *operator[](int index) {
for (unsigned int i = 0; i < SIZE; ++i) {
if (buildin[i].offset == index) {
return buildin[i].key;
}
}
for (std::map<std::string, int>::iterator
for (std::map<std::string, int>::iterator
it(user.begin()), end(user.end());
it != end; ++it) {
if ((*it).second == index) {
@ -1092,31 +1092,31 @@ public:
}
return NULL;
}
/**
** Return the index of the external storage array/vector.
**
** @param varname Name of the variable.
**
** @return Index of the variable, -1 if not found.
*/
*/
int operator[](const char*const key) {
DataKey k;
k.key = key;
k.keylen = strlen(key);
const DataKey* p = std::lower_bound(buildin, buildin + SIZE,
const DataKey* p = std::lower_bound(buildin, buildin + SIZE,
k, DataKey::key_pred);
if ((p != buildin + SIZE) && p->keylen == k.keylen &&
if ((p != buildin + SIZE) && p->keylen == k.keylen &&
0 == strcmp(p->key, key)) {
return p->offset;
} else {
std::map<std::string, int>::iterator
std::map<std::string, int>::iterator
ret(user.find(key));
if (ret != user.end()) {
return (*ret).second;
}
}
return -1;
return -1;
}
int AddKey(const char*const key)
@ -1129,7 +1129,7 @@ public:
user[key] = TotalKeys++;
return TotalKeys - 1;
}
};
struct CBoolKeys : public CKeys<NBARALREADYDEFINED> {
@ -1141,17 +1141,17 @@ public:
};
CUnitTypeVar() {}
void Init();
void Clear();
CBoolKeys BoolFlagNameLookup; /// Container of name of user defined bool flag.
CVariableKeys VariableNameLookup; /// Container of names of user defined variables.
// EventType *Event; /// Array of functions sets to call when en event occurs.
std::vector<CVariable> Variable; /// Array of user defined variables (default value for unittype).
std::vector<CVariable> Variable; /// Array of user defined variables (default value for unittype).
std::vector<CDecoVar *> DecoVar; /// Array to describe how showing variable.
unsigned int GetNumberBoolFlag(void) {
return BoolFlagNameLookup.TotalKeys;
}
@ -1160,8 +1160,8 @@ public:
return VariableNameLookup.TotalKeys;
}
};
extern CUnitTypeVar UnitTypeVar;

View file

@ -63,7 +63,7 @@ inline int get_cpu_count(void) {
#else
return 1;
#endif
};
}
class CMutex
@ -107,7 +107,6 @@ public:
return 0 == pthread_mutex_trylock (&_mut);
#endif
}
};

View file

@ -308,15 +308,12 @@ void MapSight(const CPlayer *player, int x, int y, int w, int h, int range,
int cy[4];
int steps;
int cycle;
int p;
// Units under construction have no sight range.
if (!range) {
return;
}
p = player->Index;
#ifdef MARKER_ON_INDEX
unsigned int index = y * Map.Info.MapWidth;
#endif
@ -350,7 +347,7 @@ void MapSight(const CPlayer *player, int x, int y, int w, int h, int range,
}
}
#ifdef MARKER_ON_INDEX
index += Map.Info.MapWidth;
index += Map.Info.MapWidth;
#endif
}
@ -369,7 +366,7 @@ void MapSight(const CPlayer *player, int x, int y, int w, int h, int range,
}
}
#ifdef MARKER_ON_INDEX
index += Map.Info.MapWidth;
index += Map.Info.MapWidth;
#endif
}
@ -663,7 +660,6 @@ void CViewport::DrawMapFogOfWar() const
int ex;
int dy;
int ey;
int p;
int my;
int mx;
@ -671,7 +667,6 @@ void CViewport::DrawMapFogOfWar() const
if (ReplayRevealMap) {
return;
}
p = ThisPlayer->Index;
sx = std::max<int>(MapX - 1, 0);
ex = std::min<int>(MapX + MapWidth + 1, Map.Info.MapWidth);
@ -792,7 +787,7 @@ void CMap::InitFogOfWar(void)
AlphaFogG->GenFramesMap();
AlphaFogG->UseDisplayFormat();
}
delete[] VisibleTable;
VisibleTable = new unsigned short[Info.MapWidth * Info.MapHeight];
}

View file

@ -519,7 +519,6 @@ void CMinimap::Update(void)
int my;
int n;
int visiontype; // 0 unexplored, 1 explored, >1 visible.
int bpp;
red_phase_changed = red_phase != (int)((FrameCounter / FRAMES_PER_SECOND) & 1);
if (red_phase_changed) {
@ -536,7 +535,6 @@ void CMinimap::Update(void)
}
if (!UseOpenGL) {
bpp = MinimapSurface->format->BytesPerPixel;
}
//
@ -563,6 +561,7 @@ void CMinimap::Update(void)
}
if ( visiontype == 0 || (visiontype == 1 && ((mx & 1) != (my & 1)))) {
const int bpp = MinimapSurface->format->BytesPerPixel;
if (!UseOpenGL) {
if (bpp == 2) {
*(Uint16 *)&((Uint8 *)MinimapSurface->pixels)[mx * bpp + my * MinimapSurface->pitch] =
@ -647,7 +646,7 @@ void CMinimap::Draw(int vx, int vy)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texCoord);
glVertexPointer(2, GL_FLOAT, 0, vertex);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

View file

@ -813,7 +813,7 @@ void NetworkSendSelection(CUnit **units, int count)
for (; i < MaxNetworkCommands; ++i) {
packet.Header.Type[i] = MessageNone;
}
//
// Send the Constructed packet to team members
@ -1052,7 +1052,7 @@ void NetworkEvent(void)
{
unsigned int slot = ntohs(nc->Unit);
if (slot >= 0 && slot < UnitSlotFree &&
if (slot < UnitSlotFree &&
(UnitSlots[slot]->Player->Index == player ||
Players[player].IsTeamed(UnitSlots[slot]))) {
validCommand = true;
@ -1069,8 +1069,8 @@ void NetworkEvent(void)
NetworkIn[packet.Header.Cycle][player][i].Data = *nc;
} else {
SetMessage(_("%s sent bad command"), Players[player].Name.c_str());
DebugPrint("%s sent bad command: 0x%x\n" _C_
Players[player].Name.c_str() _C_
DebugPrint("%s sent bad command: 0x%x\n" _C_
Players[player].Name.c_str() _C_
packet.Header.Type[i] & 0x7F);
}
}

View file

@ -63,8 +63,8 @@ static CSound *FindSound(const std::string &name)
if (ret != SoundMap.end()) {
return (*ret).second;
}
return NULL;
};
return NULL;
}
/**
** Add a new mapping (sound name to sound id) in the hash table
@ -98,7 +98,7 @@ CSound *SoundForName(const std::string &name)
return sound;
}
DebugPrint("Can't find sound `%s' in sound table\n" _C_ name.c_str());
return NULL;
return NULL;
}
/**

View file

@ -107,7 +107,7 @@ DisplayAutoLocker::~DisplayAutoLocker()
if (GameRunning && CPU_NUM > 1) {
DisplayUpdateLocker.UnLock();
}
};
}
//----------------------------------------------------------------------------
// Functions

View file

@ -593,7 +593,7 @@ void MissileDrawProxy::DrawMissile(const CViewport *vp) const
default:
this->Type->DrawMissileType(this->data.SpriteFrame, x, y);
break;
}
}
}
void MissileDrawProxy::operator=(const Missile* missile) {
@ -605,7 +605,7 @@ void MissileDrawProxy::operator=(const Missile* missile) {
} else {
this->data.SpriteFrame = missile->SpriteFrame;
}
};
}
/**
** Draw missile.
@ -638,7 +638,7 @@ void Missile::DrawMissile(const CViewport *vp) const
}
}
static bool MissileDrawLevelCompare(const Missile*const l,
static bool MissileDrawLevelCompare(const Missile*const l,
const Missile*const r)
{
if (l->Type->DrawLevel == r->Type->DrawLevel) {
@ -657,7 +657,7 @@ static bool MissileDrawLevelCompare(const Missile*const l,
**
** @return number of missiles returned in table
*/
int FindAndSortMissiles(const CViewport *vp,
int FindAndSortMissiles(const CViewport *vp,
Missile *table[], const int tablesize)
{
int nmissiles;
@ -692,7 +692,7 @@ int FindAndSortMissiles(const CViewport *vp,
return nmissiles;
}
int FindAndSortMissiles(const CViewport *vp,
int FindAndSortMissiles(const CViewport *vp,
MissileDrawProxy table[], const int tablesize)
{
Missile *buffer[MAX_MISSILES * 9];
@ -1327,7 +1327,7 @@ MissileType::MissileType(const std::string &ident) :
{
FiredSound.Sound = NULL;
ImpactSound.Sound = NULL;
};
}
/**
** Destructor.
@ -1672,7 +1672,7 @@ struct LandMineTargetFinder {
inline CUnit *FindOnTile(const CMapField *const mf) const
{
return mf->UnitCache.find(*this);
}
}
};
/**
@ -1687,10 +1687,10 @@ void MissileLandMine::Action()
if(LandMineTargetFinder(this->SourceUnit,
this->Type->CanHitOwner).FindOnTile(Map.Field(x,y)) != NULL) {
DebugPrint("Landmine explosion at %d,%d.\n" _C_ x _C_ y);
DebugPrint("Landmine explosion at %d,%d.\n" _C_ x _C_ y);
MissileHit(this);
this->TTL = 0;
return;
return;
}
if (!this->AnimWait--) {
NextMissileFrame(this, 1, 0);

View file

@ -529,7 +529,7 @@ void* CThread::threadFun (void *pThread)
ptr->Run ();
}
return NULL;
};
}
#endif
void CThread::Terminate ()
@ -585,7 +585,7 @@ int CThread::Wait ()
m_bRunning = false;
}
return 0;
};
}
void CThread::Exit ()
{

View file

@ -135,13 +135,13 @@ static inline const char* tolua_tocppstring (lua_State* L, int narg, const char*
const char* s = tolua_tostring(L, narg, def);
return s?s:"";
};
}
static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
const char* s = tolua_tofieldstring(L, lo, index, def);
return s?s:"";
};
}
#else
#define tolua_tocppstring tolua_tostring

View file

@ -20347,6 +20347,6 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
TOLUA_API int luaopen_stratagus (lua_State* tolua_S) {
return tolua_stratagus_open(tolua_S);
};
}
#endif

View file

@ -312,7 +312,7 @@ static int class_call_event(lua_State* L) {
};
tolua_error(L,"Attempt to call a non-callable object.",NULL);
return 0;
};
}
static int do_operator (lua_State* L, const char* op)
{

View file

@ -158,7 +158,7 @@ int push_table_instance(lua_State* L, int lo) {
};
return 0;
};
}
/* the equivalent of lua_is* for usertype */
static int lua_isusertype (lua_State* L, int lo, const char* type)

View file

@ -115,7 +115,7 @@ static void set_ubox(lua_State* L) {
lua_rawset(L,-4);
};
};
}
/* Map inheritance
* It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name'
@ -247,7 +247,7 @@ static int tolua_bnd_inherit (lua_State* L) {
/* l_obj[".c_instance"] = c_obj */
return 0;
};
}
#ifdef LUA_VERSION_NUM /* lua 5.1 */
static int tolua_bnd_setpeer(lua_State* L) {
@ -257,7 +257,7 @@ static int tolua_bnd_setpeer(lua_State* L) {
lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected.");
lua_error(L);
};
if (lua_isnil(L, -1)) {
lua_pop(L, 1);
@ -266,7 +266,7 @@ static int tolua_bnd_setpeer(lua_State* L) {
lua_setfenv(L, -2);
return 0;
};
}
static int tolua_bnd_getpeer(lua_State* L) {
@ -277,7 +277,7 @@ static int tolua_bnd_getpeer(lua_State* L) {
lua_pushnil(L);
};
return 1;
};
}
#endif
/* static int class_gc_event (lua_State* L); */
@ -513,7 +513,7 @@ static void push_collector(lua_State* L, const char* type, lua_CFunction col) {
lua_rawset(L,-3);
lua_pop(L, 1);
};
}
/* Map C class
* It maps a C class, setting the appropriate inheritance and super classes.
@ -532,7 +532,7 @@ TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name,
mapsuper(L,name,base);
lua_pushstring(L,lname);
push_collector(L, name, col);
/*
luaL_getmetatable(L,name);
@ -541,7 +541,7 @@ TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name,
lua_rawset(L,-3);
*/
luaL_getmetatable(L,name);
lua_rawset(L,-3); /* assign class metatable to module */
@ -555,7 +555,7 @@ TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name,
lua_rawset(L,-3);
lua_pop(L,1);
*/
}
@ -700,5 +700,5 @@ TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const ch
#else
lua_dobuffer(L, B, size, name);
#endif
};
}

View file

@ -130,7 +130,7 @@ void IconConfig::Load()
ExitFatal(-1);
}
#endif
};
}
/**
** Init the icons.

View file

@ -694,7 +694,7 @@ static bool CommandKey(int key)
if (KeyModifiers & ModifierAlt) {
ToggleShowBuilListMessages();
}
#endif
#endif
break;
case SDLK_TAB: // TAB toggles minimap.
@ -759,10 +759,10 @@ int HandleCheats(const std::string &input)
SetMessage("Cannot disable 'ai me' cheat");
#endif
} else {
for (int j = 0; j < ThisPlayer->TotalNumUnits; ++j) {
CUnit *guard = ThisPlayer->Units[j];
bool stand_ground =
bool stand_ground =
guard->CurrentAction() == UnitActionStandGround;
if ((stand_ground || guard->IsIdle()) &&
!guard->IsUnusable()) {
@ -1275,7 +1275,7 @@ int HoldClickDelay = 1000; /// Time to detect hold clicks.
static enum {
InitialMouseState, /// start state
ClickedMouseState, /// button is clicked
ClickedMouseState /// button is clicked
} MouseState; /// Current state of mouse
static int MouseX; /// Last mouse X position

View file

@ -620,7 +620,7 @@ static void DrawUnitInfo(CUnit *unit)
//
if (NumSelected == 1 && Selected[0] == unit) {
switch(unit->CurrentAction()) {
//
// Building training units.
//
@ -751,7 +751,7 @@ void DrawResources(void)
}
}
if (UI.Resources[FoodCost].TextX != -1) {
char tmp[128];
char tmp[128];
snprintf(tmp,sizeof(tmp), "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply);
label.SetFont(GameFont);
if (ThisPlayer->Supply < ThisPlayer->Demand) {
@ -789,7 +789,7 @@ public:
{
#ifdef DEBUG
showBuilList = false;
#endif
#endif
CleanMessages();
}
@ -800,7 +800,7 @@ public:
void ToggleShowMessages() {
show = !show;
};
#ifdef DEBUG
#ifdef DEBUG
void ToggleShowBuilListMessages() {
showBuilList = !showBuilList;
};
@ -879,7 +879,7 @@ void MessagesDisplay::DrawMessages()
PushClipping();
SetClipping(UI.MapArea.X + 8, UI.MapArea.Y + 8, Video.Width - 1,
Video.Height - 1);
}
}
snprintf(buffer, 256, "%s (%d/%d) Wait %lu [%d,%d]",
ThisPlayer->Ai->UnitTypeBuilt[z].Type->Name.c_str(),
@ -888,9 +888,9 @@ void MessagesDisplay::DrawMessages()
ThisPlayer->Ai->UnitTypeBuilt[z].Wait,
ThisPlayer->Ai->UnitTypeBuilt[z].X,
ThisPlayer->Ai->UnitTypeBuilt[z].Y);
label.DrawClip(UI.MapArea.X + 8,
UI.MapArea.Y + 8 +
UI.MapArea.Y + 8 +
z * (UI.MessageFont->Height() + 1),
buffer);
@ -905,12 +905,12 @@ void MessagesDisplay::DrawMessages()
int textHeight = MessagesCount * (UI.MessageFont->Height() + 1);
Uint32 color = Video.MapRGB(TheScreen->format, 38, 38, 78);
Video.FillTransRectangleClip(color, UI.MapArea.X + 7, UI.MapArea.Y + 7,
UI.MapArea.EndX - UI.MapArea.X - 16,
UI.MapArea.EndX - UI.MapArea.X - 16,
textHeight - MessagesScrollY + 1, 0x80);
Video.DrawRectangle(color, UI.MapArea.X + 6, UI.MapArea.Y + 6,
UI.MapArea.EndX - UI.MapArea.X - 15,
textHeight - MessagesScrollY + 2);
textHeight - MessagesScrollY + 2);
}
// Draw message line(s)
@ -921,12 +921,12 @@ void MessagesDisplay::DrawMessages()
Video.Height - 1);
}
/*
* Due parallel drawing we have to force message copy due temp
* std::string(Messages[z]) creation because
* Due parallel drawing we have to force message copy due temp
* std::string(Messages[z]) creation because
* char * pointer may change during text drawing.
*/
label.DrawClip(UI.MapArea.X + 8,
UI.MapArea.Y + 8 +
UI.MapArea.Y + 8 +
z * (UI.MessageFont->Height() + 1) - MessagesScrollY,
std::string(Messages[z]));
if (z == 0) {
@ -938,8 +938,8 @@ void MessagesDisplay::DrawMessages()
}
#ifdef DEBUG
}
#endif
#endif
}
}
@ -1264,7 +1264,7 @@ void DrawCosts(void)
if (UI.Resources[i].G) {
UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame,
x, UI.StatusLine.TextY);
x+= 20;
x+= 20;
}
x+=label.Draw(x, UI.StatusLine.TextY, Costs[i]);
if (x > Video.Width - 60) {

View file

@ -374,6 +374,7 @@ void ImageButton::draw(gcn::Graphics *graphics)
textX = getWidth() - 4;
break;
default:
textX = 0;
Assert(!"Unknown alignment.");
//throw GCN_EXCEPTION("Unknown alignment.");
}
@ -884,6 +885,7 @@ void MultiLineLabel::draw(gcn::Graphics *graphics)
textX = this->getWidth();
break;
default:
textX = 0;
Assert(!"Unknown alignment.");
//throw GCN_EXCEPTION("Unknown alignment.");
}
@ -898,6 +900,7 @@ void MultiLineLabel::draw(gcn::Graphics *graphics)
textY = this->getHeight() - (int)this->mTextRows.size() * this->getFont()->getHeight();
break;
default:
textY = 0;
Assert(!"Unknown alignment.");
//throw GCN_EXCEPTION("Unknown alignment.");
}

View file

@ -120,7 +120,7 @@ CUnitType::CUnitType() :
Vanishes(0), GroundAttack(0), ShoreBuilding(0), CanAttack(0),
BuilderOutside(0), BuilderLost(0), CanHarvest(0), Harvester(0),
Neutral(0), SelectableByRectangle(0), IsNotSelectable(0), Decoration(0),
Indestructible(0), Teleporter(0), Variable(NULL),
Indestructible(0), Teleporter(0), Variable(NULL),
GivesResource(0), Supply(0), Demand(0), FieldFlags(0), MovementMask(0),
Sprite(NULL), ShadowSprite(NULL)
{
@ -138,7 +138,7 @@ CUnitType::~CUnitType()
delete[] Variable;
BoolFlag.clear();
for (int i = 0; i < PlayerMax; ++i) {
delete[] Stats[i].Variables;
}
@ -172,7 +172,7 @@ CUnitType::~CUnitType()
bool CUnitType::CheckUserBoolFlags(char *BoolFlags) {
for (unsigned int i = 0; i < UnitTypeVar.GetNumberBoolFlag(); ++i) { // User defined flags
if (BoolFlags[i] != CONDITION_TRUE &&
if (BoolFlags[i] != CONDITION_TRUE &&
((BoolFlags[i] == CONDITION_ONLY) ^ (BoolFlag[i].value))) {
return false;
}
@ -205,7 +205,7 @@ void UpdateStats(int reset)
if (!stats->Variables) {
stats->Variables = new CVariable[UnitTypeVar.GetNumberVariable()];
}
memcpy(stats->Variables, type->Variable,
memcpy(stats->Variables, type->Variable,
UnitTypeVar.GetNumberVariable() * sizeof(*type->Variable));
}
}
@ -581,12 +581,12 @@ void CUnitTypeVar::Init()
for (unsigned int i = 0; i < UnitTypes.size(); ++i) { // adjust array for unit already defined
UnitTypes[i]->BoolFlag.resize(new_size);
}
};
}
void CUnitTypeVar::Clear()
{
Variable.clear();
for (std::vector<CDecoVar *>::iterator it = DecoVar.begin();
it != DecoVar.end(); ++it) {
delete (*it);

View file

@ -831,6 +831,9 @@ void CGraphic::Flip()
unsigned int p0 = s->pitch;
unsigned int p1 = Surface->pitch;
const int width = s->w;
#ifndef _MSC_VER
j = 0;
#endif
for (i = 0; i < s->h; ++i) {
#ifdef _MSC_VER
for (j = 0; j < width; ++j) {