Building Problem when changing LyShine.cpp

0

I have done something really simple and it worked. I have added two methods to the LyShineLua to expose to Lua. I know it is not the best practice, but I want to reuse LyShineLua to expose two simple methods just to test a c++ code. It worked. I am using it to copy and paste and I have included #include <windows.h>

Now, I am adding a third method. If the method is empty, it works. If I add this code, which loads the next level, it does not compile. The code that is giving me headache is this:

CCryAction* pCryAction = CCryAction::GetCryAction();

If I comment this line, everything compiles. If I add this line, it does not compile.

I have included CryAction in the LyShine.cpp like this:

#include "CryAction.h"
#include <IConsole.h>
#include <LoadScreenBus.h>

This is the error I have now:

Creating library c:\Amazon\Lumberyard\1.9.0.1\dev\BinTemp\win_x64_vs2015_profile\Gems\LyShine\Code\Gem.LyShine.0fefab3f13364722b2eab3b96ce2bf20.v0.1.0.lib and object c:\Amazon\Lumberyard\1.9.0.1\dev\BinTemp\win_x64_vs2015_profile\Gems\LyShine\Code\Gem.LyShine.0fefab3f13364722b2eab3b96ce2bf20.v0.1.0.exp
LyShine.cpp.108.obj : error LNK2001: unresolved external symbol "private: static class CCryAction * CCryAction::m_pThis" (?m_pThis@CCryAction@@0PEAV1@EA)
c:\Amazon\Lumberyard\1.9.0.1\dev\BinTemp\win_x64_vs2015_profile\Gems\LyShine\Code\Gem.LyShine.0fefab3f13364722b2eab3b96ce2bf20.v0.1.0.dll : fatal error LNK1120: 1 unresolved externals

Could you help me? As you can see I am not a c++ programming...

Thank you!

gefragt vor 7 Jahren168 Aufrufe
5 Antworten
0
Akzeptierte Antwort

I expose this function to Lua and it is working. I got this from the StarterGame

  static void LoadNextLevel(AZStd::string level)
{
CCryAction* pCryAction = static_cast<CCryAction*>(gEnv->pGame->GetIGameFramework());
pCryAction->ScheduleEndLevel(level.c_str(), true);
}

It seems that the way to get the CryAction inside the gem is through the gEnv. I do not know if it is correct, but it is working ;-)

beantwortet vor 7 Jahren
0

I've filed a ticket to get some clarification.

beantwortet vor 7 Jahren
0

I dont think you are able to link CryAction into LyShine. I think the reason for this, since i've got something similar with CryMovie, is that it's building everything in separate modules that are dynamically loaded so there is no ".lib" file to link against to allow access to another module's code.

beantwortet vor 7 Jahren
0

I understand your point, but I see other gems using cryaction (I guess). How is that possible? That is what I need. Any ideas?

beantwortet vor 7 Jahren
0

Hi @REDACTEDUSER

It looks like you are trying to reproduce what the CFlowNode_EndLevel FlowGraph node does. It uses a method (ScheduleEndLevel) that is not exposed via an abstract interface. The FlowGraph system can access it because the flow node code is part of CryAction. It sounds like you have a workaround to make it work though (using a cast).

Another alternative would be to do what the console command to load a level does. It uses the LoadGame method on CryAction that is exposed through IGameFramework. So you can call it like this:

            if (gEnv->pGame->GetIGameFramework())
{
gEnv->pGame->GetIGameFramework()->LoadGame("levelname");
}

Alternatively, there is also a static function you can use to avoid the cast in your example:

CCryAction::GetCryAction()->ScheduleEndLevel(level.c_str(),true);

Rob

beantwortet vor 7 Jahren

Dieser Beitrag ist geschlossen: Das Hinzufügen neuer Antworten, Kommentare und Abstimmungen ist deaktiviert.