Fix crash when the game attempts to spawn item drops. Release Build 9125.

This commit is contained in:
2024-04-28 18:58:33 -05:00
parent b9a382855c
commit c4ac37af76
6 changed files with 8 additions and 13 deletions
+3 -8
View File
@@ -52,7 +52,7 @@ std::map<std::string,MonsterData>MONSTER_DATA;
MonsterData::MonsterData()
:atk(0),collisionDmg(0),hp(0),moveSpd(0),size(0),strategy("Run Towards"){}
MonsterData::MonsterData(std::string name,int hp,int atk,const uint32_t xp,std::vector<MonsterDropData>drops,float moveSpd,float size,std::string strategy,int collisionDmg):
name(name),hp(hp),atk(atk),xp(xp),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),dropData(drops),collisionDmg(collisionDmg){}
name(name),hp(hp),atk(atk),xp(xp),moveSpd(moveSpd),size(size),strategy(strategy),dropData(drops),collisionDmg(collisionDmg){}
void MonsterData::InitializeMonsterData(){
for(auto&[key,size]:DATA["Monsters"].GetKeys()){
@@ -173,12 +173,7 @@ void MonsterData::InitializeNPCData(){
if(MONSTER_DATA.count(key)){
ERR("WARNING! A monster with the name "<<key<<" already exists in the database! Duplicates are not allowed.")
}
std::vector<std::string>animations{
NPCName+"_IDLE",
NPCName+"_JUMP",
NPCName+"_SPIT",
NPCName+"_DIE",
};
std::vector<std::string>animations;
MonsterData::imgs[NPCName]=NEW Renderable();
const rcode imgLoadResult=MonsterData::imgs[NPCName]->Load("assets/npcs/"+NPCName+".png");
@@ -270,7 +265,7 @@ void MonsterData::InitializeNPCData(){
MonsterData monster(NPCName,health,attack,xp,drops,moveSpd,size/100,strategyName,collisionDmg);
for(size_t animationRow=0;const std::string&animationName:animations){
//if(!monster.animations.insert(animationName).second)ERR(std::format("WARNING! The Animation {} for Monster {} already exists! Animations should have unique names!",animationName,NPCName));
if(!monster.animations.insert(animationName).second)ERR(std::format("WARNING! The Animation {} for Monster {} already exists! Animations should have unique names!",animationName,NPCName));
switch(animationRow){
case 0:monster.idleAnimation=animationName;break;