[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/stratagus unit.c
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src/stratagus unit.c |
Date: |
1 Jan 2004 10:27:55 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/01 10:27:54
Modified files:
src/stratagus : unit.c
Log message:
Fixed income improvements when a unit is lost
Patches:
Index: stratagus/src/stratagus/unit.c
diff -u stratagus/src/stratagus/unit.c:1.349
stratagus/src/stratagus/unit.c:1.350
--- stratagus/src/stratagus/unit.c:1.349 Sat Dec 20 16:33:20 2003
+++ stratagus/src/stratagus/unit.c Thu Jan 1 10:27:53 2004
@@ -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
//
-/address@hidden unit.c - The units. */
+/address@hidden unit.c - The units. */
//
-// (c) Copyright 1998-2003 by Lutz Sammer
+// (c) Copyright 1998-2004 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,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.c,v 1.349 2003/12/20 05:33:20 jsalmon3 Exp $
+// $Id: unit.c,v 1.350 2003/12/31 23:27:53 jsalmon3 Exp $
//@{
@@ -739,11 +739,11 @@
}
/**
-** Update informations for lost units.
+** Update information for lost units.
**
-** @param unit Pointer to unit.
+** @param unit Pointer to unit.
**
-** @note Also called by ChangeUnitOwner
+** @note Also called by ChangeUnitOwner
*/
global void UnitLost(Unit* unit)
{
@@ -755,10 +755,10 @@
DebugCheck(!unit);
player = unit->Player;
- DebugCheck(!player); // Next code didn't
support no player!
+ DebugCheck(!player); // Next code didn't support no player!
//
- // Call back to AI, for killed or lost units.
+ // Call back to AI, for killed or lost units.
//
if (player && player->AiEnabled) {
AiUnitKilled(unit);
@@ -772,7 +772,7 @@
}
//
- // Remove the unit from the player's units table.
+ // Remove the unit from the player's units table.
//
type = unit->Type;
if (player && !type->Vanishes) {
@@ -796,21 +796,21 @@
//
- // Handle unit demand. (Currently only food supported.)
+ // Handle unit demand. (Currently only food supported.)
//
if (type->Demand) {
player->Demand -= type->Demand;
if (player == ThisPlayer) {
- MustRedraw |= RedrawResources; // update food
+ MustRedraw |= RedrawResources; // update food
// FIXME: MustRedraw |= RedrawFood;
}
}
//
- // Update informations.
+ // Update information.
//
if (unit->Orders[0].Action != UnitActionBuilded) {
- if (type->Supply) {
// supply
+ if (type->Supply) {
player->Supply -= type->Supply;
if (player == ThisPlayer) {
MustRedraw |= RedrawResources;
@@ -819,12 +819,12 @@
}
//
- // Handle income improvements, look if a player
looses a building
- // which have given him a better income, find the
next lesser
- // income.
+ // Handle income improvements, look if a player loses a
building
+ // which have given him a better income, find the next best
+ // income.
//
for (i = 1; i < MaxCosts; ++i) {
- if (type->ImproveIncomes[i] == player->Incomes[i]) {
+ if (player->Incomes[i] && type->ImproveIncomes[i] ==
player->Incomes[i]) {
int m;
int j;
@@ -834,7 +834,7 @@
m =
player->Units[j]->Type->ImproveIncomes[i];
}
}
- player->Incomes[WoodCost] = m;
+ player->Incomes[i] = m;
if (player == ThisPlayer) {
MustRedraw |= RedrawInfoPanel;
}
@@ -843,7 +843,7 @@
}
//
- // Handle research cancels.
+ // Handle research cancels.
//
if (unit->Orders[0].Action == UnitActionResearch) {
unit->Player->UpgradeTimers.Upgrades[unit->Data.Research.Upgrade - Upgrades] =
0;
@@ -851,9 +851,9 @@
DebugLevel0Fn("Lost %s(%d)\n" _C_ unit->Type->Ident _C_
UnitNumber(unit));
- // Destroy resource-platform, must re-make resource patch.
+ // Destroy resource-platform, must re-make resource patch.
if (type->MustBuildOnTop && unit->Value > 0) {
- temp = MakeUnitAndPlace(unit->X, unit->Y, type->MustBuildOnTop,
&Players[15]);
+ temp = MakeUnitAndPlace(unit->X, unit->Y, type->MustBuildOnTop,
&Players[PlayerMax - 1]);
temp->Value = unit->Value;
}
DebugCheck(player->NumBuildings > UnitMax);
@@ -862,14 +862,16 @@
}
/**
-** FIXME: Docu
+** FIXME: Docu
+**
+** @param unit FIXME: docu
*/
global void UnitClearOrders(Unit *unit)
{
int i;
//
- // Release all references of the unit.
+ // Release all references of the unit.
//
for (i = unit->OrderCount; i-- > 0;) {
if (unit->Orders[i].Goal) {
@@ -2424,10 +2426,10 @@
// Look if there is a mine
//
if ((mine = ResourceOnMap(x, y, resource)) &&
- (mine->Type->CanHarvest) &&
- ((mine->Player->Player ==
PlayerMax - 1)||
- (mine->Player == unit->Player)||
- (IsAllied(unit->Player,
mine)))) {
+ mine->Type->CanHarvest &&
+ (mine->Player->Player ==
PlayerMax - 1 ||
+ mine->Player ==
unit->Player ||
+ IsAllied(unit->Player,
mine))) {
if (destu) {
n = max(abs(destx - x),
abs(desty - y));
if (n < bestd) {
@@ -2904,7 +2906,11 @@
unsigned long lastattack;
if (!damage) { // Can now
happen by splash damage
- DebugLevel0Fn("Warning no damage, try to fix by caller?\n");
+#ifdef DEBUG
+ if (!GodMode) {
+ DebugLevel0Fn("Warning no damage, try to fix by
caller?\n");
+ }
+#endif
return;
}
@@ -3723,7 +3729,7 @@
int RunStart;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.349 2003/12/20
05:33:20 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.350 2003/12/31
23:27:53 jsalmon3 Exp $\n\n");
//
// Local variables
- [Stratagus-CVS] stratagus/src/stratagus unit.c,
address@hidden <=