← Back to team overview

widelands-dev team mailing list archive

Re: Fwd: can find any more resources

 

>> 2014-07-29 20:46 GMT+02:00 Fòram na Gàidhlig <fios@xxxxxxxxxxxxxxxxxxx
>> <mailto:fios@xxxxxxxxxxxxxxxxxxx>>:
>>
>>     I've done a bit of refactoring today in this branch:
>>
>>     https://code.launchpad.net/~widelands-dev/widelands/bug-1348795
>>
>>     Check out the new ProductionSite::out_of_resources function - when
>>     that
>>     function sends a message to the player would be the point where the AI
>>     should do something about the building.
>>
>>     I don't know how the AI API works, but I guess you would either access
>>     the message or set a flag in the production site for the I to read.
> 
> That is a bad coupling direction: logic should not know about AI and
> should not offer services for it. For this purpose we have
> notifications.h. The logic should publish a Note here that the AI should
> subscribe to. For an example see src/logic/immovable.h, struct
> NoteImmovable. The logic will not care about who subscribes or if
> anybody subscribes at all. notifications/ contains a simple test case
> that shows how to use the API.

Thanks for that - so that's how the AI API works :)



>>     Message sender at the moment is "produce" or "mine". I don't
>>     really know
>>     what the sender is for, so if it doesn't break anything, feel free to
>>     change the sender as needed.
> 
> The sender is just a string imho. I do not think it is used for anything
> and I wonder why it is there….

Probably whoever originally implemented it was thinking email inbox. I
have opened a bug:

https://bugs.launchpad.net/widelands/+bug/1350260


References