Refactored monstrategy calls to not rely on the string name of the strategy. Cleaned up how strategy files are structured. Release Build 12526.
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 2m54s
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 2m54s
This commit is contained in:
parent
0fea687304
commit
349edf2ba1
@ -57,7 +57,7 @@ class ItemAttribute{
|
||||
std::string modifies="";
|
||||
std::optional<std::variant<Player*,Monster*>>target;
|
||||
public:
|
||||
inline static safemap<std::string_view,ItemAttribute>attributes;
|
||||
inline static safemap<std::string,ItemAttribute>attributes;
|
||||
ItemAttribute(std::string_view originalName,std::string_view name,bool isPct,bool showDecimal,std::string_view modifies=""sv);
|
||||
static ItemAttribute&Get(const std::string_view name,const std::optional<std::variant<Player*,Monster*>>target={});
|
||||
const std::string_view Name()const;
|
||||
|
||||
@ -226,7 +226,7 @@ void Audio::BGM::SetFadeTime(const float fadeTime){
|
||||
this->fadeTime=fadeTime;
|
||||
}
|
||||
|
||||
void Audio::BGM::AddEventVolumes(const std::string_view eventName,const VolumeList&volumes){
|
||||
void Audio::BGM::AddEventVolumes(const Event&eventName,const VolumeList&volumes){
|
||||
eventVolumes.AddEventInfo(eventName,volumes);
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ const VolumeList&Audio::EventData::GetVolumes(const Event&event)const{
|
||||
return eventInfo.at("Default Volume");
|
||||
}
|
||||
|
||||
void Audio::EventData::AddEventInfo(const std::string_view eventName,const VolumeList&volumes){
|
||||
void Audio::EventData::AddEventInfo(const Event&eventName,const VolumeList&volumes){
|
||||
eventInfo[eventName]=volumes;
|
||||
}
|
||||
|
||||
|
||||
@ -99,10 +99,10 @@ private:
|
||||
};
|
||||
class EventData{
|
||||
public:
|
||||
void AddEventInfo(const std::string_view eventName,const VolumeList&volumes);
|
||||
void AddEventInfo(const Event&eventName,const VolumeList&volumes);
|
||||
const VolumeList&GetVolumes(const Event&event)const;
|
||||
private:
|
||||
std::map<std::string_view,VolumeList>eventInfo;
|
||||
std::map<Event,VolumeList>eventInfo;
|
||||
};
|
||||
static float bgmVol;
|
||||
static float sfxVol;
|
||||
@ -116,7 +116,7 @@ private:
|
||||
void SetName(std::string_view name);
|
||||
void SetFileName(std::string_view name);
|
||||
void AddChannel(const ChannelName&name);
|
||||
void AddEventVolumes(const std::string_view eventName,const VolumeList&volumes);
|
||||
void AddEventVolumes(const Event&eventName,const VolumeList&volumes);
|
||||
void SetFadeTime(const float fadeTime);
|
||||
const ChannelID&GetChannelID(const int index);
|
||||
const ChannelIDList&GetChannelIDs()const;
|
||||
@ -136,8 +136,8 @@ private:
|
||||
private:
|
||||
MiniAudio audioEngine;
|
||||
SongName currentBGM="";
|
||||
safemap<std::string_view,BGM>bgm;
|
||||
std::set<std::string_view>events;
|
||||
safemap<SongName,BGM>bgm;
|
||||
std::set<Event>events;
|
||||
static float defaultFadeTime;
|
||||
Event currentAudioEvent="Default Volume";
|
||||
std::vector<float>prevVolumes;
|
||||
|
||||
@ -47,9 +47,8 @@ If range to player<400 backpaddle with 50% move-spd. if getting hit while backpa
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_ANIMATION_DATA
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(BOAR)
|
||||
enum PhaseName{
|
||||
MOVE,
|
||||
SCRATCH,
|
||||
@ -123,4 +122,4 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
|
||||
if(m.F(A::CHARGE_COOLDOWN)<=0)SETPHASE(PhaseName::MOVE);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -44,7 +44,7 @@ INCLUDE_game
|
||||
INCLUDE_DATA
|
||||
|
||||
float EnvironmentalAudio::ACTIVATION_RANGE;
|
||||
std::map<std::string_view,EnvironmentalAudioData>EnvironmentalAudio::SOUND_DATA;
|
||||
std::map<EnvironmentalAudioSoundName,EnvironmentalAudioData>EnvironmentalAudio::SOUND_DATA;
|
||||
|
||||
void EnvironmentalAudio::Initialize(){
|
||||
ACTIVATION_RANGE="Audio.Environmental Audio Activation Range"_F;
|
||||
|
||||
@ -54,7 +54,7 @@ class EnvironmentalAudio{
|
||||
static float ACTIVATION_RANGE;
|
||||
bool activated=false;
|
||||
size_t soundInstance=std::numeric_limits<size_t>::max();
|
||||
static std::map<std::string_view,EnvironmentalAudioData>SOUND_DATA;
|
||||
static std::map<EnvironmentalAudioSoundName,EnvironmentalAudioData>SOUND_DATA;
|
||||
public:
|
||||
static void Initialize();
|
||||
EnvironmentalAudio();
|
||||
|
||||
@ -61,11 +61,11 @@ const std::string Item::BLANK_ITEM_NAME="";
|
||||
safemap<std::string,ItemInfo>ITEM_DATA;
|
||||
safemap<std::string,IT>ITEM_CONVERSIONS;
|
||||
safemap<std::string,ItemScript>ITEM_SCRIPTS;
|
||||
safemap<std::string_view,std::set<std::string>>ITEM_CATEGORIES;
|
||||
safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
|
||||
std::shared_ptr<Item>Item::BLANK=std::make_shared<Item>();
|
||||
std::multimap<IT,std::shared_ptr<Item>>Inventory::_inventory;
|
||||
std::vector<std::shared_ptr<Item>>Inventory::blacksmithInventory;
|
||||
std::map<std::string_view,std::vector<std::shared_ptr<Item>>>Inventory::sortedInv;
|
||||
std::map<ITCategory,std::vector<std::shared_ptr<Item>>>Inventory::sortedInv;
|
||||
std::array<std::pair<IT,int>,3U>Inventory::loadoutItemsUsed;
|
||||
std::vector<ItemOverlay>ItemOverlay::items;
|
||||
std::map<std::string,ItemSet>ItemSet::sets;
|
||||
@ -135,8 +135,8 @@ void ItemInfo::InitializeItems(){
|
||||
auto ReadItems=[&](datafile&data){
|
||||
for(auto&[key,value]:data.GetKeys()){
|
||||
if(key=="")ERR("Failed to read an item block ,no name specified!");
|
||||
std::string imgPath="assets/"sv+"item_img_directory"_SV+key+".png"sv;
|
||||
Renderable&img=GFX["item_img_directory"_S+key+".png"sv];
|
||||
std::string imgPath="assets/"+"item_img_directory"_S+key+".png";
|
||||
Renderable&img=GFX["item_img_directory"_S+key+".png"];
|
||||
game->LoadResource(img,imgPath);
|
||||
|
||||
std::string scriptName="",description="",category="";
|
||||
@ -437,20 +437,20 @@ void ItemInfo::InitializeItems(){
|
||||
ItemProps::ItemProps(utils::datafile*scriptProps,utils::datafile*customProps)
|
||||
:scriptProps(scriptProps),customProps(customProps){}
|
||||
|
||||
int ItemProps::GetInt(std::string_view prop,size_t index)const{
|
||||
int ItemProps::GetInt(const std::string&prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetInt(index);
|
||||
else return (*scriptProps)[prop].GetInt(index);
|
||||
};
|
||||
float ItemProps::GetFloat(std::string_view prop,size_t index)const{
|
||||
float ItemProps::GetFloat(const std::string&prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return float((*customProps)[prop].GetReal(index));
|
||||
else return float((*scriptProps)[prop].GetReal(index));
|
||||
};
|
||||
std::string ItemProps::GetString(std::string_view prop,size_t index)const{
|
||||
std::string ItemProps::GetString(const std::string&prop,size_t index)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetString(index);
|
||||
else return (*scriptProps)[prop].GetString(index);
|
||||
};
|
||||
|
||||
const uint32_t ItemProps::PropCount(std::string_view prop)const{
|
||||
const uint32_t ItemProps::PropCount(const std::string&prop)const{
|
||||
if(customProps->HasProperty(prop)) return (*customProps)[prop].GetValueCount();
|
||||
else return uint32_t((*scriptProps)[prop].GetValueCount());
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ private:
|
||||
static std::map<EquipSlot,std::weak_ptr<Item>>equipment;
|
||||
static std::array<std::pair<IT,int>,3U>loadoutItemsUsed;
|
||||
//Only contains "1" of every item, as this is a map to index items and not the actual storage of items!
|
||||
static std::map<std::string_view,std::vector<std::shared_ptr<Item>>>sortedInv;
|
||||
static std::map<ITCategory,std::vector<std::shared_ptr<Item>>>sortedInv;
|
||||
};
|
||||
|
||||
class ItemProps{
|
||||
@ -345,10 +345,10 @@ class ItemProps{
|
||||
utils::datafile*customProps;
|
||||
public:
|
||||
ItemProps(utils::datafile*scriptProps,utils::datafile*customProps);
|
||||
int GetInt(std::string_view prop,size_t index=0)const;
|
||||
float GetFloat(std::string_view prop,size_t index=0)const;
|
||||
std::string GetString(std::string_view prop,size_t index=0)const;
|
||||
const uint32_t PropCount(std::string_view prop)const;
|
||||
int GetInt(const std::string&prop,size_t index=0)const;
|
||||
float GetFloat(const std::string&prop,size_t index=0)const;
|
||||
std::string GetString(const std::string&prop,size_t index=0)const;
|
||||
const uint32_t PropCount(const std::string&prop)const;
|
||||
};
|
||||
|
||||
class ItemInfo{
|
||||
|
||||
@ -163,18 +163,18 @@ void ItemEnchantInfo::Initialize(){
|
||||
|
||||
using enum ItemEnchantCategory;
|
||||
if(enchantCategory==CLASS){
|
||||
Class itemEnchantClass{classutils::StringToClass(std::string{key})};
|
||||
Class itemEnchantClass{classutils::StringToClass(key)};
|
||||
datafile&classEnchantData{enchantData[key]};
|
||||
for(const auto&[key,size]:classEnchantData){
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,classEnchantData[key])};
|
||||
newEnchant.abilityClass=itemEnchantClass;
|
||||
const auto&result{ENCHANT_LIST.insert({std::string{key},newEnchant})};
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchant List! Duplicates are not allowed!",key));
|
||||
}
|
||||
}else{
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,enchantData[key])};
|
||||
const auto&result{ENCHANT_LIST.insert({std::string{key},newEnchant})};
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchantment List! Duplicates are not allowed!",key));
|
||||
}
|
||||
@ -285,7 +285,7 @@ const ItemEnchant ItemEnchant::RollRandomEnchant(const std::optional<ItemEnchant
|
||||
return false;
|
||||
};
|
||||
|
||||
while(true){
|
||||
for(;;){
|
||||
ItemEnchantInfo&randomEnchant{remainingAvailableEnchants[util::random()%remainingAvailableEnchants.size()]};
|
||||
ItemEnchant newEnchant{randomEnchant.Name()};
|
||||
if(!previousEnchant||
|
||||
|
||||
@ -107,7 +107,7 @@ private:
|
||||
std::optional<EnchantAbilitySlot>abilitySlot;
|
||||
ItemAttributable minStatModifiers;
|
||||
ItemAttributable maxStatModifiers;
|
||||
std::unordered_map<std::string_view,float>config;
|
||||
std::unordered_map<std::string,float>config;
|
||||
static std::unordered_map<std::string,ItemEnchantInfo>ENCHANT_LIST;
|
||||
static std::unordered_map<ItemEnchantCategory,ItemEnchantCategoryData>ENCHANT_CATEGORIES;
|
||||
AbilityDescriptionModifiers modifiers;
|
||||
|
||||
@ -951,103 +951,103 @@ const Renderable&Input::GetIcon(IconType type)const{
|
||||
#undef END
|
||||
|
||||
std::map<std::pair<InputType,int>,GenericKey::KeyInfo> GenericKey::keyLiteral={
|
||||
{{KEY, NONE},{""}},
|
||||
{{KEY, A},{"A"}},
|
||||
{{KEY, B},{"B"}},
|
||||
{{KEY, C},{"C"}},
|
||||
{{KEY, D},{"D"}},
|
||||
{{KEY, E},{"E"}},
|
||||
{{KEY, F},{"F"}},
|
||||
{{KEY, G},{"G"}},
|
||||
{{KEY, H},{"H"}},
|
||||
{{KEY, I},{"I"}},
|
||||
{{KEY, J},{"J"}},
|
||||
{{KEY, K},{"K"}},
|
||||
{{KEY, L},{"L"}},
|
||||
{{KEY, M},{"M"}},
|
||||
{{KEY, N},{"N"}},
|
||||
{{KEY, O},{"O"}},
|
||||
{{KEY, P},{"P"}},
|
||||
{{KEY, Q},{"Q"}},
|
||||
{{KEY, R},{"R"}},
|
||||
{{KEY, S},{"S"}},
|
||||
{{KEY, T},{"T"}},
|
||||
{{KEY, U},{"U"}},
|
||||
{{KEY, V},{"V"}},
|
||||
{{KEY, W},{"W"}},
|
||||
{{KEY, X},{"X"}},
|
||||
{{KEY, Y},{"Y"}},
|
||||
{{KEY, Z},{"Z"}},
|
||||
{{KEY, K0},{"0"}},
|
||||
{{KEY, K1},{"1"}},
|
||||
{{KEY, K2},{"2"}},
|
||||
{{KEY, K3},{"3"}},
|
||||
{{KEY, K4},{"4"}},
|
||||
{{KEY, K5},{"5"}},
|
||||
{{KEY, K6},{"6"}},
|
||||
{{KEY, K7},{"7"}},
|
||||
{{KEY, K8},{"8"}},
|
||||
{{KEY, K9},{"9"}},
|
||||
{{KEY, F1},{"F1"}},
|
||||
{{KEY, F2},{"F2"}},
|
||||
{{KEY, F3},{"F3"}},
|
||||
{{KEY, F4},{"F4"}},
|
||||
{{KEY, F5},{"F5"}},
|
||||
{{KEY, F6},{"F6"}},
|
||||
{{KEY, F7},{"F7"}},
|
||||
{{KEY, F8},{"F8"}},
|
||||
{{KEY, F9},{"F9"}},
|
||||
{{KEY, F10},{"F10"}},
|
||||
{{KEY, F11},{"F11"}},
|
||||
{{KEY, F12},{"F12"}},
|
||||
{{KEY, UP},{"UP"}},
|
||||
{{KEY, DOWN},{"DOWN"}},
|
||||
{{KEY, LEFT},{"LEFT"}},
|
||||
{{KEY, RIGHT},{"RIGHT"}},
|
||||
{{KEY, SPACE},{"SPACE"}},
|
||||
{{KEY, TAB},{"TAB"}},
|
||||
{{KEY, SHIFT},{"SHIFT"}},
|
||||
{{KEY, CTRL},{"CTRL"}},
|
||||
{{KEY, INS},{"INS"}},
|
||||
{{KEY, DEL},{"DEL"}},
|
||||
{{KEY, HOME},{"HOME"}},
|
||||
{{KEY, END},{"END"}},
|
||||
{{KEY, PGUP},{"PGUP"}},
|
||||
{{KEY, PGDN},{"PGDN"}},
|
||||
{{KEY, BACK},{"BACK"}},
|
||||
{{KEY, ESCAPE},{"ESC"}},
|
||||
{{KEY, RETURN},{"ENTER"}},
|
||||
{{KEY, ENTER},{"ENTER"}},
|
||||
{{KEY, Key::PAUSE},{"PAUSE"}},
|
||||
{{KEY, SCROLL},{"SCR LK"}},
|
||||
{{KEY, NP0},{"NP0"}},
|
||||
{{KEY, NP1},{"NP1"}},
|
||||
{{KEY, NP2},{"NP2"}},
|
||||
{{KEY, NP3},{"NP3"}},
|
||||
{{KEY, NP4},{"NP4"}},
|
||||
{{KEY, NP5},{"NP5"}},
|
||||
{{KEY, NP6},{"NP6"}},
|
||||
{{KEY, NP7},{"NP7"}},
|
||||
{{KEY, NP8},{"NP8"}},
|
||||
{{KEY, NP9},{"NP9"}},
|
||||
{{KEY, NP_MUL},{"NP*"}},
|
||||
{{KEY, NP_DIV},{"NP/"}},
|
||||
{{KEY, NP_ADD},{"NP+"}},
|
||||
{{KEY, NP_SUB},{"NP-"}},
|
||||
{{KEY, NP_DECIMAL},{"NP."}},
|
||||
{{KEY, PERIOD},{"."}},
|
||||
{{KEY, EQUALS},{"="}},
|
||||
{{KEY, COMMA},{",{"}},
|
||||
{{KEY, MINUS},{"-"}},
|
||||
{{KEY, OEM_1},{";"}},
|
||||
{{KEY, OEM_2},{"/"}},
|
||||
{{KEY, OEM_3},{"~"}},
|
||||
{{KEY, OEM_4},{"["}},
|
||||
{{KEY, OEM_5},{"\\"}},
|
||||
{{KEY, OEM_6},{"]"}},
|
||||
{{KEY, OEM_7},{"\""}},
|
||||
{{KEY, OEM_8},{"\\"}},
|
||||
{{KEY, CAPS_LOCK},{"CAP LK"}},
|
||||
{{KEY, olc::Key::NONE},{""}},
|
||||
{{KEY, olc::Key::A},{"A"}},
|
||||
{{KEY, olc::Key::B},{"B"}},
|
||||
{{KEY, olc::Key::C},{"C"}},
|
||||
{{KEY, olc::Key::D},{"D"}},
|
||||
{{KEY, olc::Key::E},{"E"}},
|
||||
{{KEY, olc::Key::F},{"F"}},
|
||||
{{KEY, olc::Key::G},{"G"}},
|
||||
{{KEY, olc::Key::H},{"H"}},
|
||||
{{KEY, olc::Key::I},{"I"}},
|
||||
{{KEY, olc::Key::J},{"J"}},
|
||||
{{KEY, olc::Key::K},{"K"}},
|
||||
{{KEY, olc::Key::L},{"L"}},
|
||||
{{KEY, olc::Key::M},{"M"}},
|
||||
{{KEY, olc::Key::N},{"N"}},
|
||||
{{KEY, olc::Key::O},{"O"}},
|
||||
{{KEY, olc::Key::P},{"P"}},
|
||||
{{KEY, olc::Key::Q},{"Q"}},
|
||||
{{KEY, olc::Key::R},{"R"}},
|
||||
{{KEY, olc::Key::S},{"S"}},
|
||||
{{KEY, olc::Key::T},{"T"}},
|
||||
{{KEY, olc::Key::U},{"U"}},
|
||||
{{KEY, olc::Key::V},{"V"}},
|
||||
{{KEY, olc::Key::W},{"W"}},
|
||||
{{KEY, olc::Key::X},{"X"}},
|
||||
{{KEY, olc::Key::Y},{"Y"}},
|
||||
{{KEY, olc::Key::Z},{"Z"}},
|
||||
{{KEY, olc::Key::K0},{"0"}},
|
||||
{{KEY, olc::Key::K1},{"1"}},
|
||||
{{KEY, olc::Key::K2},{"2"}},
|
||||
{{KEY, olc::Key::K3},{"3"}},
|
||||
{{KEY, olc::Key::K4},{"4"}},
|
||||
{{KEY, olc::Key::K5},{"5"}},
|
||||
{{KEY, olc::Key::K6},{"6"}},
|
||||
{{KEY, olc::Key::K7},{"7"}},
|
||||
{{KEY, olc::Key::K8},{"8"}},
|
||||
{{KEY, olc::Key::K9},{"9"}},
|
||||
{{KEY, olc::Key::F1},{"F1"}},
|
||||
{{KEY, olc::Key::F2},{"F2"}},
|
||||
{{KEY, olc::Key::F3},{"F3"}},
|
||||
{{KEY, olc::Key::F4},{"F4"}},
|
||||
{{KEY, olc::Key::F5},{"F5"}},
|
||||
{{KEY, olc::Key::F6},{"F6"}},
|
||||
{{KEY, olc::Key::F7},{"F7"}},
|
||||
{{KEY, olc::Key::F8},{"F8"}},
|
||||
{{KEY, olc::Key::F9},{"F9"}},
|
||||
{{KEY, olc::Key::F10},{"F10"}},
|
||||
{{KEY, olc::Key::F11},{"F11"}},
|
||||
{{KEY, olc::Key::F12},{"F12"}},
|
||||
{{KEY, olc::Key::UP},{"UP"}},
|
||||
{{KEY, olc::Key::DOWN},{"DOWN"}},
|
||||
{{KEY, olc::Key::LEFT},{"LEFT"}},
|
||||
{{KEY, olc::Key::RIGHT},{"RIGHT"}},
|
||||
{{KEY, olc::Key::SPACE},{"SPACE"}},
|
||||
{{KEY, olc::Key::TAB},{"TAB"}},
|
||||
{{KEY, olc::Key::SHIFT},{"SHIFT"}},
|
||||
{{KEY, olc::Key::CTRL},{"CTRL"}},
|
||||
{{KEY, olc::Key::INS},{"INS"}},
|
||||
{{KEY, olc::Key::DEL},{"DEL"}},
|
||||
{{KEY, olc::Key::HOME},{"HOME"}},
|
||||
{{KEY, olc::Key::END},{"END"}},
|
||||
{{KEY, olc::Key::PGUP},{"PGUP"}},
|
||||
{{KEY, olc::Key::PGDN},{"PGDN"}},
|
||||
{{KEY, olc::Key::BACK},{"BACK"}},
|
||||
{{KEY, olc::Key::ESCAPE},{"ESC"}},
|
||||
{{KEY, olc::Key::RETURN},{"ENTER"}},
|
||||
{{KEY, olc::Key::ENTER},{"ENTER"}},
|
||||
{{KEY, olc::Key::PAUSE},{"PAUSE"}},
|
||||
{{KEY, olc::Key::SCROLL},{"SCR LK"}},
|
||||
{{KEY, olc::Key::NP0},{"NP0"}},
|
||||
{{KEY, olc::Key::NP1},{"NP1"}},
|
||||
{{KEY, olc::Key::NP2},{"NP2"}},
|
||||
{{KEY, olc::Key::NP3},{"NP3"}},
|
||||
{{KEY, olc::Key::NP4},{"NP4"}},
|
||||
{{KEY, olc::Key::NP5},{"NP5"}},
|
||||
{{KEY, olc::Key::NP6},{"NP6"}},
|
||||
{{KEY, olc::Key::NP7},{"NP7"}},
|
||||
{{KEY, olc::Key::NP8},{"NP8"}},
|
||||
{{KEY, olc::Key::NP9},{"NP9"}},
|
||||
{{KEY, olc::Key::NP_MUL},{"NP*"}},
|
||||
{{KEY, olc::Key::NP_DIV},{"NP/"}},
|
||||
{{KEY, olc::Key::NP_ADD},{"NP+"}},
|
||||
{{KEY, olc::Key::NP_SUB},{"NP-"}},
|
||||
{{KEY, olc::Key::NP_DECIMAL},{"NP."}},
|
||||
{{KEY, olc::Key::PERIOD},{"."}},
|
||||
{{KEY, olc::Key::EQUALS},{"="}},
|
||||
{{KEY, olc::Key::COMMA},{",{"}},
|
||||
{{KEY, olc::Key::MINUS},{"-"}},
|
||||
{{KEY, olc::Key::OEM_1},{";"}},
|
||||
{{KEY, olc::Key::OEM_2},{"/"}},
|
||||
{{KEY, olc::Key::OEM_3},{"~"}},
|
||||
{{KEY, olc::Key::OEM_4},{"["}},
|
||||
{{KEY, olc::Key::OEM_5},{"\\"}},
|
||||
{{KEY, olc::Key::OEM_6},{"]"}},
|
||||
{{KEY, olc::Key::OEM_7},{"\""}},
|
||||
{{KEY, olc::Key::OEM_8},{"\\"}},
|
||||
{{KEY, olc::Key::CAPS_LOCK},{"CAP LK"}},
|
||||
{{KEY, olc::ENUM_END},{""}},
|
||||
{{KEY, SHOULDER},{"Q-E","themes/button_qe.png"}},
|
||||
{{KEY, ARROWS},{"Arrow Keys","themes/button_arrows.png"}},
|
||||
|
||||
@ -49,6 +49,64 @@ DEFINE_STRATEGY(MAJOR_HAWK)
|
||||
//Runs the Hawk strategy and has an aggressive mode when the amount of this monster falls below an amount.
|
||||
const int majorHawkCount=std::accumulate(MONSTER_LIST.begin(),MONSTER_LIST.end(),0,[&](const int&acc,const std::shared_ptr<Monster>&monster){return std::move(acc)+((monster->IsAlive()&&monster->GetName()==ConfigString("Aggressive Name Check"))?1:0);});
|
||||
|
||||
if(majorHawkCount<=ConfigInt("Aggressive Hawk Count"))HAWK(m,fElapsedTime,"Major Hawk");
|
||||
else m.RunStrategy(HAWK); //Use normal hawk behaviors when there are too many Major Hawks.
|
||||
if(majorHawkCount<=ConfigInt("Aggressive Hawk Count")){
|
||||
enum PhaseName{
|
||||
INITIALIZE,
|
||||
FLYING,
|
||||
PREPARE_CHARGE,
|
||||
CHARGE
|
||||
};
|
||||
|
||||
#pragma region Flying Hover Effect
|
||||
m.SetZ(std::max(float(m.F(A::FLYING_HEIGHT)+ConfigFloat("Aggressive Flight Oscillation Amount")*sin((PI*m.TimeSpentAlive())/1.5f)),0.f));
|
||||
#pragma endregion
|
||||
|
||||
switch(PHASE()){
|
||||
case INITIALIZE:{
|
||||
m.F(A::TARGET_FLYING_HEIGHT)=m.F(A::FLYING_HEIGHT)=ConfigFloat("Aggressive Flight Height")-ConfigFloat("Aggressive Flight Height Variance")+util::random_range(0,ConfigFloat("Aggressive Flight Height Variance")*2);
|
||||
m.B(A::RANDOM_DIRECTION)=int(util::random_range(0,2));
|
||||
SETPHASE(FLYING);
|
||||
m.AddBuff(BuffType::SELF_INFLICTED_SLOWDOWN,INFINITE,util::random_range(0,ConfigFloat("Aggressive Flight Speed Variance")/100));
|
||||
m.F(A::ATTACK_COOLDOWN)=util::random_range(1.f,ConfigFloat("Aggressive Flight Charge Cooldown"));
|
||||
}break;
|
||||
case FLYING:{
|
||||
m.F(A::ATTACK_COOLDOWN)-=fElapsedTime;
|
||||
if(m.F(A::FLYING_HEIGHT)<m.F(A::TARGET_FLYING_HEIGHT))m.F(A::FLYING_HEIGHT)=std::min(m.F(A::TARGET_FLYING_HEIGHT),m.F(A::FLYING_HEIGHT)+ConfigFloat("Aggressive Attack Z Speed")*fElapsedTime);
|
||||
if(m.F(A::ATTACK_COOLDOWN)<=0){
|
||||
m.F(A::CASTING_TIMER)=ConfigFloat("Aggressive Attack Wait Time");
|
||||
SETPHASE(PREPARE_CHARGE);
|
||||
}else{
|
||||
float dirToPlayer{util::pointTo(game->GetPlayer()->GetPos(),m.GetPos()).polar().y};
|
||||
dirToPlayer+=m.B(A::RANDOM_DIRECTION)?0.25*PI:-0.25*PI;
|
||||
m.target=game->GetPlayer()->GetPos()+vf2d{ConfigFloat("Aggressive Flight Distance"),dirToPlayer}.cart();
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
}
|
||||
}break;
|
||||
case PREPARE_CHARGE:{
|
||||
m.F(A::CASTING_TIMER)-=fElapsedTime;
|
||||
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
|
||||
m.PerformAnimation("ATTACK");
|
||||
if(m.F(A::CASTING_TIMER)<=0){
|
||||
SETPHASE(CHARGE);
|
||||
m.PerformAnimation("ATTACKING");
|
||||
m.target=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(ConfigFloat("Aggressive Flight Distance")*2.f);
|
||||
m.UpdateFacingDirection(m.target);
|
||||
}
|
||||
}break;
|
||||
case CHARGE:{
|
||||
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=true;
|
||||
if(m.F(A::FLYING_HEIGHT)>-ConfigFloat("Aggressive Flight Oscillation Amount"))m.F(A::FLYING_HEIGHT)=std::max(-ConfigFloat("Aggressive Flight Oscillation Amount"),m.F(A::FLYING_HEIGHT)-ConfigFloat("Aggressive Attack Z Speed")*fElapsedTime);
|
||||
m.targetAcquireTimer=1.f;
|
||||
m.RunStrategy(RUN_TOWARDS);
|
||||
float distToTarget=geom2d::line<float>(m.GetPos(),m.target).length();
|
||||
if(distToTarget<12.f){
|
||||
m.F(A::TARGET_FLYING_HEIGHT)=ConfigFloat("Aggressive Flight Height")-ConfigFloat("Aggressive Flight Height Variance")+util::random_range(0,ConfigFloat("Aggressive Flight Height Variance")*2);
|
||||
SETPHASE(FLYING);
|
||||
m.F(A::ATTACK_COOLDOWN)=ConfigFloat("Aggressive Flight Charge Cooldown");
|
||||
m.PerformJumpAnimation();
|
||||
}
|
||||
m.B(A::IGNORE_DEFAULT_ANIMATIONS)=false;
|
||||
}break;
|
||||
}
|
||||
}else m.RunStrategy(HAWK); //Use normal hawk behaviors when there are too many Major Hawks.
|
||||
END_STRATEGY
|
||||
@ -58,8 +58,8 @@ std::vector<Menu*>Menu::stack;
|
||||
std::map<MenuType,Menu*>Menu::menus;
|
||||
std::string Menu::themeSelection="BlueDefault";
|
||||
safeunorderedmap<std::string,Theme>Menu::themes;
|
||||
safemap<std::string_view,std::vector<std::weak_ptr<MenuComponent>>>Menu::inventoryListeners;
|
||||
safemap<std::string_view,std::vector<std::weak_ptr<MenuComponent>>>Menu::merchantInventoryListeners;
|
||||
safemap<ITCategory,std::vector<std::weak_ptr<MenuComponent>>>Menu::inventoryListeners;
|
||||
safemap<ITCategory,std::vector<std::weak_ptr<MenuComponent>>>Menu::merchantInventoryListeners;
|
||||
std::vector<std::weak_ptr<MenuComponent>>Menu::equipStatListeners;
|
||||
std::vector<std::weak_ptr<MenuComponent>>Menu::chapterListeners;
|
||||
const vf2d Menu::CENTERED = {-456,-456};
|
||||
|
||||
@ -165,7 +165,7 @@ public:
|
||||
}
|
||||
void Update(AiL*game);
|
||||
void Draw(AiL*game);
|
||||
static void InitializeMenuListenerCategory(std::string_view category);
|
||||
static void InitializeMenuListenerCategory(const std::string&category);
|
||||
static void InitializeMenus();
|
||||
static void LockInListeners();
|
||||
static void OpenMenu(MenuType menu,bool cover=true);
|
||||
|
||||
@ -65,9 +65,12 @@ INCLUDE_BULLET_LIST
|
||||
INCLUDE_DATA
|
||||
INCLUDE_GFX
|
||||
INCLUDE_SPAWNER_CONTROLLER
|
||||
INCLUDE_SPAWNER_LIST
|
||||
|
||||
safemap<std::string,std::function<void(Monster&,float,std::string)>>STRATEGY_DATA;
|
||||
std::unordered_map<std::string,Renderable*>MonsterData::imgs;
|
||||
safeunorderedmap<Monster::MonsterStrategy,Monster::StrategyFunction>Monster::monsterStrategies;
|
||||
safeunorderedmap<std::string,Monster::MonsterStrategy>Monster::stringToStrategyMap;
|
||||
|
||||
Monster::Monster(vf2d pos,MonsterData data,bool upperLevel,bool bossMob):
|
||||
pos(pos),spawnPos(pos),hp(data.GetHealth()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),name(data.GetInternalName()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(Direction::WEST),lifetime(GetTotalLifetime()),collisionRadius(data.GetCollisionRadius()),arrowIndicator(data.HasArrowIndicator()){
|
||||
@ -442,9 +445,7 @@ void Monster::Update(const float fElapsedTime){
|
||||
}
|
||||
}
|
||||
RunStrategy:
|
||||
if(CanMove()){
|
||||
RUN_STRATEGY(GetStrategyName());
|
||||
}
|
||||
if(CanMove())RunStrategy(stringToStrategyMap.at(GetStrategyName()));
|
||||
}
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
if(HasMountedMonster())mounted_animation.value().UpdateState(internal_mounted_animState,fElapsedTime);
|
||||
@ -1085,11 +1086,11 @@ void Monster::SetZ(float z){
|
||||
this->z=z;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const StrategyName)>func){
|
||||
void Monster::SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const std::string&)>func){
|
||||
strategyDraw=func;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const StrategyName)>func){
|
||||
void Monster::SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const std::string&)>func){
|
||||
strategyDrawOverlay=func;
|
||||
}
|
||||
|
||||
@ -1339,11 +1340,11 @@ const float Monster::GetCollisionDamage()const{
|
||||
else return MONSTER_DATA[name].GetCollisionDmg();
|
||||
}
|
||||
|
||||
void Monster::SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const StrategyName strategyName)>func){
|
||||
void Monster::SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const std::string&strategyName)>func){
|
||||
strategyDeathFunc=func;
|
||||
}
|
||||
|
||||
void Monster::SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName strategyName)>func){
|
||||
void Monster::SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName&strategyName)>func){
|
||||
strategyOnHitFunc=func;
|
||||
}
|
||||
|
||||
@ -1740,10 +1741,10 @@ const float Monster::UnconsciousTime()const{
|
||||
const std::vector<MonsterAbilityData>&Monster::GetAbilities()const{
|
||||
return MONSTER_DATA.at(name).GetAbilities();
|
||||
}
|
||||
void Monster::SetPhase(std::string_view strategyName,int phase){
|
||||
void Monster::SetPhase(const std::string&strategyName,int phase){
|
||||
this->phase[strategyName]=phase;
|
||||
}
|
||||
const int Monster::GetPhase(const std::string_view strategyName){
|
||||
const int Monster::GetPhase(const std::string&strategyName){
|
||||
if(!phase.contains(strategyName))phase[strategyName]=0;
|
||||
return this->phase[strategyName];
|
||||
}
|
||||
|
||||
@ -80,6 +80,7 @@ class Monster:public IAttributable{
|
||||
friend class InventoryCreator;
|
||||
friend class DeathSpawnInfo;
|
||||
friend class MonsterTests::MonsterTest;
|
||||
friend class MonsterData;
|
||||
public:
|
||||
enum MonsterStrategy{
|
||||
RUN_TOWARDS,
|
||||
@ -128,63 +129,64 @@ public:
|
||||
};
|
||||
struct STRATEGY{
|
||||
static std::string ERR;
|
||||
static int _GetInt(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static float _GetFloat(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static Pixel _GetPixel(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static int _GetInt(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
static float _GetFloat(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
static Pixel _GetPixel(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
//Converts unit distances to pixels. (Every 100 units = 24 pixels)
|
||||
static float _GetPixels(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static olc::vf2d _GetVec(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static const std::string&_GetString(Monster&m,std::string_view param,std::string_view strategy,int index=0);
|
||||
static const datafile&_Get(Monster&m,std::string_view param,std::string_view strategy);
|
||||
static void RUN_TOWARDS(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SHOOT_AFAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void TURRET(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SLIMEKING(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void RUN_AWAY(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void FROG(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void WOLF(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BEAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void URSULE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void NPC(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BOAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOW(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GOBLIN_BOMB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void HAWK(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void ZEPHY(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void MAJOR_HAWK(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void DONOTHING(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void STONE_GOLEM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void BREAKING_PILLAR(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_MARAUDER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SEAGULL(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SANDWORM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATE_BUCCANEER(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PARROT(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void CRAB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GIANT_CRAB(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GIANT_OCTOPUS(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATES_TREASURE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void PIRATES_COIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_BARBARIAN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void _RUN_RIGHT(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_CAPTAIN(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static void SKELETON_FIRE_MAGE(Monster&m,float fElapsedTime,std::string_view strategy);
|
||||
static float _GetPixels(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
static olc::vf2d _GetVec(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
static const std::string&_GetString(Monster&m,const std::string¶m,const std::string&strategy,int index=0);
|
||||
static const datafile&_Get(Monster&m,const std::string¶m,const std::string&strategy);
|
||||
static void RUN_TOWARDS(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SHOOT_AFAR(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void TURRET(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SLIMEKING(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void RUN_AWAY(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void FROG(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void WOLF(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void BEAR(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void URSULE(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void NPC(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void BOAR(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GOBLIN_DAGGER(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GOBLIN_BOW(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GOBLIN_BOAR_RIDER(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GOBLIN_BOMB(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void HAWK(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void STONE_ELEMENTAL(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void ZEPHY(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void MAJOR_HAWK(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void DONOTHING(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void STONE_GOLEM(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void BREAKING_PILLAR(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PIRATE_MARAUDER(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PIRATE_CAPTAIN(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SEAGULL(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SANDWORM(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PIRATE_BUCCANEER(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PARROT(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void CRAB(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GIANT_CRAB(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GIANT_OCTOPUS(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void OCTOPUS_ARM(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void GHOST_OF_PIRATE_CAPTAIN(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PIRATES_TREASURE(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void PIRATES_COIN(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SKELETON_BARBARIAN(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void _RUN_RIGHT(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SKELETON_CAPTAIN(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SKELETON_CAPTAIN_FLAG(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
static void SKELETON_FIRE_MAGE(Monster&m,float fElapsedTime,const std::string&strategy);
|
||||
};
|
||||
struct StrategyFunction{
|
||||
std::string name;
|
||||
std::function<void(Monster&,float,std::string_view)>function;
|
||||
std::function<void(Monster&,float,std::string)>function;
|
||||
};
|
||||
void RunStrategy(const MonsterStrategy&strategy);
|
||||
|
||||
private:
|
||||
static safeunorderedmap<MonsterStrategy,StrategyFunction>monsterStrategies;
|
||||
static safeunorderedmap<std::string,MonsterStrategy>stringToStrategyMap;
|
||||
public:
|
||||
Monster()=delete;
|
||||
Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false);
|
||||
@ -272,10 +274,10 @@ public:
|
||||
const std::function<void(Monster&,float,std::string)>&GetStrategy()const;
|
||||
void SetSize(float newSize,bool immediate=true);
|
||||
geom2d::circle<float>BulletCollisionHitbox();
|
||||
void SetStrategyDrawFunction(std::function<void(AiL*game,Monster&monster,const StrategyName strategy)>func);
|
||||
void SetStrategyDrawOverlayFunction(std::function<void(AiL*game,Monster&monster,const StrategyName strategy)>func);
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const StrategyName strategy){};
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDrawOverlay=[](AiL*pge,Monster&m,const StrategyName strategy){};
|
||||
void SetStrategyDrawFunction(std::function<void(AiL*game,Monster&monster,const std::string&strategy)>func);
|
||||
void SetStrategyDrawOverlayFunction(std::function<void(AiL*game,Monster&monster,const std::string&strategy)>func);
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const std::string&strategy){};
|
||||
std::function<void(AiL*,Monster&,const std::string&)>strategyDrawOverlay=[](AiL*pge,Monster&m,const std::string&strategy){};
|
||||
const ItemAttributable&GetStats()const;
|
||||
const EventName&GetHurtSound();
|
||||
const EventName&GetDeathSound();
|
||||
@ -339,8 +341,8 @@ public:
|
||||
const bool FaceTarget()const;
|
||||
void ResetCurseOfDeathDamage();
|
||||
void MoveForward(const vf2d&moveForwardVec,const float fElapsedTime); //Moves the monster forward in given cartesian vector direction (will be auto-normalized) applying speeed boosts and other proper movement requirements as if you wanted to move on a frame-by-frame basis.
|
||||
void SetPhase(std::string_view,int phase);
|
||||
const int GetPhase(const std::string_view strategyName);
|
||||
void SetPhase(const std::string&strategyName,int phase);
|
||||
const int GetPhase(const std::string&strategyName);
|
||||
const float GetOriginalCollisionRadius()const;
|
||||
void SetCollisionRadius(const float collisionRadius);
|
||||
const std::string&GetStrategyName()const;
|
||||
@ -406,9 +408,9 @@ private:
|
||||
std::function<void(const HurtDamageInfo damageInfo,Monster&,const std::string&)>strategyOnHitFunc{};
|
||||
//Sets the strategy death function that runs when a monster dies.
|
||||
// The function should return false to indicate the event is over. If the event should keep running, return true.
|
||||
void SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const StrategyName strategyName)>func);
|
||||
void SetStrategyDeathFunction(std::function<bool(GameEvent&event,Monster&monster,const StrategyName&strategyName)>func);
|
||||
// The function is called immediately after taking damage. Note the damage has already gone through, and the damage data contains the final damage that was received after all damage reductions were applied. It cannot be modified.
|
||||
void SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName strategyName)>func);
|
||||
void SetStrategyOnHitFunction(std::function<void(const HurtDamageInfo damageData,Monster&monster,const StrategyName&strategyName)>func);
|
||||
//If you are trying to change a Get() stat, use the STAT_UP buff (and the optional argument) to supply an attribute you want to apply.
|
||||
const ItemAttribute&GetBonusStat(std::string_view attr)const;
|
||||
//Returns false if the monster could not be moved to the requested location due to collision.
|
||||
|
||||
@ -14,6 +14,7 @@ std::unordered_map<std::string_view,std::function<void(SpellName,CastPos,CasterM
|
||||
CreateBullet(FireBolt)(m.GetPos(),util::pointTo(m.GetPos(),game->GetPlayer()->GetPos())*ConfigFloat("Fire Bolt Bullet Speed"),"Wizard.Ability 1.Radius"_F/100*12,m.GetAttack()*ConfigFloat("Fire Bolt Damage Mult"),m.OnUpperLevel())EndBullet;
|
||||
}},
|
||||
{"Blizzard",[](SpellName spellName,CastPos pos,CasterMonster&m,const StrategyName&strategy)->void{
|
||||
//game->AddEffect(std::make_unique<Blizzard>(pos,ConfigFloat("Blizzard Radius")
|
||||
}},
|
||||
{"Freeze Ground",[](SpellName spellName,CastPos pos,CasterMonster&m,const StrategyName&strategy)->void{
|
||||
}},
|
||||
|
||||
@ -45,7 +45,6 @@ All rights reserved.
|
||||
#include"MonsterAbility.h"
|
||||
|
||||
INCLUDE_DATA
|
||||
INCLUDE_STRATEGY_DATA
|
||||
INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_ITEM_DATA
|
||||
INCLUDE_game
|
||||
@ -163,9 +162,7 @@ void MonsterData::InitializeMonsterData(){
|
||||
}
|
||||
|
||||
const std::string&strategyName=DATA["Monsters"][MonsterName]["Strategy"].GetString();
|
||||
if(!STRATEGY_DATA.count(strategyName)){
|
||||
ERR("WARNING! Strategy for "<<MonsterName<<" does not exist in strategy database!");
|
||||
}
|
||||
if(std::none_of(Monster::monsterStrategies.begin(),Monster::monsterStrategies.end(),[&strategyName](const Monster::StrategyFunction&data){return strategyName==data.name;}))ERR("WARNING! Strategy for "<<MonsterName<<" does not exist in strategy database!");
|
||||
|
||||
if(DATA["Monsters"][MonsterName].HasProperty("Display Name"))MonsterDisplayName=DATA["Monsters"][MonsterName]["Display Name"].GetString();
|
||||
|
||||
@ -349,9 +346,7 @@ void MonsterData::InitializeNPCData(){
|
||||
}
|
||||
|
||||
const std::string&strategyName=DATA["NPCs"][NPCName]["Strategy"].GetString();
|
||||
if(!STRATEGY_DATA.count(strategyName)){
|
||||
ERR("WARNING! Strategy for "<<NPCName<<" does not exist in strategy database!");
|
||||
}
|
||||
if(std::none_of(Monster::monsterStrategies.begin(),Monster::monsterStrategies.end(),[&strategyName](const Monster::StrategyFunction&data){return strategyName==data.name;}))ERR("WARNING! Strategy for "<<strategyName<<" does not exist in strategy database!");
|
||||
|
||||
MonsterData monster(NPCName,NPCName,health,attack,xp,drops,moveSpd,size/100,strategyName,collisionDmg);
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ All rights reserved.
|
||||
|
||||
#include"MonsterAttribute.h"
|
||||
|
||||
using StrategyName=std::string_view;
|
||||
using StrategyName=std::string;
|
||||
|
||||
#pragma once
|
||||
#define ConfigInt(param) Monster::STRATEGY::_GetInt(m,param,strategy)
|
||||
@ -60,7 +60,7 @@ using StrategyName=std::string_view;
|
||||
#define SETPHASE(phase) m.SetPhase(strategy,phase)
|
||||
|
||||
#define DEFINE_STRATEGY(strategyName) \
|
||||
void Monster::STRATEGY::strategyName(Monster&m,float fElapsedTime,std::string_view strategy){ \
|
||||
void Monster::STRATEGY::strategyName(Monster&m,float fElapsedTime,const std::string&strategy){ \
|
||||
using enum MonsterStrategy;
|
||||
#define END_STRATEGY }
|
||||
|
||||
|
||||
@ -44,51 +44,54 @@ INCLUDE_DATA
|
||||
std::string Monster::STRATEGY::ERR{};
|
||||
|
||||
void Monster::InitializeStrategies(){
|
||||
Monster::monsterStrategies.insert(RUN_TOWARDS,StrategyFunction{"Run Towards",Monster::STRATEGY::RUN_TOWARDS});
|
||||
Monster::monsterStrategies.insert(SHOOT_AFAR,StrategyFunction{"Shoot Afar",Monster::STRATEGY::SHOOT_AFAR});
|
||||
Monster::monsterStrategies.insert(TURRET,StrategyFunction{"Turret",Monster::STRATEGY::TURRET});
|
||||
Monster::monsterStrategies.insert(SLIMEKING,StrategyFunction{"Slime King",Monster::STRATEGY::SLIMEKING});
|
||||
Monster::monsterStrategies.insert(RUN_AWAY,StrategyFunction{"Run Away",Monster::STRATEGY::RUN_AWAY});
|
||||
Monster::monsterStrategies.insert(FROG,StrategyFunction{"Frog",Monster::STRATEGY::FROG});
|
||||
Monster::monsterStrategies.insert(WOLF,StrategyFunction{"Wolf",Monster::STRATEGY::WOLF});
|
||||
Monster::monsterStrategies.insert(BEAR,StrategyFunction{"Bear",Monster::STRATEGY::BEAR});
|
||||
Monster::monsterStrategies.insert(URSULE,StrategyFunction{"Ursule",Monster::STRATEGY::URSULE});
|
||||
Monster::monsterStrategies.insert(NPC,StrategyFunction{"NPC",Monster::STRATEGY::NPC});
|
||||
Monster::monsterStrategies.insert(BOAR,StrategyFunction{"Boar",Monster::STRATEGY::BOAR});
|
||||
Monster::monsterStrategies.insert(GOBLIN_DAGGER,StrategyFunction{"Goblin Dagger",Monster::STRATEGY::GOBLIN_DAGGER});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOW,StrategyFunction{"Goblin Bow",Monster::STRATEGY::GOBLIN_BOW});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOAR_RIDER,StrategyFunction{"Goblin Boar Rider",Monster::STRATEGY::GOBLIN_BOAR_RIDER});
|
||||
Monster::monsterStrategies.insert(GOBLIN_BOMB,StrategyFunction{"Goblin Bomb",Monster::STRATEGY::GOBLIN_BOMB});
|
||||
Monster::monsterStrategies.insert(HAWK,StrategyFunction{"Hawk",Monster::STRATEGY::HAWK});
|
||||
Monster::monsterStrategies.insert(STONE_ELEMENTAL,StrategyFunction{"Stone Elemental",Monster::STRATEGY::STONE_ELEMENTAL});
|
||||
Monster::monsterStrategies.insert(ZEPHY,StrategyFunction{"Zephy",Monster::STRATEGY::ZEPHY});
|
||||
Monster::monsterStrategies.insert(MAJOR_HAWK,StrategyFunction{"Major Hawk",Monster::STRATEGY::MAJOR_HAWK});
|
||||
Monster::monsterStrategies.insert(DONOTHING,StrategyFunction{"Do Nothing",Monster::STRATEGY::DONOTHING});
|
||||
Monster::monsterStrategies.insert(STONE_GOLEM,StrategyFunction{"Stone Golem",Monster::STRATEGY::STONE_GOLEM});
|
||||
Monster::monsterStrategies.insert(BREAKING_PILLAR,StrategyFunction{"Breaking Pillar",Monster::STRATEGY::BREAKING_PILLAR});
|
||||
Monster::monsterStrategies.insert(PIRATE_MARAUDER,StrategyFunction{"Pirate Marauder",Monster::STRATEGY::PIRATE_MARAUDER});
|
||||
Monster::monsterStrategies.insert(PIRATE_CAPTAIN,StrategyFunction{"Pirate Captain",Monster::STRATEGY::PIRATE_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(PIRATE_BUCCANEER,StrategyFunction{"Pirate Buccaneer",Monster::STRATEGY::PIRATE_BUCCANEER});
|
||||
Monster::monsterStrategies.insert(CRAB,StrategyFunction{"Crab",Monster::STRATEGY::CRAB});
|
||||
Monster::monsterStrategies.insert(SEAGULL,StrategyFunction{"Seagull",Monster::STRATEGY::SEAGULL});
|
||||
Monster::monsterStrategies.insert(SANDWORM,StrategyFunction{"Sandworm",Monster::STRATEGY::SANDWORM});
|
||||
Monster::monsterStrategies.insert(PARROT,StrategyFunction{"Parrot",Monster::STRATEGY::PARROT});
|
||||
Monster::monsterStrategies.insert(GIANT_CRAB,StrategyFunction{"Giant Crab",Monster::STRATEGY::GIANT_CRAB});
|
||||
Monster::monsterStrategies.insert(GIANT_OCTOPUS,StrategyFunction{"Giant Octopus",Monster::STRATEGY::GIANT_OCTOPUS});
|
||||
Monster::monsterStrategies.insert(OCTOPUS_ARM,StrategyFunction{"Octopus Arm",Monster::STRATEGY::OCTOPUS_ARM});
|
||||
Monster::monsterStrategies.insert(GHOST_OF_PIRATE_CAPTAIN,StrategyFunction{"Ghost of Pirate Captain",Monster::STRATEGY::GHOST_OF_PIRATE_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(PIRATES_TREASURE,StrategyFunction{"Pirate's Treasure",Monster::STRATEGY::PIRATES_TREASURE});
|
||||
Monster::monsterStrategies.insert(PIRATES_COIN,StrategyFunction{"Pirate's Coin",Monster::STRATEGY::PIRATES_COIN});
|
||||
Monster::monsterStrategies.insert(SKELETON_BARBARIAN,StrategyFunction{"Skeleton Barbarian",Monster::STRATEGY::SKELETON_BARBARIAN});
|
||||
Monster::monsterStrategies.insert(_RUN_RIGHT,StrategyFunction{"[TEST]Run Right",Monster::STRATEGY::_RUN_RIGHT});
|
||||
Monster::monsterStrategies.insert(SKELETON_CAPTAIN,StrategyFunction{"Skeleton Captain",Monster::STRATEGY::SKELETON_CAPTAIN});
|
||||
Monster::monsterStrategies.insert(SKELETON_CAPTAIN_FLAG,StrategyFunction{"Skeleton Captain Flag",Monster::STRATEGY::SKELETON_CAPTAIN_FLAG});
|
||||
Monster::monsterStrategies.insert(SKELETON_FIRE_MAGE,StrategyFunction{"Skeleton Fire Mage",Monster::STRATEGY::SKELETON_FIRE_MAGE});
|
||||
#define ADD_STRATEGY(enum,name) \
|
||||
Monster::monsterStrategies.insert(enum,StrategyFunction{name,Monster::STRATEGY::enum}); \
|
||||
Monster::stringToStrategyMap.insert(name,enum);
|
||||
ADD_STRATEGY(RUN_TOWARDS,"Run Towards");
|
||||
ADD_STRATEGY(SHOOT_AFAR,"Shoot Afar");
|
||||
ADD_STRATEGY(TURRET,"Turret");
|
||||
ADD_STRATEGY(SLIMEKING,"Slime King");
|
||||
ADD_STRATEGY(RUN_AWAY,"Run Away");
|
||||
ADD_STRATEGY(FROG,"Frog");
|
||||
ADD_STRATEGY(WOLF,"Wolf");
|
||||
ADD_STRATEGY(BEAR,"Bear");
|
||||
ADD_STRATEGY(URSULE,"Ursule");
|
||||
ADD_STRATEGY(NPC,"NPC");
|
||||
ADD_STRATEGY(BOAR,"Boar");
|
||||
ADD_STRATEGY(GOBLIN_DAGGER,"Goblin Dagger");
|
||||
ADD_STRATEGY(GOBLIN_BOW,"Goblin Bow");
|
||||
ADD_STRATEGY(GOBLIN_BOAR_RIDER,"Goblin Boar Rider");
|
||||
ADD_STRATEGY(GOBLIN_BOMB,"Goblin Bomb");
|
||||
ADD_STRATEGY(HAWK,"Hawk");
|
||||
ADD_STRATEGY(STONE_ELEMENTAL,"Stone Elemental");
|
||||
ADD_STRATEGY(ZEPHY,"Zephy");
|
||||
ADD_STRATEGY(MAJOR_HAWK,"Major Hawk");
|
||||
ADD_STRATEGY(DONOTHING,"Do Nothing");
|
||||
ADD_STRATEGY(STONE_GOLEM,"Stone Golem");
|
||||
ADD_STRATEGY(BREAKING_PILLAR,"Breaking Pillar");
|
||||
ADD_STRATEGY(PIRATE_MARAUDER,"Pirate Marauder");
|
||||
ADD_STRATEGY(PIRATE_CAPTAIN,"Pirate Captain");
|
||||
ADD_STRATEGY(PIRATE_BUCCANEER,"Pirate Buccaneer");
|
||||
ADD_STRATEGY(CRAB,"Crab");
|
||||
ADD_STRATEGY(SEAGULL,"Seagull");
|
||||
ADD_STRATEGY(SANDWORM,"Sandworm");
|
||||
ADD_STRATEGY(PARROT,"Parrot");
|
||||
ADD_STRATEGY(GIANT_CRAB,"Giant Crab");
|
||||
ADD_STRATEGY(GIANT_OCTOPUS,"Giant Octopus");
|
||||
ADD_STRATEGY(OCTOPUS_ARM,"Octopus Arm");
|
||||
ADD_STRATEGY(GHOST_OF_PIRATE_CAPTAIN,"Ghost of Pirate Captain");
|
||||
ADD_STRATEGY(PIRATES_TREASURE,"Pirate's Treasure");
|
||||
ADD_STRATEGY(PIRATES_COIN,"Pirate's Coin");
|
||||
ADD_STRATEGY(SKELETON_BARBARIAN,"Skeleton Barbarian");
|
||||
ADD_STRATEGY(_RUN_RIGHT,"[TEST]Run Right");
|
||||
ADD_STRATEGY(SKELETON_CAPTAIN,"Skeleton Captain");
|
||||
ADD_STRATEGY(SKELETON_CAPTAIN_FLAG,"Skeleton Captain Flag");
|
||||
ADD_STRATEGY(SKELETON_FIRE_MAGE,"Skeleton Fire Mage");
|
||||
|
||||
Monster::monsterStrategies.SetInitialized();
|
||||
}
|
||||
|
||||
int Monster::STRATEGY::_GetInt(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
int Monster::STRATEGY::_GetInt(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return float(DATA["NPCs"][m.name].GetProperty(param).GetInt(index));
|
||||
}else
|
||||
@ -102,7 +105,7 @@ int Monster::STRATEGY::_GetInt(Monster&m,std::string_view param,std::string_view
|
||||
return{};
|
||||
}
|
||||
}
|
||||
float Monster::STRATEGY::_GetFloat(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
float Monster::STRATEGY::_GetFloat(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return float(DATA["NPCs"][m.name].GetProperty(param).GetReal(index));
|
||||
}else
|
||||
@ -116,7 +119,7 @@ float Monster::STRATEGY::_GetFloat(Monster&m,std::string_view param,std::string_
|
||||
return{};
|
||||
}
|
||||
}
|
||||
const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
const std::string&Monster::STRATEGY::_GetString(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetString(index);
|
||||
}else
|
||||
@ -130,7 +133,7 @@ const std::string&Monster::STRATEGY::_GetString(Monster&m,std::string_view param
|
||||
return ERR;
|
||||
}
|
||||
}
|
||||
vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
vf2d Monster::STRATEGY::_GetVec(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return {DATA["NPCs"][m.name].GetProperty(param).GetReal(index),DATA["NPCs"][m.name].GetProperty(param).GetReal(index+1)};
|
||||
}else
|
||||
@ -144,7 +147,7 @@ vf2d Monster::STRATEGY::_GetVec(Monster&m,std::string_view param,std::string_vie
|
||||
return{};
|
||||
}
|
||||
}
|
||||
const datafile&Monster::STRATEGY::_Get(Monster&m,std::string_view param,std::string_view strategy){
|
||||
const datafile&Monster::STRATEGY::_Get(Monster&m,const std::string¶m,const std::string&strategy){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param);
|
||||
}else
|
||||
@ -158,7 +161,7 @@ const datafile&Monster::STRATEGY::_Get(Monster&m,std::string_view param,std::str
|
||||
return DATA;
|
||||
}
|
||||
}
|
||||
Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
Pixel Monster::STRATEGY::_GetPixel(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetPixel(index);
|
||||
}else
|
||||
@ -173,7 +176,7 @@ Pixel Monster::STRATEGY::_GetPixel(Monster&m,std::string_view param,std::string_
|
||||
}
|
||||
}
|
||||
|
||||
float Monster::STRATEGY::_GetPixels(Monster&m,std::string_view param,std::string_view strategy,int index){
|
||||
float Monster::STRATEGY::_GetPixels(Monster&m,const std::string¶m,const std::string&strategy,int index){
|
||||
if(m.IsNPC()&&DATA["NPCs"][m.name].HasProperty(param)){
|
||||
return DATA["NPCs"][m.name].GetProperty(param).GetReal(index)/100.f*24;
|
||||
}else
|
||||
|
||||
@ -52,9 +52,7 @@ INCLUDE_ANIMATION_DATA
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_GFX
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strategy){
|
||||
DEFINE_STRATEGY(SLIMEKING)
|
||||
float bulletSpd=ConfigFloat("BulletSpd")/100*24;
|
||||
|
||||
m.F(A::SHOOT_TIMER)=std::max(0.f,m.F(A::SHOOT_TIMER)-fElapsedTime);
|
||||
@ -157,7 +155,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
|
||||
};
|
||||
|
||||
if(m.F(A::RUN_AWAY_TIMER)>0){
|
||||
Monster::STRATEGY::m.RunStrategy(RUN_AWAY);
|
||||
m.RunStrategy(RUN_AWAY);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -380,7 +378,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
|
||||
}break;
|
||||
case 5:{
|
||||
float targetSize=ConfigFloat("Phase5.SizeLossPerHit")/100*m.I(A::HITS_UNTIL_DEATH);
|
||||
Monster::STRATEGY::m.RunStrategy(RUN_AWAY);
|
||||
m.RunStrategy(RUN_AWAY);
|
||||
if(targetSize>0){
|
||||
m.SetSize(targetSize,false);
|
||||
}else{
|
||||
@ -388,4 +386,4 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
END_STRATEGY
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 12502
|
||||
#define VERSION_BUILD 12526
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@ -780,7 +780,6 @@ MonsterStrategy
|
||||
|
||||
# Number of Major Hawks on the field to start using "aggressive" tactics.
|
||||
Aggressive Hawk Count = 1
|
||||
Flight Charge Cooldown = 3s
|
||||
}
|
||||
Zephy
|
||||
{
|
||||
@ -1442,5 +1441,8 @@ MonsterStrategy
|
||||
|
||||
Fire Bolt Bullet Speed = 275
|
||||
Fire Bolt Damage Mult = 1.0x
|
||||
|
||||
Blizzard Radius = 350
|
||||
|
||||
}
|
||||
}
|
||||
@ -841,23 +841,24 @@ Monsters
|
||||
###################################
|
||||
##### BEGIN HAWK PROPERTY OVERRIDES
|
||||
################################### - Required since the Major Hawk strategy is an add-on.
|
||||
Wing Flap Frequency = 0.8s
|
||||
Aggressive Wing Flap Frequency = 0.8s
|
||||
|
||||
# Amount of Z (in pixels) the Hawk flies at.
|
||||
Flight Height = 48px
|
||||
Aggressive Flight Height = 48px
|
||||
# Amount of Z (in pixels) higher or lower the Hawk chooses to fly at.
|
||||
Flight Height Variance = 8px
|
||||
Aggressive Flight Height Variance = 8px
|
||||
# 0-X% application of a slowdown debuff to vary the speeds of each Hawk.
|
||||
Flight Speed Variance = 20%
|
||||
Aggressive Flight Speed Variance = 20%
|
||||
# How far from the player the Hawk circles around.
|
||||
Flight Distance = 240px
|
||||
Aggressive Flight Distance = 240px
|
||||
|
||||
Flight Oscillation Amount = 1.5px
|
||||
Aggressive Flight Oscillation Amount = 1.5px
|
||||
|
||||
# Dropdown/Rising speed in pixels per second while attacking.
|
||||
Attack Z Speed = 160px/s
|
||||
|
||||
Attack Wait Time = 1s
|
||||
Aggressive Attack Z Speed = 160px/s
|
||||
|
||||
Aggressive Flight Charge Cooldown = 3s
|
||||
Aggressive Attack Wait Time = 1s
|
||||
#################################
|
||||
##### END HAWK PROPERTY OVERRIDES
|
||||
#################################
|
||||
@ -2238,8 +2239,8 @@ Monsters
|
||||
Abilities
|
||||
{
|
||||
#Ability Name = Mana cost, % chance to cast (every second), Cast Time (Instant = 0.0s)
|
||||
Blizzard = 50mp, 60%, 1.5sec
|
||||
Freeze Ground = 20mp, 10%, 1.0sec
|
||||
Blizzard = 60mp, 60%, 1.5sec
|
||||
Freeze Ground = 30mp, 20%, 0.0sec
|
||||
}
|
||||
|
||||
Strategy = Skeleton Fire Mage
|
||||
|
||||
BIN
Adventures in Lestoria/assets/gamepack.pak
Normal file
BIN
Adventures in Lestoria/assets/gamepack.pak
Normal file
Binary file not shown.
@ -54,8 +54,6 @@ utils::datafilefloatdata operator ""_f(const char*key,std::size_t len);
|
||||
utils::datafiledoubledata operator ""_d(const char*key,std::size_t len);
|
||||
//Read a string key from the config.
|
||||
std::string operator ""_S(const char*key,std::size_t len);
|
||||
//Read a string view key from the config.
|
||||
std::string_view operator ""_SV(const char*key,std::size_t len);
|
||||
//Read a full string key from the config.
|
||||
std::string operator ""_FS(const char*key,std::size_t len);
|
||||
//Read a boolean key from the config.
|
||||
|
||||
@ -1624,7 +1624,7 @@ config.flags = MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING; // Optional. Makes `ma_res
|
||||
|
||||
void my_custom_job_thread(...)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_job job;
|
||||
ma_result result = ma_resource_manager_next_job(pMyResourceManager, &job);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -12647,7 +12647,7 @@ MA_API MA_NO_INLINE int ma_strcmp(const char* str1, const char* str2)
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (str1[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -13238,7 +13238,7 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_
|
||||
/* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
|
||||
{
|
||||
size_t i = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (pOpenMode[i] == 0) {
|
||||
pOpenModeMB[i] = '\0';
|
||||
break;
|
||||
@ -13617,7 +13617,7 @@ static int ma_vscprintf(const ma_allocation_callbacks* pAllocationCallbacks, con
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, pAllocationCallbacks);
|
||||
if (pNewTempBuffer == NULL) {
|
||||
ma_free(pTempBuffer, pAllocationCallbacks);
|
||||
@ -13855,7 +13855,7 @@ Greatest common factor using Euclid's algorithm iteratively.
|
||||
*/
|
||||
static MA_INLINE ma_uint32 ma_gcf_u32(ma_uint32 a, ma_uint32 b)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (b == 0) {
|
||||
break;
|
||||
} else {
|
||||
@ -15893,7 +15893,7 @@ extern "C" {
|
||||
typedef ma_atomic_flag ma_atomic_spinlock;
|
||||
static MA_INLINE void ma_atomic_spinlock_lock(volatile ma_atomic_spinlock* pSpinlock)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (ma_atomic_flag_test_and_set_explicit(pSpinlock, ma_atomic_memory_order_acquire) == 0) {
|
||||
break;
|
||||
}
|
||||
@ -16057,7 +16057,7 @@ static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock,
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (ma_atomic_exchange_explicit_32(pSpinlock, 1, ma_atomic_memory_order_acquire) == 0) {
|
||||
break;
|
||||
}
|
||||
@ -16834,7 +16834,7 @@ MA_API ma_result ma_fence_acquire(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter);
|
||||
ma_uint32 newCounter = oldCounter + 1;
|
||||
|
||||
@ -16864,7 +16864,7 @@ MA_API ma_result ma_fence_release(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 oldCounter = ma_atomic_load_32(&pFence->counter);
|
||||
ma_uint32 newCounter = oldCounter - 1;
|
||||
|
||||
@ -16901,7 +16901,7 @@ MA_API ma_result ma_fence_wait(ma_fence* pFence)
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 counter;
|
||||
|
||||
counter = ma_atomic_load_32(&pFence->counter);
|
||||
@ -17232,7 +17232,7 @@ MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint6
|
||||
ma_uint32 iGroup;
|
||||
for (iGroup = 0; iGroup < ma_slot_allocator_group_capacity(pAllocator); iGroup += 1) {
|
||||
/* CAS */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 oldBitfield;
|
||||
ma_uint32 newBitfield;
|
||||
ma_uint32 bitOffset;
|
||||
@ -17688,7 +17688,7 @@ MA_API ma_result ma_job_queue_post(ma_job_queue* pQueue, const ma_job* pJob)
|
||||
#endif
|
||||
{
|
||||
/* The job is stored in memory so now we need to add it to our linked list. We only ever add items to the end of the list. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
tail = ma_atomic_load_64(&pQueue->tail);
|
||||
next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(tail)].next);
|
||||
|
||||
@ -17762,7 +17762,7 @@ MA_API ma_result ma_job_queue_next(ma_job_queue* pQueue, ma_job* pJob)
|
||||
*/
|
||||
|
||||
/* Now we need to remove the root item from the list. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
head = ma_atomic_load_64(&pQueue->head);
|
||||
tail = ma_atomic_load_64(&pQueue->tail);
|
||||
next = ma_atomic_load_64(&pQueue->pJobs[ma_job_extract_slot(head)].next);
|
||||
@ -18971,7 +18971,7 @@ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frame
|
||||
const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
|
||||
|
||||
/* We just keep going until we've exhaused all of our input frames and cannot generate any more output frames. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 deviceFramesProcessedThisIteration;
|
||||
ma_uint64 clientFramesProcessedThisIteration;
|
||||
|
||||
@ -19013,7 +19013,7 @@ static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, m
|
||||
MA_ASSERT(pRB != NULL);
|
||||
|
||||
/* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 framesToProcessInDeviceFormat = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
|
||||
ma_uint32 framesToProcessInClientFormat = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
ma_uint64 framesProcessedInDeviceFormat;
|
||||
@ -19237,7 +19237,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
|
||||
capturedDeviceFramesProcessed = 0;
|
||||
|
||||
/* At this point we have our captured data in device format and we now need to convert it to client format. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 capturedClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint8 playbackClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint32 capturedClientDataCapInFrames = sizeof(capturedClientData) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
@ -19266,7 +19266,7 @@ static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
|
||||
capturedDeviceFramesRemaining -= (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
|
||||
|
||||
/* At this point the playbackClientData buffer should be holding data that needs to be written to the device. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 convertedClientFrameCount = capturedClientFramesToProcessThisIteration;
|
||||
ma_uint64 convertedDeviceFrameCount = playbackDeviceDataCapInFrames;
|
||||
result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackClientData, &convertedClientFrameCount, playbackDeviceData, &convertedDeviceFrameCount);
|
||||
@ -19389,7 +19389,7 @@ static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData)
|
||||
ma_device* pDevice = (ma_device*)pData;
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
for (;) { /* Keep the thread alive until the device is uninitialized. */
|
||||
for (;;) { /* Keep the thread alive until the device is uninitialized. */
|
||||
ma_uint32 operation;
|
||||
|
||||
/* Wait for an operation to be requested. */
|
||||
@ -19714,7 +19714,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame
|
||||
|
||||
/* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
|
||||
targetFrame = pDevice->null_device.lastProcessedFramePlayback;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 currentFrame;
|
||||
|
||||
/* Stop waiting if the device has been stopped. */
|
||||
@ -19785,7 +19785,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u
|
||||
|
||||
/* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
|
||||
targetFrame = pDevice->null_device.lastProcessedFrameCapture + pDevice->capture.internalPeriodSizeInFrames;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 currentFrame;
|
||||
|
||||
/* Stop waiting if the device has been stopped. */
|
||||
@ -21144,7 +21144,7 @@ static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pU
|
||||
ma_context* pContext = (ma_context*)pUserData;
|
||||
MA_ASSERT(pContext != NULL);
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_context_command__wasapi cmd;
|
||||
result = ma_context_next_command__wasapi(pContext, &cmd);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -22265,7 +22265,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
|
||||
it and trying it again.
|
||||
*/
|
||||
hr = E_FAIL;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL);
|
||||
if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) {
|
||||
if (bufferDuration > 500*10000) {
|
||||
@ -23049,7 +23049,7 @@ static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
|
||||
else {
|
||||
ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
|
||||
ma_uint32 framesAvailablePlayback;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
|
||||
if (result != MA_SUCCESS) {
|
||||
break;
|
||||
@ -24890,7 +24890,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
/* At this point we have some input data that we need to output. We do not return until every mapped frame of the input data is written to the playback device. */
|
||||
mappedDeviceFramesProcessedCapture = 0;
|
||||
|
||||
for (;) { /* Keep writing to the playback device. */
|
||||
for (;;) { /* Keep writing to the playback device. */
|
||||
ma_uint8 inputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
ma_uint32 inputFramesInClientFormatCap = sizeof(inputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
|
||||
ma_uint8 outputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
|
||||
@ -24912,7 +24912,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
ma_device__handle_data_callback(pDevice, outputFramesInClientFormat, inputFramesInClientFormat, (ma_uint32)clientCapturedFramesToProcess);
|
||||
|
||||
/* At this point we have input and output data in client format. All we need to do now is convert it to the output device format. This may take a few passes. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 framesWrittenThisIteration;
|
||||
DWORD physicalPlayCursorInBytes;
|
||||
DWORD physicalWriteCursorInBytes;
|
||||
@ -25261,7 +25261,7 @@ static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
|
||||
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
|
||||
/* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
|
||||
if (isPlaybackDeviceStarted) {
|
||||
for (;) {
|
||||
for (;;) {
|
||||
DWORD availableBytesPlayback = 0;
|
||||
DWORD physicalPlayCursorInBytes;
|
||||
DWORD physicalWriteCursorInBytes;
|
||||
@ -26913,7 +26913,7 @@ static ma_bool32 ma_is_device_blacklisted__alsa(ma_device_type deviceType, const
|
||||
static const char* ma_find_char(const char* str, char c, int* index)
|
||||
{
|
||||
int i = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (str[i] == '\0') {
|
||||
if (index) *index = -1;
|
||||
return NULL;
|
||||
@ -28119,7 +28119,7 @@ static ma_result ma_device_stop__alsa(ma_device* pDevice)
|
||||
|
||||
static ma_result ma_device_wait__alsa(ma_device* pDevice, ma_snd_pcm_t* pPCM, struct pollfd* pPollDescriptors, int pollDescriptorCount, short requiredEvent)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
unsigned short revents;
|
||||
int resultALSA;
|
||||
int resultPoll = poll(pPollDescriptors, pollDescriptorCount, -1);
|
||||
@ -29475,7 +29475,7 @@ static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_ptr pMain
|
||||
MA_ASSERT(pContext != NULL);
|
||||
MA_ASSERT(pOP != NULL);
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP);
|
||||
if (state != MA_PA_OPERATION_RUNNING) {
|
||||
break; /* Done. */
|
||||
@ -29509,7 +29509,7 @@ static ma_result ma_wait_for_pa_context_to_connect__pulse(ma_context* pContext,
|
||||
int resultPA;
|
||||
ma_pa_context_state_t state;
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
state = ((ma_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)((ma_pa_context*)pPulseContext);
|
||||
if (state == MA_PA_CONTEXT_READY) {
|
||||
break; /* Done. */
|
||||
@ -29535,7 +29535,7 @@ static ma_result ma_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, m
|
||||
int resultPA;
|
||||
ma_pa_stream_state_t state;
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
state = ((ma_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((ma_pa_stream*)pStream);
|
||||
if (state == MA_PA_STREAM_READY) {
|
||||
break; /* Done. */
|
||||
@ -35985,7 +35985,7 @@ static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredForma
|
||||
/* First check to see if the preferred format is supported. */
|
||||
if (preferredFormat != ma_format_unknown) {
|
||||
counter = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
MA_ZERO_OBJECT(&encoding);
|
||||
encoding.index = counter;
|
||||
if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
|
||||
@ -36006,7 +36006,7 @@ static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredForma
|
||||
ma_format format = g_maFormatPriorities[iFormat];
|
||||
|
||||
counter = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
MA_ZERO_OBJECT(&encoding);
|
||||
encoding.index = counter;
|
||||
if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
|
||||
@ -36085,7 +36085,7 @@ static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext
|
||||
|
||||
/* Supported formats. We get this by looking at the encodings. */
|
||||
pDeviceInfo->nativeDataFormatCount = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
audio_encoding_t encoding;
|
||||
ma_format format;
|
||||
|
||||
@ -39376,7 +39376,7 @@ static ma_result ma_device_drain__opensl(ma_device* pDevice, ma_device_type devi
|
||||
pDevice->opensl.isDrainingPlayback = MA_TRUE;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
SLAndroidSimpleBufferQueueState state;
|
||||
|
||||
MA_OPENSL_BUFFERQUEUE(pBufferQueue)->GetState(pBufferQueue, &state);
|
||||
@ -40842,7 +40842,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
|
||||
ma_device__set_state(pDevice, ma_device_state_stopped);
|
||||
ma_event_signal(&pDevice->stopEvent);
|
||||
|
||||
for (;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
||||
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
|
||||
ma_result startResult;
|
||||
ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the stopped notification callback. */
|
||||
|
||||
@ -41067,7 +41067,7 @@ static ma_thread_result MA_THREADCALL ma_device_job_thread_entry(void* pUserData
|
||||
ma_device_job_thread* pJobThread = (ma_device_job_thread*)pUserData;
|
||||
MA_ASSERT(pJobThread != NULL);
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_result result;
|
||||
ma_job job;
|
||||
|
||||
@ -58479,7 +58479,7 @@ MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_da
|
||||
/* This function assumes the page has been filled with audio data by this point. As soon as we append, the page will be available for reading. */
|
||||
|
||||
/* First thing to do is update the tail. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_paged_audio_buffer_page* pOldTail = (ma_paged_audio_buffer_page*)ma_atomic_load_ptr(&pData->pTail);
|
||||
ma_paged_audio_buffer_page* pNewTail = pPage;
|
||||
|
||||
@ -63093,7 +63093,7 @@ static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis)
|
||||
size_t dataCapacity = 0;
|
||||
ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
int vorbisError;
|
||||
int consumedDataSize; /* <-- Fill by stb_vorbis_open_pushdata(). */
|
||||
size_t bytesRead;
|
||||
@ -63380,7 +63380,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram
|
||||
MA_ASSERT(pVorbis->push.framesRemaining == 0);
|
||||
|
||||
/* Getting here means we've run out of cached frames. We'll need to load some more. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
int samplesRead = 0;
|
||||
int consumedDataSize;
|
||||
|
||||
@ -65358,7 +65358,7 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec
|
||||
/* The frame count is unknown until we try reading. Thus, we just run in a loop. */
|
||||
dataCapInFrames = 0;
|
||||
pPCMFramesOut = NULL;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 frameCountToTryReading;
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
@ -67585,7 +67585,7 @@ static ma_thread_result MA_THREADCALL ma_resource_manager_job_thread(void* pUser
|
||||
ma_resource_manager* pResourceManager = (ma_resource_manager*)pUserData;
|
||||
MA_ASSERT(pResourceManager != NULL);
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_result result;
|
||||
ma_job job;
|
||||
|
||||
@ -68508,7 +68508,7 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage
|
||||
}
|
||||
|
||||
/* We have the decoder, now decode page by page just like we do when loading asynchronously. */
|
||||
for (;) {
|
||||
for (;;) {
|
||||
/* Decode next page. */
|
||||
result = ma_resource_manager_data_buffer_node_decode_next_page(pResourceManager, pDataBufferNode, pDecoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
@ -71606,7 +71606,7 @@ static ma_node_output_bus* ma_node_input_bus_next(ma_node_input_bus* pInputBus,
|
||||
ma_node_input_bus_next_begin(pInputBus);
|
||||
{
|
||||
pNext = pOutputBus;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
pNext = (ma_node_output_bus*)ma_atomic_load_ptr(&pNext->pNext);
|
||||
if (pNext == NULL) {
|
||||
break; /* Reached the end. */
|
||||
@ -72655,7 +72655,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde
|
||||
/* Getting here means we need to do another round of processing. */
|
||||
pNodeBase->cachedFrameCountOut = 0;
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
frameCountOut = 0;
|
||||
|
||||
/*
|
||||
@ -75185,7 +75185,7 @@ MA_API void ma_engine_uninit(ma_engine* pEngine)
|
||||
*/
|
||||
ma_spinlock_lock(&pEngine->inlinedSoundLock);
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_sound_inlined* pSoundToDelete = pEngine->pInlinedSoundHead;
|
||||
if (pSoundToDelete == NULL) {
|
||||
break; /* Done. */
|
||||
@ -77658,7 +77658,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav__seek_from_start(ma_dr_wav_seek_proc onSeek, ma_u
|
||||
return MA_FALSE;
|
||||
}
|
||||
offset -= 0x7FFFFFFF;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (offset <= 0x7FFFFFFF) {
|
||||
return onSeek(pUserData, (int)offset, ma_dr_wav_seek_origin_current);
|
||||
}
|
||||
@ -78586,7 +78586,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
metadataParser.pReadSeekUserData = pWav->pUserData;
|
||||
metadataParser.stage = ma_dr_wav__metadata_parser_stage_count;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_dr_wav_chunk_header header;
|
||||
ma_uint64 chunkSize;
|
||||
result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
|
||||
@ -78858,7 +78858,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
return MA_FALSE;
|
||||
}
|
||||
metadataParser.stage = ma_dr_wav__metadata_parser_stage_read;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_dr_wav_chunk_header header;
|
||||
ma_uint64 metadataBytesRead;
|
||||
result = ma_dr_wav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
|
||||
@ -78876,7 +78876,7 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
||||
}
|
||||
if (dataChunkSize == 0xFFFFFFFF && (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) && pWav->isSequentialWrite == MA_FALSE) {
|
||||
dataChunkSize = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 temp[4096];
|
||||
size_t bytesRead = pWav->onRead(pWav->pUserData, temp, sizeof(temp));
|
||||
dataChunkSize += bytesRead;
|
||||
@ -82977,7 +82977,7 @@ static ma_bool32 ma_dr_flac__find_and_seek_to_next_sync_code(ma_dr_flac_bs* bs)
|
||||
if (!ma_dr_flac__seek_bits(bs, MA_DR_FLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
|
||||
return MA_FALSE;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 hi;
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__reset_crc16(bs);
|
||||
@ -83507,7 +83507,7 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual__rice__reference(ma_dr
|
||||
MA_DR_FLAC_ASSERT(pSamplesOut != NULL);
|
||||
for (i = 0; i < count; ++i) {
|
||||
ma_uint32 zeroCounter = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 bit;
|
||||
if (!ma_dr_flac__read_uint8(bs, 1, &bit)) {
|
||||
return MA_FALSE;
|
||||
@ -83546,7 +83546,7 @@ static ma_bool32 ma_dr_flac__read_rice_parts__reference(ma_dr_flac_bs* bs, ma_ui
|
||||
{
|
||||
ma_uint32 zeroCounter = 0;
|
||||
ma_uint32 decodedRice;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 bit;
|
||||
if (!ma_dr_flac__read_uint8(bs, 1, &bit)) {
|
||||
return MA_FALSE;
|
||||
@ -83676,7 +83676,7 @@ static MA_INLINE ma_bool32 ma_dr_flac__read_rice_parts_x1(ma_dr_flac_bs* bs, ma_
|
||||
}
|
||||
} else {
|
||||
ma_uint32 zeroCounter = (ma_uint32)(MA_DR_FLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) {
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__update_crc16(bs);
|
||||
@ -83745,7 +83745,7 @@ static MA_INLINE ma_bool32 ma_dr_flac__seek_rice_parts(ma_dr_flac_bs* bs, ma_uin
|
||||
bs_cache <<= riceParamPartLoBitCount;
|
||||
}
|
||||
} else {
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (bs->nextL2Line < MA_DR_FLAC_CACHE_L2_LINE_COUNT(bs)) {
|
||||
#ifndef MA_DR_FLAC_NO_CRC
|
||||
ma_dr_flac__update_crc16(bs);
|
||||
@ -84677,7 +84677,7 @@ static ma_bool32 ma_dr_flac__decode_samples_with_residual(ma_dr_flac_bs* bs, ma_
|
||||
}
|
||||
samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder;
|
||||
partitionsRemaining = (1 << partitionOrder);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 riceParam = 0;
|
||||
if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
|
||||
if (!ma_dr_flac__read_uint8(bs, 4, &riceParam)) {
|
||||
@ -84743,7 +84743,7 @@ static ma_bool32 ma_dr_flac__read_and_seek_residual(ma_dr_flac_bs* bs, ma_uint32
|
||||
}
|
||||
samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
|
||||
partitionsRemaining = (1 << partitionOrder);
|
||||
for (;)
|
||||
for (;;)
|
||||
{
|
||||
ma_uint8 riceParam = 0;
|
||||
if (residualMethod == MA_DR_FLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
|
||||
@ -84871,7 +84871,7 @@ static ma_bool32 ma_dr_flac__read_next_flac_frame_header(ma_dr_flac_bs* bs, ma_u
|
||||
const ma_uint8 bitsPerSampleTable[8] = {0, 8, 12, (ma_uint8)-1, 16, 20, 24, (ma_uint8)-1};
|
||||
MA_DR_FLAC_ASSERT(bs != NULL);
|
||||
MA_DR_FLAC_ASSERT(header != NULL);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint8 crc8 = 0xCE;
|
||||
ma_uint8 reserved = 0;
|
||||
ma_uint8 blockingStrategy = 0;
|
||||
@ -85261,7 +85261,7 @@ static ma_result ma_dr_flac__seek_flac_frame(ma_dr_flac* pFlac)
|
||||
static ma_bool32 ma_dr_flac__read_and_decode_next_flac_frame(ma_dr_flac* pFlac)
|
||||
{
|
||||
MA_DR_FLAC_ASSERT(pFlac != NULL);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_result result;
|
||||
if (!ma_dr_flac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
|
||||
return MA_FALSE;
|
||||
@ -85357,7 +85357,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__brute_force(ma_dr_flac* pFlac, m
|
||||
return MA_FALSE;
|
||||
}
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 pcmFrameCountInThisFLACFrame;
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
@ -85415,7 +85415,7 @@ static ma_bool32 ma_dr_flac__seek_to_approximate_flac_frame_to_byte(ma_dr_flac*
|
||||
MA_DR_FLAC_ASSERT(targetByte >= rangeLo);
|
||||
MA_DR_FLAC_ASSERT(targetByte <= rangeHi);
|
||||
*pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 lastTargetByte = targetByte;
|
||||
if (!ma_dr_flac__seek_to_byte(&pFlac->bs, targetByte)) {
|
||||
if (targetByte == 0) {
|
||||
@ -85474,7 +85474,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__binary_search_internal(ma_dr_fla
|
||||
if (targetByte > byteRangeHi) {
|
||||
targetByte = byteRangeHi;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (ma_dr_flac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
|
||||
ma_uint64 newPCMRangeLo;
|
||||
ma_uint64 newPCMRangeHi;
|
||||
@ -85621,7 +85621,7 @@ static ma_bool32 ma_dr_flac__seek_to_pcm_frame__seek_table(ma_dr_flac* pFlac, ma
|
||||
return MA_FALSE;
|
||||
}
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 pcmFrameCountInThisFLACFrame;
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
@ -85821,7 +85821,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea
|
||||
ma_uint64 runningFilePos = 42;
|
||||
ma_uint64 seektablePos = 0;
|
||||
ma_uint32 seektableSize = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_dr_flac_metadata metadata;
|
||||
ma_uint8 isLastBlock = 0;
|
||||
ma_uint8 blockType;
|
||||
@ -86347,7 +86347,7 @@ static ma_result ma_dr_flac_ogg__read_page_header(ma_dr_flac_read_proc onRead, v
|
||||
return MA_AT_END;
|
||||
}
|
||||
*pBytesRead += 4;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (ma_dr_flac_ogg__is_capture_pattern(id)) {
|
||||
ma_result result;
|
||||
*pCRC32 = MA_DR_FLAC_OGG_CAPTURE_PATTERN_CRC32;
|
||||
@ -86426,7 +86426,7 @@ static ma_bool32 ma_dr_flac_oggbs__seek_physical(ma_dr_flac_oggbs* oggbs, ma_uin
|
||||
static ma_bool32 ma_dr_flac_oggbs__goto_next_page(ma_dr_flac_oggbs* oggbs, ma_dr_flac_ogg_crc_mismatch_recovery recoveryMethod)
|
||||
{
|
||||
ma_dr_flac_ogg_page_header header;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 crc32 = 0;
|
||||
ma_uint32 bytesRead;
|
||||
ma_uint32 pageBodySize;
|
||||
@ -86489,7 +86489,7 @@ static ma_uint8 ma_dr_flac_oggbs__get_current_segment_index(ma_dr_flac_oggbs* og
|
||||
}
|
||||
static ma_bool32 ma_dr_flac_oggbs__seek_to_next_packet(ma_dr_flac_oggbs* oggbs)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_bool32 atEndOfPage = MA_FALSE;
|
||||
ma_uint8 bytesRemainingInSeg;
|
||||
ma_uint8 iFirstSeg = ma_dr_flac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
|
||||
@ -86601,7 +86601,7 @@ static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64
|
||||
}
|
||||
oggbs->bytesRemainingInPage = 0;
|
||||
runningGranulePosition = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (!ma_dr_flac_oggbs__goto_next_page(oggbs, ma_dr_flac_ogg_recover_on_crc_mismatch)) {
|
||||
ma_dr_flac_oggbs__seek_physical(oggbs, originalBytePos, ma_dr_flac_seek_origin_start);
|
||||
return MA_FALSE;
|
||||
@ -86629,7 +86629,7 @@ static ma_bool32 ma_dr_flac_ogg__seek_to_pcm_frame(ma_dr_flac* pFlac, ma_uint64
|
||||
return MA_FALSE;
|
||||
}
|
||||
runningPCMFrameCount = runningGranulePosition;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 firstPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 lastPCMFrameInFLACFrame = 0;
|
||||
ma_uint64 pcmFrameCountInThisFrame;
|
||||
@ -86690,7 +86690,7 @@ static ma_bool32 ma_dr_flac__init_private__ogg(ma_dr_flac_init_info* pInit, ma_d
|
||||
return MA_FALSE;
|
||||
}
|
||||
pInit->runningFilePos += bytesRead;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
int pageBodySize;
|
||||
if ((header.headerType & 0x02) == 0) {
|
||||
return MA_FALSE;
|
||||
@ -86805,7 +86805,7 @@ static ma_bool32 ma_dr_flac__init_private(ma_dr_flac_init_info* pInit, ma_dr_fla
|
||||
pInit->bs.pUserData = pUserData;
|
||||
ma_dr_flac__reset_cache(&pInit->bs);
|
||||
relaxed = container != ma_dr_flac_container_unknown;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (onRead(pUserData, id, 4) != 4) {
|
||||
return MA_FALSE;
|
||||
}
|
||||
@ -87007,7 +87007,7 @@ static ma_dr_flac* ma_dr_flac_open_with_metadata_private(ma_dr_flac_read_proc on
|
||||
}
|
||||
if (!init.hasStreamInfoBlock) {
|
||||
pFlac->currentFLACFrame.header = init.firstFrameHeader;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_result result = ma_dr_flac__decode_flac_frame(pFlac);
|
||||
if (result == MA_SUCCESS) {
|
||||
break;
|
||||
@ -90533,7 +90533,7 @@ static void ma_dr_mp3_L3_huffman(float *dst, ma_dr_mp3_bs *bs, const ma_dr_mp3_L
|
||||
} while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
|
||||
}
|
||||
}
|
||||
for (np = 1 - big_val_cnt; dst += 4)
|
||||
for (np = 1 - big_val_cnt;; dst += 4)
|
||||
{
|
||||
const ma_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
|
||||
int leaf = codebook_count1[MA_DR_MP3_PEEK_BITS(4)];
|
||||
@ -91494,7 +91494,7 @@ static MA_INLINE float ma_dr_mp3_mix_f32_fast(float x, float y, float a)
|
||||
}
|
||||
static MA_INLINE ma_uint32 ma_dr_mp3_gcf_u32(ma_uint32 a, ma_uint32 b)
|
||||
{
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (b == 0) {
|
||||
break;
|
||||
} else {
|
||||
@ -91628,7 +91628,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__callbacks(ma_dr_mp3* pMP3, ma_d
|
||||
if (pMP3->atEnd) {
|
||||
return 0;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_dr_mp3dec_frame_info info;
|
||||
if (pMP3->dataSize < MA_DR_MP3_MIN_DATA_CHUNK_SIZE) {
|
||||
size_t bytesRead;
|
||||
@ -91711,7 +91711,7 @@ static ma_uint32 ma_dr_mp3_decode_next_frame_ex__memory(ma_dr_mp3* pMP3, ma_dr_m
|
||||
if (pMP3->atEnd) {
|
||||
return 0;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
pcmFramesRead = ma_dr_mp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
|
||||
if (pcmFramesRead > 0) {
|
||||
pcmFramesRead = ma_dr_mp3_hdr_frame_samples(pMP3->decoder.header);
|
||||
@ -92163,7 +92163,7 @@ MA_API ma_bool32 ma_dr_mp3_get_mp3_and_pcm_frame_count(ma_dr_mp3* pMP3, ma_uint6
|
||||
}
|
||||
totalPCMFrameCount = 0;
|
||||
totalMP3FrameCount = 0;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint32 pcmFramesInCurrentMP3Frame;
|
||||
pcmFramesInCurrentMP3Frame = ma_dr_mp3_decode_next_frame_ex(pMP3, NULL);
|
||||
if (pcmFramesInCurrentMP3Frame == 0) {
|
||||
@ -92271,7 +92271,7 @@ MA_API ma_bool32 ma_dr_mp3_calculate_seek_points(ma_dr_mp3* pMP3, ma_uint32* pSe
|
||||
nextTargetPCMFrame = 0;
|
||||
for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
|
||||
nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (nextTargetPCMFrame < runningPCMFrameCount) {
|
||||
pSeekPoints[iSeekPoint].seekPosInBytes = mp3FrameInfo[0].bytePos;
|
||||
pSeekPoints[iSeekPoint].pcmFrameIndex = nextTargetPCMFrame;
|
||||
@ -92329,7 +92329,7 @@ static float* ma_dr_mp3__full_read_and_close_f32(ma_dr_mp3* pMP3, ma_dr_mp3_conf
|
||||
float* pFrames = NULL;
|
||||
float temp[4096];
|
||||
MA_DR_MP3_ASSERT(pMP3 != NULL);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels;
|
||||
ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
|
||||
if (framesJustRead == 0) {
|
||||
@ -92380,7 +92380,7 @@ static ma_int16* ma_dr_mp3__full_read_and_close_s16(ma_dr_mp3* pMP3, ma_dr_mp3_c
|
||||
ma_int16* pFrames = NULL;
|
||||
ma_int16 temp[4096];
|
||||
MA_DR_MP3_ASSERT(pMP3 != NULL);
|
||||
for (;) {
|
||||
for (;;) {
|
||||
ma_uint64 framesToReadRightNow = MA_DR_MP3_COUNTOF(temp) / pMP3->channels;
|
||||
ma_uint64 framesJustRead = ma_dr_mp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
|
||||
if (framesJustRead == 0) {
|
||||
|
||||
@ -474,7 +474,7 @@ BOOL IsXInputDevice(const GUID *pGuidProductFromDirectInput) {
|
||||
goto LCleanup;
|
||||
|
||||
// Loop over all devices
|
||||
for (;) {
|
||||
for (;;) {
|
||||
// Get 20 at a time
|
||||
hr = pEnumDevices->Next(10000, 20, pDevices, &uReturned);
|
||||
if (FAILED(hr))
|
||||
|
||||
@ -63,7 +63,6 @@ David Barr, aka javidx9, <20>OneLoneCoder 2019, 2020, 2021, 2022
|
||||
#include <sstream>
|
||||
#include <numeric>
|
||||
#include "Error.h"
|
||||
#include<ranges>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
@ -185,22 +184,25 @@ namespace olc::utils
|
||||
return m_vContent;
|
||||
}
|
||||
|
||||
inline const std::unordered_map<std::string_view,size_t>&GetKeys()const{
|
||||
inline const std::unordered_map<std::string,size_t>&GetKeys()const{
|
||||
return m_mapObjects;
|
||||
}
|
||||
|
||||
inline auto GetOrderedKeys(){
|
||||
return m_vecObjects|std::views::filter([](const std::pair<std::string_view,datafile>&data){return !datafile::IsComment(data);});
|
||||
//This function is slightly expensive due to a filtering function required to remove all comments!
|
||||
inline std::vector<std::pair<std::string,datafile>> GetOrderedKeys(){
|
||||
std::vector<std::pair<std::string,datafile>>orderedKeys;
|
||||
std::copy_if(m_vecObjects.begin(),m_vecObjects.end(),std::back_inserter(orderedKeys),[&](const std::pair<std::string,datafile>&data){return !datafile::IsComment(data);});
|
||||
return orderedKeys;
|
||||
}
|
||||
|
||||
// Checks if a property exists - useful to avoid creating properties
|
||||
// via reading them, though non-essential
|
||||
inline bool HasProperty(std::string_view sName)
|
||||
inline bool HasProperty(const std::string& sName)
|
||||
{
|
||||
size_t x = sName.find_first_of('.');
|
||||
if (x != std::string::npos)
|
||||
{
|
||||
std::string_view sProperty = sName.substr(0, x);
|
||||
std::string sProperty = sName.substr(0, x);
|
||||
if(HasProperty(sProperty)){
|
||||
return GetProperty(sName.substr(0, x)).HasProperty(sName.substr(x + 1, sName.size()));
|
||||
}else{
|
||||
@ -212,13 +214,13 @@ namespace olc::utils
|
||||
}
|
||||
|
||||
// Access a datafile via a convenient name - "root.node.something.property"
|
||||
inline datafile& GetProperty(const std::string_view name)
|
||||
inline datafile& GetProperty(const std::string& name)
|
||||
{
|
||||
[[unlikely]]if(DEBUG_ACCESS_OPTIONS)LOG(std::format("Accessing Property {}",name));
|
||||
size_t x = name.find_first_of('.');
|
||||
if (x != std::string::npos)
|
||||
{
|
||||
std::string_view sProperty = name.substr(0, x);
|
||||
std::string sProperty = name.substr(0, x);
|
||||
lastAccessedProperty=sProperty;
|
||||
if (HasProperty(sProperty))
|
||||
return operator[](sProperty).GetProperty(name.substr(x + 1, name.size()));
|
||||
@ -524,7 +526,7 @@ namespace olc::utils
|
||||
BLANK="";
|
||||
m_bIsComment=false;
|
||||
}
|
||||
inline datafile& operator[](const std::string_view name)
|
||||
inline datafile& operator[](const std::string& name)
|
||||
{
|
||||
// Check if this "node"'s map already contains an object with this name...
|
||||
if (m_mapObjects.count(name) == 0)
|
||||
@ -561,13 +563,13 @@ namespace olc::utils
|
||||
|
||||
// Linkage to create "ordered" unordered_map. We have a vector of
|
||||
// "properties", and the index to a specific element is mapped.
|
||||
std::vector<std::pair<std::string_view, datafile>> m_vecObjects;
|
||||
std::unordered_map<std::string_view, size_t> m_mapObjects;
|
||||
std::vector<std::pair<std::string, datafile>> m_vecObjects;
|
||||
std::unordered_map<std::string, size_t> m_mapObjects;
|
||||
|
||||
inline static std::string lastAccessedProperty="";
|
||||
inline static std::string BLANK="";
|
||||
|
||||
inline static bool IsComment(const std::pair<std::string_view,datafile>&data){
|
||||
inline static bool IsComment(const std::pair<std::string,datafile>&data){
|
||||
return data.first.length()>0&&data.first[0]=='#';
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ public:
|
||||
auto contains(const T&key)const{
|
||||
return map.contains(key);
|
||||
}
|
||||
auto insert(T key,O obj){
|
||||
return map.insert({key,obj});
|
||||
void insert(T key,O obj){
|
||||
(*this)[key]=obj;
|
||||
}
|
||||
};
|
||||
@ -4210,7 +4210,7 @@ unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
|
||||
|
||||
static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
|
||||
{
|
||||
for(;) {
|
||||
for(;;) {
|
||||
int n;
|
||||
if (f->eof) return 0;
|
||||
n = get8(f);
|
||||
@ -4427,7 +4427,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
|
||||
if (!vorbis_find_page(f, NULL, NULL)) goto error;
|
||||
}
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
if (!get_seek_page_info(f, &mid)) goto error;
|
||||
if (mid.last_decoded_sample != ~0U) break;
|
||||
// (untested) no frames end on this page
|
||||
@ -4457,7 +4457,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
|
||||
end_pos = f->end_seg_with_known_loc;
|
||||
assert(end_pos >= 0);
|
||||
|
||||
for (;) {
|
||||
for (;;) {
|
||||
for (i = end_pos; i > 0; --i)
|
||||
if (f->segments[i-1] != 255)
|
||||
break;
|
||||
@ -5010,7 +5010,7 @@ int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_
|
||||
stb_vorbis_close(v);
|
||||
return -2;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
|
||||
if (n == 0) break;
|
||||
data_len += n;
|
||||
@ -5050,7 +5050,7 @@ int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *samp
|
||||
stb_vorbis_close(v);
|
||||
return -2;
|
||||
}
|
||||
for (;) {
|
||||
for (;;) {
|
||||
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
|
||||
if (n == 0) break;
|
||||
data_len += n;
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user