I have an really estrange error. I got an object attribute of int type called currentState
here is the declaration
class WorkerAgent : public BaseAgent {
private:
int currentState;
The code below runs a lot of times inside a loop of a game but SOMETIMES (in a random time) the code chashes the program at the line (270)
*OBS: currentState is initialized already when running this line of code (270)!
if (currentState == REPAIRING) {
if (!unit->isRepairing()) {
setState(GATHER_MINERALS);
BaseAgent* base = AgentManager::getInstance()->getClosestBase(unit->getTilePosition());
if (base != NULL) {
unit->rightClick(base->getUnit());
return;
}
} else {
return;
}
}
int cur = currentState; // (line 270)
bool b = cur == FIND_BUILDSPOT;
I have an EXCEPTION_ACCESS_VIOLATION and the program chashes.. I dont know can be happening since currentState is not a pointer neither cur
Error
VERSION: 1.16.1.1
BWAPI:
REVISION: 4160
BUILD: RELEASE
ERROR: None
LOCATION: Single Player
MAP: Stepping Stones
(3)Stepping Stones.scm
EXCEPTION: 0xC0000005 EXCEPTION_ACCESS_VIOLATION
FAULT: 0x10044217 BWAPI.dll
REGISTERS:
EDI: 00000140
ESI: 00000003
EBX: 00000000
EDX: C208C483
ECX: 5B46A60C
EAX: 035F0001
EBP: 0018EEE8
EIP: 10044217
ESP: 0018E4C4
STACK:
BWAPI.dll 0x10044217 ----
BWAPI.dll 0x10046C38 ----
BWAPI.dll 0x10047A43 ----
BWAPI.dll 0x100408C6 ----
DUMB.DLL 0x5B4254A0 WorkerAgent::computeActions
d:\programming\mestrado\bots\dumb\bthaimodule\source\workeragent.cpp:270
Any other information about the case, please ask me! I’am getting crazy with this problem!
currentStateis a member of your classWorkerAgent, which means you have to have a valid object of typeWorkerAgentforcurrentStateto exist.You’re probably using an invalid (null, uninitalized, deleted, or otherwise garbage) pointer to a
WorkerAgentin code you haven’t shown us.