From a3dd7506d377b1434f913bd65c019eed52b64b6e Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 12 Jan 2009 17:11:45 +0000 Subject: (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see. NoAI is an API (a framework) to build your own AIs in. See: http://wiki.openttd.org/wiki/index.php/AI:Main_Page With many thanks to: - glx and Rubidium for their syncing, feedback and hard work - Yexo for his feedback, patches, and AIs which tested the system very deep - Morloth for his feedback and patches - TJIP for hosting a challenge which kept NoAI on track - All AI authors for testing our AI API, and all other people who helped in one way or another -Remove: all old AIs and their cheats/hacks --- src/industry_cmd.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/industry_cmd.cpp') diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 49934af40..e752976fe 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -39,6 +39,7 @@ #include "oldpool_func.h" #include "animated_tile_func.h" #include "effectvehicle_func.h" +#include "ai/ai.hpp" #include "table/strings.h" #include "table/sprites.h" @@ -432,7 +433,10 @@ static CommandCost ClearTile_Industry(TileIndex tile, byte flags) return_cmd_error(STR_4800_IN_THE_WAY); } - if (flags & DC_EXEC) delete i; + if (flags & DC_EXEC) { + AI::BroadcastNewEvent(new AIEventIndustryClose(i->index)); + delete i; + } return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost()); } @@ -1712,6 +1716,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, SetDParam(1, ind->town->index); } AddNewsItem(indspec->new_industry_text, NS_INDUSTRY_OPEN, ind->xy, 0); + AI::BroadcastNewEvent(new AIEventIndustryOpen(ind->index)); } return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost()); @@ -1912,8 +1917,8 @@ static void MaybeNewIndustry(void) } else { SetDParam(1, ind->town->index); } - AddNewsItem(ind_spc->new_industry_text, - NS_INDUSTRY_OPEN, ind->xy, 0); + AddNewsItem(ind_spc->new_industry_text, NS_INDUSTRY_OPEN, ind->xy, 0); + AI::BroadcastNewEvent(new AIEventIndustryOpen(ind->index)); } /** @@ -2232,6 +2237,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) /* Compute news category */ if (closeit) { ns = NS_INDUSTRY_CLOSE; + AI::BroadcastNewEvent(new AIEventIndustryClose(i->index)); } else { switch (WhoCanServiceIndustry(i)) { case 0: ns = NS_INDUSTRY_NOBODY; break; -- cgit v1.2.3-54-g00ecf