Fixed bug #992785: Returning to Depot without resources
Renamed Value to ResourcesHeld for units. Add Recast:1 as to not interfere with Resources. Suicide Click uses static int for tracking not old Value.
This commit is contained in:
parent
c3480218e8
commit
37e5ad69d4
21 changed files with 89 additions and 73 deletions
|
@ -34,6 +34,7 @@
|
|||
<ul>
|
||||
<p><li>2.2 Released<p>
|
||||
<ul>
|
||||
<li>Fixed bug #992785: Returning to Depot without resources (from Russell Smith).
|
||||
<li>Fixed bug #998762: Gold mine not destroyed when empty (from Russell Smith).
|
||||
<li>Fixed bug #994321: 32bpp images flipped incorrectly (from Jimmy Salmon).
|
||||
<li>Fixed bug #994987: game unpauses when minimized (from Jimmy Salmon).
|
||||
|
|
|
@ -228,7 +228,7 @@ void HandleActionBuild(Unit* unit)
|
|||
b = OnTopDetails(build, ontop->Type);
|
||||
Assert(b);
|
||||
if (b->Data.OnTop.ReplaceOnBuild) {
|
||||
build->Value = ontop->Value; // We capture the value of what is beneath.
|
||||
build->ResourcesHeld = ontop->ResourcesHeld; // We capture the value of what is beneath.
|
||||
RemoveUnit(ontop, NULL); // Destroy building beneath
|
||||
UnitLost(ontop);
|
||||
UnitClearOrders(ontop);
|
||||
|
@ -383,7 +383,7 @@ void HandleActionBuilded(Unit* unit)
|
|||
unit->Data.Resource.Active = 0;
|
||||
// Has StartingResources, Use those
|
||||
if (type->StartingResources) {
|
||||
unit->Value = type->StartingResources;
|
||||
unit->ResourcesHeld = type->StartingResources;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ static void LoseResource(Unit* unit, const Unit* source)
|
|||
//
|
||||
// If we are loaded first search for a depot.
|
||||
//
|
||||
if (unit->Value && (depot = FindDeposit(unit, unit->X, unit->Y,
|
||||
if (unit->ResourcesHeld && (depot = FindDeposit(unit, unit->X, unit->Y,
|
||||
1000, unit->CurrentResource))) {
|
||||
if (unit->Container) {
|
||||
DropOutNearest(unit, depot->X + depot->Type->TileWidth / 2,
|
||||
|
@ -382,14 +382,14 @@ static int GatherResource(Unit* unit)
|
|||
addload = resinfo->ResourceCapacity;
|
||||
}
|
||||
// Make sure we don't bite more than we can chew.
|
||||
if (unit->Value + addload > resinfo->ResourceCapacity) {
|
||||
addload = resinfo->ResourceCapacity - unit->Value;
|
||||
if (unit->ResourcesHeld + addload > resinfo->ResourceCapacity) {
|
||||
addload = resinfo->ResourceCapacity - unit->ResourcesHeld;
|
||||
}
|
||||
|
||||
if (resinfo->TerrainHarvester) {
|
||||
unit->Value += addload;
|
||||
unit->ResourcesHeld += addload;
|
||||
|
||||
if (addload && unit->Value == resinfo->ResourceCapacity) {
|
||||
if (addload && unit->ResourcesHeld == resinfo->ResourceCapacity) {
|
||||
MapRemoveWood(unit->Orders->X, unit->Orders->Y);
|
||||
}
|
||||
} else {
|
||||
|
@ -400,26 +400,26 @@ static int GatherResource(Unit* unit)
|
|||
}
|
||||
|
||||
Assert(source);
|
||||
Assert(source->Value <= 655350);
|
||||
Assert(source->ResourcesHeld <= 655350);
|
||||
|
||||
//
|
||||
// Target is not dead, getting resources.
|
||||
//
|
||||
if (UnitVisibleAsGoal(source, unit->Player)) {
|
||||
// Don't load more that there is.
|
||||
if (addload > source->Value) {
|
||||
addload = source->Value;
|
||||
if (addload > source->ResourcesHeld) {
|
||||
addload = source->ResourcesHeld;
|
||||
}
|
||||
|
||||
unit->Value += addload;
|
||||
source->Value -= addload;
|
||||
unit->ResourcesHeld += addload;
|
||||
source->ResourcesHeld -= addload;
|
||||
}
|
||||
|
||||
//
|
||||
// End of resource: destroy the resource.
|
||||
// FIXME: implement depleted resources.
|
||||
//
|
||||
if ((!UnitVisibleAsGoal(source, unit->Player)) || (source->Value == 0)) {
|
||||
if ((!UnitVisibleAsGoal(source, unit->Player)) || (source->ResourcesHeld == 0)) {
|
||||
DebugPrint("Resource is destroyed for unit %d\n" _C_ unit->Slot);
|
||||
uins = source->UnitInside;
|
||||
//
|
||||
|
@ -443,7 +443,7 @@ static int GatherResource(Unit* unit)
|
|||
}
|
||||
}
|
||||
if (resinfo->TerrainHarvester) {
|
||||
if (unit->Value == resinfo->ResourceCapacity) {
|
||||
if (unit->ResourcesHeld == resinfo->ResourceCapacity) {
|
||||
// Mark as complete.
|
||||
unit->Data.ResWorker.DoneHarvesting = 1;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ static int GatherResource(Unit* unit)
|
|||
}
|
||||
|
||||
if (resinfo->HarvestFromOutside && !resinfo->TerrainHarvester) {
|
||||
if ((unit->Value == resinfo->ResourceCapacity) || (source == NULL)) {
|
||||
if ((unit->ResourcesHeld == resinfo->ResourceCapacity) || (source == NULL)) {
|
||||
// Mark as complete.
|
||||
unit->Data.ResWorker.DoneHarvesting = 1;
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ static int GatherResource(Unit* unit)
|
|||
}
|
||||
|
||||
if ((!resinfo->HarvestFromOutside) && (!resinfo->TerrainHarvester)) {
|
||||
return unit->Value == resinfo->ResourceCapacity && source;
|
||||
return unit->ResourcesHeld == resinfo->ResourceCapacity && source;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,13 +498,13 @@ static int StopGathering(Unit* unit)
|
|||
unit->Orders[0].Arg1 = (void*)((unit->X << 16) | unit->Y);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!unit->Value) {
|
||||
if (!unit->ResourcesHeld) {
|
||||
DebugPrint("Unit %d is empty???\n" _C_ unit->Slot);
|
||||
}
|
||||
#endif
|
||||
// Find and send to resource deposit.
|
||||
if (!(depot = FindDeposit(unit, unit->X, unit->Y, 1000, unit->CurrentResource)) ||
|
||||
!unit->Value) {
|
||||
!unit->ResourcesHeld) {
|
||||
if (!(resinfo->HarvestFromOutside || resinfo->TerrainHarvester)) {
|
||||
Assert(unit->Container);
|
||||
DropOutOnSide(unit, LookingW, source->Type->TileWidth,
|
||||
|
@ -602,10 +602,10 @@ static int MoveToDepot(Unit* unit)
|
|||
// Update resource.
|
||||
//
|
||||
unit->Player->Resources[resinfo->FinalResource] +=
|
||||
(unit->Value * unit->Player->Incomes[resinfo->FinalResource]) / 100;
|
||||
(unit->ResourcesHeld * unit->Player->Incomes[resinfo->FinalResource]) / 100;
|
||||
unit->Player->TotalResources[resinfo->FinalResource] +=
|
||||
(unit->Value * unit->Player->Incomes[resinfo->FinalResource]) / 100;
|
||||
unit->Value = 0;
|
||||
(unit->ResourcesHeld * unit->Player->Incomes[resinfo->FinalResource]) / 100;
|
||||
unit->ResourcesHeld = 0;
|
||||
|
||||
unit->Wait = resinfo->WaitAtDepot / SpeedResourcesReturn[resinfo->ResourceId];
|
||||
if (!unit->Wait) {
|
||||
|
@ -691,8 +691,8 @@ void ResourceGiveUp(Unit* unit)
|
|||
unit->SubAction = 0;
|
||||
if (unit->CurrentResource &&
|
||||
unit->Type->ResInfo[unit->CurrentResource]->LoseResources &&
|
||||
unit->Value < unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity) {
|
||||
unit->Value = 0;
|
||||
unit->ResourcesHeld < unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity) {
|
||||
unit->ResourcesHeld = 0;
|
||||
unit->CurrentResource = 0;
|
||||
}
|
||||
if (unit->Orders[0].Goal) {
|
||||
|
@ -722,13 +722,13 @@ void HandleActionResource(Unit* unit)
|
|||
}
|
||||
if (newres != unit->CurrentResource) {
|
||||
// Drop other resources.
|
||||
unit->Value = 0;
|
||||
unit->ResourcesHeld = 0;
|
||||
}
|
||||
if ((unit->CurrentResource = newres)) {
|
||||
NewResetPath(unit);
|
||||
unit->SubAction = SUB_MOVE_TO_RESOURCE;
|
||||
} else {
|
||||
unit->Value = 0;
|
||||
unit->ResourcesHeld = 0;
|
||||
ResourceGiveUp(unit);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,8 +68,13 @@ void HandleActionReturnGoods(Unit* unit)
|
|||
// Select target to return goods.
|
||||
//
|
||||
Assert(type->Harvester );
|
||||
if ((!unit->CurrentResource) && (!unit->Value)) {
|
||||
if (!unit->CurrentResource ||
|
||||
!(unit->ResourcesHeld == unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity &&
|
||||
unit->Type->ResInfo[unit->CurrentResource]->LoseResources)) {
|
||||
DebugPrint("Unit can't return resources, it doesn't carry any.\n");
|
||||
NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y, "No Resources to Return.");
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
return;
|
||||
}
|
||||
if (!unit->Orders[0].Goal) {
|
||||
if (!(destu = FindDeposit(unit, unit->X, unit->Y, 1000,
|
||||
|
|
|
@ -210,7 +210,7 @@ void HandleActionSpellCast(Unit* unit)
|
|||
}
|
||||
// FIXME FIXME FIXME: Check if already in range and skip straight to 2(casting)
|
||||
NewResetPath(unit);
|
||||
unit->Value = 0; // repeat spell on next pass? (defaults to `no')
|
||||
unit->ReCast = 0; // repeat spell on next pass? (defaults to `no')
|
||||
unit->SubAction = 1;
|
||||
// FALL THROUGH
|
||||
case 1: // Move to the target.
|
||||
|
@ -228,10 +228,10 @@ void HandleActionSpellCast(Unit* unit)
|
|||
if (flags & AnimationMissile) {
|
||||
// FIXME: what todo, if unit/goal is removed?
|
||||
if (unit->Orders[0].Goal && !UnitVisibleAsGoal(unit->Orders->Goal, unit->Player)) {
|
||||
unit->Value = 0;
|
||||
unit->ReCast = 0;
|
||||
} else {
|
||||
spell = unit->Orders[0].Arg1;
|
||||
unit->Value = SpellCast(unit, spell, unit->Orders[0].Goal,
|
||||
unit->ReCast = SpellCast(unit, spell, unit->Orders[0].Goal,
|
||||
unit->Orders[0].X, unit->Orders[0].Y);
|
||||
}
|
||||
}
|
||||
|
@ -241,14 +241,14 @@ void HandleActionSpellCast(Unit* unit)
|
|||
} else {
|
||||
// FIXME: what todo, if unit/goal is removed?
|
||||
if (unit->Orders[0].Goal && !UnitVisibleAsGoal(unit->Orders->Goal, unit->Player)) {
|
||||
unit->Value = 0;
|
||||
unit->ReCast = 0;
|
||||
} else {
|
||||
spell = unit->Orders[0].Arg1;
|
||||
unit->Value = SpellCast(unit, spell, unit->Orders[0].Goal,
|
||||
unit->ReCast = SpellCast(unit, spell, unit->Orders[0].Goal,
|
||||
unit->Orders[0].X, unit->Orders[0].Y);
|
||||
}
|
||||
}
|
||||
if (!unit->Value) {
|
||||
if (!unit->ReCast) {
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
unit->Wait = 1;
|
||||
|
|
|
@ -419,8 +419,8 @@ static void HandleUnitAction(Unit* unit)
|
|||
}
|
||||
if (unit->CurrentResource) {
|
||||
if (unit->Type->ResInfo[unit->CurrentResource]->LoseResources &&
|
||||
unit->Value < unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity) {
|
||||
unit->Value = 0;
|
||||
unit->ResourcesHeld < unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity) {
|
||||
unit->ResourcesHeld = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -834,7 +834,7 @@ void CommandReturnGoods(Unit* unit, Unit* goal, int flush)
|
|||
//
|
||||
if (!unit->Removed && unit->Orders[0].Action != UnitActionDie) {
|
||||
// FIXME: more races, could happen with many orders in queue.
|
||||
if (!unit->Type->Building && !unit->Type->Harvester && !unit->Value) {
|
||||
if (!unit->Type->Building && !unit->Type->Harvester && !unit->ResourcesHeld) {
|
||||
ClearSavedAction(unit);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -906,7 +906,7 @@ static void AiCollectResources(void)
|
|||
//
|
||||
// Send workers with resources back home.
|
||||
//
|
||||
if (unit->Value && c) {
|
||||
if (unit->ResourcesHeld && c) {
|
||||
units_with_resource[num_units_with_resource[c]++][c] = unit;
|
||||
CommandReturnGoods(unit, 0, FlushCommands);
|
||||
total_harvester++;
|
||||
|
|
|
@ -292,7 +292,7 @@ static void EditUnitInternal(int x, int y, UnitType* type, Player* player)
|
|||
// FIXME: vladi: should check place when mirror editing is enabled...?
|
||||
unit = MakeUnitAndPlace(x, y, type, player);
|
||||
if (type->GivesResource) {
|
||||
unit->Value = DefaultResourceAmounts[type->GivesResource];
|
||||
unit->ResourcesHeld = DefaultResourceAmounts[type->GivesResource];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@ static void ShowUnitInfo(const Unit* unit)
|
|||
unit->Type->Name, unit->Player->Player,
|
||||
unit->Active ? "active" : "passive");
|
||||
if (unit->Type->GivesResource) {
|
||||
sprintf(buf + i," Amount %d", unit->Value);
|
||||
sprintf(buf + i," Amount %d", unit->ResourcesHeld);
|
||||
}
|
||||
SetStatusLine(buf);
|
||||
}
|
||||
|
|
|
@ -687,13 +687,13 @@ static void EditorRandomizeUnit(const char* unit_type, int count, int value)
|
|||
|
||||
// FIXME: can overlap units
|
||||
unit = MakeUnitAndPlace(rx, ry , type, &Players[15]);
|
||||
unit->Value = value;
|
||||
unit->ResourcesHeld = value;
|
||||
unit = MakeUnitAndPlace(mx - rx - tw, ry, type, &Players[15]);
|
||||
unit->Value = value;
|
||||
unit->ResourcesHeld = value;
|
||||
unit = MakeUnitAndPlace(rx, my - ry - th, type, &Players[15]);
|
||||
unit->Value = value;
|
||||
unit->ResourcesHeld = value;
|
||||
unit = MakeUnitAndPlace(mx - rx - tw, mx - ry - th, type, &Players[15]);
|
||||
unit->Value = value;
|
||||
unit->ResourcesHeld = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ struct _unit_ {
|
|||
int GroupId; ///< unit belongs to this group id
|
||||
int LastGroup; ///< unit belongs to this last group
|
||||
|
||||
int Value; ///< value used for much
|
||||
int ResourcesHeld; ///< Resources Held by a unit
|
||||
|
||||
unsigned SubAction : 8; ///< sub-action of unit
|
||||
unsigned Wait; ///< action counter
|
||||
|
@ -600,6 +600,8 @@ struct _unit_ {
|
|||
unsigned Reset : 1; ///< can process new command
|
||||
unsigned Blink : 3; ///< Let selection rectangle blink
|
||||
unsigned Moving : 1; ///< The unit is moving
|
||||
unsigned ReCast : 1; ///< Recast again next cycle
|
||||
|
||||
/** set to random 1..100 when MakeUnit()
|
||||
** used for fancy buildings
|
||||
*/
|
||||
|
|
|
@ -1295,7 +1295,7 @@ pawn:
|
|||
DebugPrint("empty resource IN PUD.\n");
|
||||
v = 10;
|
||||
}
|
||||
unit->Value=v*2500;
|
||||
unit->ResourcesHeld = v*2500;
|
||||
} else {
|
||||
// active/inactive AI units!!
|
||||
// Johns: it is better to have active buildings
|
||||
|
@ -1544,8 +1544,8 @@ static void PudSaveUnits(gzFile f)
|
|||
buf[4]=j;
|
||||
buf[5]=Units[i]->Player->Player;
|
||||
if( Units[i]->Type->GivesResource ) {
|
||||
buf[6]=(Units[i]->Value/2500) >> 0;
|
||||
buf[7]=(Units[i]->Value/2500) >> 8;
|
||||
buf[6]=(Units[i]->ResourcesHeld/2500) >> 0;
|
||||
buf[7]=(Units[i]->ResourcesHeld/2500) >> 8;
|
||||
} else {
|
||||
buf[6]=!Units[i]->Active;
|
||||
buf[7]=0;
|
||||
|
|
|
@ -93,21 +93,22 @@ void UnSelectAll(void)
|
|||
*/
|
||||
static void HandleSuicideClick(Unit* unit)
|
||||
{
|
||||
static int NumClicks = 0;
|
||||
|
||||
Assert(unit->Type->ClicksToExplode);
|
||||
if (GameObserve) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumSelected == 1 && Selected[0] == unit) {
|
||||
unit->Value++;
|
||||
NumClicks++;
|
||||
} else {
|
||||
unit->Value = 1;
|
||||
NumClicks = 1;
|
||||
}
|
||||
|
||||
// FIXME: make this configurable
|
||||
if (unit->Value == unit->Type->ClicksToExplode) {
|
||||
if (NumClicks == unit->Type->ClicksToExplode) {
|
||||
SendCommandDismiss(unit);
|
||||
unit->Value = 0;
|
||||
NumClicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,10 +316,10 @@ static void DrawUnitInfo(const Unit* unit)
|
|||
sprintf(buf, "%s Left:", DefaultResourceNames[type->GivesResource]);
|
||||
VideoDrawText(x + 108 - VideoTextLength(GameFont, buf), y + 8 + 78,
|
||||
GameFont, buf);
|
||||
if (!unit->Value) {
|
||||
if (!unit->ResourcesHeld) {
|
||||
VideoDrawText(x + 108, y + 8 + 78, GameFont, "(none)");
|
||||
} else {
|
||||
VideoDrawNumber(x + 108, y + 8 + 78, GameFont, unit->Value);
|
||||
VideoDrawNumber(x + 108, y + 8 + 78, GameFont, unit->ResourcesHeld);
|
||||
}
|
||||
if (unit->Orders[0].Action != UnitActionBuilded) {
|
||||
return;
|
||||
|
@ -582,8 +582,8 @@ static void DrawUnitInfo(const Unit* unit)
|
|||
DrawStats(x + 108, y + 8 + 125, stats->Speed, type->_Speed);
|
||||
|
||||
// FIXME: Ugly hack.
|
||||
if (unit->Type->Harvester && unit->Value) {
|
||||
sprintf(buf, "Carry: %d %s", unit->Value,
|
||||
if (unit->Type->Harvester && unit->ResourcesHeld) {
|
||||
sprintf(buf, "Carry: %d %s", unit->ResourcesHeld,
|
||||
DefaultResourceNames[unit->CurrentResource]);
|
||||
VideoDrawText(x + 61, y + 8 + 141, GameFont, buf);
|
||||
}
|
||||
|
|
|
@ -5286,7 +5286,7 @@ void EditorEditResource(void)
|
|||
|
||||
sprintf(buf2,"Amount of %s:",DefaultResourceNames[UnitUnderCursor->Type->GivesResource]);
|
||||
menu->Items[0].D.Text.text = buf2;
|
||||
sprintf(buf, "%d~!_", UnitUnderCursor->Value);
|
||||
sprintf(buf, "%d~!_", UnitUnderCursor->ResourcesHeld);
|
||||
menu->Items[1].D.Input.buffer = buf;
|
||||
menu->Items[1].D.Input.nch = strlen(buf) - 3;
|
||||
menu->Items[1].D.Input.maxch = 6;
|
||||
|
@ -5339,7 +5339,7 @@ static void EditorEditResourceOk(void)
|
|||
ProcessMenu("menu-editor-error", 1);
|
||||
menu->Items[1].D.Text.text = NULL;
|
||||
} else {
|
||||
UnitUnderCursor->Value = value;
|
||||
UnitUnderCursor->ResourcesHeld = value;
|
||||
GameMenuReturn();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ void DoRightButton(int sx, int sy)
|
|||
if (unit->Type->Harvester) {
|
||||
if (dest) {
|
||||
// Return a loaded harvester to deposit
|
||||
if (unit->Value > 0 &&
|
||||
if (unit->ResourcesHeld > 0 &&
|
||||
dest->Type->CanStore[unit->CurrentResource] &&
|
||||
dest->Player == unit->Player) {
|
||||
dest->Blink = 4;
|
||||
|
@ -223,7 +223,7 @@ void DoRightButton(int sx, int sy)
|
|||
// Go and harvest from a building
|
||||
if ((res = dest->Type->GivesResource) &&
|
||||
unit->Type->ResInfo[res] &&
|
||||
unit->Value < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
unit->ResourcesHeld < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
dest->Type->CanHarvest &&
|
||||
(dest->Player == unit->Player ||
|
||||
(dest->Player->Player == PlayerNumNeutral))) {
|
||||
|
@ -239,7 +239,7 @@ void DoRightButton(int sx, int sy)
|
|||
IsMapFieldExplored(unit->Player, x, y) &&
|
||||
ForestOnMap(x, y) &&
|
||||
((unit->CurrentResource != res) ||
|
||||
(unit->Value < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
(unit->ResourcesHeld < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
SendCommandResourceLoc(unit, x, y,flush);
|
||||
break;
|
||||
}
|
||||
|
@ -1029,7 +1029,7 @@ static int SendResource(int sx, int sy)
|
|||
if (dest &&
|
||||
(res = dest->Type->GivesResource) &&
|
||||
unit->Type->ResInfo[res] &&
|
||||
unit->Value < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
unit->ResourcesHeld < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
dest->Type->CanHarvest &&
|
||||
(dest->Player == unit->Player ||
|
||||
(dest->Player->Player == PlayerMax - 1))) {
|
||||
|
@ -1043,9 +1043,9 @@ static int SendResource(int sx, int sy)
|
|||
unit->Type->ResInfo[res]->TerrainHarvester &&
|
||||
IsMapFieldExplored(unit->Player, x, y) &&
|
||||
ForestOnMap(x, y) &&
|
||||
Selected[i]->Value < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
Selected[i]->ResourcesHeld < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
((unit->CurrentResource != res) ||
|
||||
(unit->Value < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
(unit->ResourcesHeld < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
SendCommandResourceLoc(unit, x, y,
|
||||
!(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
|
|
|
@ -1540,6 +1540,7 @@ static int CclDefineUI(lua_State* l)
|
|||
} else if (!strcmp(value, "network-diplomacy-button")) {
|
||||
button = &ui->NetworkDiplomacyButton;
|
||||
} else {
|
||||
button = NULL;
|
||||
LuaError(l, "Unsupported tag: %s" _C_ value);
|
||||
}
|
||||
|
||||
|
|
|
@ -785,8 +785,8 @@ static int CclUnit(lua_State* l)
|
|||
unit->GroupId = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "last-group")) {
|
||||
unit->LastGroup = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "value")) {
|
||||
unit->Value = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "resources-held")) {
|
||||
unit->ResourcesHeld = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "current-resource")) {
|
||||
lua_pushvalue(l, j + 1);
|
||||
unit->CurrentResource = CclGetResourceByName(l);
|
||||
|
@ -805,6 +805,9 @@ static int CclUnit(lua_State* l)
|
|||
} else if (!strcmp(value, "moving")) {
|
||||
unit->Moving = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "re-cast")) {
|
||||
unit->ReCast = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "boarded")) {
|
||||
unit->Boarded = 1;
|
||||
--j;
|
||||
|
|
|
@ -966,9 +966,9 @@ void UnitLost(Unit* unit)
|
|||
|
||||
// Destroy resource-platform, must re-make resource patch.
|
||||
if ((b = OnTopDetails(unit, NULL)) != NULL) {
|
||||
if (b->Data.OnTop.ReplaceOnDie && (unit->Type->GivesResource && unit->Value != 0)) {
|
||||
if (b->Data.OnTop.ReplaceOnDie && (unit->Type->GivesResource && unit->ResourcesHeld != 0)) {
|
||||
temp = MakeUnitAndPlace(unit->X, unit->Y, b->Data.OnTop.Parent, &Players[PlayerNumNeutral]);
|
||||
temp->Value = unit->Value;
|
||||
temp->ResourcesHeld = unit->ResourcesHeld;
|
||||
}
|
||||
}
|
||||
Assert(player->NumBuildings <= UnitMax);
|
||||
|
@ -2909,7 +2909,7 @@ void LetUnitDie(Unit* unit)
|
|||
unit->Orders[0].Action == UnitActionBuilded &&
|
||||
unit->Data.Builded.Worker) {
|
||||
// Restore value for oil-patch
|
||||
unit->Value = unit->Data.Builded.Worker->Value;
|
||||
unit->ResourcesHeld = unit->Data.Builded.Worker->ResourcesHeld;
|
||||
}
|
||||
|
||||
DestroyAllInside(unit);
|
||||
|
@ -3713,7 +3713,7 @@ void SaveUnit(const Unit* unit, CLFile* file)
|
|||
CLprintf(file, "\"group-id\", %d,\n ", unit->GroupId);
|
||||
CLprintf(file, "\"last-group\", %d,\n ", unit->LastGroup);
|
||||
|
||||
CLprintf(file, "\"value\", %d,\n ", unit->Value);
|
||||
CLprintf(file, "\"resources-held\", %d,\n ", unit->ResourcesHeld);
|
||||
if (unit->CurrentResource) {
|
||||
CLprintf(file, "\"current-resource\", \"%s\",\n ",
|
||||
DefaultResourceNames[unit->CurrentResource]);
|
||||
|
@ -3729,6 +3729,9 @@ void SaveUnit(const Unit* unit, CLFile* file)
|
|||
if (unit->Moving) {
|
||||
CLprintf(file, " \"moving\",");
|
||||
}
|
||||
if (unit->ReCast) {
|
||||
CLprintf(file, " \"re-cast\",");
|
||||
}
|
||||
if (unit->Boarded) {
|
||||
CLprintf(file, " \"boarded\",");
|
||||
}
|
||||
|
|
|
@ -1092,10 +1092,10 @@ static void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
|
|||
|
||||
// Resources.
|
||||
if (type->GivesResource) {
|
||||
unit->Variable[RESSOURCE_INDEX].Value = unit->Value;
|
||||
unit->Variable[RESSOURCE_INDEX].Value = unit->ResourcesHeld;
|
||||
unit->Variable[RESSOURCE_INDEX].Max = 655350; // FIXME use better value ?
|
||||
} else if (type->Harvester && unit->CurrentResource) {
|
||||
unit->Variable[RESSOURCE_INDEX].Value = unit->Value;
|
||||
unit->Variable[RESSOURCE_INDEX].Value = unit->ResourcesHeld;
|
||||
unit->Variable[RESSOURCE_INDEX].Max = type->ResInfo[unit->CurrentResource]->ResourceCapacity;
|
||||
}
|
||||
|
||||
|
@ -1970,7 +1970,7 @@ void DrawUnit(const Unit* unit)
|
|||
#endif
|
||||
if (type->Harvester && unit->CurrentResource) {
|
||||
resinfo = type->ResInfo[unit->CurrentResource];
|
||||
if (unit->Value) {
|
||||
if (unit->ResourcesHeld) {
|
||||
if (resinfo->SpriteWhenLoaded) {
|
||||
sprite = resinfo->SpriteWhenLoaded;
|
||||
#ifdef USE_OPENGL
|
||||
|
|
|
@ -402,7 +402,7 @@ Unit* ResourceOnMap(int tx, int ty, int resource)
|
|||
n = UnitCacheOnTile(tx, ty, table);
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (UnitUnusable(table[i]) || !table[i]->Type->CanHarvest ||
|
||||
table[i]->Value == 0) {
|
||||
table[i]->ResourcesHeld == 0) {
|
||||
continue;
|
||||
}
|
||||
if (table[i]->Type->GivesResource == resource) {
|
||||
|
|
Loading…
Reference in a new issue