Code for Task 26591: use general notify/messages

This commit is contained in:
mr-russ 2003-02-12 12:14:32 +00:00
parent b2541018cc
commit 53b4fff082
4 changed files with 21 additions and 39 deletions

View file

@ -92,11 +92,8 @@ global void HandleActionTrain(Unit* unit)
if( player->Food<
player->NumFoodUnits+unit->Data.Train.What[0]->Demand ) {
// FIXME: GameMessage
if( player==ThisPlayer ) {
// FIXME: PlayVoice :), see task.txt
SetMessage("Not enough food...build more farms.");
} else if( unit->Player->Ai ) {
NotifyPlayer(player,NotifyYellow,unit->X,unit->Y,"Not enough food...build more farms.");
if( unit->Player->Ai ) {
AiNeedMoreFarms(unit,unit->Orders[0].Type);
}
@ -122,12 +119,10 @@ global void HandleActionTrain(Unit* unit)
nunit->TTL=GameCycle+type->DecayRate*6*CYCLES_PER_SECOND;
}
// FIXME: GameMessage
if( player==ThisPlayer ) {
SetMessageEvent( nunit->X, nunit->Y, "New %s ready",
nunit->Type->Name);
PlayUnitSound(nunit,VoiceReady);
} else if( unit->Player->Ai ) {
NotifyPlayer(player, NotifyYellow, nunit->X, nunit->Y, "New %s ready",
nunit->Type->Name);
PlayUnitSound(nunit,VoiceReady);
if( unit->Player->Ai ) {
AiTrainingComplete(unit,nunit);
}

View file

@ -79,11 +79,10 @@ global void HandleActionUpgradeTo(Unit* unit)
player->UnitTypesCount[unit->Type->Type]++;
UpdateForNewUnit(unit,1);
// FIXME: SendNotify("upgrade-complete");
if( player==ThisPlayer ) {
SetMessageEvent( unit->X, unit->Y, "Upgrade to %s complete",
unit->Type->Name );
} else if( unit->Player->Ai ) {
SetMessageEvent(player,NotifyGreen,unit->X, unit->Y,
"Upgrade to %s complete", unit->Type->Name );
if( unit->Player->Ai ) {
AiUpgradeToComplete(unit,type);
}
unit->Reset=unit->Wait=1;

View file

@ -101,10 +101,7 @@ local Order* GetNextOrder(Unit* unit,int flush)
// FIXME: johns: wrong place for an error message.
// FIXME: johns: should be checked by AI or the user interface
// NOTE: But must still be checked here.
if( unit->Player==ThisPlayer ) {
// FIXME: use a general notify call
SetMessage( "Unit order list is full" );
}
NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,"Unit order list is full" );
return NULL;
}

View file

@ -549,10 +549,8 @@ global int PlayerCheckLimits(const Player* player,const UnitType* type)
}
}
// FIXME: need a general notify function
if( player==ThisPlayer ) {
SetMessage("Cannot create more units.");
} else {
NotifyPlayer(player,NotifyYellow,0,0,"Cannot create more units.");
if( player->Ai ) {
// AiNoMoreUnits(player,type);
}
return 0;
@ -572,10 +570,8 @@ global int PlayerCheckFood(const Player* player,const UnitType* type)
// FIXME: currently all units costs 1 food
if( player->Food<player->NumFoodUnits+type->Demand ) {
// FIXME: need a general notify function
if( player==ThisPlayer ) {
SetMessage("Not enough food...build more farms.");
} else {
NotifyPlayer(player,NotifyYellow,0,0,"Not enough food...build more farms.");
if( player->Ai ) {
// FIXME: message to AI, called too much
DebugLevel3("Ai: Not enough food...build more farms.\n");
}
@ -597,21 +593,16 @@ global int PlayerCheckCosts(const Player* player,const int* costs)
{
int i;
int err;
char buf[128];
err=0;
for( i=1; i<MaxCosts; ++i ) {
if( player->Resources[i]<costs[i] ) {
// FIXME: noticed all or only one?
if( !err ) {
sprintf(buf,"Not enough %s...%s more %s."
,DefaultResourceNames[i],DefaultActions[i],DefaultResourceNames[i]);
// FIXME: use the general notify function vor this
if( player==ThisPlayer ) {
SetMessage(buf);
} else {
DebugLevel3("Ai: %s.\n" _C_ buf);
}
NotifyPlayer(player,NotifyYellow,0,0,"Not enough %s...%s more %s.",
DefaultResourceNames[i],DefaultActions[i],DefaultResourceNames[i]);
if( player->Ai ) {
DebugLevel3("Ai: Not enough %s...%s more %s." _C_
DefaultResourceNames[i] _C_ DefaultActions[i] _C_ DefaultResourceNames[i]);
}
err|=1<<i;
}