generated from sigonasr2/CPlusPlusProjectTemplate
Fix object memory clearing error
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
d700d8b83c
commit
b5dfa1e7de
@ -451,7 +451,7 @@ public:
|
||||
std::string MAP_NAME = "";
|
||||
std::string CUTSCENE_CONSOLE_TEXT = "";
|
||||
bool GAME_FLAGS[128]={};
|
||||
int**MAP=(int**)malloc(sizeof(int**)*0);
|
||||
int**MAP=NULL;
|
||||
int MAP_WIDTH=-1;
|
||||
int MAP_HEIGHT=-1;
|
||||
Decal*TILES;
|
||||
@ -2540,7 +2540,7 @@ public:
|
||||
StartCutscene(cutscene::CHECK_COORDS_2);
|
||||
CUTSCENE_OBJS[0]=CreateObject({PLAYER_COORDS[0],PLAYER_COORDS[1]},PLAYER_DECAL,playerAnim,true);
|
||||
}
|
||||
if(WALK_STEPS++>60&&!IN_BATTLE_ENCOUNTER&&playerCanMove()) {
|
||||
if(WALK_STEPS++>60&&!IN_BATTLE_ENCOUNTER) {
|
||||
PLAYER_HP=std::clamp(PLAYER_HP+1,0,PLAYER_MAXHP);
|
||||
updatePlayerState();
|
||||
WALK_STEPS=0;
|
||||
@ -2893,12 +2893,14 @@ public:
|
||||
std::ifstream f("assets/maps/"+map->filename);
|
||||
std::string data;
|
||||
CURRENT_MAP=map;
|
||||
if (MAP!=nullptr) {
|
||||
MAP_WIDTH=MAP_HEIGHT=-1;
|
||||
if (MAP!=NULL) {
|
||||
for (int y=0;y<MAP_HEIGHT;y++) {
|
||||
free(MAP[y]);
|
||||
}
|
||||
free(MAP);
|
||||
MAP=NULL;
|
||||
}
|
||||
MAP_WIDTH=MAP_HEIGHT=-1;
|
||||
for (int i=0;i<OBJECTS.size();i++) {
|
||||
delete OBJECTS[i];
|
||||
}
|
||||
@ -2917,7 +2919,9 @@ public:
|
||||
stream>>MAP_HEIGHT;
|
||||
} else
|
||||
if (y<MAP_HEIGHT) {
|
||||
MAP=(int**)realloc(MAP,sizeof(int**)*MAP_HEIGHT);
|
||||
if (MAP==NULL) {
|
||||
MAP=(int**)malloc(sizeof(int**)*MAP_HEIGHT);
|
||||
}
|
||||
MAP[y]=(int*)malloc(sizeof(int*)*MAP_WIDTH);
|
||||
for (int i=0;i<data.length();i++) {
|
||||
MAP[y][i]=data[i]-'0';
|
||||
@ -3345,7 +3349,7 @@ public:
|
||||
for (int j=0;j<OBJECTS.size();j++) {
|
||||
if (OBJECTS[j]==CUTSCENE_OBJS[i]) {
|
||||
if (CUTSCENE_OBJS[i]->tempObj) {
|
||||
OBJECTS.erase(OBJECTS.begin()+j);
|
||||
OBJECTS.erase(OBJECTS.begin()+j--);
|
||||
std::cout<<"Erased at position "<<j<<".\n";
|
||||
break;
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user