Corrected counting of unit-types of the player.

This commit is contained in:
johns 2001-04-27 18:58:30 +00:00
parent fe17bd22aa
commit 5bde80c5fc
3 changed files with 12 additions and 0 deletions

View file

@ -185,6 +185,7 @@ local int ChopWood(Unit* unit)
//
if( !--unit->Value ) {
// Have wood
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==UnitTypeOrcWorker ) {
unit->Type=UnitTypeOrcWorkerWithWood;
} else if( unit->Type==UnitTypeHumanWorker ) {
@ -194,6 +195,7 @@ local int ChopWood(Unit* unit)
DebugLevel0Fn("Wrong unit for chopping wood %d\n"
,unit->Type->Type);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
//
// Update the display.
@ -323,6 +325,7 @@ local int ReturnWithWood(Unit* unit)
MustRedraw|=RedrawResources;
}
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==UnitTypeOrcWorkerWithWood ) {
unit->Type=UnitTypeOrcWorker;
} else if( unit->Type==UnitTypeHumanWorkerWithWood ) {
@ -331,6 +334,7 @@ local int ReturnWithWood(Unit* unit)
// FIXME: must support more races.
DebugLevel0Fn("Wrong unit for returning wood %d\n",unit->Type->Type);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
if( WAIT_FOR_WOOD<MAX_UNIT_WAIT ) {
unit->Wait=WAIT_FOR_WOOD;

View file

@ -206,6 +206,7 @@ local int MineInGoldmine(Unit* unit)
//
// Change unit outfit. (Unit type is used for this.)
//
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==UnitTypeOrcWorker ) {
unit->Type=UnitTypeOrcWorkerWithGold;
} else if( unit->Type==UnitTypeHumanWorker ) {
@ -215,6 +216,7 @@ local int MineInGoldmine(Unit* unit)
DebugLevel0Fn("Wrong unit (%d,%d) for mining gold %d (%s)\n"
,unit->X,unit->Y,unit->Type->Type,unit->Type->Name);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
CheckUnitToBeDrawn(unit);
if( unit->Selected ) {
UpdateButtonPanel();
@ -320,6 +322,7 @@ local int MoveToGoldDeposit(Unit* unit)
MustRedraw|=RedrawResources;
}
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==UnitTypeOrcWorkerWithGold ) {
unit->Type=UnitTypeOrcWorker;
} else if( unit->Type==UnitTypeHumanWorkerWithGold ) {
@ -329,6 +332,7 @@ local int MoveToGoldDeposit(Unit* unit)
DebugLevel0Fn("Wrong unit (%d,%d) for returning gold %d (%s)\n"
,unit->X,unit->Y,unit->Type->Type,unit->Type->Name);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
if( WAIT_FOR_GOLD<MAX_UNIT_WAIT ) {
unit->Wait=WAIT_FOR_GOLD;

View file

@ -218,6 +218,7 @@ local int WaitInResource(Unit* unit,const Resource* resource)
//
// Change unit to full state. FIXME: more races
//
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==*resource->Human ) {
unit->Type=*resource->HumanWithResource;
} else if( unit->Type==*resource->Orc ) {
@ -227,6 +228,7 @@ local int WaitInResource(Unit* unit,const Resource* resource)
DebugLevel0Fn("Wrong unit-type `%s' for resource `%s'\n"
,unit->Type->Ident,DEFAULT_NAMES[resource->Cost]);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
//
// Find and send to resource deposit.
@ -364,6 +366,7 @@ local int MoveToDepot(Unit* unit,const Resource* resource)
//
// Change unit to empty state. FIXME: more races
//
unit->Player->UnitTypesCount[unit->Type->Type]--;
if( unit->Type==*resource->HumanWithResource ) {
unit->Type=*resource->Human;
} else if( unit->Type==*resource->OrcWithResource ) {
@ -372,6 +375,7 @@ local int MoveToDepot(Unit* unit,const Resource* resource)
DebugLevel0Fn("Wrong unit-type `%s' for resource `%s'\n"
,unit->Type->Ident,DEFAULT_NAMES[resource->Cost]);
}
unit->Player->UnitTypesCount[unit->Type->Type]++;
//
// Time to store the resource.