Move spawn debug report code to after all initialization.

pull/35/head
sigonasr2 11 months ago
parent 59c77add6b
commit a5abe82594
  1. 77
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/Version.h
  3. 2
      Adventures in Lestoria/assets/config/configuration.txt
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2322,43 +2322,6 @@ void AiL::InitializeLevels(){
backdrop.Load("backdrop_directory"_S+DATA["Backdrops"][key].GetString(),nullptr,false,false);
}
if("display_spawn_report"_I){
for(auto&[map,data]:MAP_DATA){
std::map<std::string,long>monsterCounts;
for(auto&[key,value]:MAP_DATA[map].SpawnerData){
SpawnerTag&spawnData=MAP_DATA[map].SpawnerData[key];
vf2d spawnerRadius=vf2d{spawnData.ObjectData.GetFloat("width"),spawnData.ObjectData.GetFloat("height")}/2;
for(XMLTag&monster:spawnData.monsters){
std::string monsterName=monster.GetString("value");
monsterCounts[monsterName]++;
}
}
std::cout<<"Spawns Report for "<<map<<":"<<std::endl;
for(auto&[monster,count]:monsterCounts){
std::cout<<"\t"<<count<<"x "<<monster<<std::endl;
}
std::map<ItemInfo*,long>totalDrops;
std::cout<<"Monte Carlo Test: 1 million tries:"<<std::endl;
for(int i=0;i<1000000;i++){
//Try to kill every single monster and see what drops.
for(auto&[monster,count]:monsterCounts){
Monster m=Monster{{0,0},MONSTER_DATA[monster]};
for(int j=0;j<count;j++){
auto drops=m.SpawnDrops();
for(auto&[itemInfo,count]:drops){
totalDrops[itemInfo]+=count;
}
}
}
}
std::cout<<"Average: "<<std::endl;
for(auto&[itemInfo,count]:totalDrops){
std::cout<<"\t"<<itemInfo->Name()<<" x"<<(count/1000000l);
}
}
}
Test::RunMapTests();
}
@ -2644,6 +2607,46 @@ void AiL::ValidateGameStatus(){
if(EnvironmentalAudio::SOUND_DATA.find(audio.audioName)==EnvironmentalAudio::SOUND_DATA.end())ERR(std::format("WARNING! Could not find environmental audio data {} for Map {}. Check audio/environmentalaudio.txt configuration!",audio.audioName,map.name));
}
}
#pragma region Map Spawn Statistics
if("display_spawn_report"_I){
for(auto&[map,data]:MAP_DATA){
std::map<std::string,long>monsterCounts;
for(auto&[key,value]:MAP_DATA[map].SpawnerData){
SpawnerTag&spawnData=MAP_DATA[map].SpawnerData[key];
vf2d spawnerRadius=vf2d{spawnData.ObjectData.GetFloat("width"),spawnData.ObjectData.GetFloat("height")}/2;
for(XMLTag&monster:spawnData.monsters){
std::string monsterName=monster.GetString("value");
monsterCounts[monsterName]++;
}
}
std::cout<<"Spawns Report for "<<map<<":"<<std::endl;
for(auto&[monster,count]:monsterCounts){
std::cout<<"\t"<<count<<"x "<<monster<<std::endl;
}
std::map<ItemInfo*,long>totalDrops;
std::cout<<"Monte Carlo Test: 100000 tries:"<<std::endl;
for(int i=0;i<100000;i++){
//Try to kill every single monster and see what drops.
for(auto&[monster,count]:monsterCounts){
Monster m=Monster{{0,0},MONSTER_DATA[monster]};
for(int j=0;j<count;j++){
auto drops=m.SpawnDrops();
for(auto&[itemInfo,count]:drops){
totalDrops[itemInfo]+=count;
}
ItemDrop::drops.clear(); //Since we're testing clear the drop list...
}
}
}
std::cout<<"Average: "<<std::endl;
for(auto&[itemInfo,count]:totalDrops){
std::cout<<"\t"<<itemInfo->Name()<<" x"<<std::format("{:.3}",count/100000.)<<std::endl;
}
}
}
#pragma endregion
}
void AiL::RenderVersionInfo(){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 6004
#define VERSION_BUILD 6014
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -141,7 +141,7 @@ debug_pathfinding = 0
debug_toggleable_items = 0
# Turn on to have a spawn information report displayed on startup.
display_spawn_report = 1
display_spawn_report = 0
# ms precision of animation tile caching.
animation_tile_precision = 50

Loading…
Cancel
Save