Fixed production menus: show knowledge of accessor (#850)

Maikel de Vries 2012-10-30 21:15:51 +01:00
parent aace5eb55a
commit 4b31ac8a72
2 changed files with 8 additions and 5 deletions

View File

@ -51,7 +51,7 @@ protected func Construction()
public func AddMenuProducts(object producer)
{
for (var product in producer->GetProducts())
for (var product in producer->GetProducts(GetMenuObject()))
{
var item = CreateObject(GUI_MenuItem);
if (!AddItem(item))

View File

@ -100,21 +100,24 @@ private func IsProduct(id product_id)
/** Returns an array with the ids of products which can be produced at this producer.
@return array with products.
*/
public func GetProducts()
public func GetProducts(object for_clonk)
{
var for_plr = GetOwner();
if (for_clonk)
for_plr = for_clonk-> GetOwner();
var products = [];
// Cycle through all definitions to find the ones this producer can produce.
var index = 0, product;
if (!IgnoreKnowledge() && GetOwner() != NO_OWNER)
if (!IgnoreKnowledge() && for_plr != NO_OWNER)
{
while (product = GetPlrKnowledge(GetOwner(), nil, index, C4D_Object))
while (product = GetPlrKnowledge(for_plr, nil, index, C4D_Object))
{
if (IsProduct(product))
products[GetLength(products)] = product;
index++;
}
index = 0;
while (product = GetPlrKnowledge(GetOwner(), nil, index, C4D_Vehicle))
while (product = GetPlrKnowledge(for_plr, nil, index, C4D_Vehicle))
{
if (IsProduct(product))
products[GetLength(products)] = product;