Added equivalence of units.
This commit is contained in:
parent
b613e1d06b
commit
7a203fed03
3 changed files with 32 additions and 3 deletions
|
@ -79,9 +79,11 @@ local void AiCheckUnits(void)
|
|||
const AiBuildQueue* queue;
|
||||
const int* unit_types_count;
|
||||
int i;
|
||||
int j;
|
||||
int n;
|
||||
int t;
|
||||
int x;
|
||||
int e;
|
||||
|
||||
memset(counter,0,sizeof(counter));
|
||||
//
|
||||
|
@ -101,12 +103,25 @@ local void AiCheckUnits(void)
|
|||
for( i=0; i<n; ++i ) {
|
||||
t=AiPlayer->UnitTypeRequests[i].Table[0]->Type;
|
||||
x=AiPlayer->UnitTypeRequests[i].Count;
|
||||
if( x>unit_types_count[t]+counter[t] ) { // Request it.
|
||||
|
||||
//
|
||||
// Add equivalent units
|
||||
//
|
||||
e=unit_types_count[t];
|
||||
if( t<AiHelpers.EquivCount && AiHelpers.Equiv[t] ) {
|
||||
DebugLevel3Fn("Equivalence for %s\n",
|
||||
AiPlayer->UnitTypeRequests[i].Table[0]->Ident);
|
||||
for( j=0; j<AiHelpers.Equiv[t]->Count; ++j ) {
|
||||
e+=unit_types_count[AiHelpers.Equiv[t]->Table[j]->Type];
|
||||
}
|
||||
}
|
||||
|
||||
if( x>e+counter[t] ) { // Request it.
|
||||
DebugLevel3Fn("Need %s *%d\n" _C_
|
||||
AiPlayer->UnitTypeRequests[i].Table[0]->Ident,x);
|
||||
AiAddUnitTypeRequest(AiPlayer->UnitTypeRequests[i].Table[0],
|
||||
x-unit_types_count[t]-counter[t]);
|
||||
counter[t]+=x-unit_types_count[t]-counter[t];
|
||||
x-e-counter[t]);
|
||||
counter[t]+=x-e-counter[t];
|
||||
}
|
||||
counter[t]-=x;
|
||||
}
|
||||
|
|
|
@ -284,6 +284,12 @@ typedef struct _ai_helper_ {
|
|||
*/
|
||||
int UnitLimitCount;
|
||||
AiUnitTypeTable** UnitLimit;
|
||||
/**
|
||||
** The index is the unit that should be made, giving a table of all
|
||||
** units/buildings which are equivalent.
|
||||
*/
|
||||
int EquivCount;
|
||||
AiUnitTypeTable** Equiv;
|
||||
} AiHelper;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -153,6 +153,8 @@ local SCM CclDefineAiHelper(SCM list)
|
|||
what=5;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("unit-limit")) ) {
|
||||
what=6;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("unit-equiv")) ) {
|
||||
what=7;
|
||||
} else {
|
||||
fprintf(stderr,"unknown tag\n");
|
||||
continue;
|
||||
|
@ -269,6 +271,12 @@ local SCM CclDefineAiHelper(SCM list)
|
|||
&AiHelpers.UnitLimitCount,&AiHelpers.UnitLimit,cost);
|
||||
AiHelperInsert( AiHelpers.UnitLimit+cost,base);
|
||||
break;
|
||||
case 7: // equivalence
|
||||
AiHelperSetupTable(
|
||||
&AiHelpers.EquivCount,&AiHelpers.Equiv,base->Type);
|
||||
AiHelperInsert(
|
||||
AiHelpers.Equiv+base->Type,type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue