MegaGlest Forum
Modding and game content creation => Mods => Topic started by: esraacs on 8 February 2015, 19:25:29
-
i am using megaglest with my ai engine . i use giveresource function during runtime .it completes without exception.
when interface updates its status, it generates this exception
\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateProduce [2341] unknown
Please,Could you provide a solution to resolve this exception?
if you need more details i have a screenshot but there's no attachment button here :(
-
AI-engine ?
Written in lua ?
Update: Ok I saw in another thread that you use c++. I need more info, especially the stack trace. It is quite likely that your changes corrupted the memory and cause this kind of error. Is it always the same ?
-
yes i am using c++ scripting functions and this is the details :-
*ERROR* [2015-02-08 19:32:53] In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateProduce 2341] UNKNOWN
*ERROR* [2015-02-08 19:32:53] In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateUnitCommand Line: 439] Error [In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateProduce 2341] UNKNOWN
Stack Trace:
00000000 00000000 00000000 77a25bcc ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 77a25bcc ZwGetContextThread!ntdll (null)(0) +18
]
*ERROR* [2015-02-08 19:32:54] In [game.cpp::Glest::Game::Game::update Line: 2785] Error [In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateProduce 2341] UNKNOWN
Stack Trace:
00000000 00000000 00000000 77a25bcc ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 77a25bcc ZwGetContextThread!ntdll (null)(0) +18
Stack Trace:
00000000 00000000 00000000 77a25160 ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 77a25160 ZwGetContextThread!ntdll (null)(0) +18
]
-
As I don't know what you changed in the code, what is in (..\..\source\glest_game\world\unit_updater.cpp) UnitUpdater::updateProduce in line 2341 for you ? Please show me 10 lines before and after this line here.
-
I didnt change anything in unit_updater
this exception changes every time i run the script :(
*ERROR* [2015-02-10 00:48:11] In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateHarvest 1804] UNKNOWN error
*ERROR* [2015-02-10 00:48:12] In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateUnitCommand Line: 439] Error [In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateHarvest 1804] UNKNOWN error
Stack Trace:
00000000 00000000 00000000 7813b9c2 ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 7813b9c2 ZwGetContextThread!ntdll (null)(0) +18
]
*ERROR* [2015-02-10 00:48:13] In [game.cpp::Glest::Game::Game::update Line: 2785] Error [In [..\..\source\glest_game\world\unit_updater.cpp::Glest::Game::UnitUpdater::updateHarvest 1804] UNKNOWN error
Stack Trace:
00000000 00000000 00000000 7813b9c2 ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 7813b9c2 ZwGetContextThread!ntdll (null)(0) +18
Stack Trace:
00000000 00000000 00000000 7813b7ae ZwGetContextThread!ntdll (null)(0) +18
00000000 00000000 00000000 7813b7ae ZwGetContextThread!ntdll (null)(0) +18
]
i added a key press event in game.cpp
void Game::keyPress(SDL_KeyboardEvent c) {
if(this->masterserverMode == true) {
return;
}
if(gameStarted == false || totalRenderFps <= 0) {
return;
}
try
{
if(c.keysym.sym==SDLK_SEMICOLON)
{
Plan P;
P.Test(scriptManager);
return;
}
}
catch(const exception &ex) {
//LogFile::WriteLogFile(ex.what());
ErrorDisplayMessage(ex.what(),true);
}
if(currentUIState != NULL) {
currentUIState->keyPress(c);
return;
}
chatManager.keyPress(c);
}
and here's what i try to execute
void Plan::Test(ScriptManager scriptManager)
{
try
{
LogFile::WriteLogFile("begin testing");
scriptManager.giveResource("gold",0,100);
}
catch(const exception &ex) {
LogFile::WriteLogFile(ex.what());
}
}
-
I am at work at the moment, but from what I see you call the scriptManager which is for sure not meant to be called form c++. This is the API for the lua scripting language which is maybe not initialized in your case too ( because you are not in a scenario ). So no wonder you crash on different places when you call something not initialized. But I try to look at it in detail.
Maybe you shold start with some lua scenario coding to get familiar with MG?
If you have time come to IRC so we can talk a bit more directly-> see https://megaglest.org/contact
I will be there in 1 or 2 hours too.
-
No I am using it inside a scenario beginner 1 . Does lua scripting support real time ?
I need it in real time .any hints ?
-
real time?
You can react on different events and so on. Not sure if this is real time enough for you.
-
Yes I need real time as my ai engine is in c++ .my ai engine is multi agent .I need c++ functions to use directly inside my code. Any hints?
-
You must describe a bit more detailed, what kind of AI engine do you have ?
Is it meant to replace the CPU players ? If yes, see how they are attached to the system. see ai_interface.h/cpp in the code.
In general this is here: https://github.com/MegaGlest/megaglest-source/tree/develop/source/glest_game/ai
-
No , I just want functions in c++ like giveresource, createunit , attack,update.....etc. to use them in multiagent architecture in c++ which each agent has a different functionality. No replace for players. I just want to use the main functions of the game . Please,could you mention why this exception happened ?
-
Thats very obvious because you say it crashes at different places.
Your code must have accessed non allocated memory or corrupted the stack somehow. ( Or maybe you have trouble with threads )
Thats the typical thing when different errors show up.
I have no crystal ball here to know what code changes you made. Do you have a git repository or something where I can access the code ?
-
Do I need when game keypress any event or timer In order to run giveresource ?
I didn't change anything in unit_updater or game source files .
-
You could also join MG chat http://chat.megaglest.org (http://chat.megaglest.org)
-
It doesn't matter what you changed in our code if you also have code that may have corrupted the memory.
As alket says, please join the chat for more questions.