2025-07-28 15:48 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000957AIAIpublic2009-02-21 15:46
Reporterhawk 
Assigned Tohoijui 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionwon't fix 
Summary0000957: EconmyAI does not find MetalMakerAI dll
DescriptionI can reproduce it on linux:
1) select EconmyAI for any builder unit
2) wait untill it build some power generator
3) Invalid dll message (and game over :-( )

I hacked the attached patch together, since AIs can't access Platform where filesystem and SharedObject live.
Additional InformationI'm using spring_0.76b1, on ubuntu hardy.
The problem is not package specific.
TagsNo tags attached.
Attached Files
  • patch file icon EconmyAI.patch (818 bytes) 2008-06-18 03:46 -
    --- spring_0.76b1/AI/Group/EconomyAI/Helper.cpp	2008-05-09 00:57:14.000000000 +0200
    +++ /home/vincenzo/stanzino/debian/spring/spring-0.76/spring_0.76b1/AI/Group/EconomyAI/Helper.cpp	2008-06-17 17:41:48.000000000 +0200
    @@ -1,5 +1,7 @@
     #include "StdAfx.h"
     #include "ExternalAI/IAICallback.h"
    +#include "Platform/FileSystem.h"
    +#include "Platform/SharedLib.h"
     #include "Sim/Units/UnitDef.h"
     #include "Helper.h"
     #include "GroupAI.h"
    @@ -386,11 +388,7 @@
     					continue;
     				}
     			}
    -#ifdef _WIN32
    -			metalMakerAIid = aicb->CreateGroup("AI/Helper-libs/MetalMakerAI.dll",99);
    -#else
    -			metalMakerAIid = aicb->CreateGroup("AI/Helper-libs/MetalMakerAI.so",99);
    -#endif
    +			metalMakerAIid = aicb->CreateGroup("/usr/lib/spring/AI/Helper-libs/MetalMakerAI.so",99);
     			aicb->AddUnitToGroup(unit,metalMakerAIid);
     		}
     	}
    
    patch file icon EconmyAI.patch (818 bytes) 2008-06-18 03:46 +
  • patch file icon EcoAI.patch (1,252 bytes) 2008-06-27 20:05 -
    Index: rts/ExternalAI/GroupHandler.cpp
    ===================================================================
    --- rts/ExternalAI/GroupHandler.cpp	(revision 6084)
    +++ rts/ExternalAI/GroupHandler.cpp	(working copy)
    @@ -262,6 +262,15 @@
     
     CGroup* CGroupHandler::CreateNewGroup(AIKey aiKey)
     {
    +	std::vector<std::string> match;
    +	std::string dir("AI/Helper-libs");
    +	match = filesystem.FindFiles(dir, aiKey.dllName + "." + SharedLib::GetLibExtension());
    +	for (std::vector<std::string>::iterator it = match.begin(); it != match.end(); it++)
    +	{
    +		aiKey.dllName = *it;
    +		break;
    +	}
    +
     	if(freeGroups.empty()){
     		CGroup* group=SAFE_NEW CGroup(aiKey,firstUnusedGroup++,this);
     		groups.push_back(group);
    Index: AI/Group/EconomyAI/Helper.cpp
    ===================================================================
    --- AI/Group/EconomyAI/Helper.cpp	(revision 6084)
    +++ AI/Group/EconomyAI/Helper.cpp	(working copy)
    @@ -378,11 +378,7 @@
     					continue;
     				}
     			}
    -#ifdef _WIN32
    -			metalMakerAIid = aicb->CreateGroup("AI/Helper-libs/MetalMakerAI.dll",99);
    -#else
    -			metalMakerAIid = aicb->CreateGroup("AI/Helper-libs/MetalMakerAI.so",99);
    -#endif
    +			metalMakerAIid = aicb->CreateGroup("MetalMakerAI",99);
     			aicb->AddUnitToGroup(unit,metalMakerAIid);
     		}
     	}
    
    patch file icon EcoAI.patch (1,252 bytes) 2008-06-27 20:05 +

-Relationships
related to 0000491closed Incorrect AI dll 
+Relationships

-Notes

~0002342

Kloot (developer)

Thanks, but your patch isn't necessary. You just have to set Spring's data directory so that it looks in /usr/lib/spring on your system, see the setup guide (http://spring.clan-sy.com/wiki/Build_from_source) on how to do that. There are also a few things wrong with the patch itself IMO:

1) it includes two extra headers for no reason
2) it specifies a hardcoded absolute path
3) it breaks the AI on Windows by removing the #ifdef's

Not committing this, but feel free to submit others for any bugs you might find.

~0002343

hawk (reporter)

I did not compile from sources: I used the debian package.

Spring's data directory, is set approprately, but the code involved in the patch leads to the string "AI/Helper-libs/MetalMakerAI.so" beeing passed to dlopen without adding the trailing configdir (just follow the function calls and you'll see).

My patch was not meant to "fix", but just to explain:
1) The 2 include files can be included, bu we can't link to the object code (it's inside spring executable)
2) It is not possible to know where the datadir is from inside the AI (correct me if I'm wrong), so I trimmed out the windows friendly code anyway.

The correct way to fix it would be doing the same as in:
void CGroupHandler::FindDlls(void)


Regards
Vincenzo

P.S. thank you for working on this great game & piece of code :-)

~0002371

vanto (reporter)

Well what about another patch then ...

~0003298

hoijui (reporter)

closed, as GroupAIs are deprecated
+Notes

-Issue History
Date Modified Username Field Change
2008-06-18 03:46 hawk New Issue
2008-06-18 03:46 hawk File Added: EconmyAI.patch
2008-06-18 04:23 Kloot Note Added: 0002342
2008-06-18 04:24 Kloot Status new => closed
2008-06-18 04:24 Kloot Resolution open => no change required
2008-06-18 04:24 Kloot Relationship added related to 0000491
2008-06-18 07:16 hawk Status closed => feedback
2008-06-18 07:16 hawk Resolution no change required => reopened
2008-06-18 07:16 hawk Note Added: 0002343
2008-06-27 20:04 vanto Note Added: 0002371
2008-06-27 20:05 vanto File Added: EcoAI.patch
2009-02-21 09:43 hoijui Status feedback => assigned
2009-02-21 09:43 hoijui Assigned To => hoijui
2009-02-21 15:46 hoijui Note Added: 0003298
2009-02-21 15:46 hoijui Status assigned => closed
2009-02-21 15:46 hoijui Resolution reopened => won't fix
+Issue History