From 23e0b8f205e1dd806248fcd38dd5537911d18c26 Mon Sep 17 00:00:00 2001 From: dashodanger Date: Fri, 28 Jun 2024 07:52:36 -0600 Subject: [PATCH] MIDI tweaks; update/reduce macro usage --- CMakeLists.txt | 2 +- libraries/steve/src/Chord.cpp | 24 +- libraries/steve/src/Chord.h | 38 +- libraries/steve/src/ChordChange.h | 12 +- libraries/steve/src/Config.cpp | 195 +- libraries/steve/src/Config.h | 48 +- libraries/steve/src/ConfigItemList.h | 133 +- libraries/steve/src/ConfigJson.cpp | 608 +- libraries/steve/src/ConfigJson.h | 39 +- libraries/steve/src/Instrument.h | 10 +- libraries/steve/src/ItemDescription.h | 14 +- libraries/steve/src/Music.cpp | 453 +- libraries/steve/src/Music.h | 118 +- libraries/steve/src/Rand.cpp | 58 +- libraries/steve/src/Rand.h | 40 +- libraries/steve/src/Scale.cpp | 40 +- libraries/steve/src/Scale.h | 38 +- libraries/steve/src/Steve.cpp | 210 +- libraries/steve/src/Steve.h | 76 +- libraries/steve/src/TimeSignature.h | 14 +- libraries/steve/src/creator/Arpeggio.cpp | 47 +- libraries/steve/src/creator/Arpeggio.h | 21 +- libraries/steve/src/creator/Bass.cpp | 47 +- libraries/steve/src/creator/Bass.h | 23 +- .../steve/src/creator/ChordBasedCreator.cpp | 36 +- .../steve/src/creator/ChordBasedCreator.h | 14 +- libraries/steve/src/creator/Chords.cpp | 56 +- libraries/steve/src/creator/Chords.h | 21 +- libraries/steve/src/creator/Creator.cpp | 336 +- libraries/steve/src/creator/Creator.h | 62 +- libraries/steve/src/creator/Drums.cpp | 69 +- libraries/steve/src/creator/Drums.h | 21 +- libraries/steve/src/creator/Melody.cpp | 53 +- libraries/steve/src/creator/Melody.h | 21 +- libraries/steve/src/ext/json.h | 5895 +++++++++-------- scripts/midi/safe.json | 14 +- source/bsp.cc | 28 +- source/bsp.h | 8 +- source/bsp_level.cc | 216 +- source/bsp_local.h | 37 +- source/bsp_misc.cc | 51 +- source/bsp_node.cc | 36 +- source/bsp_wad.cc | 4 +- source/csg_bsp.cc | 16 +- source/csg_doom.cc | 60 +- source/csg_local.h | 2 +- source/csg_main.cc | 20 +- source/csg_main.h | 8 +- source/csg_shade.cc | 2 +- source/csg_spots.cc | 32 +- source/dm_extra.cc | 122 +- source/dm_prefab.cc | 4 +- source/ff.h | 7 +- source/g_doom.cc | 22 +- source/g_wolf.cc | 16 +- source/lib_tga.cc | 15 +- source/lib_tga.h | 7 - source/lib_util.h | 2 - source/lib_wad.cc | 2 +- source/m_about.cc | 24 +- source/m_cookie.cc | 4 +- source/m_dialog.cc | 78 +- source/m_lua.cc | 72 +- source/m_lua.h | 4 +- source/m_manage.cc | 49 +- source/m_options.cc | 70 +- source/m_theme.cc | 71 +- source/m_trans.cc | 6 +- source/m_trans.h | 3 +- source/main.cc | 87 +- source/main.h | 16 +- source/poly.cc | 92 +- source/poly.h | 4 +- source/poly_map.cc | 36 +- source/poly_wad.cc | 8 +- source/raw_def.h | 30 +- source/slump.cc | 4904 +++++++------- source/slump.h | 637 +- source/slump_dump.cc | 87 +- source/slump_main.cc | 6 +- source/sys_assert.h | 4 +- source/sys_debug.cc | 16 +- source/sys_macro.h | 33 +- source/tx_forge.cc | 42 +- source/ui_boxes.cc | 2 +- source/ui_build.cc | 14 +- source/ui_game.cc | 19 +- source/ui_module.cc | 168 +- source/ui_window.cc | 26 +- source/ui_window.h | 11 +- 90 files changed, 8531 insertions(+), 7715 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3469c8870..9a7328f9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) string(TIMESTAMP BUILD_TIMESTAMP "%Y.%m.%d" UTC) add_compile_definitions(OBSIDIAN_TIMESTAMP="${BUILD_TIMESTAMP}") if(CONSOLE_ONLY) - add_compile_definitions(CONSOLE_ONLY) + add_compile_definitions(OBSIDIAN_CONSOLE_ONLY) endif() if(WIN32) add_compile_definitions(WIN32_LEAN_AND_MEAN) diff --git a/libraries/steve/src/Chord.cpp b/libraries/steve/src/Chord.cpp index 049e5765c..9444ca489 100644 --- a/libraries/steve/src/Chord.cpp +++ b/libraries/steve/src/Chord.cpp @@ -2,17 +2,21 @@ using namespace steve; -uint8_t ChordDescription::get_tone(uint8_t index) const { - uint8_t tone = 0; - while(index > 0) { - tone += 1; - if(((1 << tone) & tones) != 0) { - index -= 1; +uint8_t ChordDescription::get_tone(uint8_t index) const +{ + uint8_t tone = 0; + while (index > 0) + { + tone += 1; + if (((1 << tone) & tones) != 0) + { + index -= 1; + } } - } - return tone; + return tone; } -std::string Chord::to_short_string() const { - return key_name(key) + desc->suffix; +std::string Chord::to_short_string() const +{ + return key_name(key) + desc->suffix; } diff --git a/libraries/steve/src/Chord.h b/libraries/steve/src/Chord.h index b8e2b75c7..72f33687e 100644 --- a/libraries/steve/src/Chord.h +++ b/libraries/steve/src/Chord.h @@ -6,28 +6,38 @@ #include "ItemDescription.h" #include "Steve.h" -namespace steve { - struct ChordDescription : public ItemDescription { +namespace steve +{ +struct ChordDescription : public ItemDescription +{ std::string suffix; - ToneSet tones = 1; - bool uppercase = false; + ToneSet tones = 1; + bool uppercase = false; uint8_t get_tone(uint8_t index) const; - inline uint8_t get_tone_count() const { return tone_set_count(tones); } - }; + inline uint8_t get_tone_count() const + { + return tone_set_count(tones); + } +}; - struct Chord { +struct Chord +{ public: std::shared_ptr desc; - uint8_t key; - ToneSet tones; + uint8_t key; + ToneSet tones; inline Chord(std::shared_ptr desc, uint8_t key) - : desc(desc), key(key), tones(tone_set_shift(desc->tones, key)) { + : desc(desc), key(key), tones(tone_set_shift(desc->tones, key)) + { } - std::string to_short_string() const; - inline Chord shifted(uint8_t semitones) const { return Chord(desc, (key + semitones) % 12); } - }; -} + std::string to_short_string() const; + inline Chord shifted(uint8_t semitones) const + { + return Chord(desc, (key + semitones) % 12); + } +}; +} // namespace steve diff --git a/libraries/steve/src/ChordChange.h b/libraries/steve/src/ChordChange.h index 20dbde165..7782218b5 100644 --- a/libraries/steve/src/ChordChange.h +++ b/libraries/steve/src/ChordChange.h @@ -5,9 +5,11 @@ #include "Chord.h" #include "ItemDescription.h" -namespace steve { - struct ChordChange : ItemDescription { +namespace steve +{ +struct ChordChange : ItemDescription +{ std::shared_ptr source_chord, target_chord; - uint8_t tone_shift = 0; - }; -} + uint8_t tone_shift = 0; +}; +} // namespace steve diff --git a/libraries/steve/src/Config.cpp b/libraries/steve/src/Config.cpp index 3bb3303ca..114c57e33 100644 --- a/libraries/steve/src/Config.cpp +++ b/libraries/steve/src/Config.cpp @@ -13,111 +13,126 @@ using namespace steve; -std::shared_ptr Config::get_chord_change(const std::shared_ptr& source, const std::shared_ptr& target, uint8_t tone_shift) { - std::shared_ptr chord_change = _chord_changes.get_item(source->name + "->" + target->name + "+" + std::to_string(tone_shift)); - chord_change->source_chord = source; - chord_change->target_chord = target; - chord_change->tone_shift = tone_shift; - return chord_change; +std::shared_ptr Config::get_chord_change(const std::shared_ptr &source, + const std::shared_ptr &target, + uint8_t tone_shift) +{ + std::shared_ptr chord_change = + _chord_changes.get_item(source->name + "->" + target->name + "+" + std::to_string(tone_shift)); + chord_change->source_chord = source; + chord_change->target_chord = target; + chord_change->tone_shift = tone_shift; + return chord_change; } -Config::Config() { - _creators.get_item("Arpeggio")->func = [](Music* music) { - return new Arpeggio(music); - }; - _creators.get_item("Bass")->func = [](Music* music) { - return new Bass(music); - }; - _creators.get_item("Chords")->func = [](Music* music) { - return new Chords(music); - }; - _creators.get_item("Drums")->func = [](Music* music) { - return new Drums(music); - }; - _creators.get_item("Melody")->func = [](Music* music) { - return new Melody(music); - }; +Config::Config() +{ + _creators.get_item("Arpeggio")->func = [](Music *music) { return new Arpeggio(music); }; + _creators.get_item("Bass")->func = [](Music *music) { return new Bass(music); }; + _creators.get_item("Chords")->func = [](Music *music) { return new Chords(music); }; + _creators.get_item("Drums")->func = [](Music *music) { return new Drums(music); }; + _creators.get_item("Melody")->func = [](Music *music) { return new Melody(music); }; } -void Config::compute_cache() { - // This needs to happen before computing scale chords - _chords.compute_cache(); - for(auto& scale : _scales.get_all()) { - scale->compute_chords(*this); - } - - _scales.compute_cache(); - _instruments.compute_cache(); - _creators.compute_cache(); - _signatures.compute_cache(); - _chord_changes.compute_cache(); +void Config::compute_cache() +{ + // This needs to happen before computing scale chords + _chords.compute_cache(); + for (auto &scale : _scales.get_all()) + { + scale->compute_chords(*this); + } + + _scales.compute_cache(); + _instruments.compute_cache(); + _creators.compute_cache(); + _signatures.compute_cache(); + _chord_changes.compute_cache(); } -void Config::list_scales(std::ostream& out) const { - for(const auto& scale_desc : _scales.get_allowed()) { - Scale scale(scale_desc, 0); - out << scale.desc->name << ":" << std::endl; - for(const auto& chord : scale.desc->chords) { - out << '\t' << scale.get_degree_string_for_chord(chord) << "\n"; +void Config::list_scales(std::ostream &out) const +{ + for (const auto &scale_desc : _scales.get_allowed()) + { + Scale scale(scale_desc, 0); + out << scale.desc->name << ":" << std::endl; + for (const auto &chord : scale.desc->chords) + { + out << '\t' << scale.get_degree_string_for_chord(chord) << "\n"; + } } - } } -uint32_t Config::get_random_tempo() const { - const float tempo_range = max_tempo - min_tempo; - const uint32_t full_precision_tempo = uint32_t(tempo_range * Rand::next_normal()) + min_tempo; - return (full_precision_tempo / 5) * 5; +uint32_t Config::get_random_tempo() const +{ + const float tempo_range = max_tempo - min_tempo; + const uint32_t full_precision_tempo = uint32_t(tempo_range * Rand::next_normal()) + min_tempo; + return (full_precision_tempo / 5) * 5; } -std::vector Config::get_chords_inside(ToneSet tones) const { - std::vector chords; - for(const auto& desc : _chords.get_allowed()) { - for(int key(0); key < 12; key++) { - const Chord shifted_chord(desc, key); - if((tones | shifted_chord.tones) == tones) { // All chord tones are in the toneset - chords.push_back(shifted_chord); - } +std::vector Config::get_chords_inside(ToneSet tones) const +{ + std::vector chords; + for (const auto &desc : _chords.get_allowed()) + { + for (int key(0); key < 12; key++) + { + const Chord shifted_chord(desc, key); + if ((tones | shifted_chord.tones) == tones) + { // All chord tones are in the toneset + chords.push_back(shifted_chord); + } + } } - } - return chords; -} -std::vector Config::get_chord_progression(const Scale& scale) const { - std::vector chords; - - // Start with first degree chord - chords.push_back(Chord(_chords.get_random_item([scale](std::shared_ptr chord) { - return std::find_if(scale.desc->chords.begin(), scale.desc->chords.end(), [chord](const Chord& scale_chord) { - return scale_chord.desc == chord && scale_chord.key == 0; - }) != scale.desc->chords.end(); - }), - scale.key)); - - // Progress backwards - while(chords.size() < 4) { - const Chord dest_chord = chords.back(); - const std::shared_ptr chord_change = _chord_changes.get_random_item([&](std::shared_ptr chord_change) { - return dest_chord.desc == chord_change->target_chord && tone_set_within(scale.tones, tone_set_shift(chord_change->source_chord->tones, (dest_chord.key - chord_change->tone_shift + 12) % 12)); - }); - chords.push_back(Chord(chord_change->source_chord, (dest_chord.key - chord_change->tone_shift + 12) % 12)); - } - - // Reverse but keep first as start - std::reverse(chords.begin() + 1, chords.end()); - - return chords; + return chords; } +std::vector Config::get_chord_progression(const Scale &scale) const +{ + std::vector chords; + + // Start with first degree chord + chords.push_back(Chord(_chords.get_random_item([scale](std::shared_ptr chord) { + return std::find_if(scale.desc->chords.begin(), scale.desc->chords.end(), [chord](const Chord &scale_chord) { + return scale_chord.desc == chord && scale_chord.key == 0; + }) != scale.desc->chords.end(); + }), + scale.key)); + + // Progress backwards + while (chords.size() < 4) + { + const Chord dest_chord = chords.back(); + const std::shared_ptr chord_change = + _chord_changes.get_random_item([&](std::shared_ptr chord_change) { + return dest_chord.desc == chord_change->target_chord && + tone_set_within(scale.tones, + tone_set_shift(chord_change->source_chord->tones, + (dest_chord.key - chord_change->tone_shift + 12) % 12)); + }); + chords.push_back(Chord(chord_change->source_chord, (dest_chord.key - chord_change->tone_shift + 12) % 12)); + } + + // Reverse but keep first as start + std::reverse(chords.begin() + 1, chords.end()); -std::vector> Config::get_creators() const { - std::vector> creators; + return chords; +} - while(creators.empty()) { - for(const auto creator : _creators.get_allowed()) { - const uint32_t count = Rand::next(creator->min_count, creator->max_count); - for(uint32_t i = 0; i < count; i++) { - creators.push_back(creator); - } +std::vector> Config::get_creators() const +{ + std::vector> creators; + + while (creators.empty()) + { + for (const auto creator : _creators.get_allowed()) + { + const uint32_t count = Rand::next(creator->min_count, creator->max_count); + for (uint32_t i = 0; i < count; i++) + { + creators.push_back(creator); + } + } } - } - return creators; + return creators; } diff --git a/libraries/steve/src/Config.h b/libraries/steve/src/Config.h index b7836df47..76a1d7005 100644 --- a/libraries/steve/src/Config.h +++ b/libraries/steve/src/Config.h @@ -11,31 +11,43 @@ #include "TimeSignature.h" #include "creator/Creator.h" -namespace steve { - class Config { +namespace steve +{ +class Config +{ protected: - uint32_t min_tempo = 0, max_tempo = 360; - ConfigItemList _signatures; + uint32_t min_tempo = 0, max_tempo = 360; + ConfigItemList _signatures; ConfigItemList _creators; - ConfigItemList _chords; - ConfigItemList _scales; - ConfigItemList _chord_changes; - ConfigItemList _instruments; + ConfigItemList _chords; + ConfigItemList _scales; + ConfigItemList _chord_changes; + ConfigItemList _instruments; - std::shared_ptr get_chord_change(const std::shared_ptr& source, const std::shared_ptr& target, uint8_t tone_shift); + std::shared_ptr get_chord_change(const std::shared_ptr &source, + const std::shared_ptr &target, uint8_t tone_shift); public: Config(); void compute_cache(); - void list_scales(std::ostream&) const; + void list_scales(std::ostream &) const; - uint32_t get_random_tempo() const; - std::vector get_chords_inside(ToneSet tones) const; - std::vector get_chord_progression(const Scale&) const; + uint32_t get_random_tempo() const; + std::vector get_chords_inside(ToneSet tones) const; + std::vector get_chord_progression(const Scale &) const; std::vector> get_creators() const; - inline const auto& get_signatures() const { return _signatures; } - inline const auto& get_scales() const { return _scales; } - inline const auto& get_instruments() const { return _instruments; } - }; -} + inline const auto &get_signatures() const + { + return _signatures; + } + inline const auto &get_scales() const + { + return _scales; + } + inline const auto &get_instruments() const + { + return _instruments; + } +}; +} // namespace steve diff --git a/libraries/steve/src/ConfigItemList.h b/libraries/steve/src/ConfigItemList.h index dae871ddd..8ec5e07bf 100644 --- a/libraries/steve/src/ConfigItemList.h +++ b/libraries/steve/src/ConfigItemList.h @@ -8,89 +8,110 @@ #include "Rand.h" #include "Scale.h" -namespace steve { - template - class ConfigItemList { +namespace steve +{ +template class ConfigItemList +{ protected: std::vector> _items; std::vector> _allowed_items; - float _total_weight = 0.f; + float _total_weight = 0.f; public: - inline auto get_all() const { return _items; } - inline auto get_allowed() const { return _allowed_items; } - void compute_cache(); - std::shared_ptr get_item(const std::string& name); - std::shared_ptr get_random_item() const; - template - std::shared_ptr get_random_item(F predicate) const; - }; + inline auto get_all() const + { + return _items; + } + inline auto get_allowed() const + { + return _allowed_items; + } + void compute_cache(); + std::shared_ptr get_item(const std::string &name); + std::shared_ptr get_random_item() const; + template std::shared_ptr get_random_item(F predicate) const; +}; - template - void ConfigItemList::compute_cache() { +template void ConfigItemList::compute_cache() +{ bool use_whitelist = false; _allowed_items.clear(); _total_weight = 0.f; - for(const auto& item : _items) { - if(item->whitelisted) { - use_whitelist = true; - } + for (const auto &item : _items) + { + if (item->whitelisted) + { + use_whitelist = true; + } } - for(const auto& item : _items) { - if(!item->blacklisted && (!use_whitelist || item->whitelisted)) { - _allowed_items.push_back(item); - _total_weight += item->weight; - } + for (const auto &item : _items) + { + if (!item->blacklisted && (!use_whitelist || item->whitelisted)) + { + _allowed_items.push_back(item); + _total_weight += item->weight; + } } - } +} - template - std::shared_ptr ConfigItemList::get_item(const std::string& name) { - for(auto& candidate : _items) { - if(candidate->name == name) { - return candidate; - } +template std::shared_ptr ConfigItemList::get_item(const std::string &name) +{ + for (auto &candidate : _items) + { + if (candidate->name == name) + { + return candidate; + } } std::shared_ptr desc(new T); _items.push_back(desc); desc->name = name; return desc; - } +} - template - std::shared_ptr ConfigItemList::get_random_item() const { +template std::shared_ptr ConfigItemList::get_random_item() const +{ float weight_index = Rand::next(0.f, _total_weight); - for(const auto& candidate : _allowed_items) { - if(weight_index < candidate->weight) { - return candidate; - } else { - weight_index -= candidate->weight; - } + for (const auto &candidate : _allowed_items) + { + if (weight_index < candidate->weight) + { + return candidate; + } + else + { + weight_index -= candidate->weight; + } } - } - template - template - std::shared_ptr ConfigItemList::get_random_item(F predicate) const { - float filtered_weight = 0.f; +} +template template std::shared_ptr ConfigItemList::get_random_item(F predicate) const +{ + float filtered_weight = 0.f; std::vector> filtered_items; - for(const auto& candidate : _allowed_items) { - if(predicate(candidate)) { - filtered_items.push_back(candidate); - filtered_weight += candidate->weight; - } + for (const auto &candidate : _allowed_items) + { + if (predicate(candidate)) + { + filtered_items.push_back(candidate); + filtered_weight += candidate->weight; + } } float weight_index = Rand::next(0.f, filtered_weight); - for(const auto& candidate : filtered_items) { - if(weight_index < candidate->weight) { - return candidate; - } else { - weight_index -= candidate->weight; - } + for (const auto &candidate : filtered_items) + { + if (weight_index < candidate->weight) + { + return candidate; + } + else + { + weight_index -= candidate->weight; + } } return std::shared_ptr(); - } } +} // namespace steve diff --git a/libraries/steve/src/ConfigJson.cpp b/libraries/steve/src/ConfigJson.cpp index 857bf50b1..7ec7fd41f 100644 --- a/libraries/steve/src/ConfigJson.cpp +++ b/libraries/steve/src/ConfigJson.cpp @@ -4,296 +4,454 @@ using namespace steve; -template -void parse_number(json_value_s* json_value, T& target) { - if(const json_number_s* json_number = json_value_as_number(json_value)) { - target = atoi(json_number->number); - } else { - } +template void parse_number(json_value_s *json_value, T &target) +{ + if (const json_number_s *json_number = json_value_as_number(json_value)) + { + target = atoi(json_number->number); + } + else + { + } } -void parse_number(json_value_s* json_value, float& target) { - if(const json_number_s* json_number = json_value_as_number(json_value)) { - target = atof(json_number->number); - } else { - } +void parse_number(json_value_s *json_value, float &target) +{ + if (const json_number_s *json_number = json_value_as_number(json_value)) + { + target = atof(json_number->number); + } + else + { + } } -void parse_note(json_value_s* json_value, uint8_t& target) { - if(const json_string_s* json_string = json_value_as_string(json_value)) { - target = get_note_with_name(json_string->string); - } else { - parse_number(json_value, target); - } +void parse_note(json_value_s *json_value, uint8_t &target) +{ + if (const json_string_s *json_string = json_value_as_string(json_value)) + { + target = get_note_with_name(json_string->string); + } + else + { + parse_number(json_value, target); + } } -void ConfigJson::parse_file(const char* relative_filepath) { - std::string filepath; - if(!_directory_stack.empty()) { - filepath = _directory_stack.back() + relative_filepath; - } else { - filepath = relative_filepath; - } +void ConfigJson::parse_file(const char *relative_filepath) +{ + std::string filepath; + if (!_directory_stack.empty()) + { + filepath = _directory_stack.back() + relative_filepath; + } + else + { + filepath = relative_filepath; + } - { - const size_t last_slash = filepath.find_last_of('/'); - std::string directory; - if(last_slash >= 0) { - directory = filepath.substr(0, last_slash + 1); + { + const size_t last_slash = filepath.find_last_of('/'); + std::string directory; + if (last_slash >= 0) + { + directory = filepath.substr(0, last_slash + 1); + } + _directory_stack.push_back(directory); } - _directory_stack.push_back(directory); - } - FILE* file = fopen(filepath.c_str(), "rb"); - fseek(file, 0, SEEK_END); - const size_t file_size = ftell(file); - fseek(file, 0, SEEK_SET); + FILE *file = fopen(filepath.c_str(), "rb"); + fseek(file, 0, SEEK_END); + const size_t file_size = ftell(file); + fseek(file, 0, SEEK_SET); - char* file_data = (char*)malloc(file_size); - fread(file_data, 1, file_size, file); + char *file_data = (char *)malloc(file_size); + fread(file_data, 1, file_size, file); - parse_buffer(file_data, file_size); + parse_buffer(file_data, file_size); - free(file_data); + free(file_data); - _directory_stack.pop_back(); + _directory_stack.pop_back(); } -void ConfigJson::parse_buffer(const char* buffer, size_t size) { - json_parse_result_s parse_result; - json_value_s* root = json_parse_ex(buffer, size, json_parse_flags_allow_json5, nullptr, nullptr, &parse_result); +void ConfigJson::parse_buffer(const char *buffer, size_t size) +{ + json_parse_result_s parse_result; + json_value_s *root = json_parse_ex(buffer, size, json_parse_flags_allow_json5, nullptr, nullptr, &parse_result); - if(const json_object_s* root_object = json_value_as_object(root)) { - // Properties like "parents" need to be parsed first - for(const json_object_element_s* root_attribute = root_object->start; root_attribute != nullptr; root_attribute = root_attribute->next) { - if(!strcmp(root_attribute->name->string, "parents")) { - if(const json_array_s* parents = json_value_as_array(root_attribute->value)) { - for(json_array_element_s* parent = parents->start; parent != nullptr; parent = parent->next) { - if(const json_string_s* parent_path = json_value_as_string(parent->value)) { - parse_file(parent_path->string); - } else { + if (const json_object_s *root_object = json_value_as_object(root)) + { + // Properties like "parents" need to be parsed first + for (const json_object_element_s *root_attribute = root_object->start; root_attribute != nullptr; + root_attribute = root_attribute->next) + { + if (!strcmp(root_attribute->name->string, "parents")) + { + if (const json_array_s *parents = json_value_as_array(root_attribute->value)) + { + for (json_array_element_s *parent = parents->start; parent != nullptr; parent = parent->next) + { + if (const json_string_s *parent_path = json_value_as_string(parent->value)) + { + parse_file(parent_path->string); + } + else + { + } + } + } + else + { + } } - } - } else { } - } - } - for(const json_object_element_s* element = root_object->start; element != nullptr; element = element->next) { - if(!strcmp(element->name->string, "min_tempo")) { - parse_number(element->value, min_tempo); - } else if(!strcmp(element->name->string, "max_tempo")) { - parse_number(element->value, max_tempo); - } else if(!strcmp(element->name->string, "time_signatures")) { - parse_time_signatures(json_value_as_object(element->value)); - } else if(!strcmp(element->name->string, "creators")) { - parse_creators(json_value_as_object(element->value)); - } else if(!strcmp(element->name->string, "chords")) { - parse_chords(json_value_as_object(element->value)); - } else if(!strcmp(element->name->string, "scales")) { - parse_scales(json_value_as_object(element->value)); - } else if(!strcmp(element->name->string, "chord_changes")) { - parse_chord_changes(json_value_as_object(element->value)); - } else if(!strcmp(element->name->string, "instruments")) { - parse_instruments(json_value_as_object(element->value)); - } else { - } + for (const json_object_element_s *element = root_object->start; element != nullptr; element = element->next) + { + if (!strcmp(element->name->string, "min_tempo")) + { + parse_number(element->value, min_tempo); + } + else if (!strcmp(element->name->string, "max_tempo")) + { + parse_number(element->value, max_tempo); + } + else if (!strcmp(element->name->string, "time_signatures")) + { + parse_time_signatures(json_value_as_object(element->value)); + } + else if (!strcmp(element->name->string, "creators")) + { + parse_creators(json_value_as_object(element->value)); + } + else if (!strcmp(element->name->string, "chords")) + { + parse_chords(json_value_as_object(element->value)); + } + else if (!strcmp(element->name->string, "scales")) + { + parse_scales(json_value_as_object(element->value)); + } + else if (!strcmp(element->name->string, "chord_changes")) + { + parse_chord_changes(json_value_as_object(element->value)); + } + else if (!strcmp(element->name->string, "instruments")) + { + parse_instruments(json_value_as_object(element->value)); + } + else + { + } + } + } + else + { } - } else { - } - free(root); + free(root); } -void ConfigJson::parse_time_signatures(const json_object_s* time_signatures_object) { - for(const json_object_element_s* time_signature_element = time_signatures_object->start; time_signature_element != nullptr; time_signature_element = time_signature_element->next) { - std::shared_ptr desc = _signatures.get_item(time_signature_element->name->string); - std::string time_signature = time_signature_element->name->string; - auto slash_pos = time_signature.find('/'); - if(slash_pos != std::string::npos) { - desc->beats_per_bar = atoi(time_signature.substr(0, slash_pos).c_str()); - desc->beat_value = NoteValue(uint32_t(NoteValue::whole) - log2(atoi(time_signature.substr(slash_pos + 1).c_str()))); - } - if(const json_object_s* time_signature_object = json_value_as_object(time_signature_element->value)) { - parse_item(time_signature_object, *desc); +void ConfigJson::parse_time_signatures(const json_object_s *time_signatures_object) +{ + for (const json_object_element_s *time_signature_element = time_signatures_object->start; + time_signature_element != nullptr; time_signature_element = time_signature_element->next) + { + std::shared_ptr desc = _signatures.get_item(time_signature_element->name->string); + std::string time_signature = time_signature_element->name->string; + auto slash_pos = time_signature.find('/'); + if (slash_pos != std::string::npos) + { + desc->beats_per_bar = atoi(time_signature.substr(0, slash_pos).c_str()); + desc->beat_value = + NoteValue(uint32_t(NoteValue::whole) - log2(atoi(time_signature.substr(slash_pos + 1).c_str()))); + } + if (const json_object_s *time_signature_object = json_value_as_object(time_signature_element->value)) + { + parse_item(time_signature_object, *desc); + } } - } } -void ConfigJson::parse_creators(const json_object_s* creators_object) { - for(const json_object_element_s* creator_element = creators_object->start; creator_element != nullptr; creator_element = creator_element->next) { - std::shared_ptr desc = _creators.get_item(creator_element->name->string); - if(const json_object_s* creator_object = json_value_as_object(creator_element->value)) { - parse_creator(creator_object, *desc); - } else { +void ConfigJson::parse_creators(const json_object_s *creators_object) +{ + for (const json_object_element_s *creator_element = creators_object->start; creator_element != nullptr; + creator_element = creator_element->next) + { + std::shared_ptr desc = _creators.get_item(creator_element->name->string); + if (const json_object_s *creator_object = json_value_as_object(creator_element->value)) + { + parse_creator(creator_object, *desc); + } + else + { + } } - } } -void ConfigJson::parse_creator(const json_object_s* creator_object, CreatorDescription& desc) { - parse_item(creator_object, desc); - for(const json_object_element_s* creator_attribute = creator_object->start; creator_attribute != nullptr; creator_attribute = creator_attribute->next) { - const char* creator_attribute_name = creator_attribute->name->string; - if(!strcmp(creator_attribute_name, "min_count")) { - parse_number(creator_attribute->value, desc.min_count); - } else if(!strcmp(creator_attribute_name, "max_count")) { - parse_number(creator_attribute->value, desc.max_count); +void ConfigJson::parse_creator(const json_object_s *creator_object, CreatorDescription &desc) +{ + parse_item(creator_object, desc); + for (const json_object_element_s *creator_attribute = creator_object->start; creator_attribute != nullptr; + creator_attribute = creator_attribute->next) + { + const char *creator_attribute_name = creator_attribute->name->string; + if (!strcmp(creator_attribute_name, "min_count")) + { + parse_number(creator_attribute->value, desc.min_count); + } + else if (!strcmp(creator_attribute_name, "max_count")) + { + parse_number(creator_attribute->value, desc.max_count); + } } - } } -void ConfigJson::parse_chords(const json_object_s* chords_object) { - for(const json_object_element_s* chord_element = chords_object->start; chord_element != nullptr; chord_element = chord_element->next) { - std::shared_ptr desc = _chords.get_item(chord_element->name->string); - if(const json_object_s* chord_object = json_value_as_object(chord_element->value)) { - parse_chord(chord_object, *desc); - } else { +void ConfigJson::parse_chords(const json_object_s *chords_object) +{ + for (const json_object_element_s *chord_element = chords_object->start; chord_element != nullptr; + chord_element = chord_element->next) + { + std::shared_ptr desc = _chords.get_item(chord_element->name->string); + if (const json_object_s *chord_object = json_value_as_object(chord_element->value)) + { + parse_chord(chord_object, *desc); + } + else + { + } } - } } -void ConfigJson::parse_chord(const json_object_s* chord_object, ChordDescription& desc) { - parse_item(chord_object, desc); - for(const json_object_element_s* chord_attribute = chord_object->start; chord_attribute != nullptr; chord_attribute = chord_attribute->next) { - const char* chord_attribute_name = chord_attribute->name->string; - if(!strcmp(chord_attribute_name, "suffix")) { - if(const json_string_s* chord_suffix = json_value_as_string(chord_attribute->value)) { - desc.suffix = chord_suffix->string; - } else { - } - } else if(!strcmp(chord_attribute_name, "tones")) { - if(const json_array_s* chord_tones = json_value_as_array(chord_attribute->value)) { - for(json_array_element_s* element = chord_tones->start; element != nullptr; element = element->next) { - if(const json_number_s* tone = json_value_as_number(element->value)) { - desc.tones |= 1 << atoi(tone->number); - } else { - } +void ConfigJson::parse_chord(const json_object_s *chord_object, ChordDescription &desc) +{ + parse_item(chord_object, desc); + for (const json_object_element_s *chord_attribute = chord_object->start; chord_attribute != nullptr; + chord_attribute = chord_attribute->next) + { + const char *chord_attribute_name = chord_attribute->name->string; + if (!strcmp(chord_attribute_name, "suffix")) + { + if (const json_string_s *chord_suffix = json_value_as_string(chord_attribute->value)) + { + desc.suffix = chord_suffix->string; + } + else + { + } + } + else if (!strcmp(chord_attribute_name, "tones")) + { + if (const json_array_s *chord_tones = json_value_as_array(chord_attribute->value)) + { + for (json_array_element_s *element = chord_tones->start; element != nullptr; element = element->next) + { + if (const json_number_s *tone = json_value_as_number(element->value)) + { + desc.tones |= 1 << atoi(tone->number); + } + else + { + } + } + } + else + { + } + } + else if (!strcmp(chord_attribute_name, "uppercase")) + { + desc.uppercase = json_value_is_true(chord_attribute->value); } - } else { - } - } else if(!strcmp(chord_attribute_name, "uppercase")) { - desc.uppercase = json_value_is_true(chord_attribute->value); } - } } -void ConfigJson::parse_scales(const json_object_s* scales_object) { - for(const json_object_element_s* scale_element = scales_object->start; scale_element != nullptr; scale_element = scale_element->next) { - std::shared_ptr desc = _scales.get_item(scale_element->name->string); - if(const json_object_s* scale_object = json_value_as_object(scale_element->value)) { - parse_scale(scale_object, *desc); +void ConfigJson::parse_scales(const json_object_s *scales_object) +{ + for (const json_object_element_s *scale_element = scales_object->start; scale_element != nullptr; + scale_element = scale_element->next) + { + std::shared_ptr desc = _scales.get_item(scale_element->name->string); + if (const json_object_s *scale_object = json_value_as_object(scale_element->value)) + { + parse_scale(scale_object, *desc); + } } - } } -void ConfigJson::parse_scale(const json_object_s* scale_object, ScaleDescription& desc) { - parse_item(scale_object, desc); - for(const json_object_element_s* scale_attribute = scale_object->start; scale_attribute != nullptr; scale_attribute = scale_attribute->next) { - if(!strcmp(scale_attribute->name->string, "tones")) { - if(const json_array_s* scale_tones = json_value_as_array(scale_attribute->value)) { - for(json_array_element_s* element = scale_tones->start; element != nullptr; element = element->next) { - if(const json_number_s* tone = json_value_as_number(element->value)) { - desc.tones |= 1 << atoi(tone->number); - } else { - } +void ConfigJson::parse_scale(const json_object_s *scale_object, ScaleDescription &desc) +{ + parse_item(scale_object, desc); + for (const json_object_element_s *scale_attribute = scale_object->start; scale_attribute != nullptr; + scale_attribute = scale_attribute->next) + { + if (!strcmp(scale_attribute->name->string, "tones")) + { + if (const json_array_s *scale_tones = json_value_as_array(scale_attribute->value)) + { + for (json_array_element_s *element = scale_tones->start; element != nullptr; element = element->next) + { + if (const json_number_s *tone = json_value_as_number(element->value)) + { + desc.tones |= 1 << atoi(tone->number); + } + else + { + } + } + } + else + { + } } - } else { - } } - } } -void ConfigJson::parse_chord_changes(const json_object_s* chord_changes_object) { - for(const json_object_element_s* chord_change_source_element = chord_changes_object->start; chord_change_source_element != nullptr; chord_change_source_element = chord_change_source_element->next) { - const std::string source_name = chord_change_source_element->name->string; - if(const json_object_s* chord_change_target_object = json_value_as_object(chord_change_source_element->value)) { - for(const json_object_element_s* chord_change_target_element = chord_change_target_object->start; chord_change_target_element != nullptr; chord_change_target_element = chord_change_target_element->next) { - const std::string target_name = chord_change_target_element->name->string; - if(const json_object_s* chord_change_offset_object = json_value_as_object(chord_change_target_element->value)) { - for(const json_object_element_s* chord_change_offset_element = chord_change_offset_object->start; chord_change_offset_element != nullptr; chord_change_offset_element = chord_change_offset_element->next) { - const std::string offset_string = chord_change_offset_element->name->string; - if(const json_object_s* chord_change_object = json_value_as_object(chord_change_offset_element->value)) { - parse_chord_change(chord_change_object, source_name, target_name, offset_string); +void ConfigJson::parse_chord_changes(const json_object_s *chord_changes_object) +{ + for (const json_object_element_s *chord_change_source_element = chord_changes_object->start; + chord_change_source_element != nullptr; chord_change_source_element = chord_change_source_element->next) + { + const std::string source_name = chord_change_source_element->name->string; + if (const json_object_s *chord_change_target_object = json_value_as_object(chord_change_source_element->value)) + { + for (const json_object_element_s *chord_change_target_element = chord_change_target_object->start; + chord_change_target_element != nullptr; + chord_change_target_element = chord_change_target_element->next) + { + const std::string target_name = chord_change_target_element->name->string; + if (const json_object_s *chord_change_offset_object = + json_value_as_object(chord_change_target_element->value)) + { + for (const json_object_element_s *chord_change_offset_element = chord_change_offset_object->start; + chord_change_offset_element != nullptr; + chord_change_offset_element = chord_change_offset_element->next) + { + const std::string offset_string = chord_change_offset_element->name->string; + if (const json_object_s *chord_change_object = + json_value_as_object(chord_change_offset_element->value)) + { + parse_chord_change(chord_change_object, source_name, target_name, offset_string); + } + } + } } - } } - } } - } } -void ConfigJson::parse_chord_change(const json_object_s* chord_change_object, const std::string& source_string, const std::string& target_string, const std::string& offset_string) { - std::vector> source_chords; - std::vector> target_chords; - std::vector offsets; +void ConfigJson::parse_chord_change(const json_object_s *chord_change_object, const std::string &source_string, + const std::string &target_string, const std::string &offset_string) +{ + std::vector> source_chords; + std::vector> target_chords; + std::vector offsets; - if(source_string == "*") { - source_chords = _chords.get_all(); - } else { - std::stringstream ss(source_string); - for(std::string chord_name; std::getline(ss, chord_name, '|');) { - source_chords.push_back(_chords.get_item(chord_name)); + if (source_string == "*") + { + source_chords = _chords.get_all(); + } + else + { + std::stringstream ss(source_string); + for (std::string chord_name; std::getline(ss, chord_name, '|');) + { + source_chords.push_back(_chords.get_item(chord_name)); + } } - } - if(target_string == "*") { - target_chords = _chords.get_all(); - } else { - std::stringstream ss(target_string); - for(std::string chord_name; std::getline(ss, chord_name, '|');) { - target_chords.push_back(_chords.get_item(chord_name)); + if (target_string == "*") + { + target_chords = _chords.get_all(); + } + else + { + std::stringstream ss(target_string); + for (std::string chord_name; std::getline(ss, chord_name, '|');) + { + target_chords.push_back(_chords.get_item(chord_name)); + } } - } - if(offset_string == "*") { - for(uint32_t offset = 0; offset < 12; offset++) { - offsets.push_back(offset); + if (offset_string == "*") + { + for (uint32_t offset = 0; offset < 12; offset++) + { + offsets.push_back(offset); + } + } + else + { + offsets.push_back(atoi(offset_string.c_str())); } - } else { - offsets.push_back(atoi(offset_string.c_str())); - } - for(const auto& source_chord : source_chords) { - for(const auto& target_chord : target_chords) { - for(uint32_t offset : offsets) { - std::shared_ptr chord_change = get_chord_change(source_chord, target_chord, offset); - parse_item(chord_change_object, *chord_change); - } + for (const auto &source_chord : source_chords) + { + for (const auto &target_chord : target_chords) + { + for (uint32_t offset : offsets) + { + std::shared_ptr chord_change = get_chord_change(source_chord, target_chord, offset); + parse_item(chord_change_object, *chord_change); + } + } } - } } -void ConfigJson::parse_instruments(const json_object_s* instruments_object) { - for(const json_object_element_s* instrument_element = instruments_object->start; instrument_element != nullptr; instrument_element = instrument_element->next) { - std::shared_ptr desc = _instruments.get_item(instrument_element->name->string); - if(const json_object_s* instrument_object = json_value_as_object(instrument_element->value)) { - parse_instrument(instrument_object, *desc); +void ConfigJson::parse_instruments(const json_object_s *instruments_object) +{ + for (const json_object_element_s *instrument_element = instruments_object->start; instrument_element != nullptr; + instrument_element = instrument_element->next) + { + std::shared_ptr desc = _instruments.get_item(instrument_element->name->string); + if (const json_object_s *instrument_object = json_value_as_object(instrument_element->value)) + { + parse_instrument(instrument_object, *desc); + } } - } } -void ConfigJson::parse_instrument(const json_object_s* instrument_object, Instrument& desc) { - parse_item(instrument_object, desc); - for(const json_object_element_s* instrument_attribute = instrument_object->start; instrument_attribute != nullptr; instrument_attribute = instrument_attribute->next) { - if(!strcmp(instrument_attribute->name->string, "index")) { - parse_number(instrument_attribute->value, desc.midi_id); - } else if(!strcmp(instrument_attribute->name->string, "min_tone")) { - parse_note(instrument_attribute->value, desc.min_tone); - } else if(!strcmp(instrument_attribute->name->string, "max_tone")) { - parse_note(instrument_attribute->value, desc.max_tone); - } else if(!strcmp(instrument_attribute->name->string, "voices")) { - parse_note(instrument_attribute->value, desc.voices); +void ConfigJson::parse_instrument(const json_object_s *instrument_object, Instrument &desc) +{ + parse_item(instrument_object, desc); + for (const json_object_element_s *instrument_attribute = instrument_object->start; instrument_attribute != nullptr; + instrument_attribute = instrument_attribute->next) + { + if (!strcmp(instrument_attribute->name->string, "index")) + { + parse_number(instrument_attribute->value, desc.midi_id); + } + else if (!strcmp(instrument_attribute->name->string, "min_tone")) + { + parse_note(instrument_attribute->value, desc.min_tone); + } + else if (!strcmp(instrument_attribute->name->string, "max_tone")) + { + parse_note(instrument_attribute->value, desc.max_tone); + } + else if (!strcmp(instrument_attribute->name->string, "voices")) + { + parse_note(instrument_attribute->value, desc.voices); + } } - } } -void ConfigJson::parse_item(const json_object_s* item_object, ItemDescription& item) { - for(const json_object_element_s* item_attribute = item_object->start; item_attribute != nullptr; item_attribute = item_attribute->next) { - if(!strcmp(item_attribute->name->string, "whitelist")) { - item.whitelisted = json_value_is_true(item_attribute->value); - } else if(!strcmp(item_attribute->name->string, "blacklist")) { - item.blacklisted = json_value_is_true(item_attribute->value); - } else if(!strcmp(item_attribute->name->string, "weight")) { - parse_number(item_attribute->value, item.weight); +void ConfigJson::parse_item(const json_object_s *item_object, ItemDescription &item) +{ + for (const json_object_element_s *item_attribute = item_object->start; item_attribute != nullptr; + item_attribute = item_attribute->next) + { + if (!strcmp(item_attribute->name->string, "whitelist")) + { + item.whitelisted = json_value_is_true(item_attribute->value); + } + else if (!strcmp(item_attribute->name->string, "blacklist")) + { + item.blacklisted = json_value_is_true(item_attribute->value); + } + else if (!strcmp(item_attribute->name->string, "weight")) + { + parse_number(item_attribute->value, item.weight); + } } - } } diff --git a/libraries/steve/src/ConfigJson.h b/libraries/steve/src/ConfigJson.h index 7e951a684..14224d33c 100644 --- a/libraries/steve/src/ConfigJson.h +++ b/libraries/steve/src/ConfigJson.h @@ -3,25 +3,28 @@ #include "Config.h" #include "ext/json.h" -namespace steve { - class ConfigJson : public Config { +namespace steve +{ +class ConfigJson : public Config +{ protected: std::vector _directory_stack; public: - void parse_file(const char* filepath); - void parse_buffer(const char* buffer, size_t size); - void parse_time_signatures(const json_object_s*); - void parse_creators(const json_object_s*); - void parse_creator(const json_object_s*, CreatorDescription&); - void parse_chords(const json_object_s*); - void parse_chord(const json_object_s*, ChordDescription&); - void parse_scales(const json_object_s*); - void parse_scale(const json_object_s*, ScaleDescription&); - void parse_chord_changes(const json_object_s*); - void parse_chord_change(const json_object_s*, const std::string& src, const std::string& tar, const std::string& off); - void parse_instruments(const json_object_s*); - void parse_instrument(const json_object_s*, Instrument&); - void parse_item(const json_object_s*, ItemDescription&); - }; -} + void parse_file(const char *filepath); + void parse_buffer(const char *buffer, size_t size); + void parse_time_signatures(const json_object_s *); + void parse_creators(const json_object_s *); + void parse_creator(const json_object_s *, CreatorDescription &); + void parse_chords(const json_object_s *); + void parse_chord(const json_object_s *, ChordDescription &); + void parse_scales(const json_object_s *); + void parse_scale(const json_object_s *, ScaleDescription &); + void parse_chord_changes(const json_object_s *); + void parse_chord_change(const json_object_s *, const std::string &src, const std::string &tar, + const std::string &off); + void parse_instruments(const json_object_s *); + void parse_instrument(const json_object_s *, Instrument &); + void parse_item(const json_object_s *, ItemDescription &); +}; +} // namespace steve diff --git a/libraries/steve/src/Instrument.h b/libraries/steve/src/Instrument.h index dbc5b2b68..ffe055f12 100644 --- a/libraries/steve/src/Instrument.h +++ b/libraries/steve/src/Instrument.h @@ -4,10 +4,12 @@ #include "ItemDescription.h" -namespace steve { - struct Instrument : ItemDescription { +namespace steve +{ +struct Instrument : ItemDescription +{ uint8_t midi_id; uint8_t min_tone = 0, max_tone = 127; uint8_t voices = 1; - }; -} +}; +} // namespace steve diff --git a/libraries/steve/src/ItemDescription.h b/libraries/steve/src/ItemDescription.h index 08b7eb106..cac7675be 100644 --- a/libraries/steve/src/ItemDescription.h +++ b/libraries/steve/src/ItemDescription.h @@ -3,10 +3,12 @@ #include #include -namespace steve { - struct ItemDescription { +namespace steve +{ +struct ItemDescription +{ std::string name; - bool blacklisted = false, whitelisted = false; - float weight = 1.f; - }; -} + bool blacklisted = false, whitelisted = false; + float weight = 1.f; +}; +} // namespace steve diff --git a/libraries/steve/src/Music.cpp b/libraries/steve/src/Music.cpp index 65ef412e0..3ef7af5d2 100644 --- a/libraries/steve/src/Music.cpp +++ b/libraries/steve/src/Music.cpp @@ -12,226 +12,275 @@ using namespace steve; -Music::Music(const Config& config) - : _config(config), - _scale(Scale(_config.get_scales().get_random_item(), Rand::next(0, 11))), - _tempo(_config.get_random_tempo()), - _signature(_config.get_signatures().get_random_item()) { - do { - _size = uint32_t(40 * Rand::next_normal()) + 26; - } while(_size > 512); // <=512 with 46 average bars - - _size -= _size % 4; // Multiple of 4 bars - _size *= get_bar_ticks(); - - { // Generate chord progression - _chord_progression = _config.get_chord_progression(_scale); - for(uintptr_t i(0); i < bars(); i++) { - for(uintptr_t j(0); j < get_bar_ticks(); j++) { - _tones.push_back(_chord_progression[i % _chord_progression.size()].tones); - } - } - assert(_tones.size() == _size); - } - - { // Generate beats - _beats.resize(get_bar_ticks()); - for(uint32_t i = 0; i < _beats.size(); i++) { - _beats[i] = false; - for(NoteValue j = get_beat_value(); j >= NoteValue(0); j = NoteValue(uint32_t(j) - 1)) { - const auto ticks = ticks_for(j); - if((i / ticks) * ticks == i) { - if(Rand::next(0u, (uint32_t(get_beat_value()) - uint32_t(j)) * 2) == 0) { - _beats[i] = true; - break; - } +Music::Music(const Config &config) + : _config(config), _scale(Scale(_config.get_scales().get_random_item(), Rand::next(0, 11))), + _tempo(_config.get_random_tempo()), _signature(_config.get_signatures().get_random_item()) +{ + do + { + _size = uint32_t(40 * Rand::next_normal()) + 26; + } while (_size > 512); // <=512 with 46 average bars + + _size -= _size % 4; // Multiple of 4 bars + _size *= get_bar_ticks(); + + { // Generate chord progression + _chord_progression = _config.get_chord_progression(_scale); + for (uintptr_t i(0); i < bars(); i++) + { + for (uintptr_t j(0); j < get_bar_ticks(); j++) + { + _tones.push_back(_chord_progression[i % _chord_progression.size()].tones); + } + } + assert(_tones.size() == _size); + } + + { // Generate beats + _beats.resize(get_bar_ticks()); + for (uint32_t i = 0; i < _beats.size(); i++) + { + _beats[i] = false; + for (NoteValue j = get_beat_value(); j >= NoteValue(0); j = NoteValue(uint32_t(j) - 1)) + { + const auto ticks = ticks_for(j); + if ((i / ticks) * ticks == i) + { + if (Rand::next(0u, (uint32_t(get_beat_value()) - uint32_t(j)) * 2) == 0) + { + _beats[i] = true; + break; + } + } + } } - } } - } - for(const auto& creator : _config.get_creators()) { - add_creator(creator->func(this)); - } + for (const auto &creator : _config.get_creators()) + { + add_creator(creator->func(this)); + } #ifndef NDEBUG - check(); + check(); #endif } -void Music::add_creator(Creator* creator) { - creator->init(); - creator->post_init(); - paste(creator->compose(), _notes); - _creators.push_back(std::unique_ptr(creator)); +void Music::add_creator(Creator *creator) +{ + creator->init(); + creator->post_init(); + paste(creator->compose(), _notes); + _creators.push_back(std::unique_ptr(creator)); } -const Chord& Music::chord_at(size_t i) const { - return _chord_progression[(i / get_bar_ticks()) % _chord_progression.size()]; +const Chord &Music::chord_at(size_t i) const +{ + return _chord_progression[(i / get_bar_ticks()) % _chord_progression.size()]; } -ToneSet Music::tones_at(size_t start, size_t size) const { - ToneSet tones = ~0; - const uintptr_t start_bar = start / get_bar_ticks(); - const uintptr_t end_bar = (start + size - 1) / get_bar_ticks(); - for(uintptr_t i = start_bar; i <= end_bar; i++) { - tones &= _chord_progression[i % _chord_progression.size()].tones; - } - return tones; +ToneSet Music::tones_at(size_t start, size_t size) const +{ + ToneSet tones = ~0; + const uintptr_t start_bar = start / get_bar_ticks(); + const uintptr_t end_bar = (start + size - 1) / get_bar_ticks(); + for (uintptr_t i = start_bar; i <= end_bar; i++) + { + tones &= _chord_progression[i % _chord_progression.size()].tones; + } + return tones; } -bool Music::is_beat(uintptr_t i) const { - return _beats[i % _beats.size()]; +bool Music::is_beat(uintptr_t i) const +{ + return _beats[i % _beats.size()]; } -std::vector Music::beats_inside(uintptr_t min, uintptr_t max) const { - std::vector beats; - for(uintptr_t i = min; i <= max; i++) { - if(is_beat(i)) { - beats.push_back(i); - } - } - return beats; +std::vector Music::beats_inside(uintptr_t min, uintptr_t max) const +{ + std::vector beats; + for (uintptr_t i = min; i <= max; i++) + { + if (is_beat(i)) + { + beats.push_back(i); + } + } + return beats; } -std::string Music::to_short_string() const { - std::string short_string; - short_string += scale().desc->name + "_" + key_name(scale().key); - short_string += "_" + std::to_string(_signature->beats_per_bar); - short_string += std::to_string(1 << (uint32_t(NoteValue::whole) - uint32_t(get_beat_value()))); - short_string += "_" + std::to_string(tempo()); +std::string Music::to_short_string() const +{ + std::string short_string; + short_string += scale().desc->name + "_" + key_name(scale().key); + short_string += "_" + std::to_string(_signature->beats_per_bar); + short_string += std::to_string(1 << (uint32_t(NoteValue::whole) - uint32_t(get_beat_value()))); + short_string += "_" + std::to_string(tempo()); - std::replace(short_string.begin(), short_string.end(), ' ', '_'); + std::replace(short_string.begin(), short_string.end(), ' ', '_'); - return short_string; + return short_string; } -void Music::check() const { - Tones final_tones(octave_tones(_notes)); - assert(final_tones.size() <= _tones.size()); - for(uintptr_t i(0); i < final_tones.size(); i++) { - assert(tone_set_within(_scale.tones, final_tones[i])); - assert(tone_set_within(_tones[i], final_tones[i])); - } - - for(const auto& note : _notes) { - assert(is_beat(note.first)); - } +void Music::check() const +{ + Tones final_tones(octave_tones(_notes)); + assert(final_tones.size() <= _tones.size()); + for (uintptr_t i(0); i < final_tones.size(); i++) + { + assert(tone_set_within(_scale.tones, final_tones[i])); + assert(tone_set_within(_tones[i], final_tones[i])); + } + + for (const auto ¬e : _notes) + { + assert(is_beat(note.first)); + } } -static void write_bigendian(std::ostream& s, uint32_t v, uint32_t byteCount) { - if(byteCount>=4) s << uint8_t(v>>24); - if(byteCount>=3) s << uint8_t(v>>16); - if(byteCount>=2) s << uint8_t(v>>8); - if(byteCount>=1) s << uint8_t(v); +static void write_bigendian(std::ostream &s, uint32_t v, uint32_t byteCount) +{ + if (byteCount >= 4) + s << uint8_t(v >> 24); + if (byteCount >= 3) + s << uint8_t(v >> 16); + if (byteCount >= 2) + s << uint8_t(v >> 8); + if (byteCount >= 1) + s << uint8_t(v); } -class VarLength { - uint32_t _value; -public: - inline VarLength(uint32_t value) : _value(value) {} - friend inline std::ostream& operator<<(std::ostream& s, const VarLength& v) { - if(v._value >= 128) { - s << (uint8_t)(((v._value >> 7) & 0x7f) | 0x80); - } - s << (uint8_t)(v._value & 0x7f); - return s; - } +class VarLength +{ + uint32_t _value; + + public: + inline VarLength(uint32_t value) : _value(value) + { + } + friend inline std::ostream &operator<<(std::ostream &s, const VarLength &v) + { + if (v._value >= 128) + { + s << (uint8_t)(((v._value >> 7) & 0x7f) | 0x80); + } + s << (uint8_t)(v._value & 0x7f); + return s; + } }; -void Music::write_mid(std::ostream& s) const { - // Header chunk - s << "MThd"; // Chunk id - write_bigendian(s, 6, 4); // Chunk size - write_bigendian(s, 0, 2); // Format type (single track) - write_bigendian(s, 1, 2); // Number of tracks - write_bigendian(s, ticks_for(NoteValue::quarter), 2); // Time division (ticks per beat) - - // Track chunk - s << "MTrk"; - const size_t sizeoff(s.tellp()); - write_bigendian(s, 0, 4); // Placeholder for track size - - { // Tempo meta event - s << uint8_t(0) << uint8_t(0xff) << uint8_t(0x51) << uint8_t(3); - write_bigendian(s, 60000000u / _tempo, 3); // Microseconds per quarter note - } - - { // Time signature meta event - s << uint8_t(0) << uint8_t(0xff) << uint8_t(0x58) << uint8_t(4) - << uint8_t(_signature->beats_per_bar) // Numerator - << uint8_t(uint8_t(NoteValue::whole) - uint8_t(get_beat_value())) // Denominator (2^x) - << uint8_t(0x18) // Metronome pulse in clock ticks - << uint8_t(ticks_for(get_beat_value()) / ticks_for(NoteValue::thirtysecond)); // 32nd per beat - } - - for(uint32_t i(0); i < _creators.size(); i++) { - s << uint8_t(0) << uint8_t(0xC0|i) << _creators[i]->instrument()->midi_id; // Program change - } - - uint32_t last = 0; - uint32_t last_chord = -1; - - Notes end_notes; - auto process_end_notes = [&s, &last, &end_notes](uint32_t next_time) { - while(!end_notes.empty()) { - auto next_end = end_notes.begin(); - if(next_end->first <= next_time) { - s << VarLength(next_end->first - last) << uint8_t(0x80 | next_end->second.channel) << uint8_t(next_end->second.tone) << uint8_t(next_end->second.velocity); // Note off - last = next_end->first; - end_notes.erase(next_end); - } else { - break; - } - } - }; - - for(const auto& note : _notes) { - process_end_notes(note.first); - - s << VarLength(note.first - last) << uint8_t(0x90 | note.second.channel) << uint8_t(note.second.tone) << uint8_t(note.second.velocity); // Note on - - end_notes.insert(std::make_pair(note.first + note.second.duration, note.second)); - - last = note.first; - - if(note.first != last_chord && note.first != _size && note.first % get_bar_ticks() == 0) { - // Chord meta-event - const Chord chord = chord_at(note.first); - const uint8_t degree =_scale.get_degree_for_tone(chord.key); - const std::string chord_str = chord_at(note.first).to_short_string() + " (" + std::to_string(degree + 1) + ")"; - s << uint8_t(0) << uint8_t(0xFF) << uint8_t(0x01) << VarLength(chord_str.size()) << chord_str; - last_chord = note.first; - } - } - process_end_notes(last + get_bar_ticks()); - - s << uint8_t(0) << uint8_t(0xFF) << uint8_t(0x2F) << uint8_t(0); // End of track - - // Write chunk size - const size_t endoff(s.tellp()); - s.seekp(sizeoff); - write_bigendian(s, endoff-sizeoff-4, 4); +void Music::write_mid(std::ostream &s) const +{ + // Header chunk + s << "MThd"; // Chunk id + write_bigendian(s, 6, 4); // Chunk size + write_bigendian(s, 0, 2); // Format type (single track) + write_bigendian(s, 1, 2); // Number of tracks + write_bigendian(s, ticks_for(NoteValue::quarter), 2); // Time division (ticks per beat) + + // Track chunk + s << "MTrk"; + const size_t sizeoff(s.tellp()); + write_bigendian(s, 0, 4); // Placeholder for track size + + { // Tempo meta event + s << uint8_t(0) << uint8_t(0xff) << uint8_t(0x51) << uint8_t(3); + write_bigendian(s, 60000000u / _tempo, 3); // Microseconds per quarter note + } + + { // Time signature meta event + s << uint8_t(0) << uint8_t(0xff) << uint8_t(0x58) << uint8_t(4) + << uint8_t(_signature->beats_per_bar) // Numerator + << uint8_t(uint8_t(NoteValue::whole) - uint8_t(get_beat_value())) // Denominator (2^x) + << uint8_t(0x18) // Metronome pulse in clock ticks + << uint8_t(ticks_for(get_beat_value()) / ticks_for(NoteValue::thirtysecond)); // 32nd per beat + } + + for (uint32_t i(0); i < _creators.size(); i++) + { + s << uint8_t(0) << uint8_t(0xC0 | i) << _creators[i]->instrument()->midi_id; // Program change + } + + uint32_t last = 0; + uint32_t last_chord = -1; + + Notes end_notes; + auto process_end_notes = [&s, &last, &end_notes](uint32_t next_time) { + while (!end_notes.empty()) + { + auto next_end = end_notes.begin(); + if (next_end->first <= next_time) + { + s << VarLength(next_end->first - last) << uint8_t(0x80 | next_end->second.channel) + << uint8_t(next_end->second.tone) << uint8_t(next_end->second.velocity); // Note off + last = next_end->first; + end_notes.erase(next_end); + } + else + { + break; + } + } + }; + + for (const auto ¬e : _notes) + { + process_end_notes(note.first); + + s << VarLength(note.first - last) << uint8_t(0x90 | note.second.channel) << uint8_t(note.second.tone) + << uint8_t(note.second.velocity); // Note on + + end_notes.insert(std::make_pair(note.first + note.second.duration, note.second)); + + last = note.first; + + if (note.first != last_chord && note.first != _size && note.first % get_bar_ticks() == 0) + { + // Chord meta-event + const Chord chord = chord_at(note.first); + const uint8_t degree = _scale.get_degree_for_tone(chord.key); + const std::string chord_str = + chord_at(note.first).to_short_string() + " (" + std::to_string(degree + 1) + ")"; + s << uint8_t(0) << uint8_t(0xFF) << uint8_t(0x01) << VarLength(chord_str.size()) << chord_str; + last_chord = note.first; + } + } + process_end_notes(last + get_bar_ticks()); + + s << uint8_t(0) << uint8_t(0xFF) << uint8_t(0x2F) << uint8_t(0); // End of track + + // Write chunk size + const size_t endoff(s.tellp()); + s.seekp(sizeoff); + write_bigendian(s, endoff - sizeoff - 4, 4); } -void Music::write_txt(std::ostream& s) const { - s << "Scale: " << key_name(scale().key) << " " << scale().desc->name << std::endl - << "Tempo: " << tempo() << std::endl - << "Signature: " << _signature->beats_per_bar << "/" << (1 << (uint32_t(NoteValue::whole) - uint32_t(get_beat_value()))) << std::endl - << "Duration: " << duration() << std::endl << std::endl; - - { - s << "Chord progression:" << std::endl; - for(const Chord& chord : _chord_progression) { - s << " - " << _scale.get_degree_string_for_chord(chord) << " (" << chord.to_short_string() << ")" << std::endl; - } - s << std::endl; - } - - { - s << "Rhythm:" << std::endl << '\t'; - for(uintptr_t i = 0; i < _beats.size(); i += 2) { - if(i % ticks_for(get_beat_value()) == 0 && i > 0) { - s << ' '; - } - s << (is_beat(i) ? '1' : '0'); - } - s << std::endl << std::endl; - } - - s << "Creators:" << std::endl; - for(const auto& creator : _creators) { - creator->write_txt(s); - s << std::endl; - } +void Music::write_txt(std::ostream &s) const +{ + s << "Scale: " << key_name(scale().key) << " " << scale().desc->name << std::endl + << "Tempo: " << tempo() << std::endl + << "Signature: " << _signature->beats_per_bar << "/" + << (1 << (uint32_t(NoteValue::whole) - uint32_t(get_beat_value()))) << std::endl + << "Duration: " << duration() << std::endl + << std::endl; + + { + s << "Chord progression:" << std::endl; + for (const Chord &chord : _chord_progression) + { + s << " - " << _scale.get_degree_string_for_chord(chord) << " (" << chord.to_short_string() << ")" + << std::endl; + } + s << std::endl; + } + + { + s << "Rhythm:" << std::endl << '\t'; + for (uintptr_t i = 0; i < _beats.size(); i += 2) + { + if (i % ticks_for(get_beat_value()) == 0 && i > 0) + { + s << ' '; + } + s << (is_beat(i) ? '1' : '0'); + } + s << std::endl << std::endl; + } + + s << "Creators:" << std::endl; + for (const auto &creator : _creators) + { + creator->write_txt(s); + s << std::endl; + } } \ No newline at end of file diff --git a/libraries/steve/src/Music.h b/libraries/steve/src/Music.h index faf9cbb8c..107773417 100644 --- a/libraries/steve/src/Music.h +++ b/libraries/steve/src/Music.h @@ -9,47 +9,91 @@ #include "Steve.h" #include "TimeSignature.h" -namespace steve { - class Config; - class Creator; - class Music { +namespace steve +{ +class Config; +class Creator; +class Music +{ protected: - const Config& _config; - Notes _notes; - Tones _tones; + const Config &_config; + Notes _notes; + Tones _tones; std::vector> _creators; - std::vector _chord_progression; - std::vector _beats; - Scale _scale; - uint32_t _tempo, _size; - std::shared_ptr _signature; + std::vector _chord_progression; + std::vector _beats; + Scale _scale; + uint32_t _tempo, _size; + std::shared_ptr _signature; public: - Music(const Config&); - void add_creator(Creator* creator); - const Chord& chord_at(size_t i) const; - ToneSet tones_at(size_t start, size_t size = 1) const; - bool is_beat(uintptr_t i) const; + Music(const Config &); + void add_creator(Creator *creator); + const Chord &chord_at(size_t i) const; + ToneSet tones_at(size_t start, size_t size = 1) const; + bool is_beat(uintptr_t i) const; std::vector beats_inside(uintptr_t min, uintptr_t max) const; - std::string to_short_string() const; - void check() const; + std::string to_short_string() const; + void check() const; - void write_mid(std::ostream&) const; - void write_txt(std::ostream&) const; + void write_mid(std::ostream &) const; + void write_txt(std::ostream &) const; - inline const Config& get_config() const { return _config; } - inline const Notes& notes() const { return _notes; } - inline const Tones& tones() const { return _tones; } - inline const Scale& scale() const { return _scale; } - inline const std::vector chord_progression() const { return _chord_progression; } - inline size_t size() const { return _size; } - inline size_t bars() const { return _size / get_bar_ticks(); } - inline size_t get_bar_ticks() const { return ticks_for(_signature->beat_value) * _signature->beats_per_bar; } - inline NoteValue get_beat_value() const { return _signature->beat_value; } - inline size_t parts() const { return _creators.size(); } - inline const std::vector>& creators() const { return _creators; } - inline size_t tempo() const { return _tempo; } - inline size_t tickTime() const { return 60000 / (_tempo * 32); } - inline size_t duration() const { return (tickTime() * _size) / 1000; } - }; -} + inline const Config &get_config() const + { + return _config; + } + inline const Notes ¬es() const + { + return _notes; + } + inline const Tones &tones() const + { + return _tones; + } + inline const Scale &scale() const + { + return _scale; + } + inline const std::vector chord_progression() const + { + return _chord_progression; + } + inline size_t size() const + { + return _size; + } + inline size_t bars() const + { + return _size / get_bar_ticks(); + } + inline size_t get_bar_ticks() const + { + return ticks_for(_signature->beat_value) * _signature->beats_per_bar; + } + inline NoteValue get_beat_value() const + { + return _signature->beat_value; + } + inline size_t parts() const + { + return _creators.size(); + } + inline const std::vector> &creators() const + { + return _creators; + } + inline size_t tempo() const + { + return _tempo; + } + inline size_t tickTime() const + { + return 60000 / (_tempo * 32); + } + inline size_t duration() const + { + return (tickTime() * _size) / 1000; + } +}; +} // namespace steve diff --git a/libraries/steve/src/Rand.cpp b/libraries/steve/src/Rand.cpp index aa430f2b2..f2c6cff79 100644 --- a/libraries/steve/src/Rand.cpp +++ b/libraries/steve/src/Rand.cpp @@ -4,38 +4,52 @@ using namespace steve; -std::mt19937_64 Rand::generator; +std::mt19937_64 Rand::generator; static std::uniform_real_distribution nf_dist(0.f, 1.f); -static std::normal_distribution nn_dist(0.5f, 0.1f); +static std::normal_distribution nn_dist(0.5f, 0.1f); +static std::uniform_int_distribution vj_dist(-8, 8); -void Rand::reseed(uint64_t newseed) { - generator.seed(newseed); +void Rand::reseed(uint64_t newseed) +{ + generator.seed(newseed); } -float Rand::next_float() { - return nf_dist(generator); +float Rand::next_float() +{ + return nf_dist(generator); } -float Rand::next_normal() { - return std::max(0.f, std::min(1.f, nn_dist(generator))); +float Rand::next_normal() +{ + return std::max(0.f, std::min(1.f, nn_dist(generator))); } -uint32_t Rand::next(uint32_t min, uint32_t max) { - std::uniform_int_distribution dist(min, max); - return dist(generator); +int Rand::next_velocity_jitter() +{ + return vj_dist(generator); } -uint64_t Rand::next(uint64_t min, uint64_t max) { - std::uniform_int_distribution dist(min, max); - return dist(generator); + +uint32_t Rand::next(uint32_t min, uint32_t max) +{ + std::uniform_int_distribution dist(min, max); + return dist(generator); +} +uint64_t Rand::next(uint64_t min, uint64_t max) +{ + std::uniform_int_distribution dist(min, max); + return dist(generator); } -int Rand::next(int min, int max) { - std::uniform_int_distribution dist(min, max); - return dist(generator); +int Rand::next(int min, int max) +{ + std::uniform_int_distribution dist(min, max); + return dist(generator); } -float Rand::next(float min, float max) { - std::uniform_real_distribution dist(min, max); - return dist(generator); +float Rand::next(float min, float max) +{ + std::uniform_real_distribution dist(min, max); + return dist(generator); } -NoteValue Rand::next(NoteValue min, NoteValue max) { - return NoteValue(Rand::next(uint64_t(min), uint64_t(max))); +NoteValue Rand::next(NoteValue min, NoteValue max) +{ + return NoteValue(Rand::next(uint64_t(min), uint64_t(max))); } \ No newline at end of file diff --git a/libraries/steve/src/Rand.h b/libraries/steve/src/Rand.h index 4ac30224b..107fd6e2b 100644 --- a/libraries/steve/src/Rand.h +++ b/libraries/steve/src/Rand.h @@ -5,33 +5,37 @@ #include #include #include + #include "Steve.h" -namespace steve { - class Rand { +namespace steve +{ +class Rand +{ public: static std::mt19937_64 generator; - static float next_float(); - static float next_normal(); + static float next_float(); + static float next_normal(); + static int next_velocity_jitter(); - static uint32_t next(uint32_t min, uint32_t max); // Returns a random unsigned integer between min and max - static uint64_t next(uint64_t min, uint64_t max); // Returns a random unsigned integer between min and max - static int next(int min, int max); // Returns a random integer between min and max - static float next(float min, float max); // Returns a random float between min and max + static uint32_t next(uint32_t min, uint32_t max); // Returns a random unsigned integer between min and max + static uint64_t next(uint64_t min, uint64_t max); // Returns a random unsigned integer between min and max + static int next(int min, int max); // Returns a random integer between min and max + static float next(float min, float max); // Returns a random float between min and max static NoteValue next(NoteValue min, NoteValue max); static void reseed(uint64_t newseed); // Containers - template - static const T& in(const std::set& s) { - auto it(s.begin()); - std::advance(it, next(0ull, (uint64_t)s.size()-1)); - return *it; + template static const T &in(const std::set &s) + { + auto it(s.begin()); + std::advance(it, next(0ull, (uint64_t)s.size() - 1)); + return *it; } - template - inline static const T& in(const std::vector& v) { - return v[(unsigned int)next(0ull, v.size()-1)]; + template inline static const T &in(const std::vector &v) + { + return v[(unsigned int)next(0ull, v.size() - 1)]; } - }; -} +}; +} // namespace steve diff --git a/libraries/steve/src/Scale.cpp b/libraries/steve/src/Scale.cpp index 997107cd1..adbf0e50c 100644 --- a/libraries/steve/src/Scale.cpp +++ b/libraries/steve/src/Scale.cpp @@ -9,28 +9,30 @@ using namespace steve; -void ScaleDescription::compute_chords(const Config& instance) { - // Gather all chords inside scale - chords = instance.get_chords_inside(tones); - - std::sort(chords.begin(), chords.end(), [](const Chord& a, const Chord& b) { - return a.key < b.key; - }); +void ScaleDescription::compute_chords(const Config &instance) +{ + // Gather all chords inside scale + chords = instance.get_chords_inside(tones); + std::sort(chords.begin(), chords.end(), [](const Chord &a, const Chord &b) { return a.key < b.key; }); } -uint8_t Scale::get_degree_for_tone(uint8_t tone) const { - tone = tone % 12; - uint8_t cmp_tone = key; - uint8_t degree = 0; - while(cmp_tone != tone) { - cmp_tone = (cmp_tone + 1) % 12; - if((tones & (1 << cmp_tone)) != 0) { - degree += 1; +uint8_t Scale::get_degree_for_tone(uint8_t tone) const +{ + tone = tone % 12; + uint8_t cmp_tone = key; + uint8_t degree = 0; + while (cmp_tone != tone) + { + cmp_tone = (cmp_tone + 1) % 12; + if ((tones & (1 << cmp_tone)) != 0) + { + degree += 1; + } } - } - return degree; + return degree; } -std::string Scale::get_degree_string_for_chord(const Chord& chord) const { - return steve::degree_name(get_degree_for_tone(chord.key), chord.desc->uppercase) + chord.desc->suffix; +std::string Scale::get_degree_string_for_chord(const Chord &chord) const +{ + return steve::degree_name(get_degree_for_tone(chord.key), chord.desc->uppercase) + chord.desc->suffix; } diff --git a/libraries/steve/src/Scale.h b/libraries/steve/src/Scale.h index a17724f54..6734aaecf 100644 --- a/libraries/steve/src/Scale.h +++ b/libraries/steve/src/Scale.h @@ -7,25 +7,33 @@ #include "ItemDescription.h" #include "Steve.h" -namespace steve { - struct ScaleDescription : public ItemDescription { +namespace steve +{ +struct ScaleDescription : public ItemDescription +{ std::vector chords; - ToneSet tones = 1; + ToneSet tones = 1; - void compute_chords(const class Config&); - }; - struct Scale { + void compute_chords(const class Config &); +}; +struct Scale +{ std::shared_ptr desc; - uint8_t key = 0; - ToneSet tones = 0; + uint8_t key = 0; + ToneSet tones = 0; - inline Scale(const std::shared_ptr& d, uint8_t k) - : desc(d), key(k), tones(tone_set_shift(d->tones, k)) {} + inline Scale(const std::shared_ptr &d, uint8_t k) + : desc(d), key(k), tones(tone_set_shift(d->tones, k)) + { + } - inline std::string full_name() const { return std::string(key_name(key)) + " " + desc->name; } + inline std::string full_name() const + { + return std::string(key_name(key)) + " " + desc->name; + } // Zero-based - uint8_t get_degree_for_tone(uint8_t tone) const; - std::string get_degree_string_for_chord(const Chord& chord) const; - }; -} + uint8_t get_degree_for_tone(uint8_t tone) const; + std::string get_degree_string_for_chord(const Chord &chord) const; +}; +} // namespace steve diff --git a/libraries/steve/src/Steve.cpp b/libraries/steve/src/Steve.cpp index 5126b45bd..5f48d13c9 100644 --- a/libraries/steve/src/Steve.cpp +++ b/libraries/steve/src/Steve.cpp @@ -1,119 +1,155 @@ #include "Steve.h" -#include #include #include +#include #include "Chord.h" +#include "Rand.h" using namespace std; using namespace steve; -const char* steve::key_name(uint8_t key) { - static const char key_names[][3] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; - return key_names[key]; +const char *steve::key_name(uint8_t key) +{ + static const char key_names[][3] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; + return key_names[key]; } -const char* steve::degree_name(uint8_t degree, bool uppercase) { - static const char upper_degrees[][4] = {"I", "II", "III", "IV", "V", "VI", "VII"}; - static const char lower_degrees[][4] = {"i", "ii", "iii", "iv", "v", "vi", "vii"}; - return uppercase ? upper_degrees[degree] : lower_degrees[degree]; +const char *steve::degree_name(uint8_t degree, bool uppercase) +{ + static const char upper_degrees[][4] = {"I", "II", "III", "IV", "V", "VI", "VII"}; + static const char lower_degrees[][4] = {"i", "ii", "iii", "iv", "v", "vi", "vii"}; + return uppercase ? upper_degrees[degree] : lower_degrees[degree]; } -const char* steve::note_value_name(NoteValue v) { - switch(v) { - case NoteValue::sixtyfourth: return "sixtyfourth"; - case NoteValue::thirtysecond: return "thirtysecond"; - case NoteValue::sixteenth: return "sixteenth"; - case NoteValue::eighth: return "eighth"; - case NoteValue::quarter: return "quarter"; - case NoteValue::half: return "half"; - case NoteValue::whole: return "whole"; - } - return "N/A"; +const char *steve::note_value_name(NoteValue v) +{ + switch (v) + { + case NoteValue::sixtyfourth: + return "sixtyfourth"; + case NoteValue::thirtysecond: + return "thirtysecond"; + case NoteValue::sixteenth: + return "sixteenth"; + case NoteValue::eighth: + return "eighth"; + case NoteValue::quarter: + return "quarter"; + case NoteValue::half: + return "half"; + case NoteValue::whole: + return "whole"; + } + return "N/A"; } static char note_names[128 * 5]; -void steve::note_name_init() { - // Start at C-1 - // Worst case: C#-1\0 (5 bytes) - for(uint8_t note(0); note < 128; note++) { - sprintf(note_names + note * 5, "%s%d", key_name(note % 12), (note / 12) - 1); - } +void steve::note_name_init() +{ + // Start at C-1 + // Worst case: C#-1\0 (5 bytes) + for (uint8_t note(0); note < 128; note++) + { + sprintf(note_names + note * 5, "%s%d", key_name(note % 12), (note / 12) - 1); + } } -const char* steve::note_name(uint8_t note) { - return note_names + note * 5; +const char *steve::note_name(uint8_t note) +{ + return note_names + note * 5; } -uint8_t steve::get_note_with_name(const char* name) { - for(uintptr_t note = 0; note < 128; note++) { - if(!strcmp(note_names + note * 5, name)) { - return uint8_t(note); +uint8_t steve::get_note_with_name(const char *name) +{ + for (uintptr_t note = 0; note < 128; note++) + { + if (!strcmp(note_names + note * 5, name)) + { + return uint8_t(note); + } } - } - return 0; + return 0; } -ToneSet steve::tone_set_shift(const ToneSet& tones, int shifting) { - assert(shifting >= 0 && shifting < 12); - return ((tones << shifting) | (tones >> (12 - shifting))) & 0xfff; +ToneSet steve::tone_set_shift(const ToneSet &tones, int shifting) +{ + assert(shifting >= 0 && shifting < 12); + return ((tones << shifting) | (tones >> (12 - shifting))) & 0xfff; } -bool steve::tone_set_within(const ToneSet& scale, const ToneSet& chord) { - return (scale | chord) == scale; +bool steve::tone_set_within(const ToneSet &scale, const ToneSet &chord) +{ + return (scale | chord) == scale; } -uint32_t steve::tone_set_count(ToneSet tones) { - uint32_t count = 0; - while(tones) { - count += tones & 1; - tones >>= 1; - } - return count; +uint32_t steve::tone_set_count(ToneSet tones) +{ + uint32_t count = 0; + while (tones) + { + count += tones & 1; + tones >>= 1; + } + return count; } -const char* steve::tone_set_binary(ToneSet tone_set) { - static char str[13] = {}; - for(uint32_t tone(0); tone<12; tone++) { - str[tone] = (tone_set & (1< #include -namespace steve { - struct Note { +namespace steve +{ +struct Note +{ uint8_t channel, tone, velocity, duration; - }; - enum class NoteValue { +}; +enum class NoteValue +{ sixtyfourth, thirtysecond, sixteenth, @@ -18,8 +21,9 @@ namespace steve { quarter, half, whole, - }; - enum class Interval { +}; +enum class Interval +{ perfectunison = 0, minorsecond, majorsecond, @@ -32,34 +36,40 @@ namespace steve { minorseventh, majorseventh, perfectoctave, - }; - typedef std::multimap Notes; - typedef uint16_t ToneSet; - typedef uint64_t NoteSet; - typedef std::vector Tones; - struct Phrase { - Notes notes; - Tones tones; +}; +typedef std::multimap Notes; +typedef uint16_t ToneSet; +typedef uint64_t NoteSet; +typedef std::vector Tones; +struct Phrase +{ + Notes notes; + Tones tones; size_t size; - }; - inline uint32_t ticks_for(NoteValue v) { return 2 << uint32_t(v); } - const char* key_name(uint8_t); - const char* degree_name(uint8_t, bool uppercase); // Zero-based - const char* note_value_name(NoteValue); - void note_name_init(); - const char* note_name(uint8_t); - uint8_t get_note_with_name(const char*); - ToneSet tone_set_shift(const ToneSet& scale, int shifting); - bool tone_set_within(const ToneSet& scale, const ToneSet& chord); - uint32_t tone_set_count(ToneSet); - const char* tone_set_binary(ToneSet); - void add_note(Notes&, uint8_t channel, uint8_t tone, size_t start, size_t length, uint8_t velocity = 127); +}; +inline uint32_t ticks_for(NoteValue v) +{ + return 2 << uint32_t(v); +} +const char *key_name(uint8_t); +const char *degree_name(uint8_t, bool uppercase); // Zero-based +const char *note_value_name(NoteValue); +void note_name_init(); +const char *note_name(uint8_t); +uint8_t get_note_with_name(const char *); +ToneSet tone_set_shift(const ToneSet &scale, int shifting); +bool tone_set_within(const ToneSet &scale, const ToneSet &chord); +uint32_t tone_set_count(ToneSet); +const char *tone_set_binary(ToneSet); +void add_note(Notes &, uint8_t channel, uint8_t tone, size_t start, size_t length, uint8_t velocity = 127); - Tones octave_tones(const Notes&); - void paste(const Notes&, Notes&, size_t start = 0); - Notes copy(const Notes&, size_t start = 0, size_t size = -1); - bool harmony(const ToneSet* base, const ToneSet* piece, size_t size); +Tones octave_tones(const Notes &); +void paste(const Notes &, Notes &, size_t start = 0); +Notes copy(const Notes &, size_t start = 0, size_t size = -1); +bool harmony(const ToneSet *base, const ToneSet *piece, size_t size); - template - inline T clamp(T v, T min, T max) { return std::max(min, std::min(max, v)); } +template inline T clamp(T v, T min, T max) +{ + return std::max(min, std::min(max, v)); } +} // namespace steve diff --git a/libraries/steve/src/TimeSignature.h b/libraries/steve/src/TimeSignature.h index 7c2ae5026..2c6bfdbc4 100644 --- a/libraries/steve/src/TimeSignature.h +++ b/libraries/steve/src/TimeSignature.h @@ -3,9 +3,11 @@ #include "ItemDescription.h" #include "Steve.h" -namespace steve { - struct TimeSignature : public ItemDescription { - uint32_t beats_per_bar = 4; - NoteValue beat_value = NoteValue::quarter; - }; -} +namespace steve +{ +struct TimeSignature : public ItemDescription +{ + uint32_t beats_per_bar = 4; + NoteValue beat_value = NoteValue::quarter; +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Arpeggio.cpp b/libraries/steve/src/creator/Arpeggio.cpp index 3ff413f23..d2e642246 100644 --- a/libraries/steve/src/creator/Arpeggio.cpp +++ b/libraries/steve/src/creator/Arpeggio.cpp @@ -5,27 +5,32 @@ using namespace steve; -Arpeggio::Arpeggio(Music* music) - : ChordBasedCreator(music) {} -void Arpeggio::init() { - ChordBasedCreator::init(); - _min_time = NoteValue::sixteenth; - _max_time = NoteValue::quarter; +Arpeggio::Arpeggio(Music *music) : ChordBasedCreator(music) +{ } -Notes Arpeggio::get(size_t start, size_t size) const { - Notes notes; - auto times = generate_times(start, _music->get_bar_ticks()); - uintptr_t i = 0; - while(i < size) { - const uint8_t base_tone = _min_tone + 12 - (_min_tone % 12); - for(uintptr_t j = 0; j < times.size() - 1; j++) { - const Chord& chord = _music->chord_at(start + i); - const auto chord_tone_count = chord.desc->get_tone_count(); - const auto duration = times[j + 1] - times[j]; - const uint8_t tone = base_tone + chord.key + chord.desc->get_tone(j % chord_tone_count); - add_note(notes, _channel, tone, i, duration); - i += duration; +void Arpeggio::init() +{ + ChordBasedCreator::init(); + _min_time = NoteValue::sixteenth; + _max_time = NoteValue::quarter; +} +Notes Arpeggio::get(size_t start, size_t size) const +{ + Notes notes; + auto times = generate_times(start, _music->get_bar_ticks()); + uintptr_t i = 0; + while (i < size) + { + const uint8_t base_tone = _min_tone + 12 - (_min_tone % 12); + for (uintptr_t j = 0; j < times.size() - 1; j++) + { + const Chord &chord = _music->chord_at(start + i); + const auto chord_tone_count = chord.desc->get_tone_count(); + const auto duration = times[j + 1] - times[j]; + const uint8_t tone = base_tone + chord.key + chord.desc->get_tone(j % chord_tone_count); + add_note(notes, _channel, tone, i, duration); + i += duration; + } } - } - return notes; + return notes; } diff --git a/libraries/steve/src/creator/Arpeggio.h b/libraries/steve/src/creator/Arpeggio.h index 53c07e3f7..d4d77b8e4 100644 --- a/libraries/steve/src/creator/Arpeggio.h +++ b/libraries/steve/src/creator/Arpeggio.h @@ -2,12 +2,17 @@ #include "ChordBasedCreator.h" -namespace steve { - class Arpeggio : public ChordBasedCreator { +namespace steve +{ +class Arpeggio : public ChordBasedCreator +{ public: - Arpeggio(Music*); - virtual void init() override; - virtual Notes get(size_t start, size_t size) const override; - virtual const char* name() const override { return "Arpeggio"; } - }; -} + Arpeggio(Music *); + virtual void init() override; + virtual Notes get(size_t start, size_t size) const override; + virtual const char *name() const override + { + return "Arpeggio"; + } +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Bass.cpp b/libraries/steve/src/creator/Bass.cpp index eb087d97a..4f2459b45 100644 --- a/libraries/steve/src/creator/Bass.cpp +++ b/libraries/steve/src/creator/Bass.cpp @@ -4,28 +4,35 @@ using namespace steve; -Bass::Bass(Music* music) : Creator(music) {} -void Bass::init() { - Creator::init(); +Bass::Bass(Music *music) : Creator(music) +{ +} +void Bass::init() +{ + Creator::init(); - _min_tone = 36; - _max_tone = _min_tone + 12; + _min_tone = 36; + _max_tone = _min_tone + 12; } -Notes Bass::get(size_t start, size_t size) const { - Notes notes; - auto times = generate_times(start, _music->get_bar_ticks()); - uintptr_t i = 0; - while(i < size) { - for(uintptr_t j = 0; j < times.size() - 1; j++) { - const auto duration = times[j + 1] - times[j]; - const Chord& chord = _music->chord_at(start + i); - const uint8_t tone = _min_tone + chord.key; - add_note(notes, _channel, tone, i, duration); - i += duration; +Notes Bass::get(size_t start, size_t size) const +{ + Notes notes; + auto times = generate_times(start, _music->get_bar_ticks()); + uintptr_t i = 0; + while (i < size) + { + for (uintptr_t j = 0; j < times.size() - 1; j++) + { + const auto duration = times[j + 1] - times[j]; + const Chord &chord = _music->chord_at(start + i); + const uint8_t tone = _min_tone + chord.key; + add_note(notes, _channel, tone, i, duration); + i += duration; + } } - } - return notes; + return notes; } -bool Bass::is_valid_instrument(const Instrument& instrument) const { - return instrument.min_tone <= 36 && instrument.max_tone >= 48; +bool Bass::is_valid_instrument(const Instrument &instrument) const +{ + return instrument.midi_id >= 33 && instrument.midi_id <= 40; } diff --git a/libraries/steve/src/creator/Bass.h b/libraries/steve/src/creator/Bass.h index 2e73df8b1..f4848fe9d 100644 --- a/libraries/steve/src/creator/Bass.h +++ b/libraries/steve/src/creator/Bass.h @@ -2,13 +2,18 @@ #include "Creator.h" -namespace steve { - class Bass : public Creator { +namespace steve +{ +class Bass : public Creator +{ public: - Bass(Music*); - virtual void init() override; - virtual Notes get(size_t start, size_t size) const override; - virtual const char* name() const override { return "Bass"; } - virtual bool is_valid_instrument(const Instrument& instrument) const override; - }; -} + Bass(Music *); + virtual void init() override; + virtual Notes get(size_t start, size_t size) const override; + virtual const char *name() const override + { + return "Bass"; + } + virtual bool is_valid_instrument(const Instrument &instrument) const override; +}; +} // namespace steve diff --git a/libraries/steve/src/creator/ChordBasedCreator.cpp b/libraries/steve/src/creator/ChordBasedCreator.cpp index 03b2221d7..775774fb1 100644 --- a/libraries/steve/src/creator/ChordBasedCreator.cpp +++ b/libraries/steve/src/creator/ChordBasedCreator.cpp @@ -5,22 +5,28 @@ using namespace steve; -ChordBasedCreator::ChordBasedCreator(Music* music) : Creator(music) {} -void ChordBasedCreator::init() { - Creator::init(); - _min_time = Rand::next(NoteValue::quarter, NoteValue::whole); - _max_time = Rand::next(_min_time, NoteValue::whole); +ChordBasedCreator::ChordBasedCreator(Music *music) : Creator(music) +{ } -std::vector ChordBasedCreator::chord_for(uintptr_t start, size_t size) const { - const ToneSet chord(_music->tones_at(start, size)); - const uint8_t octave(Rand::next(_min_tone / 12, _max_tone / 12) * 12); +void ChordBasedCreator::init() +{ + Creator::init(); + _min_time = Rand::next(NoteValue::quarter, NoteValue::whole); + _max_time = Rand::next(_min_time, NoteValue::whole); +} +std::vector ChordBasedCreator::chord_for(uintptr_t start, size_t size) const +{ + const ToneSet chord(_music->tones_at(start, size)); + const uint8_t octave(Rand::next(_min_tone / 12, _max_tone / 12) * 12); - // Get chord tones in a vector - std::vector tones; - for(uint8_t t(0); t < 12; t++) { - if(chord & 1 << t) { - tones.push_back(t + octave); + // Get chord tones in a vector + std::vector tones; + for (uint8_t t(0); t < 12; t++) + { + if (chord & 1 << t) + { + tones.push_back(t + octave); + } } - } - return tones; + return tones; } \ No newline at end of file diff --git a/libraries/steve/src/creator/ChordBasedCreator.h b/libraries/steve/src/creator/ChordBasedCreator.h index 31d91d36f..cf0b4b780 100644 --- a/libraries/steve/src/creator/ChordBasedCreator.h +++ b/libraries/steve/src/creator/ChordBasedCreator.h @@ -2,11 +2,13 @@ #include "Creator.h" -namespace steve { - class ChordBasedCreator : public Creator { +namespace steve +{ +class ChordBasedCreator : public Creator +{ protected: - ChordBasedCreator(Music* music); - virtual void init() override; + ChordBasedCreator(Music *music); + virtual void init() override; virtual std::vector chord_for(uintptr_t start, size_t size) const; - }; -} +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Chords.cpp b/libraries/steve/src/creator/Chords.cpp index 0cca4b3c6..70ec1992c 100644 --- a/libraries/steve/src/creator/Chords.cpp +++ b/libraries/steve/src/creator/Chords.cpp @@ -5,32 +5,40 @@ using namespace steve; -Chords::Chords(Music* music) - : ChordBasedCreator(music) {} -Notes Chords::get(size_t start, size_t size) const { - Notes notes; - auto times = generate_times(start, _music->get_bar_ticks()); - uintptr_t i = 0; - while(i < size) { - for(uintptr_t j = 0; j < times.size() - 1; j++) { - const auto duration = times[j + 1] - times[j]; - const Chord& chord = _music->chord_at(start + i); - uint8_t voice_count = 0; - for(uint8_t tone = _min_tone; tone < _max_tone && voice_count < _instrument->voices; tone++) { - if(voice_count == 0 && (tone % 12) != chord.key) { - //continue; // Lowest tone need to be key - } - if(((1 << (tone % 12)) & chord.tones) != 0) { - add_note(notes, _channel, tone, i, duration); - voice_count++; +Chords::Chords(Music *music) : ChordBasedCreator(music) +{ +} +Notes Chords::get(size_t start, size_t size) const +{ + Notes notes; + auto times = generate_times(start, _music->get_bar_ticks()); + uintptr_t i = 0; + while (i < size) + { + for (uintptr_t j = 0; j < times.size() - 1; j++) + { + const auto duration = times[j + 1] - times[j]; + const Chord &chord = _music->chord_at(start + i); + uint8_t voice_count = 0; + for (uint8_t tone = _min_tone; tone < _max_tone && voice_count < _instrument->voices; tone++) + { + if (voice_count == 0 && (tone % 12) != chord.key) + { + // continue; // Lowest tone need to be key + } + if (((1 << (tone % 12)) & chord.tones) != 0) + { + add_note(notes, _channel, tone, i, duration); + voice_count++; + } + } + i += duration; } - } - i += duration; } - } - return notes; + return notes; } -bool Chords::is_valid_instrument(const Instrument& instrument) const { - return instrument.voices >= 3; +bool Chords::is_valid_instrument(const Instrument &instrument) const +{ + return instrument.voices >= 3; } \ No newline at end of file diff --git a/libraries/steve/src/creator/Chords.h b/libraries/steve/src/creator/Chords.h index a7e6d1912..2d01b9d18 100644 --- a/libraries/steve/src/creator/Chords.h +++ b/libraries/steve/src/creator/Chords.h @@ -2,12 +2,17 @@ #include "ChordBasedCreator.h" -namespace steve { - class Chords : public ChordBasedCreator { +namespace steve +{ +class Chords : public ChordBasedCreator +{ public: - Chords(Music*); - Notes get(size_t start, size_t size) const override; - const char* name() const override { return "Chords"; } - bool is_valid_instrument(const struct Instrument& instrument) const override; - }; -} + Chords(Music *); + Notes get(size_t start, size_t size) const override; + const char *name() const override + { + return "Chords"; + } + bool is_valid_instrument(const struct Instrument &instrument) const override; +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Creator.cpp b/libraries/steve/src/creator/Creator.cpp index 68c123825..6b4bb80d9 100644 --- a/libraries/steve/src/creator/Creator.cpp +++ b/libraries/steve/src/creator/Creator.cpp @@ -3,182 +3,206 @@ #include #include #include + #include "../Config.h" #include "../Music.h" #include "../Rand.h" using namespace steve; -Creator::Creator(Music* music) { - _music = music; - _channel = music->creators().size(); -} -void Creator::init() { - _phrase_size = 4 * _music->get_bar_ticks(); - - _instrument = _music->get_config().get_instruments().get_random_item( - [this](std::shared_ptr candidate) { - return is_valid_instrument(*candidate); - }); - const uint8_t ambitus_half_range(Rand::next(6, 10)); - const uint8_t instrument_range(_instrument->max_tone - _instrument->min_tone); - - { - const uint8_t mid_tone(_instrument->min_tone + ambitus_half_range + Rand::next_normal()*float(instrument_range - ambitus_half_range * 2)); - _min_tone = std::max(mid_tone - ambitus_half_range, _instrument->min_tone); - _max_tone = std::min(mid_tone + ambitus_half_range, _instrument->max_tone); - assert(_max_tone - _min_tone >= 12); - } - - _min_time = Rand::next(NoteValue::sixteenth, NoteValue::quarter); - _max_time = Rand::next(std::max(_min_time, NoteValue::quarter), NoteValue::whole); - _repetition = Rand::next_float() * 0.5f; +Creator::Creator(Music *music) +{ + _music = music; + _channel = music->creators().size(); } -void Creator::post_init() { - { // Make sure we can make notes the size of the beat - // Otherwise we may not be able to complete a bar - if(_min_time > _music->get_beat_value()) { - _min_time = _music->get_beat_value(); +void Creator::init() +{ + _phrase_size = 4 * _music->get_bar_ticks(); + + _instrument = _music->get_config().get_instruments().get_random_item( + [this](std::shared_ptr candidate) { return is_valid_instrument(*candidate); }); + const uint8_t ambitus_half_range(Rand::next(6, 10)); + const uint8_t instrument_range(_instrument->max_tone - _instrument->min_tone); + + { + const uint8_t mid_tone(_instrument->min_tone + ambitus_half_range + + Rand::next_normal() * float(instrument_range - ambitus_half_range * 2)); + _min_tone = std::max(mid_tone - ambitus_half_range, _instrument->min_tone); + _max_tone = std::min(mid_tone + ambitus_half_range, _instrument->max_tone); + assert(_max_tone - _min_tone >= 12); } - if(_max_time < _music->get_beat_value()) { - _max_time = _music->get_beat_value(); + + _min_time = Rand::next(NoteValue::sixteenth, NoteValue::quarter); + _max_time = Rand::next(std::max(_min_time, NoteValue::quarter), NoteValue::whole); + _repetition = Rand::next_float() * 0.5f; +} +void Creator::post_init() +{ + { // Make sure we can make notes the size of the beat + // Otherwise we may not be able to complete a bar + if (_min_time > _music->get_beat_value()) + { + _min_time = _music->get_beat_value(); + } + if (_max_time < _music->get_beat_value()) + { + _max_time = _music->get_beat_value(); + } } - } } -Notes Creator::compose() { - uint32_t i(0); - Notes notes; - while(i < _music->size()) { - bool new_phrase_needed(true); // If it isn't changed it means no fitting phrase was found - for(uintptr_t phrase_index(0); phrase_index < _phrases.size(); phrase_index++) { // Iterate through figures already created - const Phrase& phrase(_phrases[phrase_index]); - if(i%phrase.size == 0 // Its size is good for the place it would be in - && i + phrase.size <= _music->size() // The phrase isn't too long - && Rand::next_float() < _repetition // Add some randomness - && harmony(_music->tones().data() + i, phrase.tones.data(), phrase.tones.size())) { // It's in harmony with the current music - paste(phrase.notes, notes, i); // Paste the phrase on the music - _phrase_list.push_back(phrase_index); // Register that we used this phrase - i += phrase.size; // Go forth - new_phrase_needed = false; // Specify that the program doesn't need to create a new phrase - break; - } - } - if(new_phrase_needed) { // Needs to create a new phrase of music - Phrase phrase; - phrase.size = _phrase_size; - while(i%phrase.size != 0 || i + phrase.size > _music->size()) // Good size and not too long - phrase.size /= 2; - phrase.notes = get(i, phrase.size); // Create the phrase - phrase.tones = octave_tones(phrase.notes); - _phrase_list.push_back(_phrases.size()); // Register that we used this phrase - _phrases.push_back(phrase); // Add it to the collection of phrases - paste(phrase.notes, notes, i); // Paste it on the music - i += phrase.size; // Go forth +Notes Creator::compose() +{ + uint32_t i(0); + Notes notes; + while (i < _music->size()) + { + bool new_phrase_needed(true); // If it isn't changed it means no fitting phrase was found + for (uintptr_t phrase_index(0); phrase_index < _phrases.size(); phrase_index++) + { // Iterate through figures already created + const Phrase &phrase(_phrases[phrase_index]); + if (i % phrase.size == 0 // Its size is good for the place it would be in + && i + phrase.size <= _music->size() // The phrase isn't too long + && Rand::next_float() < _repetition // Add some randomness + && harmony(_music->tones().data() + i, phrase.tones.data(), phrase.tones.size())) + { // It's in harmony with the current music + paste(phrase.notes, notes, i); // Paste the phrase on the music + _phrase_list.push_back(phrase_index); // Register that we used this phrase + i += phrase.size; // Go forth + new_phrase_needed = false; // Specify that the program doesn't need to create a new phrase + break; + } + } + if (new_phrase_needed) + { // Needs to create a new phrase of music + Phrase phrase; + phrase.size = _phrase_size; + while (i % phrase.size != 0 || i + phrase.size > _music->size()) // Good size and not too long + phrase.size /= 2; + phrase.notes = get(i, phrase.size); // Create the phrase + phrase.tones = octave_tones(phrase.notes); + _phrase_list.push_back(_phrases.size()); // Register that we used this phrase + _phrases.push_back(phrase); // Add it to the collection of phrases + paste(phrase.notes, notes, i); // Paste it on the music + i += phrase.size; // Go forth + } } - } - return notes; + return notes; } -bool Creator::is_valid_instrument(const Instrument&) const { - return true; +bool Creator::is_valid_instrument(const Instrument &) const +{ + return true; } -void Creator::write_txt(std::ostream& s) const { - s << "\t" << name() << " (" << _instrument->name << ")" << std::endl - << "\t\t[" << note_value_name(_min_time) << ":" << note_value_name(_max_time) << "]" << std::endl - << "\t\t[" << note_name(_min_tone) << ":" << note_name(_max_tone) << "]" << std::endl - << "\t\tRepetition factor: " << _repetition << std::endl; - - { - s << "\t\tPhrases:"; - for(uintptr_t phrase_index : _phrase_list) { - s << " "; - if(phrase_index < 10) { - s << phrase_index; - } else { - s << char('a' + phrase_index - 10); - } - const Phrase& phrase(_phrases[phrase_index]); - const uint32_t bar_count(phrase.size / _music->get_bar_ticks()); - for(uint32_t i(1); i < bar_count; i++) { - s << " -"; - } +void Creator::write_txt(std::ostream &s) const +{ + s << "\t" << name() << " (" << _instrument->name << ")" << std::endl + << "\t\t[" << note_value_name(_min_time) << ":" << note_value_name(_max_time) << "]" << std::endl + << "\t\t[" << note_name(_min_tone) << ":" << note_name(_max_tone) << "]" << std::endl + << "\t\tRepetition factor: " << _repetition << std::endl; + + { + s << "\t\tPhrases:"; + for (uintptr_t phrase_index : _phrase_list) + { + s << " "; + if (phrase_index < 10) + { + s << phrase_index; + } + else + { + s << char('a' + phrase_index - 10); + } + const Phrase &phrase(_phrases[phrase_index]); + const uint32_t bar_count(phrase.size / _music->get_bar_ticks()); + for (uint32_t i(1); i < bar_count; i++) + { + s << " -"; + } + } + s << std::endl; } - s << std::endl; - } } -uintptr_t Creator::time(uintptr_t i, size_t size) const { - std::vector candidates = _music->beats_inside( - i + ticks_for(_min_time), - i + std::min(ticks_for(_max_time), size)); - assert(!candidates.empty()); - - // Transform from position to duration - for(uintptr_t& candidate : candidates) { - candidate -= i; - } - - const auto min_ticks = ticks_for(_min_time); - const auto max_ticks = ticks_for(_max_time); - const auto score = [this, i, min_ticks, max_ticks](uintptr_t c) -> uintptr_t { - if(c < min_ticks || c > max_ticks) { - return 0; +uintptr_t Creator::time(uintptr_t i, size_t size) const +{ + std::vector candidates = + _music->beats_inside(i + ticks_for(_min_time), i + std::min(ticks_for(_max_time), size)); + assert(!candidates.empty()); + + // Transform from position to duration + for (uintptr_t &candidate : candidates) + { + candidate -= i; } - if((c / min_ticks) * min_ticks != c) { - return 0; + const auto min_ticks = ticks_for(_min_time); + const auto max_ticks = ticks_for(_max_time); + const auto score = [this, i, min_ticks, max_ticks](uintptr_t c) -> uintptr_t { + if (c < min_ticks || c > max_ticks) + { + return 0; + } + + if ((c / min_ticks) * min_ticks != c) + { + return 0; + } + + if (_music->tones_at(i, c) == 0) + { + return 0; + } + + uintptr_t score = UINTPTR_MAX; + for (uintptr_t i = 0; i < sizeof(uintptr_t) * 8; i++) + { + // Low set bits reduce score greatly + // High set bits reduce score slightly + if (((1ull << i) & c) != 0) + { + score -= 1ull << (sizeof(uintptr_t) * 8 - i - 1); + } + } + return score; + }; + + // Remove unwanted candidates + auto previous_candidates = candidates; + candidates.erase( + std::remove_if(candidates.begin(), candidates.end(), [score](uintptr_t c) { return score(c) == 0; }), + candidates.end()); + if (candidates.empty()) + { + return 0; } - if(_music->tones_at(i, c) == 0) { - return 0; - } + // Sort by increasing awkwardness + std::sort(candidates.begin(), candidates.end(), [score](uintptr_t a, uintptr_t b) { return score(a) > score(b); }); - uintptr_t score = UINTPTR_MAX; - for(uintptr_t i = 0; i < sizeof(uintptr_t) * 8; i++) { - // Low set bits reduce score greatly - // High set bits reduce score slightly - if(((1ull << i) & c) != 0) { - score -= 1ull << (sizeof(uintptr_t) * 8 - i - 1); - } - } - return score; - }; - - // Remove unwanted candidates - auto previous_candidates = candidates; - candidates.erase(std::remove_if(candidates.begin(), candidates.end(), - [score](uintptr_t c) { - return score(c) == 0; - }), candidates.end()); - if(candidates.empty()) { - return 0; - } - - // Sort by increasing awkwardness - std::sort(candidates.begin(), candidates.end(), - [score](uintptr_t a, uintptr_t b) { - return score(a) > score(b); - }); - - std::exponential_distribution dist(0.5f); - const uintptr_t index = std::max(0, std::min(candidates.size() - 1, dist(Rand::generator))); - - const size_t ticks = candidates[index]; - assert(ticks <= size); - return ticks; + std::exponential_distribution dist(0.5f); + const uintptr_t index = std::max(0, std::min(candidates.size() - 1, dist(Rand::generator))); + + const size_t ticks = candidates[index]; + assert(ticks <= size); + return ticks; } -std::vector Creator::generate_times(uintptr_t start, size_t size) const { - std::vector times; - do { - uintptr_t i = 0; - times = {i}; - while(i < size) { - const uintptr_t d = time(start + i, size - i); - if(d == 0) { - break; - } - i += d; - times.push_back(i); - } - } while(times.back() != size); - return times; +std::vector Creator::generate_times(uintptr_t start, size_t size) const +{ + std::vector times; + do + { + uintptr_t i = 0; + times = {i}; + while (i < size) + { + const uintptr_t d = time(start + i, size - i); + if (d == 0) + { + break; + } + i += d; + times.push_back(i); + } + } while (times.back() != size); + return times; } \ No newline at end of file diff --git a/libraries/steve/src/creator/Creator.h b/libraries/steve/src/creator/Creator.h index bd4b54df9..4abf4236c 100644 --- a/libraries/steve/src/creator/Creator.h +++ b/libraries/steve/src/creator/Creator.h @@ -6,38 +6,46 @@ #include "../ItemDescription.h" #include "../Steve.h" -namespace steve { - struct CreatorDescription : public ItemDescription { - std::function func; - uint32_t min_count = 0, max_count = 1; - }; +namespace steve +{ +struct CreatorDescription : public ItemDescription +{ + std::function func; + uint32_t min_count = 0, max_count = 1; +}; - class Creator { +class Creator +{ protected: - class Music* _music; + class Music *_music; std::shared_ptr _instrument; - std::vector _phrases; - std::vector _phrase_list; - size_t _phrase_size; - NoteValue _min_time, _max_time; - uint8_t _min_tone, _max_tone; - float _repetition; - uint8_t _channel; + std::vector _phrases; + std::vector _phrase_list; + size_t _phrase_size; + NoteValue _min_time, _max_time; + uint8_t _min_tone, _max_tone; + float _repetition; + uint8_t _channel; public: - Creator(class Music*); - virtual ~Creator() {} - virtual void init(); - virtual void post_init(); - virtual Notes compose(); - virtual Notes get(size_t start, size_t size) const = 0; - virtual const char* name() const = 0; - virtual bool is_valid_instrument(const Instrument& instrument) const; - virtual void write_txt(std::ostream&) const; + Creator(class Music *); + virtual ~Creator() + { + } + virtual void init(); + virtual void post_init(); + virtual Notes compose(); + virtual Notes get(size_t start, size_t size) const = 0; + virtual const char *name() const = 0; + virtual bool is_valid_instrument(const Instrument &instrument) const; + virtual void write_txt(std::ostream &) const; - inline std::shared_ptr instrument() const { return _instrument; } + inline std::shared_ptr instrument() const + { + return _instrument; + } - uintptr_t time(uintptr_t i, size_t size) const; + uintptr_t time(uintptr_t i, size_t size) const; std::vector generate_times(uintptr_t i, size_t size) const; - }; -} +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Drums.cpp b/libraries/steve/src/creator/Drums.cpp index bb7dd8a19..25c74ce8a 100644 --- a/libraries/steve/src/creator/Drums.cpp +++ b/libraries/steve/src/creator/Drums.cpp @@ -5,39 +5,48 @@ using namespace steve; -Drums::Drums(Music* music) : Creator(music) {} -void Drums::init() { - Creator::init(); - _channel = 9; - _repetition = 1; +Drums::Drums(Music *music) : Creator(music) +{ } -Notes Drums::get(size_t, size_t size) const { - Notes notes; - - const auto bar_ticks = _music->get_bar_ticks(); - NoteValue max_period = NoteValue::whole; - while(((bar_ticks / ticks_for(max_period)) * ticks_for(max_period)) != bar_ticks) { - // We use only periods that can divide the bar to avoid weird things - // it would be better to actually have an idea of how drums should sound - // (this was introduced because of time signatures) - max_period = NoteValue(uint32_t(max_period) - 1); - } +void Drums::init() +{ + Creator::init(); + _channel = 9; + _repetition = 1; +} +Notes Drums::get(size_t, size_t size) const +{ + Notes notes; - uint32_t layers(Rand::next(2, 5)); - for(uint32_t i(0); i < layers; i++) { - uint8_t tone(Rand::next(35, 59)); - NoteValue period_value = Rand::next(NoteValue::eighth, max_period); - uintptr_t period = ticks_for(period_value); - uintptr_t offset = ticks_for(Rand::next(NoteValue::eighth, period_value)); - if(i == 0 || Rand::next(0, 3) > 0) { - offset = 0; + const auto bar_ticks = _music->get_bar_ticks(); + NoteValue max_period = NoteValue::whole; + while (((bar_ticks / ticks_for(max_period)) * ticks_for(max_period)) != bar_ticks) + { + // We use only periods that can divide the bar to avoid weird things + // it would be better to actually have an idea of how drums should sound + // (this was introduced because of time signatures) + max_period = NoteValue(uint32_t(max_period) - 1); } - for(uintptr_t j(offset); j < size; j += period) { - if(_music->is_beat(j)) { - add_note(notes, _channel, tone, j, 1, 100); - } + uint32_t layers(Rand::next(2, 5)); + for (uint32_t i(0); i < layers; i++) + { + uint8_t tone(Rand::next(35, 59)); + NoteValue period_value = Rand::next(NoteValue::eighth, max_period); + uintptr_t period = ticks_for(period_value); + uintptr_t offset = ticks_for(Rand::next(NoteValue::eighth, period_value)); + if (i == 0 || Rand::next(0, 3) > 0) + { + offset = 0; + } + + for (uintptr_t j(offset); j < size; j += period) + { + if (_music->is_beat(j)) + { + add_note(notes, _channel, tone, j, 1, 100); + } + } } - } - return notes; + return notes; } diff --git a/libraries/steve/src/creator/Drums.h b/libraries/steve/src/creator/Drums.h index aec473c58..946fd659f 100644 --- a/libraries/steve/src/creator/Drums.h +++ b/libraries/steve/src/creator/Drums.h @@ -2,12 +2,17 @@ #include "Creator.h" -namespace steve { - class Drums : public Creator { +namespace steve +{ +class Drums : public Creator +{ public: - Drums(Music* music); - virtual void init() override; - virtual Notes get(size_t start, size_t size) const override; - virtual const char* name() const override { return "Drums"; } - }; -} + Drums(Music *music); + virtual void init() override; + virtual Notes get(size_t start, size_t size) const override; + virtual const char *name() const override + { + return "Drums"; + } +}; +} // namespace steve diff --git a/libraries/steve/src/creator/Melody.cpp b/libraries/steve/src/creator/Melody.cpp index b957e380a..43addec5e 100644 --- a/libraries/steve/src/creator/Melody.cpp +++ b/libraries/steve/src/creator/Melody.cpp @@ -5,29 +5,38 @@ using namespace steve; -Melody::Melody(Music* music) : Creator(music) {} -Notes Melody::get(size_t start, size_t size) const { - Notes notes; - auto times = generate_times(start, size); - for(uintptr_t i = 0; i < times.size() - 1; i++) { - const auto time = times[i]; - const auto duration = times[i + 1] - time; - const auto tones = choose_note_from_chord(_music->tones_at(start + time, duration)); - const auto tone = Rand::in(tones); - add_note(notes, _channel, tone, time, duration); - } - return notes; +Melody::Melody(Music *music) : Creator(music) +{ } -std::set Melody::choose_note_from_chord(const ToneSet& tones) const { - std::set notes_in_ambitus; - for(uint8_t tone(0); tone < 12; tone++) { - if(tones & (1 << tone)) { - for(uint8_t t(tone); t <= _max_tone; t += 12) { - if(t >= _min_tone) { - notes_in_ambitus.insert(t); +Notes Melody::get(size_t start, size_t size) const +{ + Notes notes; + auto times = generate_times(start, size); + for (uintptr_t i = 0; i < times.size() - 1; i++) + { + const auto time = times[i]; + const auto duration = times[i + 1] - time; + const auto tones = choose_note_from_chord(_music->tones_at(start + time, duration)); + const auto tone = Rand::in(tones); + add_note(notes, _channel, tone, time, duration); + } + return notes; +} +std::set Melody::choose_note_from_chord(const ToneSet &tones) const +{ + std::set notes_in_ambitus; + for (uint8_t tone(0); tone < 12; tone++) + { + if (tones & (1 << tone)) + { + for (uint8_t t(tone); t <= _max_tone; t += 12) + { + if (t >= _min_tone) + { + notes_in_ambitus.insert(t); + } + } } - } } - } - return notes_in_ambitus; + return notes_in_ambitus; } \ No newline at end of file diff --git a/libraries/steve/src/creator/Melody.h b/libraries/steve/src/creator/Melody.h index efecc2bde..0846926ca 100644 --- a/libraries/steve/src/creator/Melody.h +++ b/libraries/steve/src/creator/Melody.h @@ -2,12 +2,17 @@ #include "Creator.h" -namespace steve { - class Melody : public Creator { +namespace steve +{ +class Melody : public Creator +{ public: - Melody(Music*); - Notes get(size_t start, size_t size) const override; - const char* name() const override { return "Melody"; } - std::set choose_note_from_chord(const ToneSet& chord) const; - }; -} + Melody(Music *); + Notes get(size_t start, size_t size) const override; + const char *name() const override + { + return "Melody"; + } + std::set choose_note_from_chord(const ToneSet &chord) const; +}; +} // namespace steve diff --git a/libraries/steve/src/ext/json.h b/libraries/steve/src/ext/json.h index bdf3eae0e..40f4ac3be 100644 --- a/libraries/steve/src/ext/json.h +++ b/libraries/steve/src/ext/json.h @@ -59,335 +59,334 @@ #endif #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -struct json_value_s; -struct json_parse_result_s; - -enum json_parse_flags_e { - json_parse_flags_default = 0, - - /* allow trailing commas in objects and arrays. For example, both [true,] and - {"a" : null,} would be allowed with this option on. */ - json_parse_flags_allow_trailing_comma = 0x1, - - /* allow unquoted keys for objects. For example, {a : null} would be allowed - with this option on. */ - json_parse_flags_allow_unquoted_keys = 0x2, - - /* allow a global unbracketed object. For example, a : null, b : true, c : {} - would be allowed with this option on. */ - json_parse_flags_allow_global_object = 0x4, - - /* allow objects to use '=' instead of ':' between key/value pairs. For - example, a = null, b : true would be allowed with this option on. */ - json_parse_flags_allow_equals_in_object = 0x8, - - /* allow that objects don't have to have comma separators between key/value - pairs. */ - json_parse_flags_allow_no_commas = 0x10, - - /* allow c-style comments (either variants) to be ignored in the input JSON - file. */ - json_parse_flags_allow_c_style_comments = 0x20, - - /* deprecated flag, unused. */ - json_parse_flags_deprecated = 0x40, - - /* record location information for each value. */ - json_parse_flags_allow_location_information = 0x80, - - /* allow strings to be 'single quoted'. */ - json_parse_flags_allow_single_quoted_strings = 0x100, - - /* allow numbers to be hexadecimal. */ - json_parse_flags_allow_hexadecimal_numbers = 0x200, - - /* allow numbers like +123 to be parsed. */ - json_parse_flags_allow_leading_plus_sign = 0x400, - - /* allow numbers like .0123 or 123. to be parsed. */ - json_parse_flags_allow_leading_or_trailing_decimal_point = 0x800, - - /* allow Infinity, -Infinity, NaN, -NaN. */ - json_parse_flags_allow_inf_and_nan = 0x1000, - - /* allow multi line string values. */ - json_parse_flags_allow_multi_line_strings = 0x2000, - - /* allow simplified JSON to be parsed. Simplified JSON is an enabling of a set - of other parsing options. */ - json_parse_flags_allow_simplified_json = - (json_parse_flags_allow_trailing_comma | - json_parse_flags_allow_unquoted_keys | - json_parse_flags_allow_global_object | - json_parse_flags_allow_equals_in_object | - json_parse_flags_allow_no_commas), - - /* allow JSON5 to be parsed. JSON5 is an enabling of a set of other parsing - options. */ - json_parse_flags_allow_json5 = - (json_parse_flags_allow_trailing_comma | - json_parse_flags_allow_unquoted_keys | - json_parse_flags_allow_c_style_comments | - json_parse_flags_allow_single_quoted_strings | - json_parse_flags_allow_hexadecimal_numbers | - json_parse_flags_allow_leading_plus_sign | - json_parse_flags_allow_leading_or_trailing_decimal_point | - json_parse_flags_allow_inf_and_nan | - json_parse_flags_allow_multi_line_strings) -}; - -/* Parse a JSON text file, returning a pointer to the root of the JSON - * structure. json_parse performs 1 call to malloc for the entire encoding. - * Returns 0 if an error occurred (malformed JSON input, or malloc failed). */ -json_weak struct json_value_s *json_parse(const void *src, size_t src_size); - -/* Parse a JSON text file, returning a pointer to the root of the JSON - * structure. json_parse performs 1 call to alloc_func_ptr for the entire - * encoding. Returns 0 if an error occurred (malformed JSON input, or malloc - * failed). If an error occurred, the result struct (if not NULL) will explain - * the type of error, and the location in the input it occurred. If - * alloc_func_ptr is null then malloc is used. */ -json_weak struct json_value_s * -json_parse_ex(const void *src, size_t src_size, size_t flags_bitset, - void *(*alloc_func_ptr)(void *, size_t), void *user_data, - struct json_parse_result_s *result); - -/* Extracts a value and all the data that makes it up into a newly created - * value. json_extract_value performs 1 call to malloc for the entire encoding. - */ -json_weak struct json_value_s * -json_extract_value(const struct json_value_s *value); - -/* Extracts a value and all the data that makes it up into a newly created - * value. json_extract_value performs 1 call to alloc_func_ptr for the entire - * encoding. If alloc_func_ptr is null then malloc is used. */ -json_weak struct json_value_s * -json_extract_value_ex(const struct json_value_s *value, - void *(*alloc_func_ptr)(void *, size_t), void *user_data); - -/* Write out a minified JSON utf-8 string. This string is an encoding of the - * minimal string characters required to still encode the same data. - * json_write_minified performs 1 call to malloc for the entire encoding. Return - * 0 if an error occurred (malformed JSON input, or malloc failed). The out_size - * parameter is optional as the utf-8 string is null terminated. */ -json_weak void *json_write_minified(const struct json_value_s *value, - size_t *out_size); - -/* Write out a pretty JSON utf-8 string. This string is encoded such that the - * resultant JSON is pretty in that it is easily human readable. The indent and - * newline parameters allow a user to specify what kind of indentation and - * newline they want (two spaces / three spaces / tabs? \r, \n, \r\n ?). Both - * indent and newline can be NULL, indent defaults to two spaces (" "), and - * newline defaults to linux newlines ('\n' as the newline character). - * json_write_pretty performs 1 call to malloc for the entire encoding. Return 0 - * if an error occurred (malformed JSON input, or malloc failed). The out_size - * parameter is optional as the utf-8 string is null terminated. */ -json_weak void *json_write_pretty(const struct json_value_s *value, - const char *indent, const char *newline, - size_t *out_size); - -/* Reinterpret a JSON value as a string. Returns null is the value was not a - * string. */ -json_weak struct json_string_s * -json_value_as_string(struct json_value_s *const value); - -/* Reinterpret a JSON value as a number. Returns null is the value was not a - * number. */ -json_weak struct json_number_s * -json_value_as_number(struct json_value_s *const value); - -/* Reinterpret a JSON value as an object. Returns null is the value was not an - * object. */ -json_weak struct json_object_s * -json_value_as_object(struct json_value_s *const value); - -/* Reinterpret a JSON value as an array. Returns null is the value was not an - * array. */ -json_weak struct json_array_s * -json_value_as_array(struct json_value_s *const value); - -/* Whether the value is true. */ -json_weak int json_value_is_true(const struct json_value_s *const value); - -/* Whether the value is false. */ -json_weak int json_value_is_false(const struct json_value_s *const value); - -/* Whether the value is null. */ -json_weak int json_value_is_null(const struct json_value_s *const value); - -/* The various types JSON values can be. Used to identify what a value is. */ -typedef enum json_type_e { - json_type_string, - json_type_number, - json_type_object, - json_type_array, - json_type_true, - json_type_false, - json_type_null - -} json_type_t; - -/* A JSON string value. */ -typedef struct json_string_s { - /* utf-8 string */ - const char *string; - /* The size (in bytes) of the string */ - size_t string_size; - -} json_string_t; - -/* A JSON string value (extended). */ -typedef struct json_string_ex_s { - /* The JSON string this extends. */ - struct json_string_s string; - - /* The character offset for the value in the JSON input. */ - size_t offset; - - /* The line number for the value in the JSON input. */ - size_t line_no; - - /* The row number for the value in the JSON input, in bytes. */ - size_t row_no; - -} json_string_ex_t; - -/* A JSON number value. */ -typedef struct json_number_s { - /* ASCII string containing representation of the number. */ - const char *number; - /* the size (in bytes) of the number. */ - size_t number_size; - -} json_number_t; - -/* an element of a JSON object. */ -typedef struct json_object_element_s { - /* the name of this element. */ - struct json_string_s *name; - /* the value of this element. */ - struct json_value_s *value; - /* the next object element (can be NULL if the last element in the object). */ - struct json_object_element_s *next; - -} json_object_element_t; - -/* a JSON object value. */ -typedef struct json_object_s { - /* a linked list of the elements in the object. */ - struct json_object_element_s *start; - /* the number of elements in the object. */ - size_t length; - -} json_object_t; - -/* an element of a JSON array. */ -typedef struct json_array_element_s { - /* the value of this element. */ - struct json_value_s *value; - /* the next array element (can be NULL if the last element in the array). */ - struct json_array_element_s *next; - -} json_array_element_t; - -/* a JSON array value. */ -typedef struct json_array_s { - /* a linked list of the elements in the array. */ - struct json_array_element_s *start; - /* the number of elements in the array. */ - size_t length; - -} json_array_t; - -/* a JSON value. */ -typedef struct json_value_s { - /* a pointer to either a json_string_s, json_number_s, json_object_s, or. */ - /* json_array_s. Should be cast to the appropriate struct type based on what. - */ - /* the type of this value is. */ - void *payload; - /* must be one of json_type_e. If type is json_type_true, json_type_false, or. - */ - /* json_type_null, payload will be NULL. */ - size_t type; - -} json_value_t; - -/* a JSON value (extended). */ -typedef struct json_value_ex_s { - /* the JSON value this extends. */ - struct json_value_s value; - - /* the character offset for the value in the JSON input. */ - size_t offset; - - /* the line number for the value in the JSON input. */ - size_t line_no; - - /* the row number for the value in the JSON input, in bytes. */ - size_t row_no; - -} json_value_ex_t; - -/* a parsing error code. */ -enum json_parse_error_e { - /* no error occurred (huzzah!). */ - json_parse_error_none = 0, - - /* expected either a comma or a closing '}' or ']' to close an object or. */ - /* array! */ - json_parse_error_expected_comma_or_closing_bracket, - - /* colon separating name/value pair was missing! */ - json_parse_error_expected_colon, - - /* expected string to begin with '"'! */ - json_parse_error_expected_opening_quote, - - /* invalid escaped sequence in string! */ - json_parse_error_invalid_string_escape_sequence, + struct json_value_s; + struct json_parse_result_s; + + enum json_parse_flags_e + { + json_parse_flags_default = 0, + + /* allow trailing commas in objects and arrays. For example, both [true,] and + {"a" : null,} would be allowed with this option on. */ + json_parse_flags_allow_trailing_comma = 0x1, + + /* allow unquoted keys for objects. For example, {a : null} would be allowed + with this option on. */ + json_parse_flags_allow_unquoted_keys = 0x2, + + /* allow a global unbracketed object. For example, a : null, b : true, c : {} + would be allowed with this option on. */ + json_parse_flags_allow_global_object = 0x4, + + /* allow objects to use '=' instead of ':' between key/value pairs. For + example, a = null, b : true would be allowed with this option on. */ + json_parse_flags_allow_equals_in_object = 0x8, + + /* allow that objects don't have to have comma separators between key/value + pairs. */ + json_parse_flags_allow_no_commas = 0x10, + + /* allow c-style comments (either variants) to be ignored in the input JSON + file. */ + json_parse_flags_allow_c_style_comments = 0x20, + + /* deprecated flag, unused. */ + json_parse_flags_deprecated = 0x40, + + /* record location information for each value. */ + json_parse_flags_allow_location_information = 0x80, + + /* allow strings to be 'single quoted'. */ + json_parse_flags_allow_single_quoted_strings = 0x100, + + /* allow numbers to be hexadecimal. */ + json_parse_flags_allow_hexadecimal_numbers = 0x200, + + /* allow numbers like +123 to be parsed. */ + json_parse_flags_allow_leading_plus_sign = 0x400, + + /* allow numbers like .0123 or 123. to be parsed. */ + json_parse_flags_allow_leading_or_trailing_decimal_point = 0x800, + + /* allow Infinity, -Infinity, NaN, -NaN. */ + json_parse_flags_allow_inf_and_nan = 0x1000, + + /* allow multi line string values. */ + json_parse_flags_allow_multi_line_strings = 0x2000, + + /* allow simplified JSON to be parsed. Simplified JSON is an enabling of a set + of other parsing options. */ + json_parse_flags_allow_simplified_json = + (json_parse_flags_allow_trailing_comma | json_parse_flags_allow_unquoted_keys | + json_parse_flags_allow_global_object | json_parse_flags_allow_equals_in_object | + json_parse_flags_allow_no_commas), + + /* allow JSON5 to be parsed. JSON5 is an enabling of a set of other parsing + options. */ + json_parse_flags_allow_json5 = + (json_parse_flags_allow_trailing_comma | json_parse_flags_allow_unquoted_keys | + json_parse_flags_allow_c_style_comments | json_parse_flags_allow_single_quoted_strings | + json_parse_flags_allow_hexadecimal_numbers | json_parse_flags_allow_leading_plus_sign | + json_parse_flags_allow_leading_or_trailing_decimal_point | json_parse_flags_allow_inf_and_nan | + json_parse_flags_allow_multi_line_strings) + }; + + /* Parse a JSON text file, returning a pointer to the root of the JSON + * structure. json_parse performs 1 call to malloc for the entire encoding. + * Returns 0 if an error occurred (malformed JSON input, or malloc failed). */ + json_weak struct json_value_s *json_parse(const void *src, size_t src_size); + + /* Parse a JSON text file, returning a pointer to the root of the JSON + * structure. json_parse performs 1 call to alloc_func_ptr for the entire + * encoding. Returns 0 if an error occurred (malformed JSON input, or malloc + * failed). If an error occurred, the result struct (if not NULL) will explain + * the type of error, and the location in the input it occurred. If + * alloc_func_ptr is null then malloc is used. */ + json_weak struct json_value_s *json_parse_ex(const void *src, size_t src_size, size_t flags_bitset, + void *(*alloc_func_ptr)(void *, size_t), void *user_data, + struct json_parse_result_s *result); + + /* Extracts a value and all the data that makes it up into a newly created + * value. json_extract_value performs 1 call to malloc for the entire encoding. + */ + json_weak struct json_value_s *json_extract_value(const struct json_value_s *value); + + /* Extracts a value and all the data that makes it up into a newly created + * value. json_extract_value performs 1 call to alloc_func_ptr for the entire + * encoding. If alloc_func_ptr is null then malloc is used. */ + json_weak struct json_value_s *json_extract_value_ex(const struct json_value_s *value, + void *(*alloc_func_ptr)(void *, size_t), void *user_data); + + /* Write out a minified JSON utf-8 string. This string is an encoding of the + * minimal string characters required to still encode the same data. + * json_write_minified performs 1 call to malloc for the entire encoding. Return + * 0 if an error occurred (malformed JSON input, or malloc failed). The out_size + * parameter is optional as the utf-8 string is null terminated. */ + json_weak void *json_write_minified(const struct json_value_s *value, size_t *out_size); + + /* Write out a pretty JSON utf-8 string. This string is encoded such that the + * resultant JSON is pretty in that it is easily human readable. The indent and + * newline parameters allow a user to specify what kind of indentation and + * newline they want (two spaces / three spaces / tabs? \r, \n, \r\n ?). Both + * indent and newline can be NULL, indent defaults to two spaces (" "), and + * newline defaults to linux newlines ('\n' as the newline character). + * json_write_pretty performs 1 call to malloc for the entire encoding. Return 0 + * if an error occurred (malformed JSON input, or malloc failed). The out_size + * parameter is optional as the utf-8 string is null terminated. */ + json_weak void *json_write_pretty(const struct json_value_s *value, const char *indent, const char *newline, + size_t *out_size); + + /* Reinterpret a JSON value as a string. Returns null is the value was not a + * string. */ + json_weak struct json_string_s *json_value_as_string(struct json_value_s *const value); + + /* Reinterpret a JSON value as a number. Returns null is the value was not a + * number. */ + json_weak struct json_number_s *json_value_as_number(struct json_value_s *const value); + + /* Reinterpret a JSON value as an object. Returns null is the value was not an + * object. */ + json_weak struct json_object_s *json_value_as_object(struct json_value_s *const value); + + /* Reinterpret a JSON value as an array. Returns null is the value was not an + * array. */ + json_weak struct json_array_s *json_value_as_array(struct json_value_s *const value); + + /* Whether the value is true. */ + json_weak int json_value_is_true(const struct json_value_s *const value); + + /* Whether the value is false. */ + json_weak int json_value_is_false(const struct json_value_s *const value); + + /* Whether the value is null. */ + json_weak int json_value_is_null(const struct json_value_s *const value); + + /* The various types JSON values can be. Used to identify what a value is. */ + typedef enum json_type_e + { + json_type_string, + json_type_number, + json_type_object, + json_type_array, + json_type_true, + json_type_false, + json_type_null + + } json_type_t; + + /* A JSON string value. */ + typedef struct json_string_s + { + /* utf-8 string */ + const char *string; + /* The size (in bytes) of the string */ + size_t string_size; + + } json_string_t; + + /* A JSON string value (extended). */ + typedef struct json_string_ex_s + { + /* The JSON string this extends. */ + struct json_string_s string; + + /* The character offset for the value in the JSON input. */ + size_t offset; + + /* The line number for the value in the JSON input. */ + size_t line_no; + + /* The row number for the value in the JSON input, in bytes. */ + size_t row_no; + + } json_string_ex_t; + + /* A JSON number value. */ + typedef struct json_number_s + { + /* ASCII string containing representation of the number. */ + const char *number; + /* the size (in bytes) of the number. */ + size_t number_size; + + } json_number_t; + + /* an element of a JSON object. */ + typedef struct json_object_element_s + { + /* the name of this element. */ + struct json_string_s *name; + /* the value of this element. */ + struct json_value_s *value; + /* the next object element (can be NULL if the last element in the object). */ + struct json_object_element_s *next; + + } json_object_element_t; + + /* a JSON object value. */ + typedef struct json_object_s + { + /* a linked list of the elements in the object. */ + struct json_object_element_s *start; + /* the number of elements in the object. */ + size_t length; + + } json_object_t; + + /* an element of a JSON array. */ + typedef struct json_array_element_s + { + /* the value of this element. */ + struct json_value_s *value; + /* the next array element (can be NULL if the last element in the array). */ + struct json_array_element_s *next; + + } json_array_element_t; + + /* a JSON array value. */ + typedef struct json_array_s + { + /* a linked list of the elements in the array. */ + struct json_array_element_s *start; + /* the number of elements in the array. */ + size_t length; + + } json_array_t; + + /* a JSON value. */ + typedef struct json_value_s + { + /* a pointer to either a json_string_s, json_number_s, json_object_s, or. */ + /* json_array_s. Should be cast to the appropriate struct type based on what. + */ + /* the type of this value is. */ + void *payload; + /* must be one of json_type_e. If type is json_type_true, json_type_false, or. + */ + /* json_type_null, payload will be NULL. */ + size_t type; + + } json_value_t; + + /* a JSON value (extended). */ + typedef struct json_value_ex_s + { + /* the JSON value this extends. */ + struct json_value_s value; + + /* the character offset for the value in the JSON input. */ + size_t offset; + + /* the line number for the value in the JSON input. */ + size_t line_no; + + /* the row number for the value in the JSON input, in bytes. */ + size_t row_no; + + } json_value_ex_t; + + /* a parsing error code. */ + enum json_parse_error_e + { + /* no error occurred (huzzah!). */ + json_parse_error_none = 0, + + /* expected either a comma or a closing '}' or ']' to close an object or. */ + /* array! */ + json_parse_error_expected_comma_or_closing_bracket, + + /* colon separating name/value pair was missing! */ + json_parse_error_expected_colon, + + /* expected string to begin with '"'! */ + json_parse_error_expected_opening_quote, + + /* invalid escaped sequence in string! */ + json_parse_error_invalid_string_escape_sequence, + + /* invalid number format! */ + json_parse_error_invalid_number_format, - /* invalid number format! */ - json_parse_error_invalid_number_format, + /* invalid value! */ + json_parse_error_invalid_value, - /* invalid value! */ - json_parse_error_invalid_value, - - /* reached end of buffer before object/array was complete! */ - json_parse_error_premature_end_of_buffer, + /* reached end of buffer before object/array was complete! */ + json_parse_error_premature_end_of_buffer, - /* string was malformed! */ - json_parse_error_invalid_string, + /* string was malformed! */ + json_parse_error_invalid_string, - /* a call to malloc, or a user provider allocator, failed. */ - json_parse_error_allocator_failed, + /* a call to malloc, or a user provider allocator, failed. */ + json_parse_error_allocator_failed, - /* the JSON input had unexpected trailing characters that weren't part of the. - JSON value. */ - json_parse_error_unexpected_trailing_characters, + /* the JSON input had unexpected trailing characters that weren't part of the. + JSON value. */ + json_parse_error_unexpected_trailing_characters, - /* catch-all error for everything else that exploded (real bad chi!). */ - json_parse_error_unknown -}; + /* catch-all error for everything else that exploded (real bad chi!). */ + json_parse_error_unknown + }; -/* error report from json_parse_ex(). */ -typedef struct json_parse_result_s { - /* the error code (one of json_parse_error_e). */ - size_t error; + /* error report from json_parse_ex(). */ + typedef struct json_parse_result_s + { + /* the error code (one of json_parse_error_e). */ + size_t error; - /* the character offset for the error in the JSON input. */ - size_t error_offset; + /* the character offset for the error in the JSON input. */ + size_t error_offset; - /* the line number for the error in the JSON input. */ - size_t error_line_no; + /* the line number for the error in the JSON input. */ + size_t error_line_no; - /* the row number for the error, in bytes. */ - size_t error_row_no; + /* the row number for the error, in bytes. */ + size_t error_row_no; -} json_parse_result_t; + } json_parse_result_t; #ifdef __cplusplus } /* extern "C". */ @@ -453,2993 +452,3303 @@ typedef struct json_parse_result_s { #pragma warning(disable : 5045) #endif -struct json_parse_state_s { - const char *src; - size_t size; - size_t offset; - size_t flags_bitset; - char *data; - char *dom; - size_t dom_size; - size_t data_size; - size_t line_no; /* line counter for error reporting. */ - size_t line_offset; /* (offset-line_offset) is the character number (in - bytes). */ - size_t error; +struct json_parse_state_s +{ + const char *src; + size_t size; + size_t offset; + size_t flags_bitset; + char *data; + char *dom; + size_t dom_size; + size_t data_size; + size_t line_no; /* line counter for error reporting. */ + size_t line_offset; /* (offset-line_offset) is the character number (in + bytes). */ + size_t error; }; json_weak int json_hexadecimal_digit(const char c); -int json_hexadecimal_digit(const char c) { - if ('0' <= c && c <= '9') { - return c - '0'; - } - if ('a' <= c && c <= 'f') { - return c - 'a' + 10; - } - if ('A' <= c && c <= 'F') { - return c - 'A' + 10; - } - return -1; +int json_hexadecimal_digit(const char c) +{ + if ('0' <= c && c <= '9') + { + return c - '0'; + } + if ('a' <= c && c <= 'f') + { + return c - 'a' + 10; + } + if ('A' <= c && c <= 'F') + { + return c - 'A' + 10; + } + return -1; } -json_weak int json_hexadecimal_value(const char *c, const unsigned long size, - unsigned long *result); -int json_hexadecimal_value(const char *c, const unsigned long size, - unsigned long *result) { - const char *p; - int digit; +json_weak int json_hexadecimal_value(const char *c, const unsigned long size, unsigned long *result); +int json_hexadecimal_value(const char *c, const unsigned long size, unsigned long *result) +{ + const char *p; + int digit; - if (size > sizeof(unsigned long) * 2) { - return 0; - } - - *result = 0; - for (p = c; (unsigned long)(p - c) < size; ++p) { - *result <<= 4; - digit = json_hexadecimal_digit(*p); - if (digit < 0 || digit > 15) { - return 0; - } - *result |= (unsigned char)digit; - } - return 1; + if (size > sizeof(unsigned long) * 2) + { + return 0; + } + + *result = 0; + for (p = c; (unsigned long)(p - c) < size; ++p) + { + *result <<= 4; + digit = json_hexadecimal_digit(*p); + if (digit < 0 || digit > 15) + { + return 0; + } + *result |= (unsigned char)digit; + } + return 1; } json_weak int json_skip_whitespace(struct json_parse_state_s *state); -int json_skip_whitespace(struct json_parse_state_s *state) { - size_t offset = state->offset; - const size_t size = state->size; - const char *const src = state->src; - - if (offset >= state->size) { - return 0; - } +int json_skip_whitespace(struct json_parse_state_s *state) +{ + size_t offset = state->offset; + const size_t size = state->size; + const char *const src = state->src; + + if (offset >= state->size) + { + return 0; + } - /* the only valid whitespace according to ECMA-404 is ' ', '\n', '\r' and - * '\t'. */ - switch (src[offset]) { - default: - return 0; - case ' ': - case '\r': - case '\t': - case '\n': - break; - } - - do { - switch (src[offset]) { + /* the only valid whitespace according to ECMA-404 is ' ', '\n', '\r' and + * '\t'. */ + switch (src[offset]) + { default: - /* Update offset. */ - state->offset = offset; - return 1; + return 0; case ' ': case '\r': case '\t': - break; case '\n': - state->line_no++; - state->line_offset = offset; - break; + break; } - offset++; - } while (offset < size); - - /* Update offset. */ - state->offset = offset; - return 1; -} - -json_weak int json_skip_c_style_comments(struct json_parse_state_s *state); -int json_skip_c_style_comments(struct json_parse_state_s *state) { - /* to have a C-style comment we need at least 2 characters of space */ - if ((state->offset + 2) > state->size) { - return 0; - } - - /* do we have a comment? */ - if ('/' == state->src[state->offset]) { - if ('/' == state->src[state->offset + 1]) { - /* we had a comment of the form // */ - - /* skip first '/' */ - state->offset++; - - /* skip second '/' */ - state->offset++; - - while (state->offset < state->size) { - switch (state->src[state->offset]) { + do + { + switch (src[offset]) + { default: - /* skip the character in the comment */ - state->offset++; - break; + /* Update offset. */ + state->offset = offset; + return 1; + case ' ': + case '\r': + case '\t': + break; case '\n': - /* if we have a newline, our comment has ended! Skip the newline */ - state->offset++; - - /* we entered a newline, so move our line info forward */ - state->line_no++; - state->line_offset = state->offset; - return 1; + state->line_no++; + state->line_offset = offset; + break; } - } - /* we reached the end of the JSON file! */ - return 1; - } else if ('*' == state->src[state->offset + 1]) { - /* we had a comment in the C-style long form */ + offset++; + } while (offset < size); - /* skip '/' */ - state->offset++; + /* Update offset. */ + state->offset = offset; + return 1; +} - /* skip '*' */ - state->offset++; +json_weak int json_skip_c_style_comments(struct json_parse_state_s *state); +int json_skip_c_style_comments(struct json_parse_state_s *state) +{ + /* to have a C-style comment we need at least 2 characters of space */ + if ((state->offset + 2) > state->size) + { + return 0; + } - while (state->offset + 1 < state->size) { - if (('*' == state->src[state->offset]) && - ('/' == state->src[state->offset + 1])) { - /* we reached the end of our comment! */ - state->offset += 2; - return 1; - } else if ('\n' == state->src[state->offset]) { - /* we entered a newline, so move our line info forward */ - state->line_no++; - state->line_offset = state->offset; + /* do we have a comment? */ + if ('/' == state->src[state->offset]) + { + if ('/' == state->src[state->offset + 1]) + { + /* we had a comment of the form // */ + + /* skip first '/' */ + state->offset++; + + /* skip second '/' */ + state->offset++; + + while (state->offset < state->size) + { + switch (state->src[state->offset]) + { + default: + /* skip the character in the comment */ + state->offset++; + break; + case '\n': + /* if we have a newline, our comment has ended! Skip the newline */ + state->offset++; + + /* we entered a newline, so move our line info forward */ + state->line_no++; + state->line_offset = state->offset; + return 1; + } + } + + /* we reached the end of the JSON file! */ + return 1; + } + else if ('*' == state->src[state->offset + 1]) + { + /* we had a comment in the C-style long form */ + + /* skip '/' */ + state->offset++; + + /* skip '*' */ + state->offset++; + + while (state->offset + 1 < state->size) + { + if (('*' == state->src[state->offset]) && ('/' == state->src[state->offset + 1])) + { + /* we reached the end of our comment! */ + state->offset += 2; + return 1; + } + else if ('\n' == state->src[state->offset]) + { + /* we entered a newline, so move our line info forward */ + state->line_no++; + state->line_offset = state->offset; + } + + /* skip character within comment */ + state->offset++; + } + + /* comment wasn't ended correctly which is a failure */ + return 1; } - - /* skip character within comment */ - state->offset++; - } - - /* comment wasn't ended correctly which is a failure */ - return 1; } - } - /* we didn't have any comment, which is ok too! */ - return 0; + /* we didn't have any comment, which is ok too! */ + return 0; } json_weak int json_skip_all_skippables(struct json_parse_state_s *state); -int json_skip_all_skippables(struct json_parse_state_s *state) { - /* skip all whitespace and other skippables until there are none left. note - * that the previous version suffered from read past errors should. the - * stream end on json_skip_c_style_comments eg. '{"a" ' with comments flag. - */ - - int did_consume = 0; - const size_t size = state->size; - - if (json_parse_flags_allow_c_style_comments & state->flags_bitset) { - do { - if (state->offset == size) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } - - did_consume = json_skip_whitespace(state); - - /* This should really be checked on access, not in front of every call. - */ - if (state->offset >= size) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } +int json_skip_all_skippables(struct json_parse_state_s *state) +{ + /* skip all whitespace and other skippables until there are none left. note + * that the previous version suffered from read past errors should. the + * stream end on json_skip_c_style_comments eg. '{"a" ' with comments flag. + */ - did_consume |= json_skip_c_style_comments(state); - } while (0 != did_consume); - } else { - do { - if (state->offset == size) { + int did_consume = 0; + const size_t size = state->size; + + if (json_parse_flags_allow_c_style_comments & state->flags_bitset) + { + do + { + if (state->offset == size) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } + + did_consume = json_skip_whitespace(state); + + /* This should really be checked on access, not in front of every call. + */ + if (state->offset >= size) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } + + did_consume |= json_skip_c_style_comments(state); + } while (0 != did_consume); + } + else + { + do + { + if (state->offset == size) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } + + did_consume = json_skip_whitespace(state); + } while (0 != did_consume); + } + + if (state->offset == size) + { state->error = json_parse_error_premature_end_of_buffer; return 1; - } - - did_consume = json_skip_whitespace(state); - } while (0 != did_consume); - } - - if (state->offset == size) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + } - return 0; + return 0; } -json_weak int json_get_value_size(struct json_parse_state_s *state, - int is_global_object); - -json_weak int json_get_string_size(struct json_parse_state_s *state, - size_t is_key); -int json_get_string_size(struct json_parse_state_s *state, size_t is_key) { - size_t offset = state->offset; - const size_t size = state->size; - size_t data_size = 0; - const char *const src = state->src; - const int is_single_quote = '\'' == src[offset]; - const char quote_to_use = is_single_quote ? '\'' : '"'; - const size_t flags_bitset = state->flags_bitset; - unsigned long codepoint; - unsigned long high_surrogate = 0; - - if ((json_parse_flags_allow_location_information & flags_bitset) != 0 && - is_key != 0) { - state->dom_size += sizeof(struct json_string_ex_s); - } else { - state->dom_size += sizeof(struct json_string_s); - } - - if ('"' != src[offset]) { - /* if we are allowed single quoted strings check for that too. */ - if (!((json_parse_flags_allow_single_quoted_strings & flags_bitset) && - is_single_quote)) { - state->error = json_parse_error_expected_opening_quote; - state->offset = offset; - return 1; - } - } - - /* skip leading '"' or '\''. */ - offset++; - - while ((offset < size) && (quote_to_use != src[offset])) { - /* add space for the character. */ - data_size++; - - switch (src[offset]) { - default: - break; - case '\0': - case '\t': - state->error = json_parse_error_invalid_string; - state->offset = offset; - return 1; +json_weak int json_get_value_size(struct json_parse_state_s *state, int is_global_object); + +json_weak int json_get_string_size(struct json_parse_state_s *state, size_t is_key); +int json_get_string_size(struct json_parse_state_s *state, size_t is_key) +{ + size_t offset = state->offset; + const size_t size = state->size; + size_t data_size = 0; + const char *const src = state->src; + const int is_single_quote = '\'' == src[offset]; + const char quote_to_use = is_single_quote ? '\'' : '"'; + const size_t flags_bitset = state->flags_bitset; + unsigned long codepoint; + unsigned long high_surrogate = 0; + + if ((json_parse_flags_allow_location_information & flags_bitset) != 0 && is_key != 0) + { + state->dom_size += sizeof(struct json_string_ex_s); + } + else + { + state->dom_size += sizeof(struct json_string_s); } - if ('\\' == src[offset]) { - /* skip reverse solidus character. */ - offset++; - - if (offset == size) { - state->error = json_parse_error_premature_end_of_buffer; - state->offset = offset; - return 1; - } - - switch (src[offset]) { - default: - state->error = json_parse_error_invalid_string_escape_sequence; - state->offset = offset; - return 1; - case '"': - case '\\': - case '/': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': - /* all valid characters! */ - offset++; - break; - case 'u': - if (!(offset + 5 < size)) { - /* invalid escaped unicode sequence! */ - state->error = json_parse_error_invalid_string_escape_sequence; - state->offset = offset; - return 1; - } - - codepoint = 0; - if (!json_hexadecimal_value(&src[offset + 1], 4, &codepoint)) { - /* escaped unicode sequences must contain 4 hexadecimal digits! */ - state->error = json_parse_error_invalid_string_escape_sequence; - state->offset = offset; - return 1; - } - - /* Valid sequence! - * see: https://en.wikipedia.org/wiki/UTF-8#Invalid_code_points. - * 1 7 U + 0000 U + 007F 0xxxxxxx. - * 2 11 U + 0080 U + 07FF 110xxxxx - * 10xxxxxx. - * 3 16 U + 0800 U + FFFF 1110xxxx - * 10xxxxxx 10xxxxxx. - * 4 21 U + 10000 U + 10FFFF 11110xxx - * 10xxxxxx 10xxxxxx 10xxxxxx. - * Note: the high and low surrogate halves used by UTF-16 (U+D800 - * through U+DFFF) and code points not encodable by UTF-16 (those after - * U+10FFFF) are not legal Unicode values, and their UTF-8 encoding must - * be treated as an invalid byte sequence. */ - - if (high_surrogate != 0) { - /* we previously read the high half of the \uxxxx\uxxxx pair, so now - * we expect the low half. */ - if (codepoint >= 0xdc00 && - codepoint <= 0xdfff) { /* low surrogate range. */ - data_size += 3; - high_surrogate = 0; - } else { - state->error = json_parse_error_invalid_string_escape_sequence; + if ('"' != src[offset]) + { + /* if we are allowed single quoted strings check for that too. */ + if (!((json_parse_flags_allow_single_quoted_strings & flags_bitset) && is_single_quote)) + { + state->error = json_parse_error_expected_opening_quote; state->offset = offset; return 1; - } - } else if (codepoint <= 0x7f) { - data_size += 0; - } else if (codepoint <= 0x7ff) { - data_size += 1; - } else if (codepoint >= 0xd800 && - codepoint <= 0xdbff) { /* high surrogate range. */ - /* The codepoint is the first half of a "utf-16 surrogate pair". so we - * need the other half for it to be valid: \uHHHH\uLLLL. */ - if (offset + 11 > size || '\\' != src[offset + 5] || - 'u' != src[offset + 6]) { - state->error = json_parse_error_invalid_string_escape_sequence; + } + } + + /* skip leading '"' or '\''. */ + offset++; + + while ((offset < size) && (quote_to_use != src[offset])) + { + /* add space for the character. */ + data_size++; + + switch (src[offset]) + { + default: + break; + case '\0': + case '\t': + state->error = json_parse_error_invalid_string; state->offset = offset; return 1; - } - high_surrogate = codepoint; - } else if (codepoint >= 0xd800 && - codepoint <= 0xdfff) { /* low surrogate range. */ - /* we did not read the other half before. */ - state->error = json_parse_error_invalid_string_escape_sequence; - state->offset = offset; - return 1; - } else { - data_size += 2; - } - /* escaped codepoints after 0xffff are supported in json through utf-16 - * surrogate pairs: \uD83D\uDD25 for U+1F525. */ - - offset += 5; - break; - } - } else if (('\r' == src[offset]) || ('\n' == src[offset])) { - if (!(json_parse_flags_allow_multi_line_strings & flags_bitset)) { - /* invalid escaped unicode sequence! */ - state->error = json_parse_error_invalid_string_escape_sequence; - state->offset = offset; - return 1; - } + } - offset++; - } else { - /* skip character (valid part of sequence). */ - offset++; + if ('\\' == src[offset]) + { + /* skip reverse solidus character. */ + offset++; + + if (offset == size) + { + state->error = json_parse_error_premature_end_of_buffer; + state->offset = offset; + return 1; + } + + switch (src[offset]) + { + default: + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + case '"': + case '\\': + case '/': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + /* all valid characters! */ + offset++; + break; + case 'u': + if (!(offset + 5 < size)) + { + /* invalid escaped unicode sequence! */ + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + + codepoint = 0; + if (!json_hexadecimal_value(&src[offset + 1], 4, &codepoint)) + { + /* escaped unicode sequences must contain 4 hexadecimal digits! */ + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + + /* Valid sequence! + * see: https://en.wikipedia.org/wiki/UTF-8#Invalid_code_points. + * 1 7 U + 0000 U + 007F 0xxxxxxx. + * 2 11 U + 0080 U + 07FF 110xxxxx + * 10xxxxxx. + * 3 16 U + 0800 U + FFFF 1110xxxx + * 10xxxxxx 10xxxxxx. + * 4 21 U + 10000 U + 10FFFF 11110xxx + * 10xxxxxx 10xxxxxx 10xxxxxx. + * Note: the high and low surrogate halves used by UTF-16 (U+D800 + * through U+DFFF) and code points not encodable by UTF-16 (those after + * U+10FFFF) are not legal Unicode values, and their UTF-8 encoding must + * be treated as an invalid byte sequence. */ + + if (high_surrogate != 0) + { + /* we previously read the high half of the \uxxxx\uxxxx pair, so now + * we expect the low half. */ + if (codepoint >= 0xdc00 && codepoint <= 0xdfff) + { /* low surrogate range. */ + data_size += 3; + high_surrogate = 0; + } + else + { + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + } + else if (codepoint <= 0x7f) + { + data_size += 0; + } + else if (codepoint <= 0x7ff) + { + data_size += 1; + } + else if (codepoint >= 0xd800 && codepoint <= 0xdbff) + { /* high surrogate range. */ + /* The codepoint is the first half of a "utf-16 surrogate pair". so we + * need the other half for it to be valid: \uHHHH\uLLLL. */ + if (offset + 11 > size || '\\' != src[offset + 5] || 'u' != src[offset + 6]) + { + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + high_surrogate = codepoint; + } + else if (codepoint >= 0xd800 && codepoint <= 0xdfff) + { /* low surrogate range. */ + /* we did not read the other half before. */ + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + else + { + data_size += 2; + } + /* escaped codepoints after 0xffff are supported in json through utf-16 + * surrogate pairs: \uD83D\uDD25 for U+1F525. */ + + offset += 5; + break; + } + } + else if (('\r' == src[offset]) || ('\n' == src[offset])) + { + if (!(json_parse_flags_allow_multi_line_strings & flags_bitset)) + { + /* invalid escaped unicode sequence! */ + state->error = json_parse_error_invalid_string_escape_sequence; + state->offset = offset; + return 1; + } + + offset++; + } + else + { + /* skip character (valid part of sequence). */ + offset++; + } } - } - /* If the offset is equal to the size, we had a non-terminated string! */ - if (offset == size) { - state->error = json_parse_error_premature_end_of_buffer; - state->offset = offset - 1; - return 1; - } + /* If the offset is equal to the size, we had a non-terminated string! */ + if (offset == size) + { + state->error = json_parse_error_premature_end_of_buffer; + state->offset = offset - 1; + return 1; + } - /* skip trailing '"' or '\''. */ - offset++; + /* skip trailing '"' or '\''. */ + offset++; - /* add enough space to store the string. */ - state->data_size += data_size; + /* add enough space to store the string. */ + state->data_size += data_size; - /* one more byte for null terminator ending the string! */ - state->data_size++; + /* one more byte for null terminator ending the string! */ + state->data_size++; - /* update offset. */ - state->offset = offset; + /* update offset. */ + state->offset = offset; - return 0; + return 0; } json_weak int is_valid_unquoted_key_char(const char c); -int is_valid_unquoted_key_char(const char c) { - return (('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || ('_' == c)); +int is_valid_unquoted_key_char(const char c) +{ + return (('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('_' == c)); } json_weak int json_get_key_size(struct json_parse_state_s *state); -int json_get_key_size(struct json_parse_state_s *state) { - const size_t flags_bitset = state->flags_bitset; - - if (json_parse_flags_allow_unquoted_keys & flags_bitset) { - size_t offset = state->offset; - const size_t size = state->size; - const char *const src = state->src; - size_t data_size = state->data_size; - - /* if we are allowing unquoted keys, first grok for a quote... */ - if ('"' == src[offset]) { - /* ... if we got a comma, just parse the key as a string as normal. */ - return json_get_string_size(state, 1); - } else if ((json_parse_flags_allow_single_quoted_strings & flags_bitset) && - ('\'' == src[offset])) { - /* ... if we got a comma, just parse the key as a string as normal. */ - return json_get_string_size(state, 1); - } else { - while ((offset < size) && is_valid_unquoted_key_char(src[offset])) { - offset++; - data_size++; - } - - /* one more byte for null terminator ending the string! */ - data_size++; - - if (json_parse_flags_allow_location_information & flags_bitset) { - state->dom_size += sizeof(struct json_string_ex_s); - } else { - state->dom_size += sizeof(struct json_string_s); - } - - /* update offset. */ - state->offset = offset; +int json_get_key_size(struct json_parse_state_s *state) +{ + const size_t flags_bitset = state->flags_bitset; + + if (json_parse_flags_allow_unquoted_keys & flags_bitset) + { + size_t offset = state->offset; + const size_t size = state->size; + const char *const src = state->src; + size_t data_size = state->data_size; + + /* if we are allowing unquoted keys, first grok for a quote... */ + if ('"' == src[offset]) + { + /* ... if we got a comma, just parse the key as a string as normal. */ + return json_get_string_size(state, 1); + } + else if ((json_parse_flags_allow_single_quoted_strings & flags_bitset) && ('\'' == src[offset])) + { + /* ... if we got a comma, just parse the key as a string as normal. */ + return json_get_string_size(state, 1); + } + else + { + while ((offset < size) && is_valid_unquoted_key_char(src[offset])) + { + offset++; + data_size++; + } + + /* one more byte for null terminator ending the string! */ + data_size++; + + if (json_parse_flags_allow_location_information & flags_bitset) + { + state->dom_size += sizeof(struct json_string_ex_s); + } + else + { + state->dom_size += sizeof(struct json_string_s); + } + + /* update offset. */ + state->offset = offset; - /* update data_size. */ - state->data_size = data_size; + /* update data_size. */ + state->data_size = data_size; - return 0; + return 0; + } + } + else + { + /* we are only allowed to have quoted keys, so just parse a string! */ + return json_get_string_size(state, 1); } - } else { - /* we are only allowed to have quoted keys, so just parse a string! */ - return json_get_string_size(state, 1); - } } -json_weak int json_get_object_size(struct json_parse_state_s *state, - int is_global_object); -int json_get_object_size(struct json_parse_state_s *state, - int is_global_object) { - const size_t flags_bitset = state->flags_bitset; - const char *const src = state->src; - const size_t size = state->size; - size_t elements = 0; - int allow_comma = 0; - int found_closing_brace = 0; - - if (is_global_object) { - /* if we found an opening '{' of an object, we actually have a normal JSON - * object at the root of the DOM... */ - if (!json_skip_all_skippables(state) && '{' == state->src[state->offset]) { - /* . and we don't actually have a global object after all! */ - is_global_object = 0; - } - } - - if (!is_global_object) { - if ('{' != src[state->offset]) { - state->error = json_parse_error_unknown; - return 1; - } - - /* skip leading '{'. */ - state->offset++; - } +json_weak int json_get_object_size(struct json_parse_state_s *state, int is_global_object); +int json_get_object_size(struct json_parse_state_s *state, int is_global_object) +{ + const size_t flags_bitset = state->flags_bitset; + const char *const src = state->src; + const size_t size = state->size; + size_t elements = 0; + int allow_comma = 0; + int found_closing_brace = 0; + + if (is_global_object) + { + /* if we found an opening '{' of an object, we actually have a normal JSON + * object at the root of the DOM... */ + if (!json_skip_all_skippables(state) && '{' == state->src[state->offset]) + { + /* . and we don't actually have a global object after all! */ + is_global_object = 0; + } + } - state->dom_size += sizeof(struct json_object_s); + if (!is_global_object) + { + if ('{' != src[state->offset]) + { + state->error = json_parse_error_unknown; + return 1; + } - if ((state->offset == size) && !is_global_object) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + /* skip leading '{'. */ + state->offset++; + } - do { - if (!is_global_object) { - if (json_skip_all_skippables(state)) { + state->dom_size += sizeof(struct json_object_s); + + if ((state->offset == size) && !is_global_object) + { state->error = json_parse_error_premature_end_of_buffer; return 1; - } + } - if ('}' == src[state->offset]) { - /* skip trailing '}'. */ - state->offset++; + do + { + if (!is_global_object) + { + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } - found_closing_brace = 1; + if ('}' == src[state->offset]) + { + /* skip trailing '}'. */ + state->offset++; - /* finished the object! */ - break; - } - } else { - /* we don't require brackets, so that means the object ends when the input - * stream ends! */ - if (json_skip_all_skippables(state)) { - break; - } - } + found_closing_brace = 1; - /* if we parsed at least one element previously, grok for a comma. */ - if (allow_comma) { - if (',' == src[state->offset]) { - /* skip comma. */ - state->offset++; - allow_comma = 0; - } else if (json_parse_flags_allow_no_commas & flags_bitset) { - /* we don't require a comma, and we didn't find one, which is ok! */ - allow_comma = 0; - } else { - /* otherwise we are required to have a comma, and we found none. */ - state->error = json_parse_error_expected_comma_or_closing_bracket; - return 1; - } + /* finished the object! */ + break; + } + } + else + { + /* we don't require brackets, so that means the object ends when the input + * stream ends! */ + if (json_skip_all_skippables(state)) + { + break; + } + } - if (json_parse_flags_allow_trailing_comma & flags_bitset) { - continue; - } else { - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; + /* if we parsed at least one element previously, grok for a comma. */ + if (allow_comma) + { + if (',' == src[state->offset]) + { + /* skip comma. */ + state->offset++; + allow_comma = 0; + } + else if (json_parse_flags_allow_no_commas & flags_bitset) + { + /* we don't require a comma, and we didn't find one, which is ok! */ + allow_comma = 0; + } + else + { + /* otherwise we are required to have a comma, and we found none. */ + state->error = json_parse_error_expected_comma_or_closing_bracket; + return 1; + } + + if (json_parse_flags_allow_trailing_comma & flags_bitset) + { + continue; + } + else + { + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } + } } - } - } - if (json_get_key_size(state)) { - /* key parsing failed! */ - state->error = json_parse_error_invalid_string; - return 1; - } + if (json_get_key_size(state)) + { + /* key parsing failed! */ + state->error = json_parse_error_invalid_string; + return 1; + } - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } - if (json_parse_flags_allow_equals_in_object & flags_bitset) { - const char current = src[state->offset]; - if ((':' != current) && ('=' != current)) { - state->error = json_parse_error_expected_colon; - return 1; - } - } else { - if (':' != src[state->offset]) { - state->error = json_parse_error_expected_colon; - return 1; - } - } + if (json_parse_flags_allow_equals_in_object & flags_bitset) + { + const char current = src[state->offset]; + if ((':' != current) && ('=' != current)) + { + state->error = json_parse_error_expected_colon; + return 1; + } + } + else + { + if (':' != src[state->offset]) + { + state->error = json_parse_error_expected_colon; + return 1; + } + } - /* skip colon. */ - state->offset++; + /* skip colon. */ + state->offset++; - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } - if (json_get_value_size(state, /* is_global_object = */ 0)) { - /* value parsing failed! */ - return 1; - } + if (json_get_value_size(state, /* is_global_object = */ 0)) + { + /* value parsing failed! */ + return 1; + } - /* successfully parsed a name/value pair! */ - elements++; - allow_comma = 1; - } while (state->offset < size); + /* successfully parsed a name/value pair! */ + elements++; + allow_comma = 1; + } while (state->offset < size); - if ((state->offset == size) && !is_global_object && !found_closing_brace) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + if ((state->offset == size) && !is_global_object && !found_closing_brace) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } - state->dom_size += sizeof(struct json_object_element_s) * elements; + state->dom_size += sizeof(struct json_object_element_s) * elements; - return 0; + return 0; } json_weak int json_get_array_size(struct json_parse_state_s *state); -int json_get_array_size(struct json_parse_state_s *state) { - const size_t flags_bitset = state->flags_bitset; - size_t elements = 0; - int allow_comma = 0; - const char *const src = state->src; - const size_t size = state->size; - - if ('[' != src[state->offset]) { - /* expected array to begin with leading '['. */ - state->error = json_parse_error_unknown; - return 1; - } +int json_get_array_size(struct json_parse_state_s *state) +{ + const size_t flags_bitset = state->flags_bitset; + size_t elements = 0; + int allow_comma = 0; + const char *const src = state->src; + const size_t size = state->size; + + if ('[' != src[state->offset]) + { + /* expected array to begin with leading '['. */ + state->error = json_parse_error_unknown; + return 1; + } - /* skip leading '['. */ - state->offset++; + /* skip leading '['. */ + state->offset++; - state->dom_size += sizeof(struct json_array_s); + state->dom_size += sizeof(struct json_array_s); - while (state->offset < size) { - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } + while (state->offset < size) + { + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } - if (']' == src[state->offset]) { - /* skip trailing ']'. */ - state->offset++; + if (']' == src[state->offset]) + { + /* skip trailing ']'. */ + state->offset++; - state->dom_size += sizeof(struct json_array_element_s) * elements; + state->dom_size += sizeof(struct json_array_element_s) * elements; - /* finished the object! */ - return 0; - } + /* finished the object! */ + return 0; + } - /* if we parsed at least once element previously, grok for a comma. */ - if (allow_comma) { - if (',' == src[state->offset]) { - /* skip comma. */ - state->offset++; - allow_comma = 0; - } else if (!(json_parse_flags_allow_no_commas & flags_bitset)) { - state->error = json_parse_error_expected_comma_or_closing_bracket; - return 1; - } + /* if we parsed at least once element previously, grok for a comma. */ + if (allow_comma) + { + if (',' == src[state->offset]) + { + /* skip comma. */ + state->offset++; + allow_comma = 0; + } + else if (!(json_parse_flags_allow_no_commas & flags_bitset)) + { + state->error = json_parse_error_expected_comma_or_closing_bracket; + return 1; + } + + if (json_parse_flags_allow_trailing_comma & flags_bitset) + { + allow_comma = 0; + continue; + } + else + { + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; + } + } + } - if (json_parse_flags_allow_trailing_comma & flags_bitset) { - allow_comma = 0; - continue; - } else { - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; + if (json_get_value_size(state, /* is_global_object = */ 0)) + { + /* value parsing failed! */ + return 1; } - } - } - if (json_get_value_size(state, /* is_global_object = */ 0)) { - /* value parsing failed! */ - return 1; + /* successfully parsed an array element! */ + elements++; + allow_comma = 1; } - /* successfully parsed an array element! */ - elements++; - allow_comma = 1; - } - - /* we consumed the entire input before finding the closing ']' of the array! - */ - state->error = json_parse_error_premature_end_of_buffer; - return 1; + /* we consumed the entire input before finding the closing ']' of the array! + */ + state->error = json_parse_error_premature_end_of_buffer; + return 1; } json_weak int json_get_number_size(struct json_parse_state_s *state); -int json_get_number_size(struct json_parse_state_s *state) { - const size_t flags_bitset = state->flags_bitset; - size_t offset = state->offset; - const size_t size = state->size; - int had_leading_digits = 0; - const char *const src = state->src; - - state->dom_size += sizeof(struct json_number_s); - - if ((json_parse_flags_allow_hexadecimal_numbers & flags_bitset) && - (offset + 1 < size) && ('0' == src[offset]) && - (('x' == src[offset + 1]) || ('X' == src[offset + 1]))) { - /* skip the leading 0x that identifies a hexadecimal number. */ - offset += 2; - - /* consume hexadecimal digits. */ - while ((offset < size) && (('0' <= src[offset] && src[offset] <= '9') || - ('a' <= src[offset] && src[offset] <= 'f') || - ('A' <= src[offset] && src[offset] <= 'F'))) { - offset++; - } - } else { - int found_sign = 0; - int inf_or_nan = 0; - - if ((offset < size) && - (('-' == src[offset]) || - ((json_parse_flags_allow_leading_plus_sign & flags_bitset) && - ('+' == src[offset])))) { - /* skip valid leading '-' or '+'. */ - offset++; - - found_sign = 1; - } - - if (json_parse_flags_allow_inf_and_nan & flags_bitset) { - const char inf[9] = "Infinity"; - const size_t inf_strlen = sizeof(inf) - 1; - const char nan[4] = "NaN"; - const size_t nan_strlen = sizeof(nan) - 1; - - if (offset + inf_strlen < size) { - int found = 1; - size_t i; - for (i = 0; i < inf_strlen; i++) { - if (inf[i] != src[offset + i]) { - found = 0; - break; - } +int json_get_number_size(struct json_parse_state_s *state) +{ + const size_t flags_bitset = state->flags_bitset; + size_t offset = state->offset; + const size_t size = state->size; + int had_leading_digits = 0; + const char *const src = state->src; + + state->dom_size += sizeof(struct json_number_s); + + if ((json_parse_flags_allow_hexadecimal_numbers & flags_bitset) && (offset + 1 < size) && ('0' == src[offset]) && + (('x' == src[offset + 1]) || ('X' == src[offset + 1]))) + { + /* skip the leading 0x that identifies a hexadecimal number. */ + offset += 2; + + /* consume hexadecimal digits. */ + while ((offset < size) && + (('0' <= src[offset] && src[offset] <= '9') || ('a' <= src[offset] && src[offset] <= 'f') || + ('A' <= src[offset] && src[offset] <= 'F'))) + { + offset++; } + } + else + { + int found_sign = 0; + int inf_or_nan = 0; - if (found) { - /* We found our special 'Infinity' keyword! */ - offset += inf_strlen; + if ((offset < size) && (('-' == src[offset]) || + ((json_parse_flags_allow_leading_plus_sign & flags_bitset) && ('+' == src[offset])))) + { + /* skip valid leading '-' or '+'. */ + offset++; - inf_or_nan = 1; + found_sign = 1; } - } - if (offset + nan_strlen < size) { - int found = 1; - size_t i; - for (i = 0; i < nan_strlen; i++) { - if (nan[i] != src[offset + i]) { - found = 0; - break; - } + if (json_parse_flags_allow_inf_and_nan & flags_bitset) + { + const char inf[9] = "Infinity"; + const size_t inf_strlen = sizeof(inf) - 1; + const char nan[4] = "NaN"; + const size_t nan_strlen = sizeof(nan) - 1; + + if (offset + inf_strlen < size) + { + int found = 1; + size_t i; + for (i = 0; i < inf_strlen; i++) + { + if (inf[i] != src[offset + i]) + { + found = 0; + break; + } + } + + if (found) + { + /* We found our special 'Infinity' keyword! */ + offset += inf_strlen; + + inf_or_nan = 1; + } + } + + if (offset + nan_strlen < size) + { + int found = 1; + size_t i; + for (i = 0; i < nan_strlen; i++) + { + if (nan[i] != src[offset + i]) + { + found = 0; + break; + } + } + + if (found) + { + /* We found our special 'NaN' keyword! */ + offset += nan_strlen; + + inf_or_nan = 1; + } + } + + if (inf_or_nan) + { + if (offset < size) + { + switch (src[offset]) + { + default: + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'e': + case 'E': + /* cannot follow an inf or nan with digits! */ + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + } + } + } } - if (found) { - /* We found our special 'NaN' keyword! */ - offset += nan_strlen; + if (found_sign && !inf_or_nan && (offset < size) && !('0' <= src[offset] && src[offset] <= '9')) + { + /* check if we are allowing leading '.'. */ + if (!(json_parse_flags_allow_leading_or_trailing_decimal_point & flags_bitset) || ('.' != src[offset])) + { + /* a leading '-' must be immediately followed by any digit! */ + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + } + } + + if ((offset < size) && ('0' == src[offset])) + { + /* skip valid '0'. */ + offset++; + + /* we need to record whether we had any leading digits for checks later. + */ + had_leading_digits = 1; + + if ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) + { + /* a leading '0' must not be immediately followed by any digit! */ + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + } + } + + /* the main digits of our number next. */ + while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) + { + offset++; + + /* we need to record whether we had any leading digits for checks later. + */ + had_leading_digits = 1; + } - inf_or_nan = 1; + if ((offset < size) && ('.' == src[offset])) + { + offset++; + + if ((offset >= size) || !('0' <= src[offset] && src[offset] <= '9')) + { + if (!(json_parse_flags_allow_leading_or_trailing_decimal_point & flags_bitset) || !had_leading_digits) + { + /* a decimal point must be followed by at least one digit. */ + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + } + } + + /* a decimal point can be followed by more digits of course! */ + while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) + { + offset++; + } } - } - if (inf_or_nan) { - if (offset < size) { - switch (src[offset]) { - default: + if ((offset < size) && ('e' == src[offset] || 'E' == src[offset])) + { + /* our number has an exponent! Skip 'e' or 'E'. */ + offset++; + + if ((offset < size) && ('-' == src[offset] || '+' == src[offset])) + { + /* skip optional '-' or '+'. */ + offset++; + } + + if ((offset < size) && !('0' <= src[offset] && src[offset] <= '9')) + { + /* an exponent must have at least one digit! */ + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + } + + /* consume exponent digits. */ + do + { + offset++; + } while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')); + } + } + + if (offset < size) + { + switch (src[offset]) + { + case ' ': + case '\t': + case '\r': + case '\n': + case '}': + case ',': + case ']': + /* all of the above are ok. */ break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'e': - case 'E': - /* cannot follow an inf or nan with digits! */ - state->error = json_parse_error_invalid_number_format; + case '=': + if (json_parse_flags_allow_equals_in_object & flags_bitset) + { + break; + } + + state->error = json_parse_error_invalid_number_format; + state->offset = offset; + return 1; + default: + state->error = json_parse_error_invalid_number_format; state->offset = offset; return 1; - } } - } } - if (found_sign && !inf_or_nan && (offset < size) && - !('0' <= src[offset] && src[offset] <= '9')) { - /* check if we are allowing leading '.'. */ - if (!(json_parse_flags_allow_leading_or_trailing_decimal_point & - flags_bitset) || - ('.' != src[offset])) { - /* a leading '-' must be immediately followed by any digit! */ - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; - } - } + state->data_size += offset - state->offset; - if ((offset < size) && ('0' == src[offset])) { - /* skip valid '0'. */ - offset++; + /* one more byte for null terminator ending the number string! */ + state->data_size++; - /* we need to record whether we had any leading digits for checks later. - */ - had_leading_digits = 1; + /* update offset. */ + state->offset = offset; - if ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) { - /* a leading '0' must not be immediately followed by any digit! */ - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; - } - } + return 0; +} - /* the main digits of our number next. */ - while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) { - offset++; +json_weak int json_get_value_size(struct json_parse_state_s *state, int is_global_object); +int json_get_value_size(struct json_parse_state_s *state, int is_global_object) +{ + const size_t flags_bitset = state->flags_bitset; + const char *const src = state->src; + size_t offset; + const size_t size = state->size; - /* we need to record whether we had any leading digits for checks later. - */ - had_leading_digits = 1; + if (json_parse_flags_allow_location_information & flags_bitset) + { + state->dom_size += sizeof(struct json_value_ex_s); + } + else + { + state->dom_size += sizeof(struct json_value_s); } - if ((offset < size) && ('.' == src[offset])) { - offset++; - - if ((offset >= size) || !('0' <= src[offset] && src[offset] <= '9')) { - if (!(json_parse_flags_allow_leading_or_trailing_decimal_point & - flags_bitset) || - !had_leading_digits) { - /* a decimal point must be followed by at least one digit. */ - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; + if (is_global_object) + { + return json_get_object_size(state, /* is_global_object = */ 1); + } + else + { + if (json_skip_all_skippables(state)) + { + state->error = json_parse_error_premature_end_of_buffer; + return 1; } - } - /* a decimal point can be followed by more digits of course! */ - while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')) { - offset++; - } + /* can cache offset now. */ + offset = state->offset; + + switch (src[offset]) + { + case '"': + return json_get_string_size(state, 0); + case '\'': + if (json_parse_flags_allow_single_quoted_strings & flags_bitset) + { + return json_get_string_size(state, 0); + } + else + { + /* invalid value! */ + state->error = json_parse_error_invalid_value; + return 1; + } + case '{': + return json_get_object_size(state, /* is_global_object = */ 0); + case '[': + return json_get_array_size(state); + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return json_get_number_size(state); + case '+': + if (json_parse_flags_allow_leading_plus_sign & flags_bitset) + { + return json_get_number_size(state); + } + else + { + /* invalid value! */ + state->error = json_parse_error_invalid_number_format; + return 1; + } + case '.': + if (json_parse_flags_allow_leading_or_trailing_decimal_point & flags_bitset) + { + return json_get_number_size(state); + } + else + { + /* invalid value! */ + state->error = json_parse_error_invalid_number_format; + return 1; + } + default: + if ((offset + 4) <= size && 't' == src[offset + 0] && 'r' == src[offset + 1] && 'u' == src[offset + 2] && + 'e' == src[offset + 3]) + { + state->offset += 4; + return 0; + } + else if ((offset + 5) <= size && 'f' == src[offset + 0] && 'a' == src[offset + 1] && + 'l' == src[offset + 2] && 's' == src[offset + 3] && 'e' == src[offset + 4]) + { + state->offset += 5; + return 0; + } + else if ((offset + 4) <= size && 'n' == state->src[offset + 0] && 'u' == state->src[offset + 1] && + 'l' == state->src[offset + 2] && 'l' == state->src[offset + 3]) + { + state->offset += 4; + return 0; + } + else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && (offset + 3) <= size && + 'N' == src[offset + 0] && 'a' == src[offset + 1] && 'N' == src[offset + 2]) + { + return json_get_number_size(state); + } + else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && (offset + 8) <= size && + 'I' == src[offset + 0] && 'n' == src[offset + 1] && 'f' == src[offset + 2] && + 'i' == src[offset + 3] && 'n' == src[offset + 4] && 'i' == src[offset + 5] && + 't' == src[offset + 6] && 'y' == src[offset + 7]) + { + return json_get_number_size(state); + } + + /* invalid value! */ + state->error = json_parse_error_invalid_value; + return 1; + } } +} - if ((offset < size) && ('e' == src[offset] || 'E' == src[offset])) { - /* our number has an exponent! Skip 'e' or 'E'. */ - offset++; - - if ((offset < size) && ('-' == src[offset] || '+' == src[offset])) { - /* skip optional '-' or '+'. */ - offset++; - } +json_weak void json_parse_value(struct json_parse_state_s *state, int is_global_object, struct json_value_s *value); - if ((offset < size) && !('0' <= src[offset] && src[offset] <= '9')) { - /* an exponent must have at least one digit! */ - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; - } +json_weak void json_parse_string(struct json_parse_state_s *state, struct json_string_s *string); +void json_parse_string(struct json_parse_state_s *state, struct json_string_s *string) +{ + size_t offset = state->offset; + size_t bytes_written = 0; + const char *const src = state->src; + const char quote_to_use = '\'' == src[offset] ? '\'' : '"'; + char *data = state->data; + unsigned long high_surrogate = 0; + unsigned long codepoint; - /* consume exponent digits. */ - do { - offset++; - } while ((offset < size) && ('0' <= src[offset] && src[offset] <= '9')); - } - } + string->string = data; - if (offset < size) { - switch (src[offset]) { - case ' ': - case '\t': - case '\r': - case '\n': - case '}': - case ',': - case ']': - /* all of the above are ok. */ - break; - case '=': - if (json_parse_flags_allow_equals_in_object & flags_bitset) { - break; - } + /* skip leading '"' or '\''. */ + offset++; - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; - default: - state->error = json_parse_error_invalid_number_format; - state->offset = offset; - return 1; + while (quote_to_use != src[offset]) + { + if ('\\' == src[offset]) + { + /* skip the reverse solidus. */ + offset++; + + switch (src[offset++]) + { + default: + return; /* we cannot ever reach here. */ + case 'u': { + codepoint = 0; + if (!json_hexadecimal_value(&src[offset], 4, &codepoint)) + { + return; /* this shouldn't happen as the value was already validated. + */ + } + + offset += 4; + + if (codepoint <= 0x7fu) + { + data[bytes_written++] = (char)codepoint; /* 0xxxxxxx. */ + } + else if (codepoint <= 0x7ffu) + { + data[bytes_written++] = (char)(0xc0u | (codepoint >> 6)); /* 110xxxxx. */ + data[bytes_written++] = (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ + } + else if (codepoint >= 0xd800 && codepoint <= 0xdbff) + { /* high surrogate. */ + high_surrogate = codepoint; + continue; /* we need the low half to form a complete codepoint. */ + } + else if (codepoint >= 0xdc00 && codepoint <= 0xdfff) + { /* low surrogate. */ + /* combine with the previously read half to obtain the complete + * codepoint. */ + const unsigned long surrogate_offset = 0x10000u - (0xD800u << 10) - 0xDC00u; + codepoint = (high_surrogate << 10) + codepoint + surrogate_offset; + high_surrogate = 0; + data[bytes_written++] = (char)(0xF0u | (codepoint >> 18)); /* 11110xxx. */ + data[bytes_written++] = (char)(0x80u | ((codepoint >> 12) & 0x3fu)); /* 10xxxxxx. */ + data[bytes_written++] = (char)(0x80u | ((codepoint >> 6) & 0x3fu)); /* 10xxxxxx. */ + data[bytes_written++] = (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ + } + else + { + /* we assume the value was validated and thus is within the valid + * range. */ + data[bytes_written++] = (char)(0xe0u | (codepoint >> 12)); /* 1110xxxx. */ + data[bytes_written++] = (char)(0x80u | ((codepoint >> 6) & 0x3fu)); /* 10xxxxxx. */ + data[bytes_written++] = (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ + } + } + break; + case '"': + data[bytes_written++] = '"'; + break; + case '\\': + data[bytes_written++] = '\\'; + break; + case '/': + data[bytes_written++] = '/'; + break; + case 'b': + data[bytes_written++] = '\b'; + break; + case 'f': + data[bytes_written++] = '\f'; + break; + case 'n': + data[bytes_written++] = '\n'; + break; + case 'r': + data[bytes_written++] = '\r'; + break; + case 't': + data[bytes_written++] = '\t'; + break; + case '\r': + data[bytes_written++] = '\r'; + + /* check if we have a "\r\n" sequence. */ + if ('\n' == src[offset]) + { + data[bytes_written++] = '\n'; + offset++; + } + + break; + case '\n': + data[bytes_written++] = '\n'; + break; + } + } + else + { + /* copy the character. */ + data[bytes_written++] = src[offset++]; + } } - } - - state->data_size += offset - state->offset; - /* one more byte for null terminator ending the number string! */ - state->data_size++; + /* skip trailing '"' or '\''. */ + offset++; - /* update offset. */ - state->offset = offset; + /* record the size of the string. */ + string->string_size = bytes_written; - return 0; -} + /* add null terminator to string. */ + data[bytes_written++] = '\0'; -json_weak int json_get_value_size(struct json_parse_state_s *state, - int is_global_object); -int json_get_value_size(struct json_parse_state_s *state, - int is_global_object) { - const size_t flags_bitset = state->flags_bitset; - const char *const src = state->src; - size_t offset; - const size_t size = state->size; - - if (json_parse_flags_allow_location_information & flags_bitset) { - state->dom_size += sizeof(struct json_value_ex_s); - } else { - state->dom_size += sizeof(struct json_value_s); - } - - if (is_global_object) { - return json_get_object_size(state, /* is_global_object = */ 1); - } else { - if (json_skip_all_skippables(state)) { - state->error = json_parse_error_premature_end_of_buffer; - return 1; - } - - /* can cache offset now. */ - offset = state->offset; + /* move data along. */ + state->data += bytes_written; - switch (src[offset]) { - case '"': - return json_get_string_size(state, 0); - case '\'': - if (json_parse_flags_allow_single_quoted_strings & flags_bitset) { - return json_get_string_size(state, 0); - } else { - /* invalid value! */ - state->error = json_parse_error_invalid_value; - return 1; - } - case '{': - return json_get_object_size(state, /* is_global_object = */ 0); - case '[': - return json_get_array_size(state); - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return json_get_number_size(state); - case '+': - if (json_parse_flags_allow_leading_plus_sign & flags_bitset) { - return json_get_number_size(state); - } else { - /* invalid value! */ - state->error = json_parse_error_invalid_number_format; - return 1; - } - case '.': - if (json_parse_flags_allow_leading_or_trailing_decimal_point & - flags_bitset) { - return json_get_number_size(state); - } else { - /* invalid value! */ - state->error = json_parse_error_invalid_number_format; - return 1; - } - default: - if ((offset + 4) <= size && 't' == src[offset + 0] && - 'r' == src[offset + 1] && 'u' == src[offset + 2] && - 'e' == src[offset + 3]) { - state->offset += 4; - return 0; - } else if ((offset + 5) <= size && 'f' == src[offset + 0] && - 'a' == src[offset + 1] && 'l' == src[offset + 2] && - 's' == src[offset + 3] && 'e' == src[offset + 4]) { - state->offset += 5; - return 0; - } else if ((offset + 4) <= size && 'n' == state->src[offset + 0] && - 'u' == state->src[offset + 1] && - 'l' == state->src[offset + 2] && - 'l' == state->src[offset + 3]) { - state->offset += 4; - return 0; - } else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && - (offset + 3) <= size && 'N' == src[offset + 0] && - 'a' == src[offset + 1] && 'N' == src[offset + 2]) { - return json_get_number_size(state); - } else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && - (offset + 8) <= size && 'I' == src[offset + 0] && - 'n' == src[offset + 1] && 'f' == src[offset + 2] && - 'i' == src[offset + 3] && 'n' == src[offset + 4] && - 'i' == src[offset + 5] && 't' == src[offset + 6] && - 'y' == src[offset + 7]) { - return json_get_number_size(state); - } - - /* invalid value! */ - state->error = json_parse_error_invalid_value; - return 1; - } - } + /* update offset. */ + state->offset = offset; } -json_weak void json_parse_value(struct json_parse_state_s *state, - int is_global_object, - struct json_value_s *value); - -json_weak void json_parse_string(struct json_parse_state_s *state, - struct json_string_s *string); -void json_parse_string(struct json_parse_state_s *state, - struct json_string_s *string) { - size_t offset = state->offset; - size_t bytes_written = 0; - const char *const src = state->src; - const char quote_to_use = '\'' == src[offset] ? '\'' : '"'; - char *data = state->data; - unsigned long high_surrogate = 0; - unsigned long codepoint; - - string->string = data; - - /* skip leading '"' or '\''. */ - offset++; - - while (quote_to_use != src[offset]) { - if ('\\' == src[offset]) { - /* skip the reverse solidus. */ - offset++; - - switch (src[offset++]) { - default: - return; /* we cannot ever reach here. */ - case 'u': { - codepoint = 0; - if (!json_hexadecimal_value(&src[offset], 4, &codepoint)) { - return; /* this shouldn't happen as the value was already validated. - */ - } - - offset += 4; - - if (codepoint <= 0x7fu) { - data[bytes_written++] = (char)codepoint; /* 0xxxxxxx. */ - } else if (codepoint <= 0x7ffu) { - data[bytes_written++] = - (char)(0xc0u | (codepoint >> 6)); /* 110xxxxx. */ - data[bytes_written++] = - (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ - } else if (codepoint >= 0xd800 && - codepoint <= 0xdbff) { /* high surrogate. */ - high_surrogate = codepoint; - continue; /* we need the low half to form a complete codepoint. */ - } else if (codepoint >= 0xdc00 && - codepoint <= 0xdfff) { /* low surrogate. */ - /* combine with the previously read half to obtain the complete - * codepoint. */ - const unsigned long surrogate_offset = - 0x10000u - (0xD800u << 10) - 0xDC00u; - codepoint = (high_surrogate << 10) + codepoint + surrogate_offset; - high_surrogate = 0; - data[bytes_written++] = - (char)(0xF0u | (codepoint >> 18)); /* 11110xxx. */ - data[bytes_written++] = - (char)(0x80u | ((codepoint >> 12) & 0x3fu)); /* 10xxxxxx. */ - data[bytes_written++] = - (char)(0x80u | ((codepoint >> 6) & 0x3fu)); /* 10xxxxxx. */ - data[bytes_written++] = - (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ - } else { - /* we assume the value was validated and thus is within the valid - * range. */ - data[bytes_written++] = - (char)(0xe0u | (codepoint >> 12)); /* 1110xxxx. */ - data[bytes_written++] = - (char)(0x80u | ((codepoint >> 6) & 0x3fu)); /* 10xxxxxx. */ - data[bytes_written++] = - (char)(0x80u | (codepoint & 0x3fu)); /* 10xxxxxx. */ - } - } break; - case '"': - data[bytes_written++] = '"'; - break; - case '\\': - data[bytes_written++] = '\\'; - break; - case '/': - data[bytes_written++] = '/'; - break; - case 'b': - data[bytes_written++] = '\b'; - break; - case 'f': - data[bytes_written++] = '\f'; - break; - case 'n': - data[bytes_written++] = '\n'; - break; - case 'r': - data[bytes_written++] = '\r'; - break; - case 't': - data[bytes_written++] = '\t'; - break; - case '\r': - data[bytes_written++] = '\r'; - - /* check if we have a "\r\n" sequence. */ - if ('\n' == src[offset]) { - data[bytes_written++] = '\n'; - offset++; +json_weak void json_parse_key(struct json_parse_state_s *state, struct json_string_s *string); +void json_parse_key(struct json_parse_state_s *state, struct json_string_s *string) +{ + if (json_parse_flags_allow_unquoted_keys & state->flags_bitset) + { + const char *const src = state->src; + char *const data = state->data; + size_t offset = state->offset; + + /* if we are allowing unquoted keys, check for quoted anyway... */ + if (('"' == src[offset]) || ('\'' == src[offset])) + { + /* ... if we got a quote, just parse the key as a string as normal. */ + json_parse_string(state, string); } + else + { + size_t size = 0; - break; - case '\n': - data[bytes_written++] = '\n'; - break; - } - } else { - /* copy the character. */ - data[bytes_written++] = src[offset++]; - } - } + string->string = state->data; - /* skip trailing '"' or '\''. */ - offset++; + while (is_valid_unquoted_key_char(src[offset])) + { + data[size++] = src[offset++]; + } - /* record the size of the string. */ - string->string_size = bytes_written; + /* add null terminator to string. */ + data[size] = '\0'; - /* add null terminator to string. */ - data[bytes_written++] = '\0'; + /* record the size of the string. */ + string->string_size = size++; - /* move data along. */ - state->data += bytes_written; + /* move data along. */ + state->data += size; - /* update offset. */ - state->offset = offset; + /* update offset. */ + state->offset = offset; + } + } + else + { + /* we are only allowed to have quoted keys, so just parse a string! */ + json_parse_string(state, string); + } } -json_weak void json_parse_key(struct json_parse_state_s *state, - struct json_string_s *string); -void json_parse_key(struct json_parse_state_s *state, - struct json_string_s *string) { - if (json_parse_flags_allow_unquoted_keys & state->flags_bitset) { - const char *const src = state->src; - char *const data = state->data; - size_t offset = state->offset; +json_weak void json_parse_object(struct json_parse_state_s *state, int is_global_object, struct json_object_s *object); +void json_parse_object(struct json_parse_state_s *state, int is_global_object, struct json_object_s *object) +{ + const size_t flags_bitset = state->flags_bitset; + const size_t size = state->size; + const char *const src = state->src; + size_t elements = 0; + int allow_comma = 0; + struct json_object_element_s *previous = json_null; + + if (is_global_object) + { + /* if we skipped some whitespace, and then found an opening '{' of an. */ + /* object, we actually have a normal JSON object at the root of the DOM... + */ + if ('{' == src[state->offset]) + { + /* . and we don't actually have a global object after all! */ + is_global_object = 0; + } + } - /* if we are allowing unquoted keys, check for quoted anyway... */ - if (('"' == src[offset]) || ('\'' == src[offset])) { - /* ... if we got a quote, just parse the key as a string as normal. */ - json_parse_string(state, string); - } else { - size_t size = 0; + if (!is_global_object) + { + /* skip leading '{'. */ + state->offset++; + } - string->string = state->data; + (void)json_skip_all_skippables(state); - while (is_valid_unquoted_key_char(src[offset])) { - data[size++] = src[offset++]; - } + /* reset elements. */ + elements = 0; - /* add null terminator to string. */ - data[size] = '\0'; + while (state->offset < size) + { + struct json_object_element_s *element = json_null; + struct json_string_s *string = json_null; + struct json_value_s *value = json_null; - /* record the size of the string. */ - string->string_size = size++; + if (!is_global_object) + { + (void)json_skip_all_skippables(state); - /* move data along. */ - state->data += size; + if ('}' == src[state->offset]) + { + /* skip trailing '}'. */ + state->offset++; - /* update offset. */ - state->offset = offset; - } - } else { - /* we are only allowed to have quoted keys, so just parse a string! */ - json_parse_string(state, string); - } -} + /* finished the object! */ + break; + } + } + else + { + if (json_skip_all_skippables(state)) + { + /* global object ends when the file ends! */ + break; + } + } -json_weak void json_parse_object(struct json_parse_state_s *state, - int is_global_object, - struct json_object_s *object); -void json_parse_object(struct json_parse_state_s *state, int is_global_object, - struct json_object_s *object) { - const size_t flags_bitset = state->flags_bitset; - const size_t size = state->size; - const char *const src = state->src; - size_t elements = 0; - int allow_comma = 0; - struct json_object_element_s *previous = json_null; - - if (is_global_object) { - /* if we skipped some whitespace, and then found an opening '{' of an. */ - /* object, we actually have a normal JSON object at the root of the DOM... - */ - if ('{' == src[state->offset]) { - /* . and we don't actually have a global object after all! */ - is_global_object = 0; - } - } + /* if we parsed at least one element previously, grok for a comma. */ + if (allow_comma) + { + if (',' == src[state->offset]) + { + /* skip comma. */ + state->offset++; + allow_comma = 0; + continue; + } + } - if (!is_global_object) { - /* skip leading '{'. */ - state->offset++; - } + element = (struct json_object_element_s *)state->dom; - (void)json_skip_all_skippables(state); + state->dom += sizeof(struct json_object_element_s); - /* reset elements. */ - elements = 0; + if (json_null == previous) + { + /* this is our first element, so record it in our object. */ + object->start = element; + } + else + { + previous->next = element; + } - while (state->offset < size) { - struct json_object_element_s *element = json_null; - struct json_string_s *string = json_null; - struct json_value_s *value = json_null; + previous = element; - if (!is_global_object) { - (void)json_skip_all_skippables(state); + if (json_parse_flags_allow_location_information & flags_bitset) + { + struct json_string_ex_s *string_ex = (struct json_string_ex_s *)state->dom; + state->dom += sizeof(struct json_string_ex_s); - if ('}' == src[state->offset]) { - /* skip trailing '}'. */ - state->offset++; + string_ex->offset = state->offset; + string_ex->line_no = state->line_no; + string_ex->row_no = state->offset - state->line_offset; - /* finished the object! */ - break; - } - } else { - if (json_skip_all_skippables(state)) { - /* global object ends when the file ends! */ - break; - } - } + string = &(string_ex->string); + } + else + { + string = (struct json_string_s *)state->dom; + state->dom += sizeof(struct json_string_s); + } + + element->name = string; - /* if we parsed at least one element previously, grok for a comma. */ - if (allow_comma) { - if (',' == src[state->offset]) { - /* skip comma. */ + (void)json_parse_key(state, string); + + (void)json_skip_all_skippables(state); + + /* skip colon or equals. */ state->offset++; - allow_comma = 0; - continue; - } - } - element = (struct json_object_element_s *)state->dom; + (void)json_skip_all_skippables(state); - state->dom += sizeof(struct json_object_element_s); + if (json_parse_flags_allow_location_information & flags_bitset) + { + struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state->dom; + state->dom += sizeof(struct json_value_ex_s); - if (json_null == previous) { - /* this is our first element, so record it in our object. */ - object->start = element; - } else { - previous->next = element; - } + value_ex->offset = state->offset; + value_ex->line_no = state->line_no; + value_ex->row_no = state->offset - state->line_offset; - previous = element; + value = &(value_ex->value); + } + else + { + value = (struct json_value_s *)state->dom; + state->dom += sizeof(struct json_value_s); + } - if (json_parse_flags_allow_location_information & flags_bitset) { - struct json_string_ex_s *string_ex = - (struct json_string_ex_s *)state->dom; - state->dom += sizeof(struct json_string_ex_s); + element->value = value; - string_ex->offset = state->offset; - string_ex->line_no = state->line_no; - string_ex->row_no = state->offset - state->line_offset; + json_parse_value(state, /* is_global_object = */ 0, value); - string = &(string_ex->string); - } else { - string = (struct json_string_s *)state->dom; - state->dom += sizeof(struct json_string_s); + /* successfully parsed a name/value pair! */ + elements++; + allow_comma = 1; } - element->name = string; + /* if we had at least one element, end the linked list. */ + if (previous) + { + previous->next = json_null; + } - (void)json_parse_key(state, string); + if (0 == elements) + { + object->start = json_null; + } - (void)json_skip_all_skippables(state); + object->length = elements; +} + +json_weak void json_parse_array(struct json_parse_state_s *state, struct json_array_s *array); +void json_parse_array(struct json_parse_state_s *state, struct json_array_s *array) +{ + const char *const src = state->src; + const size_t size = state->size; + size_t elements = 0; + int allow_comma = 0; + struct json_array_element_s *previous = json_null; - /* skip colon or equals. */ + /* skip leading '['. */ state->offset++; (void)json_skip_all_skippables(state); - if (json_parse_flags_allow_location_information & flags_bitset) { - struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state->dom; - state->dom += sizeof(struct json_value_ex_s); + /* reset elements. */ + elements = 0; - value_ex->offset = state->offset; - value_ex->line_no = state->line_no; - value_ex->row_no = state->offset - state->line_offset; + do + { + struct json_array_element_s *element = json_null; + struct json_value_s *value = json_null; - value = &(value_ex->value); - } else { - value = (struct json_value_s *)state->dom; - state->dom += sizeof(struct json_value_s); - } + (void)json_skip_all_skippables(state); - element->value = value; + if (']' == src[state->offset]) + { + /* skip trailing ']'. */ + state->offset++; - json_parse_value(state, /* is_global_object = */ 0, value); + /* finished the array! */ + break; + } - /* successfully parsed a name/value pair! */ - elements++; - allow_comma = 1; - } + /* if we parsed at least one element previously, grok for a comma. */ + if (allow_comma) + { + if (',' == src[state->offset]) + { + /* skip comma. */ + state->offset++; + allow_comma = 0; + continue; + } + } - /* if we had at least one element, end the linked list. */ - if (previous) { - previous->next = json_null; - } + element = (struct json_array_element_s *)state->dom; - if (0 == elements) { - object->start = json_null; - } + state->dom += sizeof(struct json_array_element_s); - object->length = elements; -} + if (json_null == previous) + { + /* this is our first element, so record it in our array. */ + array->start = element; + } + else + { + previous->next = element; + } -json_weak void json_parse_array(struct json_parse_state_s *state, - struct json_array_s *array); -void json_parse_array(struct json_parse_state_s *state, - struct json_array_s *array) { - const char *const src = state->src; - const size_t size = state->size; - size_t elements = 0; - int allow_comma = 0; - struct json_array_element_s *previous = json_null; + previous = element; - /* skip leading '['. */ - state->offset++; + if (json_parse_flags_allow_location_information & state->flags_bitset) + { + struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state->dom; + state->dom += sizeof(struct json_value_ex_s); - (void)json_skip_all_skippables(state); + value_ex->offset = state->offset; + value_ex->line_no = state->line_no; + value_ex->row_no = state->offset - state->line_offset; - /* reset elements. */ - elements = 0; + value = &(value_ex->value); + } + else + { + value = (struct json_value_s *)state->dom; + state->dom += sizeof(struct json_value_s); + } - do { - struct json_array_element_s *element = json_null; - struct json_value_s *value = json_null; + element->value = value; - (void)json_skip_all_skippables(state); + json_parse_value(state, /* is_global_object = */ 0, value); - if (']' == src[state->offset]) { - /* skip trailing ']'. */ - state->offset++; + /* successfully parsed an array element! */ + elements++; + allow_comma = 1; + } while (state->offset < size); - /* finished the array! */ - break; + /* end the linked list. */ + if (previous) + { + previous->next = json_null; } - /* if we parsed at least one element previously, grok for a comma. */ - if (allow_comma) { - if (',' == src[state->offset]) { - /* skip comma. */ - state->offset++; - allow_comma = 0; - continue; - } + if (0 == elements) + { + array->start = json_null; } - element = (struct json_array_element_s *)state->dom; - - state->dom += sizeof(struct json_array_element_s); + array->length = elements; +} - if (json_null == previous) { - /* this is our first element, so record it in our array. */ - array->start = element; - } else { - previous->next = element; +json_weak void json_parse_number(struct json_parse_state_s *state, struct json_number_s *number); +void json_parse_number(struct json_parse_state_s *state, struct json_number_s *number) +{ + const size_t flags_bitset = state->flags_bitset; + size_t offset = state->offset; + const size_t size = state->size; + size_t bytes_written = 0; + const char *const src = state->src; + char *data = state->data; + + number->number = data; + + if (json_parse_flags_allow_hexadecimal_numbers & flags_bitset) + { + if (('0' == src[offset]) && (('x' == src[offset + 1]) || ('X' == src[offset + 1]))) + { + /* consume hexadecimal digits. */ + while ((offset < size) && + (('0' <= src[offset] && src[offset] <= '9') || ('a' <= src[offset] && src[offset] <= 'f') || + ('A' <= src[offset] && src[offset] <= 'F') || ('x' == src[offset]) || ('X' == src[offset]))) + { + data[bytes_written++] = src[offset++]; + } + } } - previous = element; + while (offset < size) + { + int end = 0; + + switch (src[offset]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + case 'e': + case 'E': + case '+': + case '-': + data[bytes_written++] = src[offset++]; + break; + default: + end = 1; + break; + } - if (json_parse_flags_allow_location_information & state->flags_bitset) { - struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state->dom; - state->dom += sizeof(struct json_value_ex_s); + if (0 != end) + { + break; + } + } - value_ex->offset = state->offset; - value_ex->line_no = state->line_no; - value_ex->row_no = state->offset - state->line_offset; + if (json_parse_flags_allow_inf_and_nan & flags_bitset) + { + const size_t inf_strlen = 8; /* = strlen("Infinity");. */ + const size_t nan_strlen = 3; /* = strlen("NaN");. */ + + if (offset + inf_strlen < size) + { + if ('I' == src[offset]) + { + size_t i; + /* We found our special 'Infinity' keyword! */ + for (i = 0; i < inf_strlen; i++) + { + data[bytes_written++] = src[offset++]; + } + } + } - value = &(value_ex->value); - } else { - value = (struct json_value_s *)state->dom; - state->dom += sizeof(struct json_value_s); + if (offset + nan_strlen < size) + { + if ('N' == src[offset]) + { + size_t i; + /* We found our special 'NaN' keyword! */ + for (i = 0; i < nan_strlen; i++) + { + data[bytes_written++] = src[offset++]; + } + } + } } - element->value = value; - - json_parse_value(state, /* is_global_object = */ 0, value); + /* record the size of the number. */ + number->number_size = bytes_written; + /* add null terminator to number string. */ + data[bytes_written++] = '\0'; + /* move data along. */ + state->data += bytes_written; + /* update offset. */ + state->offset = offset; +} - /* successfully parsed an array element! */ - elements++; - allow_comma = 1; - } while (state->offset < size); +json_weak void json_parse_value(struct json_parse_state_s *state, int is_global_object, struct json_value_s *value); +void json_parse_value(struct json_parse_state_s *state, int is_global_object, struct json_value_s *value) +{ + const size_t flags_bitset = state->flags_bitset; + const char *const src = state->src; + const size_t size = state->size; + size_t offset; - /* end the linked list. */ - if (previous) { - previous->next = json_null; - } + (void)json_skip_all_skippables(state); - if (0 == elements) { - array->start = json_null; - } + /* cache offset now. */ + offset = state->offset; - array->length = elements; + if (is_global_object) + { + value->type = json_type_object; + value->payload = state->dom; + state->dom += sizeof(struct json_object_s); + json_parse_object(state, /* is_global_object = */ 1, (struct json_object_s *)value->payload); + } + else + { + switch (src[offset]) + { + case '"': + case '\'': + value->type = json_type_string; + value->payload = state->dom; + state->dom += sizeof(struct json_string_s); + json_parse_string(state, (struct json_string_s *)value->payload); + break; + case '{': + value->type = json_type_object; + value->payload = state->dom; + state->dom += sizeof(struct json_object_s); + json_parse_object(state, /* is_global_object = */ 0, (struct json_object_s *)value->payload); + break; + case '[': + value->type = json_type_array; + value->payload = state->dom; + state->dom += sizeof(struct json_array_s); + json_parse_array(state, (struct json_array_s *)value->payload); + break; + case '-': + case '+': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + value->type = json_type_number; + value->payload = state->dom; + state->dom += sizeof(struct json_number_s); + json_parse_number(state, (struct json_number_s *)value->payload); + break; + default: + if ((offset + 4) <= size && 't' == src[offset + 0] && 'r' == src[offset + 1] && 'u' == src[offset + 2] && + 'e' == src[offset + 3]) + { + value->type = json_type_true; + value->payload = json_null; + state->offset += 4; + } + else if ((offset + 5) <= size && 'f' == src[offset + 0] && 'a' == src[offset + 1] && + 'l' == src[offset + 2] && 's' == src[offset + 3] && 'e' == src[offset + 4]) + { + value->type = json_type_false; + value->payload = json_null; + state->offset += 5; + } + else if ((offset + 4) <= size && 'n' == src[offset + 0] && 'u' == src[offset + 1] && + 'l' == src[offset + 2] && 'l' == src[offset + 3]) + { + value->type = json_type_null; + value->payload = json_null; + state->offset += 4; + } + else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && (offset + 3) <= size && + 'N' == src[offset + 0] && 'a' == src[offset + 1] && 'N' == src[offset + 2]) + { + value->type = json_type_number; + value->payload = state->dom; + state->dom += sizeof(struct json_number_s); + json_parse_number(state, (struct json_number_s *)value->payload); + } + else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && (offset + 8) <= size && + 'I' == src[offset + 0] && 'n' == src[offset + 1] && 'f' == src[offset + 2] && + 'i' == src[offset + 3] && 'n' == src[offset + 4] && 'i' == src[offset + 5] && + 't' == src[offset + 6] && 'y' == src[offset + 7]) + { + value->type = json_type_number; + value->payload = state->dom; + state->dom += sizeof(struct json_number_s); + json_parse_number(state, (struct json_number_s *)value->payload); + } + break; + } + } } -json_weak void json_parse_number(struct json_parse_state_s *state, - struct json_number_s *number); -void json_parse_number(struct json_parse_state_s *state, - struct json_number_s *number) { - const size_t flags_bitset = state->flags_bitset; - size_t offset = state->offset; - const size_t size = state->size; - size_t bytes_written = 0; - const char *const src = state->src; - char *data = state->data; - - number->number = data; - - if (json_parse_flags_allow_hexadecimal_numbers & flags_bitset) { - if (('0' == src[offset]) && - (('x' == src[offset + 1]) || ('X' == src[offset + 1]))) { - /* consume hexadecimal digits. */ - while ((offset < size) && - (('0' <= src[offset] && src[offset] <= '9') || - ('a' <= src[offset] && src[offset] <= 'f') || - ('A' <= src[offset] && src[offset] <= 'F') || - ('x' == src[offset]) || ('X' == src[offset]))) { - data[bytes_written++] = src[offset++]; - } - } - } - - while (offset < size) { - int end = 0; - - switch (src[offset]) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '.': - case 'e': - case 'E': - case '+': - case '-': - data[bytes_written++] = src[offset++]; - break; - default: - end = 1; - break; +struct json_value_s *json_parse_ex(const void *src, size_t src_size, size_t flags_bitset, + void *(*alloc_func_ptr)(void *user_data, size_t size), void *user_data, + struct json_parse_result_s *result) +{ + struct json_parse_state_s state; + void *allocation; + struct json_value_s *value; + size_t total_size; + int input_error; + + if (result) + { + result->error = json_parse_error_none; + result->error_offset = 0; + result->error_line_no = 0; + result->error_row_no = 0; + } + + if (json_null == src) + { + /* invalid src pointer was null! */ + return json_null; } - if (0 != end) { - break; - } - } + state.src = (const char *)src; + state.size = src_size; + state.offset = 0; + state.line_no = 1; + state.line_offset = 0; + state.error = json_parse_error_none; + state.dom_size = 0; + state.data_size = 0; + state.flags_bitset = flags_bitset; + + input_error = json_get_value_size(&state, (int)(json_parse_flags_allow_global_object & state.flags_bitset)); + + if (0 == input_error) + { + json_skip_all_skippables(&state); - if (json_parse_flags_allow_inf_and_nan & flags_bitset) { - const size_t inf_strlen = 8; /* = strlen("Infinity");. */ - const size_t nan_strlen = 3; /* = strlen("NaN");. */ + if (state.offset != state.size) + { + /* our parsing didn't have an error, but there are characters remaining in + * the input that weren't part of the JSON! */ - if (offset + inf_strlen < size) { - if ('I' == src[offset]) { - size_t i; - /* We found our special 'Infinity' keyword! */ - for (i = 0; i < inf_strlen; i++) { - data[bytes_written++] = src[offset++]; + state.error = json_parse_error_unexpected_trailing_characters; + input_error = 1; } - } } - if (offset + nan_strlen < size) { - if ('N' == src[offset]) { - size_t i; - /* We found our special 'NaN' keyword! */ - for (i = 0; i < nan_strlen; i++) { - data[bytes_written++] = src[offset++]; + if (input_error) + { + /* parsing value's size failed (most likely an invalid JSON DOM!). */ + if (result) + { + result->error = state.error; + result->error_offset = state.offset; + result->error_line_no = state.line_no; + result->error_row_no = state.offset - state.line_offset; } - } + return json_null; } - } - /* record the size of the number. */ - number->number_size = bytes_written; - /* add null terminator to number string. */ - data[bytes_written++] = '\0'; - /* move data along. */ - state->data += bytes_written; - /* update offset. */ - state->offset = offset; -} + /* our total allocation is the combination of the dom and data sizes (we. */ + /* first encode the structure of the JSON, and then the data referenced by. */ + /* the JSON values). */ + total_size = state.dom_size + state.data_size; -json_weak void json_parse_value(struct json_parse_state_s *state, - int is_global_object, - struct json_value_s *value); -void json_parse_value(struct json_parse_state_s *state, int is_global_object, - struct json_value_s *value) { - const size_t flags_bitset = state->flags_bitset; - const char *const src = state->src; - const size_t size = state->size; - size_t offset; - - (void)json_skip_all_skippables(state); - - /* cache offset now. */ - offset = state->offset; - - if (is_global_object) { - value->type = json_type_object; - value->payload = state->dom; - state->dom += sizeof(struct json_object_s); - json_parse_object(state, /* is_global_object = */ 1, - (struct json_object_s *)value->payload); - } else { - switch (src[offset]) { - case '"': - case '\'': - value->type = json_type_string; - value->payload = state->dom; - state->dom += sizeof(struct json_string_s); - json_parse_string(state, (struct json_string_s *)value->payload); - break; - case '{': - value->type = json_type_object; - value->payload = state->dom; - state->dom += sizeof(struct json_object_s); - json_parse_object(state, /* is_global_object = */ 0, - (struct json_object_s *)value->payload); - break; - case '[': - value->type = json_type_array; - value->payload = state->dom; - state->dom += sizeof(struct json_array_s); - json_parse_array(state, (struct json_array_s *)value->payload); - break; - case '-': - case '+': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '.': - value->type = json_type_number; - value->payload = state->dom; - state->dom += sizeof(struct json_number_s); - json_parse_number(state, (struct json_number_s *)value->payload); - break; - default: - if ((offset + 4) <= size && 't' == src[offset + 0] && - 'r' == src[offset + 1] && 'u' == src[offset + 2] && - 'e' == src[offset + 3]) { - value->type = json_type_true; - value->payload = json_null; - state->offset += 4; - } else if ((offset + 5) <= size && 'f' == src[offset + 0] && - 'a' == src[offset + 1] && 'l' == src[offset + 2] && - 's' == src[offset + 3] && 'e' == src[offset + 4]) { - value->type = json_type_false; - value->payload = json_null; - state->offset += 5; - } else if ((offset + 4) <= size && 'n' == src[offset + 0] && - 'u' == src[offset + 1] && 'l' == src[offset + 2] && - 'l' == src[offset + 3]) { - value->type = json_type_null; - value->payload = json_null; - state->offset += 4; - } else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && - (offset + 3) <= size && 'N' == src[offset + 0] && - 'a' == src[offset + 1] && 'N' == src[offset + 2]) { - value->type = json_type_number; - value->payload = state->dom; - state->dom += sizeof(struct json_number_s); - json_parse_number(state, (struct json_number_s *)value->payload); - } else if ((json_parse_flags_allow_inf_and_nan & flags_bitset) && - (offset + 8) <= size && 'I' == src[offset + 0] && - 'n' == src[offset + 1] && 'f' == src[offset + 2] && - 'i' == src[offset + 3] && 'n' == src[offset + 4] && - 'i' == src[offset + 5] && 't' == src[offset + 6] && - 'y' == src[offset + 7]) { - value->type = json_type_number; - value->payload = state->dom; - state->dom += sizeof(struct json_number_s); - json_parse_number(state, (struct json_number_s *)value->payload); - } - break; + if (json_null == alloc_func_ptr) + { + allocation = malloc(total_size); + } + else + { + allocation = alloc_func_ptr(user_data, total_size); + } + + if (json_null == allocation) + { + /* malloc failed! */ + if (result) + { + result->error = json_parse_error_allocator_failed; + result->error_offset = 0; + result->error_line_no = 0; + result->error_row_no = 0; + } + + return json_null; } - } -} -struct json_value_s * -json_parse_ex(const void *src, size_t src_size, size_t flags_bitset, - void *(*alloc_func_ptr)(void *user_data, size_t size), - void *user_data, struct json_parse_result_s *result) { - struct json_parse_state_s state; - void *allocation; - struct json_value_s *value; - size_t total_size; - int input_error; - - if (result) { - result->error = json_parse_error_none; - result->error_offset = 0; - result->error_line_no = 0; - result->error_row_no = 0; - } - - if (json_null == src) { - /* invalid src pointer was null! */ - return json_null; - } - - state.src = (const char *)src; - state.size = src_size; - state.offset = 0; - state.line_no = 1; - state.line_offset = 0; - state.error = json_parse_error_none; - state.dom_size = 0; - state.data_size = 0; - state.flags_bitset = flags_bitset; - - input_error = json_get_value_size( - &state, (int)(json_parse_flags_allow_global_object & state.flags_bitset)); - - if (0 == input_error) { - json_skip_all_skippables(&state); - - if (state.offset != state.size) { - /* our parsing didn't have an error, but there are characters remaining in - * the input that weren't part of the JSON! */ - - state.error = json_parse_error_unexpected_trailing_characters; - input_error = 1; - } - } - - if (input_error) { - /* parsing value's size failed (most likely an invalid JSON DOM!). */ - if (result) { - result->error = state.error; - result->error_offset = state.offset; - result->error_line_no = state.line_no; - result->error_row_no = state.offset - state.line_offset; - } - return json_null; - } - - /* our total allocation is the combination of the dom and data sizes (we. */ - /* first encode the structure of the JSON, and then the data referenced by. */ - /* the JSON values). */ - total_size = state.dom_size + state.data_size; - - if (json_null == alloc_func_ptr) { - allocation = malloc(total_size); - } else { - allocation = alloc_func_ptr(user_data, total_size); - } - - if (json_null == allocation) { - /* malloc failed! */ - if (result) { - result->error = json_parse_error_allocator_failed; - result->error_offset = 0; - result->error_line_no = 0; - result->error_row_no = 0; - } - - return json_null; - } - - /* reset offset so we can reuse it. */ - state.offset = 0; - - /* reset the line information so we can reuse it. */ - state.line_no = 1; - state.line_offset = 0; - - state.dom = (char *)allocation; - state.data = state.dom + state.dom_size; - - if (json_parse_flags_allow_location_information & state.flags_bitset) { - struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state.dom; - state.dom += sizeof(struct json_value_ex_s); - - value_ex->offset = state.offset; - value_ex->line_no = state.line_no; - value_ex->row_no = state.offset - state.line_offset; - - value = &(value_ex->value); - } else { - value = (struct json_value_s *)state.dom; - state.dom += sizeof(struct json_value_s); - } - - json_parse_value( - &state, (int)(json_parse_flags_allow_global_object & state.flags_bitset), - value); - - return (struct json_value_s *)allocation; + /* reset offset so we can reuse it. */ + state.offset = 0; + + /* reset the line information so we can reuse it. */ + state.line_no = 1; + state.line_offset = 0; + + state.dom = (char *)allocation; + state.data = state.dom + state.dom_size; + + if (json_parse_flags_allow_location_information & state.flags_bitset) + { + struct json_value_ex_s *value_ex = (struct json_value_ex_s *)state.dom; + state.dom += sizeof(struct json_value_ex_s); + + value_ex->offset = state.offset; + value_ex->line_no = state.line_no; + value_ex->row_no = state.offset - state.line_offset; + + value = &(value_ex->value); + } + else + { + value = (struct json_value_s *)state.dom; + state.dom += sizeof(struct json_value_s); + } + + json_parse_value(&state, (int)(json_parse_flags_allow_global_object & state.flags_bitset), value); + + return (struct json_value_s *)allocation; } -struct json_value_s *json_parse(const void *src, size_t src_size) { - return json_parse_ex(src, src_size, json_parse_flags_default, json_null, - json_null, json_null); +struct json_value_s *json_parse(const void *src, size_t src_size) +{ + return json_parse_ex(src, src_size, json_parse_flags_default, json_null, json_null, json_null); } -struct json_extract_result_s { - size_t dom_size; - size_t data_size; +struct json_extract_result_s +{ + size_t dom_size; + size_t data_size; }; -struct json_value_s *json_extract_value(const struct json_value_s *value) { - return json_extract_value_ex(value, json_null, json_null); +struct json_value_s *json_extract_value(const struct json_value_s *value) +{ + return json_extract_value_ex(value, json_null, json_null); } -json_weak struct json_extract_result_s -json_extract_get_number_size(const struct json_number_s *const number); -json_weak struct json_extract_result_s -json_extract_get_string_size(const struct json_string_s *const string); -json_weak struct json_extract_result_s -json_extract_get_object_size(const struct json_object_s *const object); -json_weak struct json_extract_result_s -json_extract_get_array_size(const struct json_array_s *const array); -json_weak struct json_extract_result_s -json_extract_get_value_size(const struct json_value_s *const value); - -struct json_extract_result_s -json_extract_get_number_size(const struct json_number_s *const number) { - struct json_extract_result_s result; - result.dom_size = sizeof(struct json_number_s); - result.data_size = number->number_size; - return result; +json_weak struct json_extract_result_s json_extract_get_number_size(const struct json_number_s *const number); +json_weak struct json_extract_result_s json_extract_get_string_size(const struct json_string_s *const string); +json_weak struct json_extract_result_s json_extract_get_object_size(const struct json_object_s *const object); +json_weak struct json_extract_result_s json_extract_get_array_size(const struct json_array_s *const array); +json_weak struct json_extract_result_s json_extract_get_value_size(const struct json_value_s *const value); + +struct json_extract_result_s json_extract_get_number_size(const struct json_number_s *const number) +{ + struct json_extract_result_s result; + result.dom_size = sizeof(struct json_number_s); + result.data_size = number->number_size; + return result; } -struct json_extract_result_s -json_extract_get_string_size(const struct json_string_s *const string) { - struct json_extract_result_s result; - result.dom_size = sizeof(struct json_string_s); - result.data_size = string->string_size + 1; - return result; +struct json_extract_result_s json_extract_get_string_size(const struct json_string_s *const string) +{ + struct json_extract_result_s result; + result.dom_size = sizeof(struct json_string_s); + result.data_size = string->string_size + 1; + return result; } -struct json_extract_result_s -json_extract_get_object_size(const struct json_object_s *const object) { - struct json_extract_result_s result; - size_t i; - const struct json_object_element_s *element = object->start; +struct json_extract_result_s json_extract_get_object_size(const struct json_object_s *const object) +{ + struct json_extract_result_s result; + size_t i; + const struct json_object_element_s *element = object->start; - result.dom_size = sizeof(struct json_object_s) + - (sizeof(struct json_object_element_s) * object->length); - result.data_size = 0; + result.dom_size = sizeof(struct json_object_s) + (sizeof(struct json_object_element_s) * object->length); + result.data_size = 0; - for (i = 0; i < object->length; i++) { - const struct json_extract_result_s string_result = - json_extract_get_string_size(element->name); - const struct json_extract_result_s value_result = - json_extract_get_value_size(element->value); + for (i = 0; i < object->length; i++) + { + const struct json_extract_result_s string_result = json_extract_get_string_size(element->name); + const struct json_extract_result_s value_result = json_extract_get_value_size(element->value); - result.dom_size += string_result.dom_size; - result.data_size += string_result.data_size; + result.dom_size += string_result.dom_size; + result.data_size += string_result.data_size; - result.dom_size += value_result.dom_size; - result.data_size += value_result.data_size; + result.dom_size += value_result.dom_size; + result.data_size += value_result.data_size; - element = element->next; - } + element = element->next; + } - return result; + return result; } -struct json_extract_result_s -json_extract_get_array_size(const struct json_array_s *const array) { - struct json_extract_result_s result; - size_t i; - const struct json_array_element_s *element = array->start; +struct json_extract_result_s json_extract_get_array_size(const struct json_array_s *const array) +{ + struct json_extract_result_s result; + size_t i; + const struct json_array_element_s *element = array->start; + + result.dom_size = sizeof(struct json_array_s) + (sizeof(struct json_array_element_s) * array->length); + result.data_size = 0; - result.dom_size = sizeof(struct json_array_s) + - (sizeof(struct json_array_element_s) * array->length); - result.data_size = 0; + for (i = 0; i < array->length; i++) + { + const struct json_extract_result_s value_result = json_extract_get_value_size(element->value); - for (i = 0; i < array->length; i++) { - const struct json_extract_result_s value_result = - json_extract_get_value_size(element->value); + result.dom_size += value_result.dom_size; + result.data_size += value_result.data_size; - result.dom_size += value_result.dom_size; - result.data_size += value_result.data_size; + element = element->next; + } - element = element->next; - } + return result; +} + +struct json_extract_result_s json_extract_get_value_size(const struct json_value_s *const value) +{ + struct json_extract_result_s result = {0, 0}; + + switch (value->type) + { + default: + break; + case json_type_object: + result = json_extract_get_object_size((const struct json_object_s *)value->payload); + break; + case json_type_array: + result = json_extract_get_array_size((const struct json_array_s *)value->payload); + break; + case json_type_number: + result = json_extract_get_number_size((const struct json_number_s *)value->payload); + break; + case json_type_string: + result = json_extract_get_string_size((const struct json_string_s *)value->payload); + break; + } - return result; -} + result.dom_size += sizeof(struct json_value_s); -struct json_extract_result_s -json_extract_get_value_size(const struct json_value_s *const value) { - struct json_extract_result_s result = {0, 0}; - - switch (value->type) { - default: - break; - case json_type_object: - result = json_extract_get_object_size( - (const struct json_object_s *)value->payload); - break; - case json_type_array: - result = json_extract_get_array_size( - (const struct json_array_s *)value->payload); - break; - case json_type_number: - result = json_extract_get_number_size( - (const struct json_number_s *)value->payload); - break; - case json_type_string: - result = json_extract_get_string_size( - (const struct json_string_s *)value->payload); - break; - } - - result.dom_size += sizeof(struct json_value_s); - - return result; + return result; } -struct json_extract_state_s { - char *dom; - char *data; +struct json_extract_state_s +{ + char *dom; + char *data; }; json_weak void json_extract_copy_value(struct json_extract_state_s *const state, - const struct json_value_s *const value); -void json_extract_copy_value(struct json_extract_state_s *const state, - const struct json_value_s *const value) { - struct json_string_s *string; - struct json_number_s *number; - struct json_object_s *object; - struct json_array_s *array; - struct json_value_s *new_value; - - memcpy(state->dom, value, sizeof(struct json_value_s)); - new_value = (struct json_value_s *)state->dom; - state->dom += sizeof(struct json_value_s); - new_value->payload = state->dom; - - if (json_type_string == value->type) { - memcpy(state->dom, value->payload, sizeof(struct json_string_s)); - string = (struct json_string_s *)state->dom; - state->dom += sizeof(struct json_string_s); - - memcpy(state->data, string->string, string->string_size + 1); - string->string = state->data; - state->data += string->string_size + 1; - } else if (json_type_number == value->type) { - memcpy(state->dom, value->payload, sizeof(struct json_number_s)); - number = (struct json_number_s *)state->dom; - state->dom += sizeof(struct json_number_s); - - memcpy(state->data, number->number, number->number_size); - number->number = state->data; - state->data += number->number_size; - } else if (json_type_object == value->type) { - struct json_object_element_s *element; - size_t i; + const struct json_value_s *const value); +void json_extract_copy_value(struct json_extract_state_s *const state, const struct json_value_s *const value) +{ + struct json_string_s *string; + struct json_number_s *number; + struct json_object_s *object; + struct json_array_s *array; + struct json_value_s *new_value; + + memcpy(state->dom, value, sizeof(struct json_value_s)); + new_value = (struct json_value_s *)state->dom; + state->dom += sizeof(struct json_value_s); + new_value->payload = state->dom; + + if (json_type_string == value->type) + { + memcpy(state->dom, value->payload, sizeof(struct json_string_s)); + string = (struct json_string_s *)state->dom; + state->dom += sizeof(struct json_string_s); + + memcpy(state->data, string->string, string->string_size + 1); + string->string = state->data; + state->data += string->string_size + 1; + } + else if (json_type_number == value->type) + { + memcpy(state->dom, value->payload, sizeof(struct json_number_s)); + number = (struct json_number_s *)state->dom; + state->dom += sizeof(struct json_number_s); + + memcpy(state->data, number->number, number->number_size); + number->number = state->data; + state->data += number->number_size; + } + else if (json_type_object == value->type) + { + struct json_object_element_s *element; + size_t i; - memcpy(state->dom, value->payload, sizeof(struct json_object_s)); - object = (struct json_object_s *)state->dom; - state->dom += sizeof(struct json_object_s); + memcpy(state->dom, value->payload, sizeof(struct json_object_s)); + object = (struct json_object_s *)state->dom; + state->dom += sizeof(struct json_object_s); - element = object->start; - object->start = (struct json_object_element_s *)state->dom; + element = object->start; + object->start = (struct json_object_element_s *)state->dom; - for (i = 0; i < object->length; i++) { - struct json_value_s *previous_value; - struct json_object_element_s *previous_element; + for (i = 0; i < object->length; i++) + { + struct json_value_s *previous_value; + struct json_object_element_s *previous_element; - memcpy(state->dom, element, sizeof(struct json_object_element_s)); - element = (struct json_object_element_s *)state->dom; - state->dom += sizeof(struct json_object_element_s); + memcpy(state->dom, element, sizeof(struct json_object_element_s)); + element = (struct json_object_element_s *)state->dom; + state->dom += sizeof(struct json_object_element_s); - string = element->name; - memcpy(state->dom, string, sizeof(struct json_string_s)); - string = (struct json_string_s *)state->dom; - state->dom += sizeof(struct json_string_s); - element->name = string; + string = element->name; + memcpy(state->dom, string, sizeof(struct json_string_s)); + string = (struct json_string_s *)state->dom; + state->dom += sizeof(struct json_string_s); + element->name = string; - memcpy(state->data, string->string, string->string_size + 1); - string->string = state->data; - state->data += string->string_size + 1; + memcpy(state->data, string->string, string->string_size + 1); + string->string = state->data; + state->data += string->string_size + 1; - previous_value = element->value; - element->value = (struct json_value_s *)state->dom; - json_extract_copy_value(state, previous_value); + previous_value = element->value; + element->value = (struct json_value_s *)state->dom; + json_extract_copy_value(state, previous_value); - previous_element = element; - element = element->next; + previous_element = element; + element = element->next; - if (element) { - previous_element->next = (struct json_object_element_s *)state->dom; - } + if (element) + { + previous_element->next = (struct json_object_element_s *)state->dom; + } + } } - } else if (json_type_array == value->type) { - struct json_array_element_s *element; - size_t i; + else if (json_type_array == value->type) + { + struct json_array_element_s *element; + size_t i; - memcpy(state->dom, value->payload, sizeof(struct json_array_s)); - array = (struct json_array_s *)state->dom; - state->dom += sizeof(struct json_array_s); + memcpy(state->dom, value->payload, sizeof(struct json_array_s)); + array = (struct json_array_s *)state->dom; + state->dom += sizeof(struct json_array_s); - element = array->start; - array->start = (struct json_array_element_s *)state->dom; + element = array->start; + array->start = (struct json_array_element_s *)state->dom; - for (i = 0; i < array->length; i++) { - struct json_value_s *previous_value; - struct json_array_element_s *previous_element; + for (i = 0; i < array->length; i++) + { + struct json_value_s *previous_value; + struct json_array_element_s *previous_element; - memcpy(state->dom, element, sizeof(struct json_array_element_s)); - element = (struct json_array_element_s *)state->dom; - state->dom += sizeof(struct json_array_element_s); + memcpy(state->dom, element, sizeof(struct json_array_element_s)); + element = (struct json_array_element_s *)state->dom; + state->dom += sizeof(struct json_array_element_s); - previous_value = element->value; - element->value = (struct json_value_s *)state->dom; - json_extract_copy_value(state, previous_value); + previous_value = element->value; + element->value = (struct json_value_s *)state->dom; + json_extract_copy_value(state, previous_value); - previous_element = element; - element = element->next; + previous_element = element; + element = element->next; - if (element) { - previous_element->next = (struct json_array_element_s *)state->dom; - } + if (element) + { + previous_element->next = (struct json_array_element_s *)state->dom; + } + } } - } } -struct json_value_s *json_extract_value_ex(const struct json_value_s *value, - void *(*alloc_func_ptr)(void *, - size_t), - void *user_data) { - void *allocation; - struct json_extract_result_s result; - struct json_extract_state_s state; - size_t total_size; - - if (json_null == value) { - /* invalid value was null! */ - return json_null; - } +struct json_value_s *json_extract_value_ex(const struct json_value_s *value, void *(*alloc_func_ptr)(void *, size_t), + void *user_data) +{ + void *allocation; + struct json_extract_result_s result; + struct json_extract_state_s state; + size_t total_size; + + if (json_null == value) + { + /* invalid value was null! */ + return json_null; + } - result = json_extract_get_value_size(value); - total_size = result.dom_size + result.data_size; + result = json_extract_get_value_size(value); + total_size = result.dom_size + result.data_size; - if (json_null == alloc_func_ptr) { - allocation = malloc(total_size); - } else { - allocation = alloc_func_ptr(user_data, total_size); - } + if (json_null == alloc_func_ptr) + { + allocation = malloc(total_size); + } + else + { + allocation = alloc_func_ptr(user_data, total_size); + } - state.dom = (char *)allocation; - state.data = state.dom + result.dom_size; + state.dom = (char *)allocation; + state.data = state.dom + result.dom_size; - json_extract_copy_value(&state, value); + json_extract_copy_value(&state, value); - return (struct json_value_s *)allocation; + return (struct json_value_s *)allocation; } -struct json_string_s *json_value_as_string(struct json_value_s *const value) { - if (value->type != json_type_string) { - return json_null; - } +struct json_string_s *json_value_as_string(struct json_value_s *const value) +{ + if (value->type != json_type_string) + { + return json_null; + } - return (struct json_string_s *)value->payload; + return (struct json_string_s *)value->payload; } -struct json_number_s *json_value_as_number(struct json_value_s *const value) { - if (value->type != json_type_number) { - return json_null; - } +struct json_number_s *json_value_as_number(struct json_value_s *const value) +{ + if (value->type != json_type_number) + { + return json_null; + } - return (struct json_number_s *)value->payload; + return (struct json_number_s *)value->payload; } -struct json_object_s *json_value_as_object(struct json_value_s *const value) { - if (value->type != json_type_object) { - return json_null; - } +struct json_object_s *json_value_as_object(struct json_value_s *const value) +{ + if (value->type != json_type_object) + { + return json_null; + } - return (struct json_object_s *)value->payload; + return (struct json_object_s *)value->payload; } -struct json_array_s *json_value_as_array(struct json_value_s *const value) { - if (value->type != json_type_array) { - return json_null; - } +struct json_array_s *json_value_as_array(struct json_value_s *const value) +{ + if (value->type != json_type_array) + { + return json_null; + } - return (struct json_array_s *)value->payload; + return (struct json_array_s *)value->payload; } -int json_value_is_true(const struct json_value_s *const value) { - return value->type == json_type_true; +int json_value_is_true(const struct json_value_s *const value) +{ + return value->type == json_type_true; } -int json_value_is_false(const struct json_value_s *const value) { - return value->type == json_type_false; +int json_value_is_false(const struct json_value_s *const value) +{ + return value->type == json_type_false; } -int json_value_is_null(const struct json_value_s *const value) { - return value->type == json_type_null; +int json_value_is_null(const struct json_value_s *const value) +{ + return value->type == json_type_null; } -json_weak int -json_write_minified_get_value_size(const struct json_value_s *value, - size_t *size); - -json_weak int json_write_get_number_size(const struct json_number_s *number, - size_t *size); -int json_write_get_number_size(const struct json_number_s *number, - size_t *size) { - json_uintmax_t parsed_number; - size_t i; +json_weak int json_write_minified_get_value_size(const struct json_value_s *value, size_t *size); - if (number->number_size >= 2) { - switch (number->number[1]) { - default: - break; - case 'x': - case 'X': - /* the number is a json_parse_flags_allow_hexadecimal_numbers hexadecimal - * so we have to do extra work to convert it to a non-hexadecimal for JSON - * output. */ - parsed_number = json_strtoumax(number->number, json_null, 0); - - i = 0; - - while (0 != parsed_number) { - parsed_number /= 10; - i++; - } +json_weak int json_write_get_number_size(const struct json_number_s *number, size_t *size); +int json_write_get_number_size(const struct json_number_s *number, size_t *size) +{ + json_uintmax_t parsed_number; + size_t i; - *size += i; - return 0; + if (number->number_size >= 2) + { + switch (number->number[1]) + { + default: + break; + case 'x': + case 'X': + /* the number is a json_parse_flags_allow_hexadecimal_numbers hexadecimal + * so we have to do extra work to convert it to a non-hexadecimal for JSON + * output. */ + parsed_number = json_strtoumax(number->number, json_null, 0); + + i = 0; + + while (0 != parsed_number) + { + parsed_number /= 10; + i++; + } + + *size += i; + return 0; + } } - } - - /* check to see if the number has leading/trailing decimal point. */ - i = 0; - /* skip any leading '+' or '-'. */ - if ((i < number->number_size) && - (('+' == number->number[i]) || ('-' == number->number[i]))) { - i++; - } + /* check to see if the number has leading/trailing decimal point. */ + i = 0; - /* check if we have infinity. */ - if ((i < number->number_size) && ('I' == number->number[i])) { - const char *inf = "Infinity"; - size_t k; + /* skip any leading '+' or '-'. */ + if ((i < number->number_size) && (('+' == number->number[i]) || ('-' == number->number[i]))) + { + i++; + } - for (k = i; k < number->number_size; k++) { - const char c = *inf++; + /* check if we have infinity. */ + if ((i < number->number_size) && ('I' == number->number[i])) + { + const char *inf = "Infinity"; + size_t k; + + for (k = i; k < number->number_size; k++) + { + const char c = *inf++; + + /* Check if we found the Infinity string! */ + if ('\0' == c) + { + break; + } + else if (c != number->number[k]) + { + break; + } + } - /* Check if we found the Infinity string! */ - if ('\0' == c) { - break; - } else if (c != number->number[k]) { - break; - } - } + if ('\0' == *inf) + { + /* Inf becomes 1.7976931348623158e308 because JSON can't support it. */ + *size += 22; - if ('\0' == *inf) { - /* Inf becomes 1.7976931348623158e308 because JSON can't support it. */ - *size += 22; + /* if we had a leading '-' we need to record it in the JSON output. */ + if ('-' == number->number[0]) + { + *size += 1; + } + } - /* if we had a leading '-' we need to record it in the JSON output. */ - if ('-' == number->number[0]) { - *size += 1; - } + return 0; } - return 0; - } - - /* check if we have nan. */ - if ((i < number->number_size) && ('N' == number->number[i])) { - const char *nan = "NaN"; - size_t k; + /* check if we have nan. */ + if ((i < number->number_size) && ('N' == number->number[i])) + { + const char *nan = "NaN"; + size_t k; + + for (k = i; k < number->number_size; k++) + { + const char c = *nan++; + + /* Check if we found the NaN string! */ + if ('\0' == c) + { + break; + } + else if (c != number->number[k]) + { + break; + } + } - for (k = i; k < number->number_size; k++) { - const char c = *nan++; + if ('\0' == *nan) + { + /* NaN becomes 1 because JSON can't support it. */ + *size += 1; - /* Check if we found the NaN string! */ - if ('\0' == c) { - break; - } else if (c != number->number[k]) { - break; - } + return 0; + } } - if ('\0' == *nan) { - /* NaN becomes 1 because JSON can't support it. */ - *size += 1; - - return 0; + /* if we had a leading decimal point. */ + if ((i < number->number_size) && ('.' == number->number[i])) + { + /* 1 + because we had a leading decimal point. */ + *size += 1; + goto cleanup; } - } - /* if we had a leading decimal point. */ - if ((i < number->number_size) && ('.' == number->number[i])) { - /* 1 + because we had a leading decimal point. */ - *size += 1; - goto cleanup; - } - - for (; i < number->number_size; i++) { - const char c = number->number[i]; - if (!('0' <= c && c <= '9')) { - break; + for (; i < number->number_size; i++) + { + const char c = number->number[i]; + if (!('0' <= c && c <= '9')) + { + break; + } } - } - /* if we had a trailing decimal point. */ - if ((i + 1 == number->number_size) && ('.' == number->number[i])) { - /* 1 + because we had a trailing decimal point. */ - *size += 1; - goto cleanup; - } + /* if we had a trailing decimal point. */ + if ((i + 1 == number->number_size) && ('.' == number->number[i])) + { + /* 1 + because we had a trailing decimal point. */ + *size += 1; + goto cleanup; + } cleanup: - *size += number->number_size; /* the actual string of the number. */ + *size += number->number_size; /* the actual string of the number. */ - /* if we had a leading '+' we don't record it in the JSON output. */ - if ('+' == number->number[0]) { - *size -= 1; - } + /* if we had a leading '+' we don't record it in the JSON output. */ + if ('+' == number->number[0]) + { + *size -= 1; + } - return 0; + return 0; } -json_weak int json_write_get_string_size(const struct json_string_s *string, - size_t *size); -int json_write_get_string_size(const struct json_string_s *string, - size_t *size) { - size_t i; - for (i = 0; i < string->string_size; i++) { - switch (string->string[i]) { - case '"': - case '\\': - case '\b': - case '\f': - case '\n': - case '\r': - case '\t': - *size += 2; - break; - default: - *size += 1; - break; +json_weak int json_write_get_string_size(const struct json_string_s *string, size_t *size); +int json_write_get_string_size(const struct json_string_s *string, size_t *size) +{ + size_t i; + for (i = 0; i < string->string_size; i++) + { + switch (string->string[i]) + { + case '"': + case '\\': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + *size += 2; + break; + default: + *size += 1; + break; + } } - } - *size += 2; /* need to encode the surrounding '"' characters. */ + *size += 2; /* need to encode the surrounding '"' characters. */ - return 0; + return 0; } -json_weak int -json_write_minified_get_array_size(const struct json_array_s *array, - size_t *size); -int json_write_minified_get_array_size(const struct json_array_s *array, - size_t *size) { - struct json_array_element_s *element; +json_weak int json_write_minified_get_array_size(const struct json_array_s *array, size_t *size); +int json_write_minified_get_array_size(const struct json_array_s *array, size_t *size) +{ + struct json_array_element_s *element; - *size += 2; /* '[' and ']'. */ + *size += 2; /* '[' and ']'. */ - if (1 < array->length) { - *size += array->length - 1; /* ','s seperate each element. */ - } + if (1 < array->length) + { + *size += array->length - 1; /* ','s seperate each element. */ + } - for (element = array->start; json_null != element; element = element->next) { - if (json_write_minified_get_value_size(element->value, size)) { - /* value was malformed! */ - return 1; + for (element = array->start; json_null != element; element = element->next) + { + if (json_write_minified_get_value_size(element->value, size)) + { + /* value was malformed! */ + return 1; + } } - } - return 0; + return 0; } -json_weak int -json_write_minified_get_object_size(const struct json_object_s *object, - size_t *size); -int json_write_minified_get_object_size(const struct json_object_s *object, - size_t *size) { - struct json_object_element_s *element; - - *size += 2; /* '{' and '}'. */ +json_weak int json_write_minified_get_object_size(const struct json_object_s *object, size_t *size); +int json_write_minified_get_object_size(const struct json_object_s *object, size_t *size) +{ + struct json_object_element_s *element; - *size += object->length; /* ':'s seperate each name/value pair. */ + *size += 2; /* '{' and '}'. */ - if (1 < object->length) { - *size += object->length - 1; /* ','s seperate each element. */ - } + *size += object->length; /* ':'s seperate each name/value pair. */ - for (element = object->start; json_null != element; element = element->next) { - if (json_write_get_string_size(element->name, size)) { - /* string was malformed! */ - return 1; + if (1 < object->length) + { + *size += object->length - 1; /* ','s seperate each element. */ } - if (json_write_minified_get_value_size(element->value, size)) { - /* value was malformed! */ - return 1; + for (element = object->start; json_null != element; element = element->next) + { + if (json_write_get_string_size(element->name, size)) + { + /* string was malformed! */ + return 1; + } + + if (json_write_minified_get_value_size(element->value, size)) + { + /* value was malformed! */ + return 1; + } } - } - return 0; + return 0; } -json_weak int -json_write_minified_get_value_size(const struct json_value_s *value, - size_t *size); -int json_write_minified_get_value_size(const struct json_value_s *value, - size_t *size) { - switch (value->type) { - default: - /* unknown value type found! */ - return 1; - case json_type_number: - return json_write_get_number_size((struct json_number_s *)value->payload, - size); - case json_type_string: - return json_write_get_string_size((struct json_string_s *)value->payload, - size); - case json_type_array: - return json_write_minified_get_array_size( - (struct json_array_s *)value->payload, size); - case json_type_object: - return json_write_minified_get_object_size( - (struct json_object_s *)value->payload, size); - case json_type_true: - *size += 4; /* the string "true". */ - return 0; - case json_type_false: - *size += 5; /* the string "false". */ - return 0; - case json_type_null: - *size += 4; /* the string "null". */ - return 0; - } +json_weak int json_write_minified_get_value_size(const struct json_value_s *value, size_t *size); +int json_write_minified_get_value_size(const struct json_value_s *value, size_t *size) +{ + switch (value->type) + { + default: + /* unknown value type found! */ + return 1; + case json_type_number: + return json_write_get_number_size((struct json_number_s *)value->payload, size); + case json_type_string: + return json_write_get_string_size((struct json_string_s *)value->payload, size); + case json_type_array: + return json_write_minified_get_array_size((struct json_array_s *)value->payload, size); + case json_type_object: + return json_write_minified_get_object_size((struct json_object_s *)value->payload, size); + case json_type_true: + *size += 4; /* the string "true". */ + return 0; + case json_type_false: + *size += 5; /* the string "false". */ + return 0; + case json_type_null: + *size += 4; /* the string "null". */ + return 0; + } } -json_weak char *json_write_minified_value(const struct json_value_s *value, - char *data); +json_weak char *json_write_minified_value(const struct json_value_s *value, char *data); -json_weak char *json_write_number(const struct json_number_s *number, - char *data); -char *json_write_number(const struct json_number_s *number, char *data) { - json_uintmax_t parsed_number, backup; - size_t i; +json_weak char *json_write_number(const struct json_number_s *number, char *data); +char *json_write_number(const struct json_number_s *number, char *data) +{ + json_uintmax_t parsed_number, backup; + size_t i; - if (number->number_size >= 2) { - switch (number->number[1]) { - default: - break; - case 'x': - case 'X': - /* The number is a json_parse_flags_allow_hexadecimal_numbers hexadecimal - * so we have to do extra work to convert it to a non-hexadecimal for JSON - * output. */ - parsed_number = json_strtoumax(number->number, json_null, 0); + if (number->number_size >= 2) + { + switch (number->number[1]) + { + default: + break; + case 'x': + case 'X': + /* The number is a json_parse_flags_allow_hexadecimal_numbers hexadecimal + * so we have to do extra work to convert it to a non-hexadecimal for JSON + * output. */ + parsed_number = json_strtoumax(number->number, json_null, 0); - /* We need a copy of parsed number twice, so take a backup of it. */ - backup = parsed_number; + /* We need a copy of parsed number twice, so take a backup of it. */ + backup = parsed_number; - i = 0; + i = 0; - while (0 != parsed_number) { - parsed_number /= 10; - i++; - } + while (0 != parsed_number) + { + parsed_number /= 10; + i++; + } - /* Restore parsed_number to its original value stored in the backup. */ - parsed_number = backup; + /* Restore parsed_number to its original value stored in the backup. */ + parsed_number = backup; - /* Now use backup to take a copy of i, or the length of the string. */ - backup = i; + /* Now use backup to take a copy of i, or the length of the string. */ + backup = i; - do { - *(data + i - 1) = '0' + (char)(parsed_number % 10); - parsed_number /= 10; - i--; - } while (0 != parsed_number); + do + { + *(data + i - 1) = '0' + (char)(parsed_number % 10); + parsed_number /= 10; + i--; + } while (0 != parsed_number); - data += backup; + data += backup; - return data; + return data; + } } - } - /* check to see if the number has leading/trailing decimal point. */ - i = 0; + /* check to see if the number has leading/trailing decimal point. */ + i = 0; - /* skip any leading '-'. */ - if ((i < number->number_size) && - (('+' == number->number[i]) || ('-' == number->number[i]))) { - i++; - } + /* skip any leading '-'. */ + if ((i < number->number_size) && (('+' == number->number[i]) || ('-' == number->number[i]))) + { + i++; + } - /* check if we have infinity. */ - if ((i < number->number_size) && ('I' == number->number[i])) { - const char *inf = "Infinity"; - size_t k; + /* check if we have infinity. */ + if ((i < number->number_size) && ('I' == number->number[i])) + { + const char *inf = "Infinity"; + size_t k; + + for (k = i; k < number->number_size; k++) + { + const char c = *inf++; + + /* Check if we found the Infinity string! */ + if ('\0' == c) + { + break; + } + else if (c != number->number[k]) + { + break; + } + } - for (k = i; k < number->number_size; k++) { - const char c = *inf++; + if ('\0' == *inf++) + { + const char *dbl_max; - /* Check if we found the Infinity string! */ - if ('\0' == c) { - break; - } else if (c != number->number[k]) { - break; - } - } + /* if we had a leading '-' we need to record it in the JSON output. */ + if ('-' == number->number[0]) + { + *data++ = '-'; + } - if ('\0' == *inf++) { - const char *dbl_max; + /* Inf becomes 1.7976931348623158e308 because JSON can't support it. */ + for (dbl_max = "1.7976931348623158e308"; '\0' != *dbl_max; dbl_max++) + { + *data++ = *dbl_max; + } - /* if we had a leading '-' we need to record it in the JSON output. */ - if ('-' == number->number[0]) { - *data++ = '-'; - } + return data; + } + } - /* Inf becomes 1.7976931348623158e308 because JSON can't support it. */ - for (dbl_max = "1.7976931348623158e308"; '\0' != *dbl_max; dbl_max++) { - *data++ = *dbl_max; - } + /* check if we have nan. */ + if ((i < number->number_size) && ('N' == number->number[i])) + { + const char *nan = "NaN"; + size_t k; + + for (k = i; k < number->number_size; k++) + { + const char c = *nan++; + + /* Check if we found the NaN string! */ + if ('\0' == c) + { + break; + } + else if (c != number->number[k]) + { + break; + } + } - return data; + if ('\0' == *nan++) + { + /* NaN becomes 0 because JSON can't support it. */ + *data++ = '0'; + return data; + } } - } - /* check if we have nan. */ - if ((i < number->number_size) && ('N' == number->number[i])) { - const char *nan = "NaN"; - size_t k; + /* if we had a leading decimal point. */ + if ((i < number->number_size) && ('.' == number->number[i])) + { + i = 0; - for (k = i; k < number->number_size; k++) { - const char c = *nan++; + /* skip any leading '+'. */ + if ('+' == number->number[i]) + { + i++; + } - /* Check if we found the NaN string! */ - if ('\0' == c) { - break; - } else if (c != number->number[k]) { - break; - } - } + /* output the leading '-' if we had one. */ + if ('-' == number->number[i]) + { + *data++ = '-'; + i++; + } - if ('\0' == *nan++) { - /* NaN becomes 0 because JSON can't support it. */ - *data++ = '0'; - return data; - } - } + /* insert a '0' to fix the leading decimal point for JSON output. */ + *data++ = '0'; - /* if we had a leading decimal point. */ - if ((i < number->number_size) && ('.' == number->number[i])) { - i = 0; + /* and output the rest of the number as normal. */ + for (; i < number->number_size; i++) + { + *data++ = number->number[i]; + } - /* skip any leading '+'. */ - if ('+' == number->number[i]) { - i++; + return data; } - /* output the leading '-' if we had one. */ - if ('-' == number->number[i]) { - *data++ = '-'; - i++; + for (; i < number->number_size; i++) + { + const char c = number->number[i]; + if (!('0' <= c && c <= '9')) + { + break; + } } - /* insert a '0' to fix the leading decimal point for JSON output. */ - *data++ = '0'; + /* if we had a trailing decimal point. */ + if ((i + 1 == number->number_size) && ('.' == number->number[i])) + { + i = 0; - /* and output the rest of the number as normal. */ - for (; i < number->number_size; i++) { - *data++ = number->number[i]; - } + /* skip any leading '+'. */ + if ('+' == number->number[i]) + { + i++; + } - return data; - } + /* output the leading '-' if we had one. */ + if ('-' == number->number[i]) + { + *data++ = '-'; + i++; + } + + /* and output the rest of the number as normal. */ + for (; i < number->number_size; i++) + { + *data++ = number->number[i]; + } - for (; i < number->number_size; i++) { - const char c = number->number[i]; - if (!('0' <= c && c <= '9')) { - break; + /* insert a '0' to fix the trailing decimal point for JSON output. */ + *data++ = '0'; + + return data; } - } - /* if we had a trailing decimal point. */ - if ((i + 1 == number->number_size) && ('.' == number->number[i])) { i = 0; /* skip any leading '+'. */ - if ('+' == number->number[i]) { - i++; - } - - /* output the leading '-' if we had one. */ - if ('-' == number->number[i]) { - *data++ = '-'; - i++; + if ('+' == number->number[i]) + { + i++; } - /* and output the rest of the number as normal. */ - for (; i < number->number_size; i++) { - *data++ = number->number[i]; + for (; i < number->number_size; i++) + { + *data++ = number->number[i]; } - /* insert a '0' to fix the trailing decimal point for JSON output. */ - *data++ = '0'; - return data; - } - - i = 0; - - /* skip any leading '+'. */ - if ('+' == number->number[i]) { - i++; - } +} - for (; i < number->number_size; i++) { - *data++ = number->number[i]; - } +json_weak char *json_write_string(const struct json_string_s *string, char *data); +char *json_write_string(const struct json_string_s *string, char *data) +{ + size_t i; - return data; -} + *data++ = '"'; /* open the string. */ -json_weak char *json_write_string(const struct json_string_s *string, - char *data); -char *json_write_string(const struct json_string_s *string, char *data) { - size_t i; - - *data++ = '"'; /* open the string. */ - - for (i = 0; i < string->string_size; i++) { - switch (string->string[i]) { - case '"': - *data++ = '\\'; /* escape the control character. */ - *data++ = '"'; - break; - case '\\': - *data++ = '\\'; /* escape the control character. */ - *data++ = '\\'; - break; - case '\b': - *data++ = '\\'; /* escape the control character. */ - *data++ = 'b'; - break; - case '\f': - *data++ = '\\'; /* escape the control character. */ - *data++ = 'f'; - break; - case '\n': - *data++ = '\\'; /* escape the control character. */ - *data++ = 'n'; - break; - case '\r': - *data++ = '\\'; /* escape the control character. */ - *data++ = 'r'; - break; - case '\t': - *data++ = '\\'; /* escape the control character. */ - *data++ = 't'; - break; - default: - *data++ = string->string[i]; - break; + for (i = 0; i < string->string_size; i++) + { + switch (string->string[i]) + { + case '"': + *data++ = '\\'; /* escape the control character. */ + *data++ = '"'; + break; + case '\\': + *data++ = '\\'; /* escape the control character. */ + *data++ = '\\'; + break; + case '\b': + *data++ = '\\'; /* escape the control character. */ + *data++ = 'b'; + break; + case '\f': + *data++ = '\\'; /* escape the control character. */ + *data++ = 'f'; + break; + case '\n': + *data++ = '\\'; /* escape the control character. */ + *data++ = 'n'; + break; + case '\r': + *data++ = '\\'; /* escape the control character. */ + *data++ = 'r'; + break; + case '\t': + *data++ = '\\'; /* escape the control character. */ + *data++ = 't'; + break; + default: + *data++ = string->string[i]; + break; + } } - } - *data++ = '"'; /* close the string. */ + *data++ = '"'; /* close the string. */ - return data; + return data; } -json_weak char *json_write_minified_array(const struct json_array_s *array, - char *data); -char *json_write_minified_array(const struct json_array_s *array, char *data) { - struct json_array_element_s *element = json_null; +json_weak char *json_write_minified_array(const struct json_array_s *array, char *data); +char *json_write_minified_array(const struct json_array_s *array, char *data) +{ + struct json_array_element_s *element = json_null; - *data++ = '['; /* open the array. */ + *data++ = '['; /* open the array. */ - for (element = array->start; json_null != element; element = element->next) { - if (element != array->start) { - *data++ = ','; /* ','s seperate each element. */ - } + for (element = array->start; json_null != element; element = element->next) + { + if (element != array->start) + { + *data++ = ','; /* ','s seperate each element. */ + } - data = json_write_minified_value(element->value, data); + data = json_write_minified_value(element->value, data); - if (json_null == data) { - /* value was malformed! */ - return json_null; + if (json_null == data) + { + /* value was malformed! */ + return json_null; + } } - } - *data++ = ']'; /* close the array. */ + *data++ = ']'; /* close the array. */ - return data; + return data; } -json_weak char *json_write_minified_object(const struct json_object_s *object, - char *data); -char *json_write_minified_object(const struct json_object_s *object, - char *data) { - struct json_object_element_s *element = json_null; +json_weak char *json_write_minified_object(const struct json_object_s *object, char *data); +char *json_write_minified_object(const struct json_object_s *object, char *data) +{ + struct json_object_element_s *element = json_null; - *data++ = '{'; /* open the object. */ + *data++ = '{'; /* open the object. */ - for (element = object->start; json_null != element; element = element->next) { - if (element != object->start) { - *data++ = ','; /* ','s seperate each element. */ - } + for (element = object->start; json_null != element; element = element->next) + { + if (element != object->start) + { + *data++ = ','; /* ','s seperate each element. */ + } - data = json_write_string(element->name, data); + data = json_write_string(element->name, data); - if (json_null == data) { - /* string was malformed! */ - return json_null; - } + if (json_null == data) + { + /* string was malformed! */ + return json_null; + } - *data++ = ':'; /* ':'s seperate each name/value pair. */ + *data++ = ':'; /* ':'s seperate each name/value pair. */ - data = json_write_minified_value(element->value, data); + data = json_write_minified_value(element->value, data); - if (json_null == data) { - /* value was malformed! */ - return json_null; + if (json_null == data) + { + /* value was malformed! */ + return json_null; + } } - } - *data++ = '}'; /* close the object. */ + *data++ = '}'; /* close the object. */ - return data; + return data; } -json_weak char *json_write_minified_value(const struct json_value_s *value, - char *data); -char *json_write_minified_value(const struct json_value_s *value, char *data) { - switch (value->type) { - default: - /* unknown value type found! */ - return json_null; - case json_type_number: - return json_write_number((struct json_number_s *)value->payload, data); - case json_type_string: - return json_write_string((struct json_string_s *)value->payload, data); - case json_type_array: - return json_write_minified_array((struct json_array_s *)value->payload, - data); - case json_type_object: - return json_write_minified_object((struct json_object_s *)value->payload, - data); - case json_type_true: - data[0] = 't'; - data[1] = 'r'; - data[2] = 'u'; - data[3] = 'e'; - return data + 4; - case json_type_false: - data[0] = 'f'; - data[1] = 'a'; - data[2] = 'l'; - data[3] = 's'; - data[4] = 'e'; - return data + 5; - case json_type_null: - data[0] = 'n'; - data[1] = 'u'; - data[2] = 'l'; - data[3] = 'l'; - return data + 4; - } +json_weak char *json_write_minified_value(const struct json_value_s *value, char *data); +char *json_write_minified_value(const struct json_value_s *value, char *data) +{ + switch (value->type) + { + default: + /* unknown value type found! */ + return json_null; + case json_type_number: + return json_write_number((struct json_number_s *)value->payload, data); + case json_type_string: + return json_write_string((struct json_string_s *)value->payload, data); + case json_type_array: + return json_write_minified_array((struct json_array_s *)value->payload, data); + case json_type_object: + return json_write_minified_object((struct json_object_s *)value->payload, data); + case json_type_true: + data[0] = 't'; + data[1] = 'r'; + data[2] = 'u'; + data[3] = 'e'; + return data + 4; + case json_type_false: + data[0] = 'f'; + data[1] = 'a'; + data[2] = 'l'; + data[3] = 's'; + data[4] = 'e'; + return data + 5; + case json_type_null: + data[0] = 'n'; + data[1] = 'u'; + data[2] = 'l'; + data[3] = 'l'; + return data + 4; + } } -void *json_write_minified(const struct json_value_s *value, size_t *out_size) { - size_t size = 0; - char *data = json_null; - char *data_end = json_null; +void *json_write_minified(const struct json_value_s *value, size_t *out_size) +{ + size_t size = 0; + char *data = json_null; + char *data_end = json_null; - if (json_null == value) { - return json_null; - } + if (json_null == value) + { + return json_null; + } - if (json_write_minified_get_value_size(value, &size)) { - /* value was malformed! */ - return json_null; - } + if (json_write_minified_get_value_size(value, &size)) + { + /* value was malformed! */ + return json_null; + } - size += 1; /* for the '\0' null terminating character. */ + size += 1; /* for the '\0' null terminating character. */ - data = (char *)malloc(size); + data = (char *)malloc(size); - if (json_null == data) { - /* malloc failed! */ - return json_null; - } + if (json_null == data) + { + /* malloc failed! */ + return json_null; + } - data_end = json_write_minified_value(value, data); + data_end = json_write_minified_value(value, data); - if (json_null == data_end) { - /* bad chi occurred! */ - free(data); - return json_null; - } + if (json_null == data_end) + { + /* bad chi occurred! */ + free(data); + return json_null; + } - /* null terminated the string. */ - *data_end = '\0'; + /* null terminated the string. */ + *data_end = '\0'; - if (json_null != out_size) { - *out_size = size; - } + if (json_null != out_size) + { + *out_size = size; + } - return data; + return data; } -json_weak int json_write_pretty_get_value_size(const struct json_value_s *value, - size_t depth, size_t indent_size, - size_t newline_size, - size_t *size); +json_weak int json_write_pretty_get_value_size(const struct json_value_s *value, size_t depth, size_t indent_size, + size_t newline_size, size_t *size); -json_weak int json_write_pretty_get_array_size(const struct json_array_s *array, - size_t depth, size_t indent_size, - size_t newline_size, - size_t *size); -int json_write_pretty_get_array_size(const struct json_array_s *array, - size_t depth, size_t indent_size, - size_t newline_size, size_t *size) { - struct json_array_element_s *element; +json_weak int json_write_pretty_get_array_size(const struct json_array_s *array, size_t depth, size_t indent_size, + size_t newline_size, size_t *size); +int json_write_pretty_get_array_size(const struct json_array_s *array, size_t depth, size_t indent_size, + size_t newline_size, size_t *size) +{ + struct json_array_element_s *element; - *size += 1; /* '['. */ + *size += 1; /* '['. */ - if (0 < array->length) { - /* if we have any elements we need to add a newline after our '['. */ - *size += newline_size; + if (0 < array->length) + { + /* if we have any elements we need to add a newline after our '['. */ + *size += newline_size; - *size += array->length - 1; /* ','s seperate each element. */ + *size += array->length - 1; /* ','s seperate each element. */ - for (element = array->start; json_null != element; - element = element->next) { - /* each element gets an indent. */ - *size += (depth + 1) * indent_size; + for (element = array->start; json_null != element; element = element->next) + { + /* each element gets an indent. */ + *size += (depth + 1) * indent_size; - if (json_write_pretty_get_value_size(element->value, depth + 1, - indent_size, newline_size, size)) { - /* value was malformed! */ - return 1; - } + if (json_write_pretty_get_value_size(element->value, depth + 1, indent_size, newline_size, size)) + { + /* value was malformed! */ + return 1; + } - /* each element gets a newline too. */ - *size += newline_size; - } + /* each element gets a newline too. */ + *size += newline_size; + } - /* since we wrote out some elements, need to add a newline and indentation. - */ - /* to the trailing ']'. */ - *size += depth * indent_size; - } + /* since we wrote out some elements, need to add a newline and indentation. + */ + /* to the trailing ']'. */ + *size += depth * indent_size; + } - *size += 1; /* ']'. */ + *size += 1; /* ']'. */ - return 0; + return 0; } -json_weak int -json_write_pretty_get_object_size(const struct json_object_s *object, - size_t depth, size_t indent_size, - size_t newline_size, size_t *size); -int json_write_pretty_get_object_size(const struct json_object_s *object, - size_t depth, size_t indent_size, - size_t newline_size, size_t *size) { - struct json_object_element_s *element; +json_weak int json_write_pretty_get_object_size(const struct json_object_s *object, size_t depth, size_t indent_size, + size_t newline_size, size_t *size); +int json_write_pretty_get_object_size(const struct json_object_s *object, size_t depth, size_t indent_size, + size_t newline_size, size_t *size) +{ + struct json_object_element_s *element; - *size += 1; /* '{'. */ + *size += 1; /* '{'. */ - if (0 < object->length) { - *size += newline_size; /* need a newline next. */ + if (0 < object->length) + { + *size += newline_size; /* need a newline next. */ - *size += object->length - 1; /* ','s seperate each element. */ + *size += object->length - 1; /* ','s seperate each element. */ - for (element = object->start; json_null != element; - element = element->next) { - /* each element gets an indent and newline. */ - *size += (depth + 1) * indent_size; - *size += newline_size; + for (element = object->start; json_null != element; element = element->next) + { + /* each element gets an indent and newline. */ + *size += (depth + 1) * indent_size; + *size += newline_size; - if (json_write_get_string_size(element->name, size)) { - /* string was malformed! */ - return 1; - } + if (json_write_get_string_size(element->name, size)) + { + /* string was malformed! */ + return 1; + } - *size += 3; /* seperate each name/value pair with " : ". */ + *size += 3; /* seperate each name/value pair with " : ". */ - if (json_write_pretty_get_value_size(element->value, depth + 1, - indent_size, newline_size, size)) { - /* value was malformed! */ - return 1; - } - } + if (json_write_pretty_get_value_size(element->value, depth + 1, indent_size, newline_size, size)) + { + /* value was malformed! */ + return 1; + } + } - *size += depth * indent_size; - } + *size += depth * indent_size; + } - *size += 1; /* '}'. */ + *size += 1; /* '}'. */ - return 0; + return 0; } -json_weak int json_write_pretty_get_value_size(const struct json_value_s *value, - size_t depth, size_t indent_size, - size_t newline_size, - size_t *size); -int json_write_pretty_get_value_size(const struct json_value_s *value, - size_t depth, size_t indent_size, - size_t newline_size, size_t *size) { - switch (value->type) { - default: - /* unknown value type found! */ - return 1; - case json_type_number: - return json_write_get_number_size((struct json_number_s *)value->payload, - size); - case json_type_string: - return json_write_get_string_size((struct json_string_s *)value->payload, - size); - case json_type_array: - return json_write_pretty_get_array_size( - (struct json_array_s *)value->payload, depth, indent_size, newline_size, - size); - case json_type_object: - return json_write_pretty_get_object_size( - (struct json_object_s *)value->payload, depth, indent_size, - newline_size, size); - case json_type_true: - *size += 4; /* the string "true". */ - return 0; - case json_type_false: - *size += 5; /* the string "false". */ - return 0; - case json_type_null: - *size += 4; /* the string "null". */ - return 0; - } +json_weak int json_write_pretty_get_value_size(const struct json_value_s *value, size_t depth, size_t indent_size, + size_t newline_size, size_t *size); +int json_write_pretty_get_value_size(const struct json_value_s *value, size_t depth, size_t indent_size, + size_t newline_size, size_t *size) +{ + switch (value->type) + { + default: + /* unknown value type found! */ + return 1; + case json_type_number: + return json_write_get_number_size((struct json_number_s *)value->payload, size); + case json_type_string: + return json_write_get_string_size((struct json_string_s *)value->payload, size); + case json_type_array: + return json_write_pretty_get_array_size((struct json_array_s *)value->payload, depth, indent_size, newline_size, + size); + case json_type_object: + return json_write_pretty_get_object_size((struct json_object_s *)value->payload, depth, indent_size, + newline_size, size); + case json_type_true: + *size += 4; /* the string "true". */ + return 0; + case json_type_false: + *size += 5; /* the string "false". */ + return 0; + case json_type_null: + *size += 4; /* the string "null". */ + return 0; + } } -json_weak char *json_write_pretty_value(const struct json_value_s *value, - size_t depth, const char *indent, +json_weak char *json_write_pretty_value(const struct json_value_s *value, size_t depth, const char *indent, const char *newline, char *data); -json_weak char *json_write_pretty_array(const struct json_array_s *array, - size_t depth, const char *indent, +json_weak char *json_write_pretty_array(const struct json_array_s *array, size_t depth, const char *indent, const char *newline, char *data); -char *json_write_pretty_array(const struct json_array_s *array, size_t depth, - const char *indent, const char *newline, - char *data) { - size_t k, m; - struct json_array_element_s *element; - - *data++ = '['; /* open the array. */ - - if (0 < array->length) { - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; - } +char *json_write_pretty_array(const struct json_array_s *array, size_t depth, const char *indent, const char *newline, + char *data) +{ + size_t k, m; + struct json_array_element_s *element; - for (element = array->start; json_null != element; - element = element->next) { - if (element != array->start) { - *data++ = ','; /* ','s seperate each element. */ + *data++ = '['; /* open the array. */ - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; + if (0 < array->length) + { + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; } - } - for (k = 0; k < depth + 1; k++) { - for (m = 0; '\0' != indent[m]; m++) { - *data++ = indent[m]; + for (element = array->start; json_null != element; element = element->next) + { + if (element != array->start) + { + *data++ = ','; /* ','s seperate each element. */ + + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; + } + } + + for (k = 0; k < depth + 1; k++) + { + for (m = 0; '\0' != indent[m]; m++) + { + *data++ = indent[m]; + } + } + + data = json_write_pretty_value(element->value, depth + 1, indent, newline, data); + + if (json_null == data) + { + /* value was malformed! */ + return json_null; + } } - } - - data = json_write_pretty_value(element->value, depth + 1, indent, newline, - data); - - if (json_null == data) { - /* value was malformed! */ - return json_null; - } - } - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; - } + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; + } - for (k = 0; k < depth; k++) { - for (m = 0; '\0' != indent[m]; m++) { - *data++ = indent[m]; - } + for (k = 0; k < depth; k++) + { + for (m = 0; '\0' != indent[m]; m++) + { + *data++ = indent[m]; + } + } } - } - *data++ = ']'; /* close the array. */ + *data++ = ']'; /* close the array. */ - return data; + return data; } -json_weak char *json_write_pretty_object(const struct json_object_s *object, - size_t depth, const char *indent, +json_weak char *json_write_pretty_object(const struct json_object_s *object, size_t depth, const char *indent, const char *newline, char *data); -char *json_write_pretty_object(const struct json_object_s *object, size_t depth, - const char *indent, const char *newline, - char *data) { - size_t k, m; - struct json_object_element_s *element; - - *data++ = '{'; /* open the object. */ - - if (0 < object->length) { - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; - } +char *json_write_pretty_object(const struct json_object_s *object, size_t depth, const char *indent, + const char *newline, char *data) +{ + size_t k, m; + struct json_object_element_s *element; - for (element = object->start; json_null != element; - element = element->next) { - if (element != object->start) { - *data++ = ','; /* ','s seperate each element. */ + *data++ = '{'; /* open the object. */ - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; + if (0 < object->length) + { + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; } - } - for (k = 0; k < depth + 1; k++) { - for (m = 0; '\0' != indent[m]; m++) { - *data++ = indent[m]; + for (element = object->start; json_null != element; element = element->next) + { + if (element != object->start) + { + *data++ = ','; /* ','s seperate each element. */ + + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; + } + } + + for (k = 0; k < depth + 1; k++) + { + for (m = 0; '\0' != indent[m]; m++) + { + *data++ = indent[m]; + } + } + + data = json_write_string(element->name, data); + + if (json_null == data) + { + /* string was malformed! */ + return json_null; + } + + /* " : "s seperate each name/value pair. */ + *data++ = ' '; + *data++ = ':'; + *data++ = ' '; + + data = json_write_pretty_value(element->value, depth + 1, indent, newline, data); + + if (json_null == data) + { + /* value was malformed! */ + return json_null; + } } - } - data = json_write_string(element->name, data); - - if (json_null == data) { - /* string was malformed! */ - return json_null; - } - - /* " : "s seperate each name/value pair. */ - *data++ = ' '; - *data++ = ':'; - *data++ = ' '; - - data = json_write_pretty_value(element->value, depth + 1, indent, newline, - data); - - if (json_null == data) { - /* value was malformed! */ - return json_null; - } - } - - for (k = 0; '\0' != newline[k]; k++) { - *data++ = newline[k]; - } + for (k = 0; '\0' != newline[k]; k++) + { + *data++ = newline[k]; + } - for (k = 0; k < depth; k++) { - for (m = 0; '\0' != indent[m]; m++) { - *data++ = indent[m]; - } + for (k = 0; k < depth; k++) + { + for (m = 0; '\0' != indent[m]; m++) + { + *data++ = indent[m]; + } + } } - } - *data++ = '}'; /* close the object. */ + *data++ = '}'; /* close the object. */ - return data; + return data; } -json_weak char *json_write_pretty_value(const struct json_value_s *value, - size_t depth, const char *indent, +json_weak char *json_write_pretty_value(const struct json_value_s *value, size_t depth, const char *indent, const char *newline, char *data); -char *json_write_pretty_value(const struct json_value_s *value, size_t depth, - const char *indent, const char *newline, - char *data) { - switch (value->type) { - default: - /* unknown value type found! */ - return json_null; - case json_type_number: - return json_write_number((struct json_number_s *)value->payload, data); - case json_type_string: - return json_write_string((struct json_string_s *)value->payload, data); - case json_type_array: - return json_write_pretty_array((struct json_array_s *)value->payload, depth, - indent, newline, data); - case json_type_object: - return json_write_pretty_object((struct json_object_s *)value->payload, - depth, indent, newline, data); - case json_type_true: - data[0] = 't'; - data[1] = 'r'; - data[2] = 'u'; - data[3] = 'e'; - return data + 4; - case json_type_false: - data[0] = 'f'; - data[1] = 'a'; - data[2] = 'l'; - data[3] = 's'; - data[4] = 'e'; - return data + 5; - case json_type_null: - data[0] = 'n'; - data[1] = 'u'; - data[2] = 'l'; - data[3] = 'l'; - return data + 4; - } +char *json_write_pretty_value(const struct json_value_s *value, size_t depth, const char *indent, const char *newline, + char *data) +{ + switch (value->type) + { + default: + /* unknown value type found! */ + return json_null; + case json_type_number: + return json_write_number((struct json_number_s *)value->payload, data); + case json_type_string: + return json_write_string((struct json_string_s *)value->payload, data); + case json_type_array: + return json_write_pretty_array((struct json_array_s *)value->payload, depth, indent, newline, data); + case json_type_object: + return json_write_pretty_object((struct json_object_s *)value->payload, depth, indent, newline, data); + case json_type_true: + data[0] = 't'; + data[1] = 'r'; + data[2] = 'u'; + data[3] = 'e'; + return data + 4; + case json_type_false: + data[0] = 'f'; + data[1] = 'a'; + data[2] = 'l'; + data[3] = 's'; + data[4] = 'e'; + return data + 5; + case json_type_null: + data[0] = 'n'; + data[1] = 'u'; + data[2] = 'l'; + data[3] = 'l'; + return data + 4; + } } -void *json_write_pretty(const struct json_value_s *value, const char *indent, - const char *newline, size_t *out_size) { - size_t size = 0; - size_t indent_size = 0; - size_t newline_size = 0; - char *data = json_null; - char *data_end = json_null; +void *json_write_pretty(const struct json_value_s *value, const char *indent, const char *newline, size_t *out_size) +{ + size_t size = 0; + size_t indent_size = 0; + size_t newline_size = 0; + char *data = json_null; + char *data_end = json_null; - if (json_null == value) { - return json_null; - } + if (json_null == value) + { + return json_null; + } - if (json_null == indent) { - indent = " "; /* default to two spaces. */ - } + if (json_null == indent) + { + indent = " "; /* default to two spaces. */ + } - if (json_null == newline) { - newline = "\n"; /* default to linux newlines. */ - } + if (json_null == newline) + { + newline = "\n"; /* default to linux newlines. */ + } - while ('\0' != indent[indent_size]) { - ++indent_size; /* skip non-null terminating characters. */ - } + while ('\0' != indent[indent_size]) + { + ++indent_size; /* skip non-null terminating characters. */ + } - while ('\0' != newline[newline_size]) { - ++newline_size; /* skip non-null terminating characters. */ - } + while ('\0' != newline[newline_size]) + { + ++newline_size; /* skip non-null terminating characters. */ + } - if (json_write_pretty_get_value_size(value, 0, indent_size, newline_size, - &size)) { - /* value was malformed! */ - return json_null; - } + if (json_write_pretty_get_value_size(value, 0, indent_size, newline_size, &size)) + { + /* value was malformed! */ + return json_null; + } - size += 1; /* for the '\0' null terminating character. */ + size += 1; /* for the '\0' null terminating character. */ - data = (char *)malloc(size); + data = (char *)malloc(size); - if (json_null == data) { - /* malloc failed! */ - return json_null; - } + if (json_null == data) + { + /* malloc failed! */ + return json_null; + } - data_end = json_write_pretty_value(value, 0, indent, newline, data); + data_end = json_write_pretty_value(value, 0, indent, newline, data); - if (json_null == data_end) { - /* bad chi occurred! */ - free(data); - return json_null; - } + if (json_null == data_end) + { + /* bad chi occurred! */ + free(data); + return json_null; + } - /* null terminated the string. */ - *data_end = '\0'; + /* null terminated the string. */ + *data_end = '\0'; - if (json_null != out_size) { - *out_size = size; - } + if (json_null != out_size) + { + *out_size = size; + } - return data; + return data; } #if defined(__clang__) diff --git a/scripts/midi/safe.json b/scripts/midi/safe.json index 61c68373a..286881831 100644 --- a/scripts/midi/safe.json +++ b/scripts/midi/safe.json @@ -20,13 +20,23 @@ }, "creators": { "Arpeggio": { + "min_count": 0, "max_count": 0 }, "Bass": { - "min_count": 1 + "min_count": 2, + "max_count": 3 }, - "Melody": { + "Chords": { + "min_count": 0, + "max_count": 0 + }, + "Drums": { "min_count": 1, + "max_count": 1 + }, + "Melody": { + "min_count": 2, "max_count": 3 } }, diff --git a/source/bsp.cc b/source/bsp.cc index 448ad1537..756f7c2f5 100644 --- a/source/bsp.cc +++ b/source/bsp.cc @@ -180,7 +180,7 @@ static void VisitFile(const std::string &filename, buildinfo_t *build_info) void ShowBanner() { printf("+-----------------------------------------------+\n"); - printf("| AJBSP " AJBSP_VERSION " (C) 2022 Andrew Apted, et al |\n"); + printf("| AJBSP %s (C) 2022 Andrew Apted, et al |\n", AJBSP_VERSION); printf("+-----------------------------------------------+\n"); fflush(stdout); @@ -285,7 +285,7 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info) // sanity checks for the sizes and properties of certain types. // useful when porting. // -#define assert_size(type, size) \ +#define AJBSP_ASSERT_SIZE(type, size) \ do \ { \ if (sizeof(type) != size) \ @@ -294,18 +294,18 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info) void CheckTypeSizes(buildinfo_t *build_info) { - assert_size(uint8_t, 1); - assert_size(int8_t, 1); - assert_size(uint16_t, 2); - assert_size(int16_t, 2); - assert_size(uint32_t, 4); - assert_size(int32_t, 4); - - assert_size(raw_linedef_t, 14); - assert_size(raw_sector_s, 26); - assert_size(raw_sidedef_t, 30); - assert_size(raw_thing_t, 10); - assert_size(raw_vertex_t, 4); + AJBSP_ASSERT_SIZE(uint8_t, 1); + AJBSP_ASSERT_SIZE(int8_t, 1); + AJBSP_ASSERT_SIZE(uint16_t, 2); + AJBSP_ASSERT_SIZE(int16_t, 2); + AJBSP_ASSERT_SIZE(uint32_t, 4); + AJBSP_ASSERT_SIZE(int32_t, 4); + + AJBSP_ASSERT_SIZE(raw_linedef_t, 14); + AJBSP_ASSERT_SIZE(raw_sector_s, 26); + AJBSP_ASSERT_SIZE(raw_sidedef_t, 30); + AJBSP_ASSERT_SIZE(raw_thing_t, 10); + AJBSP_ASSERT_SIZE(raw_vertex_t, 4); } int AJBSP_BuildNodes(const std::string &filename, buildinfo_t *build_info) diff --git a/source/bsp.h b/source/bsp.h index 2ab4694b4..bec60ee3e 100644 --- a/source/bsp.h +++ b/source/bsp.h @@ -22,15 +22,15 @@ #include -#define AJBSP_VERSION "1.05" +constexpr const char *AJBSP_VERSION = "1.05"; // // Node Build Information Structure // -#define SPLIT_COST_MIN 1 -#define SPLIT_COST_DEFAULT 11 -#define SPLIT_COST_MAX 32 +constexpr uint8_t SPLIT_COST_MIN = 1; +constexpr uint8_t SPLIT_COST_DEFAULT = 11; +constexpr uint8_t SPLIT_COST_MAX = 32; class buildinfo_t { diff --git a/source/bsp_level.cc b/source/bsp_level.cc index 88ac3f6d9..e89c1b9b3 100644 --- a/source/bsp_level.cc +++ b/source/bsp_level.cc @@ -33,11 +33,11 @@ #include "sys_endian.h" #include "sys_macro.h" -#define DEBUG_BLOCKMAP 0 -#define DEBUG_REJECT 0 +#define AJBSP_DEBUG_BLOCKMAP 0 +#define AJBSP_DEBUG_REJECT 0 -#define DEBUG_LOAD 0 -#define DEBUG_BSP 0 +#define AJBSP_DEBUG_LOAD 0 +#define AJBSP_DEBUG_BSP 0 namespace ajbsp { @@ -60,9 +60,9 @@ static uint16_t *block_dups; static int block_compression; static int block_overflowed; -#define BLOCK_LIMIT 16000 +static constexpr uint16_t BLOCK_LIMIT = 16000; -#define DUMMY_DUP 0xFFFF +static constexpr uint16_t DUMMY_DUP = 0xFFFF; void GetBlockmapBounds(int *x, int *y, int *w, int *h) { @@ -147,12 +147,12 @@ int CheckLinedefInsideBox(int xmin, int ymin, int xmax, int ymax, int x1, int y1 /* ----- create blockmap ------------------------------------ */ -#define BK_NUM 0 -#define BK_MAX 1 -#define BK_XOR 2 -#define BK_FIRST 3 +static constexpr uint8_t BK_NUM = 0; +static constexpr uint8_t BK_MAX = 1; +static constexpr uint8_t BK_XOR = 2; +static constexpr uint8_t BK_FIRST = 3; -#define BK_QUANTUM 32 +static constexpr uint8_t BK_QUANTUM = 32; static void BlockAdd(int blk_num, int line_index) { @@ -266,7 +266,7 @@ static void CreateBlockmap(void) { block_lines = (uint16_t **)UtilCalloc(block_count * sizeof(uint16_t *)); - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *L = lev_linedefs[i]; @@ -504,7 +504,7 @@ static void FindBlockmapLimits(bbox_t *bbox) bbox->minx = bbox->miny = SHRT_MAX; bbox->maxx = bbox->maxy = SHRT_MIN; - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *L = lev_linedefs[i]; @@ -535,10 +535,10 @@ static void FindBlockmapLimits(bbox_t *bbox) } } - if (num_linedefs > 0) + if ((int)lev_linedefs.size() > 0) { - block_mid_x = RoundToInteger(mid_x / (double)num_linedefs); - block_mid_y = RoundToInteger(mid_y / (double)num_linedefs); + block_mid_x = OBSIDIAN_I_ROUND(mid_x / (double)(int)lev_linedefs.size()); + block_mid_y = OBSIDIAN_I_ROUND(mid_y / (double)(int)lev_linedefs.size()); } #if DEBUG_BLOCKMAP @@ -566,7 +566,7 @@ void InitBlockmap() void PutBlockmap() { - if (!cur_info->do_blockmap || num_linedefs == 0) + if (!cur_info->do_blockmap || (int)lev_linedefs.size() == 0) { // just create an empty blockmap lump CreateLevelLump("BLOCKMAP")->Finish(); @@ -617,12 +617,12 @@ static int rej_total_size; // in bytes // static void Reject_Init() { - rej_total_size = (num_sectors * num_sectors + 7) / 8; + rej_total_size = ((int)lev_sectors.size() * (int)lev_sectors.size() + 7) / 8; rej_matrix = new uint8_t[rej_total_size]; memset(rej_matrix, 0, rej_total_size); - for (int i = 0; i < num_sectors; i++) + for (int i = 0; i < (int)lev_sectors.size(); i++) { sector_t *sec = lev_sectors[i]; @@ -644,7 +644,7 @@ static void Reject_Free() // static void Reject_GroupSectors() { - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *line = lev_linedefs[i]; @@ -698,7 +698,7 @@ static void Reject_DebugGroups() { // Note: this routine is destructive to the group numbers - for (int i = 0; i < num_sectors; i++) + for (int i = 0; i < (int)lev_sectors.size(); i++) { sector_t *sec = lev_sectors[i]; sector_t *tmp; @@ -725,7 +725,7 @@ static void Reject_DebugGroups() static void Reject_ProcessSectors() { - for (int view = 0; view < num_sectors; view++) + for (int view = 0; view < (int)lev_sectors.size(); view++) { for (int target = 0; target < view; target++) { @@ -737,8 +737,8 @@ static void Reject_ProcessSectors() // for symmetry, do both sides at same time - int p1 = view * num_sectors + target; - int p2 = target * num_sectors + view; + int p1 = view * (int)lev_sectors.size() + target; + int p2 = target * (int)lev_sectors.size() + view; rej_matrix[p1 >> 3] |= (1 << (p1 & 7)); rej_matrix[p2 >> 3] |= (1 << (p2 & 7)); @@ -761,7 +761,7 @@ static void Reject_WriteLump() // void PutReject() { - if (!cur_info->do_reject || num_sectors == 0) + if (!cur_info->do_reject || (int)lev_sectors.size() == 0) { // just create an empty reject lump CreateLevelLump("REJECT")->Finish(); @@ -967,7 +967,7 @@ void FreeWallTips() static vertex_t *SafeLookupVertex(int num) { - if (num >= num_vertices) + if (num >= (int)lev_vertices.size()) FatalError("illegal vertex number #%d\n", num); return lev_vertices[num]; @@ -978,7 +978,7 @@ static sector_t *SafeLookupSector(uint16_t num) if (num == 0xFFFF) return NULL; - if (num >= num_sectors) + if (num >= (int)lev_sectors.size()) FatalError("illegal sector number #%d\n", (int)num); return lev_sectors[num]; @@ -990,7 +990,7 @@ static inline sidedef_t *SafeLookupSidedef(uint16_t num) return NULL; // silently ignore illegal sidedef numbers - if (num >= (unsigned int)num_sidedefs) + if (num >= (unsigned int)(int)lev_sidedefs.size()) return NULL; return lev_sidedefs[num]; @@ -1028,7 +1028,7 @@ void GetVertices() vert->y = (double)LE_S16(raw.y); } - num_old_vert = num_vertices; + num_old_vert = (int)lev_vertices.size(); } void GetSectors() @@ -1315,11 +1315,11 @@ static inline int VanillaSegAngle(const seg_t *seg) /* ----- UDMF reading routines ------------------------- */ -#define UDMF_THING 1 -#define UDMF_VERTEX 2 -#define UDMF_SECTOR 3 -#define UDMF_SIDEDEF 4 -#define UDMF_LINEDEF 5 +static constexpr uint8_t UDMF_THING = 1; +static constexpr uint8_t UDMF_VERTEX = 2; +static constexpr uint8_t UDMF_SECTOR = 3; +static constexpr uint8_t UDMF_SIDEDEF = 4; +static constexpr uint8_t UDMF_LINEDEF = 5; void ParseThingField(thing_t *thing, const std::string &key, ajparse::token_kind_e kind, const std::string &value) { @@ -1353,7 +1353,7 @@ void ParseSidedefField(sidedef_t *side, const std::string &key, ajparse::token_k { int num = ajparse::LEX_Int(value); - if (num < 0 || num >= num_sectors) + if (num < 0 || num >= (int)lev_sectors.size()) FatalError("illegal sector number #%d\n", (int)num); side->sector = lev_sectors[num]; @@ -1378,7 +1378,7 @@ void ParseLinedefField(linedef_t *line, const std::string &key, ajparse::token_k { int num = ajparse::LEX_Int(value); - if (num < 0 || num >= (int)num_sidedefs) + if (num < 0 || num >= (int)(int)lev_sidedefs.size()) line->right = NULL; else line->right = lev_sidedefs[num]; @@ -1388,7 +1388,7 @@ void ParseLinedefField(linedef_t *line, const std::string &key, ajparse::token_k { int num = ajparse::LEX_Int(value); - if (num < 0 || num >= (int)num_sidedefs) + if (num < 0 || num >= (int)(int)lev_sidedefs.size()) line->left = NULL; else line->left = lev_sidedefs[num]; @@ -1594,7 +1594,7 @@ void ParseUDMF() ParseUDMF_Pass(data, 2); ParseUDMF_Pass(data, 3); - num_old_vert = num_vertices; + num_old_vert = (int)lev_vertices.size(); } /* ----- writing routines ------------------------------ */ @@ -1614,11 +1614,11 @@ void PutVertices(const char *name, int do_gl) int count, i; // this size is worst-case scenario - int size = num_vertices * (int)sizeof(raw_vertex_t); + int size = (int)lev_vertices.size() * (int)sizeof(raw_vertex_t); Lump_c *lump = CreateLevelLump(name, size); - for (i = 0, count = 0; i < num_vertices; i++) + for (i = 0, count = 0; i < (int)lev_vertices.size(); i++) { raw_vertex_t raw; @@ -1629,8 +1629,8 @@ void PutVertices(const char *name, int do_gl) continue; } - raw.x = LE_S16(RoundToInteger(vert->x)); - raw.y = LE_S16(RoundToInteger(vert->y)); + raw.x = LE_S16(OBSIDIAN_I_ROUND(vert->x)); + raw.y = LE_S16(OBSIDIAN_I_ROUND(vert->y)); lump->Write(&raw, sizeof(raw)); @@ -1654,7 +1654,7 @@ void PutGLVertices(int do_v5) int count, i; // this size is worst-case scenario - int size = 4 + num_vertices * (int)sizeof(raw_v2_vertex_t); + int size = 4 + (int)lev_vertices.size() * (int)sizeof(raw_v2_vertex_t); Lump_c *lump = CreateLevelLump("GL_VERT", size); @@ -1663,7 +1663,7 @@ void PutGLVertices(int do_v5) else lump->Write(lev_v2_magic, 4); - for (i = 0, count = 0; i < num_vertices; i++) + for (i = 0, count = 0; i < (int)lev_vertices.size(); i++) { raw_v2_vertex_t raw; @@ -1672,8 +1672,8 @@ void PutGLVertices(int do_v5) if (!vert->is_new) continue; - raw.x = LE_S32(RoundToInteger(vert->x * 65536.0)); - raw.y = LE_S32(RoundToInteger(vert->y * 65536.0)); + raw.x = LE_S32(OBSIDIAN_I_ROUND(vert->x * 65536.0)); + raw.y = LE_S32(OBSIDIAN_I_ROUND(vert->y * 65536.0)); lump->Write(&raw, sizeof(raw)); @@ -1713,11 +1713,11 @@ static inline uint32_t VertexIndex_XNOD(const vertex_t *v) void PutSegs() { // this size is worst-case scenario - int size = num_segs * (int)sizeof(raw_seg_t); + int size = (int)lev_segs.size() * (int)sizeof(raw_seg_t); Lump_c *lump = CreateLevelLump("SEGS", size); - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) { raw_seg_t raw; @@ -1742,7 +1742,7 @@ void PutSegs() lump->Finish(); - if (num_segs > 65534) + if ((int)lev_segs.size() > 65534) { LogPrint("Number of segs has overflowed.\n"); MarkOverflow(LIMIT_SEGS); @@ -1752,14 +1752,14 @@ void PutSegs() void PutGLSegs_V2() { // should not happen (we should have upgraded to V5) - SYS_ASSERT(num_segs <= 65534); + SYS_ASSERT((int)lev_segs.size() <= 65534); // this size is worst-case scenario - int size = num_segs * (int)sizeof(raw_gl_seg_t); + int size = (int)lev_segs.size() * (int)sizeof(raw_gl_seg_t); Lump_c *lump = CreateLevelLump("GL_SEGS", size); - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) { raw_gl_seg_t raw; @@ -1795,11 +1795,11 @@ void PutGLSegs_V2() void PutGLSegs_V5() { // this size is worst-case scenario - int size = num_segs * (int)sizeof(raw_v5_seg_t); + int size = (int)lev_segs.size() * (int)sizeof(raw_v5_seg_t); Lump_c *lump = CreateLevelLump("GL_SEGS", size); - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) { raw_v5_seg_t raw; @@ -1834,11 +1834,11 @@ void PutGLSegs_V5() void PutSubsecs(const char *name, int do_gl) { - int size = num_subsecs * (int)sizeof(raw_subsec_t); + int size = (int)lev_subsecs.size() * (int)sizeof(raw_subsec_t); Lump_c *lump = CreateLevelLump(name, size); - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { raw_subsec_t raw; @@ -1854,7 +1854,7 @@ void PutSubsecs(const char *name, int do_gl) #endif } - if (num_subsecs > 32767) + if ((int)lev_subsecs.size() > 32767) { LogPrint("Number of %s has overflowed.\n", do_gl ? "GL subsectors" : "subsectors"); MarkOverflow(do_gl ? LIMIT_GL_SSECT : LIMIT_SSECTORS); @@ -1865,11 +1865,11 @@ void PutSubsecs(const char *name, int do_gl) void PutGLSubsecs_V5() { - int size = num_subsecs * (int)sizeof(raw_v5_subsec_t); + int size = (int)lev_subsecs.size() * (int)sizeof(raw_v5_subsec_t); Lump_c *lump = CreateLevelLump("GL_SSECT", size); - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { raw_v5_subsec_t raw; @@ -1903,10 +1903,10 @@ static void PutOneNode(node_t *node, Lump_c *lump) raw_node_t raw; // note that x/y/dx/dy are always integral in non-UDMF maps - raw.x = LE_S16(RoundToInteger(node->x)); - raw.y = LE_S16(RoundToInteger(node->y)); - raw.dx = LE_S16(RoundToInteger(node->dx)); - raw.dy = LE_S16(RoundToInteger(node->dy)); + raw.x = LE_S16(OBSIDIAN_I_ROUND(node->x)); + raw.y = LE_S16(OBSIDIAN_I_ROUND(node->y)); + raw.dx = LE_S16(OBSIDIAN_I_ROUND(node->dx)); + raw.dy = LE_S16(OBSIDIAN_I_ROUND(node->dy)); raw.b1.minx = LE_S16(node->r.bounds.minx); raw.b1.miny = LE_S16(node->r.bounds.miny); @@ -1954,10 +1954,10 @@ static void PutOneNode_V5(node_t *node, Lump_c *lump) raw_v5_node_t raw; - raw.x = LE_S16(RoundToInteger(node->x)); - raw.y = LE_S16(RoundToInteger(node->y)); - raw.dx = LE_S16(RoundToInteger(node->dx)); - raw.dy = LE_S16(RoundToInteger(node->dy)); + raw.x = LE_S16(OBSIDIAN_I_ROUND(node->x)); + raw.y = LE_S16(OBSIDIAN_I_ROUND(node->y)); + raw.dx = LE_S16(OBSIDIAN_I_ROUND(node->dx)); + raw.dy = LE_S16(OBSIDIAN_I_ROUND(node->dy)); raw.b1.minx = LE_S16(node->r.bounds.minx); raw.b1.miny = LE_S16(node->r.bounds.miny); @@ -1998,7 +1998,7 @@ void PutNodes(const char *name, int do_v5, node_t *root) int struct_size = do_v5 ? (int)sizeof(raw_v5_node_t) : (int)sizeof(raw_node_t); // this can be bigger than the actual size, but never smaller - int max_size = (num_nodes + 1) * struct_size; + int max_size = ((int)lev_nodes.size() + 1) * struct_size; Lump_c *lump = CreateLevelLump(name, max_size); @@ -2014,8 +2014,8 @@ void PutNodes(const char *name, int do_v5, node_t *root) lump->Finish(); - if (node_cur_index != num_nodes) - FatalError("PutNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); + if (node_cur_index != (int)lev_nodes.size()) + FatalError("PutNodes miscounted (%d != %d)\n", node_cur_index, (int)lev_nodes.size()); if (!do_v5 && node_cur_index > 32767) { @@ -2030,21 +2030,21 @@ void CheckLimits() // for sectors, but there may be source ports or tools treating 0xFFFF // as a special value, so we are extra cautious here (and in some of // the other checks below, like the vertex counts). - if (num_sectors > 65535) + if ((int)lev_sectors.size() > 65535) { LogPrint("Map has too many sectors.\n"); MarkOverflow(LIMIT_SECTORS); } // the sidedef 0xFFFF is reserved to mean "no side" in DOOM map format - if (num_sidedefs > 65535) + if ((int)lev_sidedefs.size() > 65535) { LogPrint("Map has too many sidedefs.\n"); MarkOverflow(LIMIT_SIDEDEFS); } // the linedef 0xFFFF is reserved for minisegs in GL nodes - if (num_linedefs > 65535) + if ((int)lev_linedefs.size() > 65535) { LogPrint("Map has too many linedefs.\n"); MarkOverflow(LIMIT_LINEDEFS); @@ -2052,7 +2052,8 @@ void CheckLimits() if (cur_info->gl_nodes && !cur_info->force_v5) { - if (num_old_vert > 32767 || num_new_vert > 32767 || num_segs > 65535 || num_nodes > 32767) + if (num_old_vert > 32767 || num_new_vert > 32767 || (int)lev_segs.size() > 65535 || + (int)lev_nodes.size() > 32767) { LogPrint("Forcing V5 of GL-Nodes due to overflows.\n"); lev_force_v5 = true; @@ -2061,7 +2062,8 @@ void CheckLimits() if (!cur_info->force_xnod) { - if (num_old_vert > 32767 || num_new_vert > 32767 || num_segs > 32767 || num_nodes > 32767) + if (num_old_vert > 32767 || num_new_vert > 32767 || (int)lev_segs.size() > 32767 || + (int)lev_nodes.size() > 32767) { LogPrint("Forcing XNOD format nodes due to overflows.\n"); lev_force_xnod = true; @@ -2080,7 +2082,7 @@ struct Compare_seg_pred void SortSegs() { // do a sanity check - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) if (lev_segs[i]->index < 0) FatalError("Seg %p never reached a subsector!\n", i); @@ -2112,7 +2114,7 @@ void PutZVertices() ZLibAppendLump(&orgverts, 4); ZLibAppendLump(&newverts, 4); - for (i = 0, count = 0; i < num_vertices; i++) + for (i = 0, count = 0; i < (int)lev_vertices.size(); i++) { raw_v2_vertex_t raw; @@ -2121,8 +2123,8 @@ void PutZVertices() if (!vert->is_new) continue; - raw.x = LE_S32(RoundToInteger(vert->x * 65536.0)); - raw.y = LE_S32(RoundToInteger(vert->y * 65536.0)); + raw.x = LE_S32(OBSIDIAN_I_ROUND(vert->x * 65536.0)); + raw.y = LE_S32(OBSIDIAN_I_ROUND(vert->y * 65536.0)); ZLibAppendLump(&raw, sizeof(raw)); @@ -2135,12 +2137,12 @@ void PutZVertices() void PutZSubsecs() { - uint32_t raw_num = LE_U32(num_subsecs); + uint32_t raw_num = LE_U32((int)lev_subsecs.size()); ZLibAppendLump(&raw_num, 4); int cur_seg_index = 0; - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { const subsec_t *sub = lev_subsecs[i]; @@ -2161,16 +2163,16 @@ void PutZSubsecs() FatalError("PutZSubsecs: miscounted segs in sub %d (%d != %d)\n", i, count, sub->seg_count); } - if (cur_seg_index != num_segs) - FatalError("PutZSubsecs miscounted segs (%d != %d)\n", cur_seg_index, num_segs); + if (cur_seg_index != (int)lev_segs.size()) + FatalError("PutZSubsecs miscounted segs (%d != %d)\n", cur_seg_index, (int)lev_segs.size()); } void PutZSegs() { - uint32_t raw_num = LE_U32(num_segs); + uint32_t raw_num = LE_U32((int)lev_segs.size()); ZLibAppendLump(&raw_num, 4); - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) { const seg_t *seg = lev_segs[i]; @@ -2192,10 +2194,10 @@ void PutZSegs() void PutXGL3Segs() { - uint32_t raw_num = LE_U32(num_segs); + uint32_t raw_num = LE_U32((int)lev_segs.size()); ZLibAppendLump(&raw_num, 4); - for (int i = 0; i < num_segs; i++) + for (int i = 0; i < (int)lev_segs.size(); i++) { const seg_t *seg = lev_segs[i]; @@ -2232,10 +2234,10 @@ static void PutOneZNode(node_t *node, bool do_xgl3) if (do_xgl3) { - uint32_t x = LE_S32(RoundToInteger(node->x * 65536.0)); - uint32_t y = LE_S32(RoundToInteger(node->y * 65536.0)); - uint32_t dx = LE_S32(RoundToInteger(node->dx * 65536.0)); - uint32_t dy = LE_S32(RoundToInteger(node->dy * 65536.0)); + uint32_t x = LE_S32(OBSIDIAN_I_ROUND(node->x * 65536.0)); + uint32_t y = LE_S32(OBSIDIAN_I_ROUND(node->y * 65536.0)); + uint32_t dx = LE_S32(OBSIDIAN_I_ROUND(node->dx * 65536.0)); + uint32_t dy = LE_S32(OBSIDIAN_I_ROUND(node->dy * 65536.0)); ZLibAppendLump(&x, 4); ZLibAppendLump(&y, 4); @@ -2244,10 +2246,10 @@ static void PutOneZNode(node_t *node, bool do_xgl3) } else { - raw.x = LE_S16(RoundToInteger(node->x)); - raw.y = LE_S16(RoundToInteger(node->y)); - raw.dx = LE_S16(RoundToInteger(node->dx)); - raw.dy = LE_S16(RoundToInteger(node->dy)); + raw.x = LE_S16(OBSIDIAN_I_ROUND(node->x)); + raw.y = LE_S16(OBSIDIAN_I_ROUND(node->y)); + raw.dx = LE_S16(OBSIDIAN_I_ROUND(node->dx)); + raw.dy = LE_S16(OBSIDIAN_I_ROUND(node->dy)); ZLibAppendLump(&raw.x, 2); ZLibAppendLump(&raw.y, 2); @@ -2295,7 +2297,7 @@ static void PutOneZNode(node_t *node, bool do_xgl3) void PutZNodes(node_t *root, bool do_xgl3) { - uint32_t raw_num = LE_U32(num_nodes); + uint32_t raw_num = LE_U32((int)lev_nodes.size()); ZLibAppendLump(&raw_num, 4); node_cur_index = 0; @@ -2303,8 +2305,8 @@ void PutZNodes(node_t *root, bool do_xgl3) if (root) PutOneZNode(root, do_xgl3); - if (node_cur_index != num_nodes) - FatalError("PutZNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); + if (node_cur_index != (int)lev_nodes.size()) + FatalError("PutZNodes miscounted (%d != %d)\n", node_cur_index, (int)lev_nodes.size()); } static int CalcZDoomNodesSize() @@ -2315,10 +2317,10 @@ static int CalcZDoomNodesSize() int size = 32; // header + a bit extra - size += 8 + num_vertices * 8; - size += 4 + num_subsecs * 4; - size += 4 + num_segs * 11; - size += 4 + num_nodes * sizeof(raw_v5_node_t); + size += 8 + (int)lev_vertices.size() * 8; + size += 4 + (int)lev_subsecs.size() * 4; + size += 4 + (int)lev_segs.size() * 11; + size += 4 + (int)lev_nodes.size() * sizeof(raw_v5_node_t); if (cur_info->force_compress) { @@ -2420,8 +2422,8 @@ void LoadLevel() PruneVerticesAtEnd(); } - LogPrint(" Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", num_vertices, num_sectors, - num_sidedefs, num_linedefs, num_things); + LogPrint(" Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", (int)lev_vertices.size(), + (int)lev_sectors.size(), (int)lev_sidedefs.size(), (int)lev_linedefs.size(), (int)lev_things.size()); DetectOverlappingVertices(); DetectOverlappingLines(); @@ -2468,7 +2470,7 @@ void UpdateGLMarker(Lump_c *marker) marker->Printf("LEVEL=%s\n", lev_current_name); } - marker->Printf("BUILDER=%s\n", "AJBSP " AJBSP_VERSION); + marker->Printf("BUILDER=AJBSP %s\n", AJBSP_VERSION); marker->Finish(); } @@ -2922,8 +2924,8 @@ build_result_e BuildLevel(int lev_idx) if (ret == BUILD_OK) { - LogPrint(" Built %d NODES, %d SSECTORS, %d SEGS, %d VERTEXES\n", num_nodes, num_subsecs, num_segs, - num_old_vert + num_new_vert); + LogPrint(" Built %d NODES, %d SSECTORS, %d SEGS, %d VERTEXES\n", (int)lev_nodes.size(), + (int)lev_subsecs.size(), (int)lev_segs.size(), num_old_vert + num_new_vert); if (root_node != NULL) { diff --git a/source/bsp_local.h b/source/bsp_local.h index 7c3a540f2..28209e29d 100644 --- a/source/bsp_local.h +++ b/source/bsp_local.h @@ -283,7 +283,7 @@ class seg_t // a seg with this index is removed by SortSegs(). // it must be a very high value. -#define SEG_IS_GARBAGE (1 << 29) +constexpr int SEG_IS_GARBAGE = (1 << 29); class subsec_t { @@ -412,17 +412,6 @@ extern std::vector lev_subsecs; extern std::vector lev_nodes; extern std::vector lev_walltips; -#define num_vertices ((int)lev_vertices.size()) -#define num_linedefs ((int)lev_linedefs.size()) -#define num_sidedefs ((int)lev_sidedefs.size()) -#define num_sectors ((int)lev_sectors.size()) -#define num_things ((int)lev_things.size()) - -#define num_segs ((int)lev_segs.size()) -#define num_subsecs ((int)lev_subsecs.size()) -#define num_nodes ((int)lev_nodes.size()) -#define num_walltips ((int)lev_walltips.size()) - extern int num_old_vert; extern int num_new_vert; @@ -450,19 +439,19 @@ void ZLibAppendLump(const void *data, int length); void ZLibFinishLump(void); /* limit flags, to show what went wrong */ -#define LIMIT_VERTEXES 0x000001 -#define LIMIT_SECTORS 0x000002 -#define LIMIT_SIDEDEFS 0x000004 -#define LIMIT_LINEDEFS 0x000008 +constexpr uint8_t LIMIT_VERTEXES = 0x000001; +constexpr uint8_t LIMIT_SECTORS = 0x000002; +constexpr uint8_t LIMIT_SIDEDEFS = 0x000004; +constexpr uint8_t LIMIT_LINEDEFS = 0x000008; -#define LIMIT_SEGS 0x000010 -#define LIMIT_SSECTORS 0x000020 -#define LIMIT_NODES 0x000040 +constexpr uint8_t LIMIT_SEGS = 0x000010; +constexpr uint8_t LIMIT_SSECTORS = 0x000020; +constexpr uint8_t LIMIT_NODES = 0x000040; -#define LIMIT_GL_VERT 0x000100 -#define LIMIT_GL_SEGS 0x000200 -#define LIMIT_GL_SSECT 0x000400 -#define LIMIT_GL_NODES 0x000800 +constexpr uint16_t LIMIT_GL_VERT = 0x000100; +constexpr uint16_t LIMIT_GL_SEGS = 0x000200; +constexpr uint16_t LIMIT_GL_SSECT = 0x000400; +constexpr uint16_t LIMIT_GL_NODES = 0x000800; //------------------------------------------------------------------------ // ANALYZE : Analyzing level structures @@ -492,7 +481,7 @@ vertex_t *NewVertexDegenerate(vertex_t *start, vertex_t *end); // SEG : Choose the best Seg to use for a node line. //------------------------------------------------------------------------ -#define IFFY_LEN 4.0 +constexpr double IFFY_LEN = 4.0; inline void ListAddSeg(seg_t **list_ptr, seg_t *seg) { diff --git a/source/bsp_misc.cc b/source/bsp_misc.cc index 55d65a31b..ce6cb4170 100644 --- a/source/bsp_misc.cc +++ b/source/bsp_misc.cc @@ -29,10 +29,10 @@ #include "sys_debug.h" #include "sys_macro.h" -#define DEBUG_WALLTIPS 0 -#define DEBUG_POLYOBJ 0 -#define DEBUG_WINDOW_FX 0 -#define DEBUG_OVERLAPS 0 +#define AJBSP_DEBUG_WALLTIPS 0 +#define AJBSP_DEBUG_POLYOBJ 0 +#define AJBSP_DEBUG_WINDOW_FX 0 +#define AJBSP_DEBUG_OVERLAPS 0 namespace ajbsp { @@ -41,7 +41,7 @@ namespace ajbsp // ANALYZE : Analyzing level structures //------------------------------------------------------------------------ -#define POLY_BOX_SZ 10 +static constexpr uint8_t POLY_BOX_SZ = 10; /* ----- polyobj handling ----------------------------- */ @@ -62,7 +62,7 @@ void MarkPolyobjSector(sector_t *sector) // the sector from being split. sector->has_polyobj = true; - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { linedef_t *L = lev_linedefs[i]; @@ -91,7 +91,7 @@ void MarkPolyobjPoint(double x, double y) int bmaxx = (int)(x + POLY_BOX_SZ); int bmaxy = (int)(y + POLY_BOX_SZ); - for (i = 0; i < num_linedefs; i++) + for (i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *L = lev_linedefs[i]; @@ -121,7 +121,7 @@ void MarkPolyobjPoint(double x, double y) // If the point is sitting directly on a (two-sided) line, // then we mark the sectors on both sides. - for (i = 0; i < num_linedefs; i++) + for (i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *L = lev_linedefs[i]; @@ -216,7 +216,7 @@ void DetectPolyobjSectors(bool is_udmf) // things in UDMF maps. // -JL- First go through all lines to see if level contains any polyobjs - for (i = 0; i < num_linedefs; i++) + for (i = 0; i < (int)lev_linedefs.size(); i++) { linedef_t *L = lev_linedefs[i]; @@ -224,7 +224,7 @@ void DetectPolyobjSectors(bool is_udmf) break; } - if (i == num_linedefs) + if (i == (int)lev_linedefs.size()) { // -JL- No polyobjs in this level return; @@ -236,7 +236,7 @@ void DetectPolyobjSectors(bool is_udmf) if (is_udmf) hexen_style = false; - for (i = 0; i < num_things; i++) + for (i = 0; i < (int)lev_things.size(); i++) { thing_t *T = lev_things[i]; @@ -252,7 +252,7 @@ void DetectPolyobjSectors(bool is_udmf) DebugPrint("Using %s style polyobj things\n", hexen_style ? "HEXEN" : "ZDOOM"); #endif - for (i = 0; i < num_things; i++) + for (i = 0; i < (int)lev_things.size(); i++) { thing_t *T = lev_things[i]; @@ -301,7 +301,7 @@ struct Compare_vertex_X_pred void DetectOverlappingVertices(void) { - if (num_vertices < 2) + if ((int)lev_vertices.size() < 2) return; // copy the vertex pointers @@ -312,11 +312,11 @@ void DetectOverlappingVertices(void) std::sort(array.begin(), array.end(), Compare_vertex_X_pred()); // now mark them off - for (int i = 0; i < num_vertices - 1; i++) + for (int i = 0; i < (int)lev_vertices.size() - 1; i++) { vertex_t *A = array[i]; - for (int k = i + 1; k < num_vertices; k++) + for (int k = i + 1; k < (int)lev_vertices.size(); k++) { vertex_t *B = array[k]; @@ -339,7 +339,7 @@ void DetectOverlappingVertices(void) // DOES NOT affect the on-disk linedefs. // this is mainly to help the miniseg creation code. - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { linedef_t *L = lev_linedefs[i]; @@ -357,12 +357,12 @@ void DetectOverlappingVertices(void) void PruneVerticesAtEnd(void) { - int old_num = num_vertices; + int old_num = (int)lev_vertices.size(); // scan all vertices. // only remove from the end, so stop when hit a used one. - for (int i = num_vertices - 1; i >= 0; i--) + for (int i = (int)lev_vertices.size() - 1; i >= 0; i--) { vertex_t *V = lev_vertices[i]; @@ -374,14 +374,14 @@ void PruneVerticesAtEnd(void) lev_vertices.pop_back(); } - int unused = old_num - num_vertices; + int unused = old_num - (int)lev_vertices.size(); if (unused > 0) { LogPrint(" Pruned %d unused vertices at end\n", unused); } - num_old_vert = num_vertices; + num_old_vert = (int)lev_vertices.size(); } struct Compare_line_MinX_pred @@ -405,11 +405,11 @@ void DetectOverlappingLines(void) int count = 0; - for (int i = 0; i < num_linedefs - 1; i++) + for (int i = 0; i < (int)lev_linedefs.size() - 1; i++) { linedef_t *A = array[i]; - for (int k = i + 1; k < num_linedefs; k++) + for (int k = i + 1; k < (int)lev_linedefs.size(); k++) { linedef_t *B = array[k]; @@ -484,7 +484,7 @@ void vertex_t::AddWallTip(double dx, double dy, bool open_left, bool open_right) void CalculateWallTips() { - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { const linedef_t *L = lev_linedefs[i]; @@ -507,7 +507,7 @@ void CalculateWallTips() } #if DEBUG_WALLTIPS - for (int k = 0; k < num_vertices; k++) + for (int k = 0; k < (int)lev_vertices.size(); k++) { vertex_t *V = lev_vertices[k]; @@ -585,7 +585,8 @@ vertex_t *NewVertexDegenerate(vertex_t *start, vertex_t *end) dx /= dlen; dy /= dlen; - while (RoundToInteger(vert->x) == RoundToInteger(start->x) && RoundToInteger(vert->y) == RoundToInteger(start->y)) + while (OBSIDIAN_I_ROUND(vert->x) == OBSIDIAN_I_ROUND(start->x) && + OBSIDIAN_I_ROUND(vert->y) == OBSIDIAN_I_ROUND(start->y)) { vert->x += dx; vert->y += dy; diff --git a/source/bsp_node.cc b/source/bsp_node.cc index a04870e12..e91c9fd10 100644 --- a/source/bsp_node.cc +++ b/source/bsp_node.cc @@ -26,12 +26,12 @@ #include "sys_debug.h" #include "sys_macro.h" -#define DEBUG_SPLIT 0 -#define DEBUG_CUTLIST 0 +#define AJBSP_DEBUG_SPLIT 0 +#define AJBSP_DEBUG_CUTLIST 0 -#define DEBUG_BUILDER 0 -#define DEBUG_SORTER 0 -#define DEBUG_SUBSEC 0 +#define AJBSP_DEBUG_BUILDER 0 +#define AJBSP_DEBUG_SORTER 0 +#define AJBSP_DEBUG_SUBSEC 0 // // To be able to divide the nodes down, this routine must decide which @@ -54,9 +54,9 @@ namespace ajbsp { -#define PRECIOUS_MULTIPLY 100 +static constexpr uint8_t PRECIOUS_MULTIPLY = 100; -#define SEG_FAST_THRESHHOLD 200 +static constexpr uint8_t SEG_FAST_THRESHHOLD = 200; class eval_info_t { @@ -1176,7 +1176,7 @@ seg_t *CreateSegs() { seg_t *list = NULL; - for (int i = 0; i < num_linedefs; i++) + for (int i = 0; i < (int)lev_linedefs.size(); i++) { linedef_t *line = lev_linedefs[i]; @@ -1446,7 +1446,7 @@ subsec_t *CreateSubsec(quadtree_c *tree) subsec_t *sub = NewSubsec(); // compute subsector's index - sub->index = num_subsecs - 1; + sub->index = (int)lev_subsecs.size() - 1; // copy segs into subsector sub->seg_list = NULL; @@ -1580,7 +1580,7 @@ void ClockwiseBspTree() { int cur_seg_index = 0; - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { subsec_t *sub = lev_subsecs[i]; @@ -1646,7 +1646,7 @@ void NormaliseBspTree() int cur_seg_index = 0; - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { subsec_t *sub = lev_subsecs[i]; @@ -1657,7 +1657,7 @@ void NormaliseBspTree() void RoundOffVertices() { - for (int i = 0; i < num_vertices; i++) + for (int i = 0; i < (int)lev_vertices.size(); i++) { vertex_t *vert = lev_vertices[i]; @@ -1691,8 +1691,8 @@ void subsec_t::RoundOff() for (seg = seg_list; seg; seg = seg->next) { // is the seg degenerate ? - if (RoundToInteger(seg->start->x) == RoundToInteger(seg->end->x) && - RoundToInteger(seg->start->y) == RoundToInteger(seg->end->y)) + if (OBSIDIAN_I_ROUND(seg->start->x) == OBSIDIAN_I_ROUND(seg->end->x) && + OBSIDIAN_I_ROUND(seg->start->y) == OBSIDIAN_I_ROUND(seg->end->y)) { seg->is_degenerate = true; @@ -1727,9 +1727,9 @@ void subsec_t::RoundOff() last_real_degen->end = NewVertexDegenerate(last_real_degen->start, last_real_degen->end); #if DEBUG_SUBSEC - DebugPrint("Degenerate after: (%d,%d) -> (%d,%d)\n", RoundToInteger(last_real_degen->start->x), - RoundToInteger(last_real_degen->start->y), RoundToInteger(last_real_degen->end->x), - RoundToInteger(last_real_degen->end->y)); + DebugPrint("Degenerate after: (%d,%d) -> (%d,%d)\n", OBSIDIAN_I_ROUND(last_real_degen->start->x), + OBSIDIAN_I_ROUND(last_real_degen->start->y), OBSIDIAN_I_ROUND(last_real_degen->end->x), + OBSIDIAN_I_ROUND(last_real_degen->end->y)); #endif last_real_degen->is_degenerate = false; @@ -1778,7 +1778,7 @@ void RoundOffBspTree() RoundOffVertices(); - for (int i = 0; i < num_subsecs; i++) + for (int i = 0; i < (int)lev_subsecs.size(); i++) { subsec_t *sub = lev_subsecs[i]; diff --git a/source/bsp_wad.cc b/source/bsp_wad.cc index acb07e00e..b078295f7 100644 --- a/source/bsp_wad.cc +++ b/source/bsp_wad.cc @@ -30,7 +30,7 @@ #include "sys_endian.h" #include "sys_macro.h" -#define DEBUG_WAD 0 +#define AJBSP_DEBUG_WAD 0 namespace ajbsp { @@ -381,7 +381,7 @@ int Wad_file::FindLumpNum(const char *name) return -1; // not found } -#define MAX_LUMPS_IN_A_LEVEL 21 +static constexpr uint8_t MAX_LUMPS_IN_A_LEVEL = 21; int Wad_file::LevelLookupLump(int lev_num, const char *name) { diff --git a/source/csg_bsp.cc b/source/csg_bsp.cc index 84aac244d..8b63cf088 100644 --- a/source/csg_bsp.cc +++ b/source/csg_bsp.cc @@ -161,8 +161,8 @@ void snag_c::CalcAlongs() a1 /= SNAG_EPSILON; a2 /= SNAG_EPSILON; - q_along1 = RoundToInteger(a1); - q_along2 = RoundToInteger(a2); + q_along1 = OBSIDIAN_I_ROUND(a1); + q_along2 = OBSIDIAN_I_ROUND(a2); } bool snag_c::SameSides() const @@ -723,8 +723,8 @@ bsp_node_c *bsp_root; static void QuantizeVert(const brush_vert_c *V, int *qx, int *qy) { - *qx = RoundToInteger(V->x / QUANTIZE_GRID); - *qy = RoundToInteger(V->y / QUANTIZE_GRID); + *qx = OBSIDIAN_I_ROUND(V->x / QUANTIZE_GRID); + *qy = OBSIDIAN_I_ROUND(V->y / QUANTIZE_GRID); } static bool OnSameLine(double x1, double y1, double x2, double y2, const snag_c *S, double DIST) @@ -2232,7 +2232,7 @@ void CSG_BSP_Free() // TESTING GOODIES //------------------------------------------------------------------------ -#ifdef DEBUG_CSG_BSP +#ifdef CSG_DEBUG_BSP #include "g_doom.h" @@ -2246,8 +2246,8 @@ static int TestVertex(snag_c *S, int which) double x = which ? S->x2 : S->x1; double y = which ? S->y2 : S->y1; - int ix = RoundToInteger(x + RX * 0); - int iy = RoundToInteger(y + RY * 0); + int ix = OBSIDIAN_I_ROUND(x + RX * 0); + int iy = OBSIDIAN_I_ROUND(y + RY * 0); int id = (iy << 16) + ix; @@ -2309,7 +2309,7 @@ void CSG_TestRegions_Doom() { csg_entity_c *E = R->entities[k]; - DM_AddThing(RoundToInteger(E->x), RoundToInteger(E->y), 0, 11, sec_id, 7, 0, 0, NULL); + DM_AddThing(OBSIDIAN_I_ROUND(E->x), OBSIDIAN_I_ROUND(E->y), 0, 11, sec_id, 7, 0, 0, NULL); } for (k = 0; k < R->snags.size(); k++) diff --git a/source/csg_doom.cc b/source/csg_doom.cc index 7ad491751..213b2f7c0 100644 --- a/source/csg_doom.cc +++ b/source/csg_doom.cc @@ -47,28 +47,28 @@ static int map_bound_y1, map_bound_y2; static int dummy_pos_x; static int dummy_pos_y; -#define SEC_FLOOR_SPECIAL (1 << 1) -#define SEC_CEIL_SPECIAL (1 << 2) +constexpr uint8_t SEC_FLOOR_SPECIAL = (1 << 1); +constexpr uint8_t SEC_CEIL_SPECIAL = (1 << 2); double light_dist_factor = 800.0; -#define COLINEAR_THRESHHOLD 0.01 +constexpr double COLINEAR_THRESHHOLD = 0.01; -#define MTF_ALL_SKILLS (MTF_Easy | MTF_Medium | MTF_Hard) +constexpr int MTF_ALL_SKILLS = (MTF_Easy | MTF_Medium | MTF_Hard); -#define MTF_HEXEN_CLASSES (32 + 64 + 128) -#define MTF_HEXEN_MODES (256 + 512 + 1024) +constexpr int MTF_HEXEN_CLASSES = (32 + 64 + 128); +constexpr int MTF_HEXEN_MODES = (256 + 512 + 1024); -#define MTF_EDGE_EXFLOOR_SHIFT 10 +constexpr uint8_t MTF_EDGE_EXFLOOR_SHIFT = 10; // fake linedef special for lower-unpegging -#define LIN_FAKE_UNPEGGED 991 +constexpr uint16_t LIN_FAKE_UNPEGGED = 991; // fake sector special to merge sector with lowest neighbor floor -#define SEC_GRAB_NB_FLOOR 993 +constexpr uint16_t SEC_GRAB_NB_FLOOR = 993; // fake sector special for teleporting monster closets -#define SEC_DEPOT_PEER 988 +constexpr uint16_t SEC_DEPOT_PEER = 988; class extrafloor_c { @@ -614,8 +614,8 @@ class linedef_c sidedef_c *B_front = B->front; sidedef_c *B_back = B->back; - int A_len = RoundToInteger(length); - int B_len = RoundToInteger(B->length); + int A_len = OBSIDIAN_I_ROUND(length); + int B_len = OBSIDIAN_I_ROUND(B->length); if (!CanMergeSides(front, B_front)) { @@ -916,8 +916,8 @@ static void MakeSector(region_c *R) double f_delta = f_face->getDouble("delta_z"); double c_delta = c_face->getDouble("delta_z"); - S->f_h = RoundToInteger(B->t.z + f_delta); - S->c_h = RoundToInteger(T->b.z + c_delta); + S->f_h = OBSIDIAN_I_ROUND(B->t.z + f_delta); + S->c_h = OBSIDIAN_I_ROUND(T->b.z + c_delta); // when delta-ing up the floor, limit it to the ceiling // (this can be important in outdoor rooms) @@ -1171,7 +1171,7 @@ static int NaturalXOffset(Doom::linedef_c *L, int side) along = AlongDist(0, 0, L->end->x, L->end->y, L->start->x, L->start->y); } - return RoundToInteger(-along); + return OBSIDIAN_I_ROUND(-along); } static int CalcXOffset(snag_c *S, brush_vert_c *V, int ox) @@ -1293,7 +1293,7 @@ static sidedef_c *MakeSidedef(linedef_c *L, sector_c *sec, sector_c *back, snag_ // adjust Y-offset for higher floor than expected int sec_max_z = OBSIDIAN_MAX(sec->f_h, back->f_h); - r_oy += RoundToInteger(rail->parent->b.z) - sec_max_z; + r_oy += OBSIDIAN_I_ROUND(rail->parent->b.z) - sec_max_z; } } @@ -1584,11 +1584,11 @@ static void MakeLine(region_c *R, snag_c *S) } // skip snags which would become zero length linedefs - int x1 = RoundToInteger(S->x1); - int y1 = RoundToInteger(S->y1); + int x1 = OBSIDIAN_I_ROUND(S->x1); + int y1 = OBSIDIAN_I_ROUND(S->y1); - int x2 = RoundToInteger(S->x2); - int y2 = RoundToInteger(S->y2); + int x2 = OBSIDIAN_I_ROUND(S->x2); + int y2 = OBSIDIAN_I_ROUND(S->y2); if (x1 == x2 && y1 == y2) { @@ -1896,14 +1896,14 @@ static void AlignTextures() while (P->sim_prev && P->sim_prev->front->x_offset == IVAL_NONE) { - P->sim_prev->front->x_offset = P->front->x_offset - RoundToInteger(P->sim_prev->length); + P->sim_prev->front->x_offset = P->front->x_offset - OBSIDIAN_I_ROUND(P->sim_prev->length); P = P->sim_prev; prev_count++; } while (N->sim_next && N->sim_next->front->x_offset == IVAL_NONE) { - N->sim_next->front->x_offset = N->front->x_offset + RoundToInteger(N->length); + N->sim_next->front->x_offset = N->front->x_offset + OBSIDIAN_I_ROUND(N->length); N = N->sim_next; next_count++; } @@ -2256,7 +2256,7 @@ static void RoundCorners() // DUMMY SECTORS //------------------------------------------------------------------------ -#define DUMMY_MAX_SHARE 8 +constexpr uint8_t DUMMY_MAX_SHARE = 8; class dummy_line_info_c { @@ -2534,8 +2534,8 @@ static void SolidExtraFloor(sector_c *sec, gap_c *gap1, gap_c *gap2) } } - EF->top_h = RoundToInteger(gap2->bottom->t.z); - EF->bottom_h = RoundToInteger(gap1->top->b.z); + EF->top_h = OBSIDIAN_I_ROUND(gap2->bottom->t.z); + EF->bottom_h = OBSIDIAN_I_ROUND(gap1->top->b.z); EF->top = gap2->bottom->t.face.getStr("tex", dummy_plane_tex); EF->bottom = gap1->top->b.face.getStr("tex", dummy_plane_tex); @@ -2565,11 +2565,11 @@ static void LiquidExtraFloor(sector_c *sec, csg_brush_c *liquid) if (EF->line_special == 301) // Legacy style { EF->bottom_h = sec->f_h; - EF->top_h = RoundToInteger(liquid->t.z); + EF->top_h = OBSIDIAN_I_ROUND(liquid->t.z); } else // EDGE style { - EF->bottom_h = RoundToInteger(liquid->t.z); + EF->bottom_h = OBSIDIAN_I_ROUND(liquid->t.z); EF->top_h = EF->bottom_h + 128; // not significant } @@ -3019,9 +3019,9 @@ static void WriteThing(sector_c *S, csg_entity_c *E) return; } - int x = RoundToInteger(E->x); - int y = RoundToInteger(E->y); - int z = RoundToInteger(E->z); + int x = OBSIDIAN_I_ROUND(E->x); + int y = OBSIDIAN_I_ROUND(E->y); + int z = OBSIDIAN_I_ROUND(E->z); int h = z - S->f_h; diff --git a/source/csg_local.h b/source/csg_local.h index 24c4dc2b4..497a435f5 100644 --- a/source/csg_local.h +++ b/source/csg_local.h @@ -25,7 +25,7 @@ #include "csg_main.h" -#define SNAG_EPSILON 0.001 +constexpr double SNAG_EPSILON = 0.001; /***** CLASSES ****************/ diff --git a/source/csg_main.cc b/source/csg_main.cc index ba3cba251..d58dfc2de 100644 --- a/source/csg_main.cc +++ b/source/csg_main.cc @@ -30,7 +30,7 @@ #include "sys_assert.h" #include "sys_macro.h" -#define EPSILON 0.001 +constexpr double EPSILON = 0.001; double CLUSTER_SIZE = 128.0; @@ -191,9 +191,9 @@ std::string dummy_plane_tex; double CHUNK_SIZE = 512.0; // csg_spots.cc -#define SPOT_LOW_CEIL 1 -#define SPOT_WALL 2 -#define SPOT_LEDGE 3 +constexpr uint8_t SPOT_LOW_CEIL = 1; +constexpr uint8_t SPOT_WALL = 2; +constexpr uint8_t SPOT_LEDGE = 3; int spot_low_h = 72; int spot_high_h = 128; @@ -236,7 +236,7 @@ int csg_property_set_c::getInt(const std::string &key, int def_val) const { std::string str = getStr(key); - return !str.empty() ? RoundToInteger(StringToDouble(str)) : def_val; + return !str.empty() ? OBSIDIAN_I_ROUND(StringToDouble(str)) : def_val; } void csg_property_set_c::getHexenArgs(uint8_t *arg5) const @@ -656,7 +656,7 @@ bool csg_entity_c::Match(std::string_view want_name) const //------------------------------------------------------------------------ -#define QUAD_NODE_SIZE 320 +constexpr uint16_t QUAD_NODE_SIZE = 320; class brush_quad_node_c { @@ -881,8 +881,8 @@ class brush_quad_node_c double t_delta = B->t.face.getDouble("delta_z", 0); double b_delta = B->b.face.getDouble("delta_z", 0); - int t_z = RoundToInteger(B->t.z + t_delta); - int b_z = RoundToInteger(B->b.z + b_delta); + int t_z = OBSIDIAN_I_ROUND(B->t.z + t_delta); + int b_z = OBSIDIAN_I_ROUND(B->b.z + b_delta); // skip brushes underneath the floor (or the floor itself) if (t_z < floor_h + 1) @@ -920,8 +920,8 @@ class brush_quad_node_c // rounding to integer here, I don't think it is any problem, // as the spot polygon-drawing code is fairly robust. - shape.push_back(RoundToInteger(V->x)); - shape.push_back(RoundToInteger(V->y)); + shape.push_back(OBSIDIAN_I_ROUND(V->x)); + shape.push_back(OBSIDIAN_I_ROUND(V->y)); } SPOT_FillPolygon(content, &shape[0], num_vert); diff --git a/source/csg_main.h b/source/csg_main.h index 1f5b0696f..8e42d3bb2 100644 --- a/source/csg_main.h +++ b/source/csg_main.h @@ -32,10 +32,10 @@ class csg_entity_c; class quake_plane_c; // very high (low) value for uncapped brushes -#define EXTREME_H 32000 +constexpr uint16_t EXTREME_H = 32000; // epsilon for height comparisons -#define Z_EPSILON 0.01 +constexpr double Z_EPSILON = 0.01; // this is used for all games. defaults to 512.0 extern double CHUNK_SIZE; @@ -45,8 +45,8 @@ extern double CHUNK_SIZE; extern double CLUSTER_SIZE; // unset values (handy sometimes) -#define IVAL_NONE -27777 -#define FVAL_NONE -27777.75f +constexpr int16_t IVAL_NONE = -27777; +constexpr float FVAL_NONE = -27777.75f; /******* CLASSES ***************/ diff --git a/source/csg_shade.cc b/source/csg_shade.cc index 9ca815850..13aca5d74 100644 --- a/source/csg_shade.cc +++ b/source/csg_shade.cc @@ -71,7 +71,7 @@ Lighting Model */ -#define DEFAULT_AMBIENT_LEVEL 144 +constexpr uint8_t DEFAULT_AMBIENT_LEVEL = 144; static int current_region_group; diff --git a/source/csg_spots.cc b/source/csg_spots.cc index 9dd57f26f..a2d2061e5 100644 --- a/source/csg_spots.cc +++ b/source/csg_spots.cc @@ -26,19 +26,19 @@ #include "sys_assert.h" #include "sys_macro.h" -#define GRID_SIZE 20 +constexpr uint8_t GRID_SIZE = 20; -#define MAX_MON_CELLS 14 /* i.e. 280 units */ +constexpr uint8_t MAX_MON_CELLS = 14; /* i.e. 280 units */ -#define SPOT_CLEAR 0 -#define SPOT_LOW_CEIL 1 -#define SPOT_WALL 2 -#define SPOT_LEDGE 3 +constexpr uint8_t SPOT_CLEAR = 0; +constexpr uint8_t SPOT_LOW_CEIL = 1; +constexpr uint8_t SPOT_WALL = 2; +constexpr uint8_t SPOT_LEDGE = 3; -#define NEAR_WALL 0x08 -#define HAS_ITEM 0x10 -#define HAS_MON 0x20 -#define IS_DUD 0x40 +constexpr uint8_t NEAR_WALL = 0x08; +constexpr uint8_t HAS_ITEM = 0x10; +constexpr uint8_t HAS_MON = 0x20; +constexpr uint8_t IS_DUD = 0x40; static int grid_min_x, grid_min_y; static int grid_max_x, grid_max_y; @@ -824,10 +824,10 @@ int SPOT_begin(lua_State *L) // int SPOT_draw_line(lua_State *L) { - int x1 = RoundToInteger(luaL_checknumber(L, 1)); - int y1 = RoundToInteger(luaL_checknumber(L, 2)); - int x2 = RoundToInteger(luaL_checknumber(L, 3)); - int y2 = RoundToInteger(luaL_checknumber(L, 4)); + int x1 = OBSIDIAN_I_ROUND(luaL_checknumber(L, 1)); + int y1 = OBSIDIAN_I_ROUND(luaL_checknumber(L, 2)); + int x2 = OBSIDIAN_I_ROUND(luaL_checknumber(L, 3)); + int y2 = OBSIDIAN_I_ROUND(luaL_checknumber(L, 4)); int content = luaL_checkinteger(L, 5); @@ -855,8 +855,8 @@ static int polygon_coord(lua_State *L, int stack_pos, std::vector if (!lua_isnil(L, -2)) { - int x = RoundToInteger(luaL_checknumber(L, -2)); - int y = RoundToInteger(luaL_checknumber(L, -1)); + int x = OBSIDIAN_I_ROUND(luaL_checknumber(L, -2)); + int y = OBSIDIAN_I_ROUND(luaL_checknumber(L, -1)); points.push_back(grid_point_c(x, y)); } diff --git a/source/dm_extra.cc b/source/dm_extra.cc index 3fa4f49ad..e573bcbb4 100644 --- a/source/dm_extra.cc +++ b/source/dm_extra.cc @@ -44,9 +44,7 @@ static int sky_W; static int sky_H; static int sky_final_W; -#define MAX_POST_LEN 200 - -#define CUR_PIXEL(py) (pixels[((py) % H) * W]) +constexpr uint8_t MAX_POST_LEN = 200; static void AddPost(qLump_c *lump, int y, int len, const uint8_t *pixels, int W, int H) { @@ -58,17 +56,17 @@ static void AddPost(qLump_c *lump, int y, int len, const uint8_t *pixels, int W, uint8_t buffer[512]; uint8_t *dest = buffer; - *dest++ = y; // Y-OFFSET - *dest++ = len; // # PIXELS + *dest++ = y; // Y-OFFSET + *dest++ = len; // # PIXELS - *dest++ = CUR_PIXEL(y); // TOP-PADDING + *dest++ = pixels[((y) % H) * W]; // TOP-PADDING for (; len > 0; len--, y++) { - *dest++ = CUR_PIXEL(y); + *dest++ = pixels[((y) % H) * W]; } - *dest++ = CUR_PIXEL(y - 1); // BOTTOM-PADDING + *dest++ = pixels[((y - 1) % H) * W]; // BOTTOM-PADDING lump->Append(buffer, dest - buffer); } @@ -97,7 +95,7 @@ qLump_c *CreatePatch(int new_W, int new_H, int ofs_X, int ofs_Y, const uint8_t * for (y = 0; y < new_H;) { - if (trans_p >= 0 && CUR_PIXEL(y) == trans_p) + if (trans_p >= 0 && pixels[((y) % H) * W] == trans_p) { y++; continue; @@ -105,7 +103,7 @@ qLump_c *CreatePatch(int new_W, int new_H, int ofs_X, int ofs_Y, const uint8_t * int len = 1; - while ((y + len) < new_H && len < MAX_POST_LEN && !(trans_p >= 0 && CUR_PIXEL(y + len) == trans_p)) + while ((y + len) < new_H && len < MAX_POST_LEN && !(trans_p >= 0 && pixels[((y + len) % H) * W] == trans_p)) { len++; } @@ -142,8 +140,6 @@ qLump_c *CreatePatch(int new_W, int new_H, int ofs_X, int ofs_Y, const uint8_t * return lump; } -#undef CUR_PIXEL - qLump_c *CreateFlat(int new_W, int new_H, const uint8_t *pixels, int W, int H) { qLump_c *lump = new qLump_c(); @@ -1035,7 +1031,7 @@ static qLump_c *DoLoadLump(int src_entry) return lump; } -#define NUM_LEVEL_LUMPS 12 +constexpr uint8_t NUM_LEVEL_LUMPS = 12; static const char *level_lumps[NUM_LEVEL_LUMPS] = { "THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES", "SEGS", "SSECTORS", "NODES", "SECTORS", "REJECT", "BLOCKMAP", @@ -1408,7 +1404,7 @@ static rgb_color_t Grab_Color(lua_State *L, int stack_idx) luaL_error(L, "bad color string"); } - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } if (lua_istable(L, stack_idx)) @@ -1435,18 +1431,18 @@ static rgb_color_t Grab_Color(lua_State *L, int stack_idx) lua_pop(L, 3); - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } luaL_error(L, "bad color value (not a string or table)"); - return MAKE_RGBA(0, 0, 0, 255); /* NOT REACHED */ + return OBSIDIAN_MAKE_RGBA(0, 0, 0, 255); /* NOT REACHED */ } static uint8_t PaletteLookup(rgb_color_t col, const rgb_color_t *palette) { - int r = RGB_RED(col); - int g = RGB_GREEN(col); - int b = RGB_BLUE(col); + int r = OBSIDIAN_RGB_RED(col); + int g = OBSIDIAN_RGB_GREEN(col); + int b = OBSIDIAN_RGB_BLUE(col); int best = 0; int best_dist = (1 << 30); @@ -1454,9 +1450,9 @@ static uint8_t PaletteLookup(rgb_color_t col, const rgb_color_t *palette) // ignore the very last color for (int c = 0; c < 255; c++) { - int dr = r - RGB_RED(palette[c]); - int dg = g - RGB_GREEN(palette[c]); - int db = b - RGB_BLUE(palette[c]); + int dr = r - OBSIDIAN_RGB_RED(palette[c]); + int dg = g - OBSIDIAN_RGB_GREEN(palette[c]); + int db = b - OBSIDIAN_RGB_BLUE(palette[c]); int dist = dr * dr + dg * dg + db * db; @@ -1528,7 +1524,7 @@ static struct for (int i = 0; i < 4; i++) { - color[i] = MAKE_RGBA(0, 0, 0, 255); + color[i] = OBSIDIAN_MAKE_RGBA(0, 0, 0, 255); } box_w = 1; @@ -1647,9 +1643,9 @@ static int TitleAveragePixel(int x, int y) { const rgb_color_t c = title_pix[(y + ky) * title_W3 + (x + kx)]; - r += RGB_RED(c); - g += RGB_GREEN(c); - b += RGB_BLUE(c); + r += OBSIDIAN_RGB_RED(c); + g += OBSIDIAN_RGB_GREEN(c); + b += OBSIDIAN_RGB_BLUE(c); } } @@ -1657,7 +1653,7 @@ static int TitleAveragePixel(int x, int y) g = g / 9; b = b / 9; - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static qLump_c *TitleCreateTGA() @@ -1694,9 +1690,9 @@ static qLump_c *TitleCreateTGA() { rgb_color_t col = TitleAveragePixel(x, y); - lump->AddByte(RGB_BLUE(col)); - lump->AddByte(RGB_GREEN(col)); - lump->AddByte(RGB_RED(col)); + lump->AddByte(OBSIDIAN_RGB_BLUE(col)); + lump->AddByte(OBSIDIAN_RGB_GREEN(col)); + lump->AddByte(OBSIDIAN_RGB_RED(col)); } } @@ -1825,7 +1821,7 @@ int title_set_palette(lua_State *L) lua_pop(L, 3); - title_palette[c] = MAKE_RGBA(r, g, b, 255); + title_palette[c] = OBSIDIAN_MAKE_RGBA(r, g, b, 255); } return 0; @@ -1968,15 +1964,15 @@ static inline rgb_color_t CalcAlphaBlend(rgb_color_t C1, rgb_color_t C2, int alp return C1; } - int r = RGB_RED(C1) * (256 - alpha) + RGB_RED(C2) * alpha; - int g = RGB_GREEN(C1) * (256 - alpha) + RGB_GREEN(C2) * alpha; - int b = RGB_BLUE(C1) * (256 - alpha) + RGB_BLUE(C2) * alpha; + int r = OBSIDIAN_RGB_RED(C1) * (256 - alpha) + OBSIDIAN_RGB_RED(C2) * alpha; + int g = OBSIDIAN_RGB_GREEN(C1) * (256 - alpha) + OBSIDIAN_RGB_GREEN(C2) * alpha; + int b = OBSIDIAN_RGB_BLUE(C1) * (256 - alpha) + OBSIDIAN_RGB_BLUE(C2) * alpha; r >>= 8; g >>= 8; b >>= 8; - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static inline rgb_color_t CalcGradient(float along) @@ -2011,50 +2007,50 @@ static inline rgb_color_t CalcGradient(float along) along = pow(along, 0.75); } - int r = RGB_RED(col1) * (1 - along) + RGB_RED(col2) * along; - int g = RGB_GREEN(col1) * (1 - along) + RGB_GREEN(col2) * along; - int b = RGB_BLUE(col1) * (1 - along) + RGB_BLUE(col2) * along; + int r = OBSIDIAN_RGB_RED(col1) * (1 - along) + OBSIDIAN_RGB_RED(col2) * along; + int g = OBSIDIAN_RGB_GREEN(col1) * (1 - along) + OBSIDIAN_RGB_GREEN(col2) * along; + int b = OBSIDIAN_RGB_BLUE(col1) * (1 - along) + OBSIDIAN_RGB_BLUE(col2) * along; - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static inline rgb_color_t CalcAdditive(rgb_color_t C1, rgb_color_t C2) { - int r = RGB_RED(C1) + RGB_RED(C2); - int g = RGB_GREEN(C1) + RGB_GREEN(C2); - int b = RGB_BLUE(C1) + RGB_BLUE(C2); + int r = OBSIDIAN_RGB_RED(C1) + OBSIDIAN_RGB_RED(C2); + int g = OBSIDIAN_RGB_GREEN(C1) + OBSIDIAN_RGB_GREEN(C2); + int b = OBSIDIAN_RGB_BLUE(C1) + OBSIDIAN_RGB_BLUE(C2); r = OBSIDIAN_MIN(r, 255); g = OBSIDIAN_MIN(g, 255); b = OBSIDIAN_MIN(b, 255); - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static inline rgb_color_t CalcSubtract(rgb_color_t C1, rgb_color_t C2) { - int r = RGB_RED(C1) - RGB_RED(C2); - int g = RGB_GREEN(C1) - RGB_GREEN(C2); - int b = RGB_BLUE(C1) - RGB_BLUE(C2); + int r = OBSIDIAN_RGB_RED(C1) - OBSIDIAN_RGB_RED(C2); + int g = OBSIDIAN_RGB_GREEN(C1) - OBSIDIAN_RGB_GREEN(C2); + int b = OBSIDIAN_RGB_BLUE(C1) - OBSIDIAN_RGB_BLUE(C2); r = OBSIDIAN_MAX(r, 0); g = OBSIDIAN_MAX(g, 0); b = OBSIDIAN_MAX(b, 0); - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static inline rgb_color_t CalcMultiply(rgb_color_t C1, rgb_color_t C2) { - int r = RGB_RED(C1) * (RGB_RED(C2) + 1); - int g = RGB_GREEN(C1) * (RGB_GREEN(C2) + 1); - int b = RGB_BLUE(C1) * (RGB_BLUE(C2) + 1); + int r = OBSIDIAN_RGB_RED(C1) * (OBSIDIAN_RGB_RED(C2) + 1); + int g = OBSIDIAN_RGB_GREEN(C1) * (OBSIDIAN_RGB_GREEN(C2) + 1); + int b = OBSIDIAN_RGB_BLUE(C1) * (OBSIDIAN_RGB_BLUE(C2) + 1); r = r >> 8; g = g >> 8; b = b >> 8; - return MAKE_RGBA(r, g, b, 255); + return OBSIDIAN_MAKE_RGBA(r, g, b, 255); } static inline rgb_color_t CalcPixel(int x, int y) @@ -2081,7 +2077,7 @@ static inline rgb_color_t CalcPixel(int x, int y) case REND_Textured: if (!title_last_tga) { - return MAKE_RGBA(0, 255, 255, 255); + return OBSIDIAN_MAKE_RGBA(0, 255, 255, 255); } px = (x / 3) % title_last_tga->width; @@ -2434,7 +2430,7 @@ static void TDraw_Image(int x, int y, tga_image_c *img) rgb_color_t pix = img->pixels[dy * img->width + dx]; - int alpha = RGB_ALPHA(pix); + int alpha = OBSIDIAN_RGB_ALPHA(pix); if (alpha == 0) { continue; @@ -2586,24 +2582,24 @@ int title_draw_clouds(lua_State *L) if (src < 1.0) { - r = RGB_RED(hue2) * src + RGB_RED(hue1) * (1.0 - src); - g = RGB_GREEN(hue2) * src + RGB_GREEN(hue1) * (1.0 - src); - b = RGB_BLUE(hue2) * src + RGB_BLUE(hue1) * (1.0 - src); + r = OBSIDIAN_RGB_RED(hue2) * src + OBSIDIAN_RGB_RED(hue1) * (1.0 - src); + g = OBSIDIAN_RGB_GREEN(hue2) * src + OBSIDIAN_RGB_GREEN(hue1) * (1.0 - src); + b = OBSIDIAN_RGB_BLUE(hue2) * src + OBSIDIAN_RGB_BLUE(hue1) * (1.0 - src); } else { src = src - 1.0; - r = RGB_RED(hue3) * src + RGB_RED(hue2) * (1.0 - src); - g = RGB_GREEN(hue3) * src + RGB_GREEN(hue2) * (1.0 - src); - b = RGB_BLUE(hue3) * src + RGB_BLUE(hue2) * (1.0 - src); + r = OBSIDIAN_RGB_RED(hue3) * src + OBSIDIAN_RGB_RED(hue2) * (1.0 - src); + g = OBSIDIAN_RGB_GREEN(hue3) * src + OBSIDIAN_RGB_GREEN(hue2) * (1.0 - src); + b = OBSIDIAN_RGB_BLUE(hue3) * src + OBSIDIAN_RGB_BLUE(hue2) * (1.0 - src); } int r2 = OBSIDIAN_CLAMP(0, r, 255); int g2 = OBSIDIAN_CLAMP(0, g, 255); int b2 = OBSIDIAN_CLAMP(0, b, 255); - rgb_color_t col = MAKE_RGBA(r2, g2, b2, 255); + rgb_color_t col = OBSIDIAN_MAKE_RGBA(r2, g2, b2, 255); for (int dy = 0; dy < 3; dy++) { @@ -2726,15 +2722,15 @@ for (int kx = 0 ; kx < W ; kx++) ity = OBSIDIAN_CLAMP(0, ity, 255); if ((int)(K * 32) & 3) - col = MAKE_RGBA(0 , 0 , ity, 255); + col = OBSIDIAN_MAKE_RGBA(0 , 0 , ity, 255); else - col = MAKE_RGBA(0 ,ity , 0, 255); + col = OBSIDIAN_MAKE_RGBA(0 ,ity , 0, 255); #else // moon colors int ity = 80 + (nx + nx + nx) * 60; ity = OBSIDIAN_CLAMP(0, ity, 255); - col = MAKE_RGBA(ity, ity, ity, 255); + col = OBSIDIAN_MAKE_RGBA(ity, ity, ity, 255); #endif title_pix[y * title_W3 + x] = col; diff --git a/source/dm_prefab.cc b/source/dm_prefab.cc index 43551dbfc..be08633cc 100644 --- a/source/dm_prefab.cc +++ b/source/dm_prefab.cc @@ -113,7 +113,7 @@ static int calc_thing_z(int x, int y) const ajpoly::polygon_c *poly = ajpoly::Polygon(p); // ignore void space - if (!poly->sector || poly->sector->index < 0 || poly->sector->index == VOID_SECTOR_IDX) + if (!poly->sector || poly->sector->index < 0 || poly->sector->index == ajpoly::VOID_SECTOR_IDX) { continue; } @@ -478,7 +478,7 @@ int wadfab_get_polygon(lua_State *L) // result #1 : SECTOR int sect_id = poly->sector ? poly->sector->index : -1; - if (sect_id == VOID_SECTOR_IDX) + if (sect_id == ajpoly::VOID_SECTOR_IDX) { sect_id = -1; } diff --git a/source/ff.h b/source/ff.h index c44babffc..7c2ff1cc9 100644 --- a/source/ff.h +++ b/source/ff.h @@ -1,5 +1,4 @@ -#ifndef FILENAME_FORMATTER_FF_H -#define FILENAME_FORMATTER_FF_H +#pragma once #ifdef __cplusplus extern "C" @@ -28,6 +27,4 @@ extern "C" #ifdef __cplusplus } -#endif - -#endif // FILENAME_FORMATTER_FF_H +#endif \ No newline at end of file diff --git a/source/g_doom.cc b/source/g_doom.cc index d07225b81..732a70869 100644 --- a/source/g_doom.cc +++ b/source/g_doom.cc @@ -289,7 +289,7 @@ namespace Doom void Send_Prog_Nodes(int progress, int num_maps) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Nodes(progress, num_maps); @@ -461,7 +461,7 @@ bool Doom::StartWAD(const std::string &filename) { if (!WAD_OpenWrite(filename)) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY DLG_ShowError(_("Unable to create wad file:\n\n%s"), strerror(errno)); #else printf("%s\n\n%s\n", _("Unable to create wad file:"), strerror(errno)); @@ -693,7 +693,8 @@ int Doom::v094_add_vertex(lua_State *L) return 0; } -void Doom::AddSector(int f_h, const std::string &f_tex, int c_h, const std::string &c_tex, int light, int special, int tag) +void Doom::AddSector(int f_h, const std::string &f_tex, int c_h, const std::string &c_tex, int light, int special, + int tag) { if (!UDMF_mode) { @@ -738,7 +739,8 @@ int Doom::v094_add_sector(lua_State *L) return 0; } -void Doom::AddSidedef(int sector, const std::string &l_tex, const std::string &m_tex, const std::string &u_tex, int x_offset, int y_offset) +void Doom::AddSidedef(int sector, const std::string &l_tex, const std::string &m_tex, const std::string &u_tex, + int x_offset, int y_offset) { if (!UDMF_mode) { @@ -1357,7 +1359,7 @@ bool Doom::game_interface_c::Start(const char *preset) } else { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (compress_output) { std::string zip_preset = preset; @@ -1402,7 +1404,7 @@ bool Doom::game_interface_c::Start(const char *preset) { map_format = FORMAT_BINARY; build_nodes = true; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Init(0, ""); @@ -1434,10 +1436,10 @@ bool Doom::game_interface_c::Start(const char *preset) return false; } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { - main_win->build_box->Prog_Init(20, N_("CSG")); + main_win->build_box->Prog_Init(20, _("CSG")); } #endif @@ -1548,7 +1550,7 @@ void Doom::game_interface_c::Property(std::string key, std::string value) if (StringCompare(key, "level_name") == 0) { level_name = value.c_str(); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY } else if (StringCompare(key, "description") == 0 && main_win) { @@ -1614,7 +1616,7 @@ void Doom::game_interface_c::EndLevel() FatalError("Script problem: did not set level name!\n"); } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Step("CSG"); diff --git a/source/g_wolf.cc b/source/g_wolf.cc index 82437363a..724901bc5 100644 --- a/source/g_wolf.cc +++ b/source/g_wolf.cc @@ -18,7 +18,7 @@ // //------------------------------------------------------------------------ -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY #include #endif #include "lib_util.h" @@ -28,11 +28,11 @@ #include "minilua.h" #include "sys_assert.h" -#define TEMP_GAMEFILE "GAMEMAPS.TMP" -#define TEMP_MAPTEMP "MAPTEMP.TMP" -#define TEMP_HEADFILE "MAPHEAD.TMP" +static constexpr const char *TEMP_GAMEFILE = "GAMEMAPS.TMP"; +static constexpr const char *TEMP_MAPTEMP = "MAPTEMP.TMP"; +static constexpr const char *TEMP_HEADFILE = "MAPHEAD.TMP"; -#define RLEW_TAG 0xABCD +static constexpr uint16_t RLEW_TAG = 0xABCD; static uint8_t no_tile = 48; static uint8_t no_obj = 0; @@ -52,7 +52,7 @@ static uint16_t *thing_plane; static std::string level_name; -#define PL_START 2 +static constexpr uint8_t PL_START = 2; std::string wolf_output_dir; extern std::string BestDirectory(); @@ -410,7 +410,7 @@ bool wolf_game_interface_c::Start(const char *ext) } else { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY int old_font_h = FL_NORMAL_SIZE; FL_NORMAL_SIZE = 14 + KF; @@ -496,7 +496,7 @@ bool wolf_game_interface_c::Start(const char *ext) solid_plane = new uint16_t[64 * 64 + 8]; // extra space for compressor thing_plane = new uint16_t[64 * 64 + 8]; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Init(0, ""); diff --git a/source/lib_tga.cc b/source/lib_tga.cc index d40a2f89b..031b3f76c 100644 --- a/source/lib_tga.cc +++ b/source/lib_tga.cc @@ -28,6 +28,7 @@ #include "m_addons.h" #include "main.h" +#include "sys_macro.h" tga_image_c::tga_image_c(int W, int H) : width(W), height(H), opacity(OPAC_UNKNOWN) { @@ -174,7 +175,7 @@ tga_image_c *TGA_LoadImage(const char *path) a = *buf_p++; } - palette[n] = MAKE_RGBA(r, g, b, a); + palette[n] = OBSIDIAN_MAKE_RGBA(r, g, b, a); } } @@ -206,7 +207,7 @@ tga_image_c *TGA_LoadImage(const char *path) a = *buf_p++; } - *p++ = MAKE_RGBA(r, g, b, a); + *p++ = OBSIDIAN_MAKE_RGBA(r, g, b, a); if (a == 0) { @@ -262,7 +263,7 @@ tga_image_c *TGA_LoadImage(const char *path) for (int j = 0; j < packet_size; j++) { - *p++ = MAKE_RGBA(r, g, b, a); + *p++ = OBSIDIAN_MAKE_RGBA(r, g, b, a); x++; @@ -296,7 +297,7 @@ tga_image_c *TGA_LoadImage(const char *path) a = *buf_p++; } - *p++ = MAKE_RGBA(r, g, b, a); + *p++ = OBSIDIAN_MAKE_RGBA(r, g, b, a); if (a == 0) { @@ -341,7 +342,7 @@ tga_image_c *TGA_LoadImage(const char *path) *p++ = col; - uint8_t a = RGB_ALPHA(col); + uint8_t a = OBSIDIAN_RGB_ALPHA(col); if (a == 0) { @@ -371,7 +372,7 @@ tga_image_c *TGA_LoadImage(const char *path) { rgb_color_t col = palette[*buf_p++]; - uint8_t a = RGB_ALPHA(col); + uint8_t a = OBSIDIAN_RGB_ALPHA(col); if (a == 0) { @@ -412,7 +413,7 @@ tga_image_c *TGA_LoadImage(const char *path) *p++ = col; - uint8_t a = RGB_ALPHA(col); + uint8_t a = OBSIDIAN_RGB_ALPHA(col); if (a == 0) { diff --git a/source/lib_tga.h b/source/lib_tga.h index b72130114..70be534bf 100644 --- a/source/lib_tga.h +++ b/source/lib_tga.h @@ -24,13 +24,6 @@ // this layout is compatible with Fl_Color (except for alpha) typedef unsigned int rgb_color_t; -#define MAKE_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | (a)) - -#define RGB_RED(col) ((col >> 24) & 255) -#define RGB_GREEN(col) ((col >> 16) & 255) -#define RGB_BLUE(col) ((col >> 8) & 255) -#define RGB_ALPHA(col) ((col) & 255) - typedef enum { OPAC_UNKNOWN = 0, diff --git a/source/lib_util.h b/source/lib_util.h index 4262ad48d..cc52a9f3e 100644 --- a/source/lib_util.h +++ b/source/lib_util.h @@ -140,8 +140,6 @@ uint32_t IntHash(uint32_t key); uint32_t StringHash(const std::string &str); uint64_t StringHash64(const std::string &str); -#define ALIGN_LEN(x) (((x) + 3) & ~3) - double PerpDist(double x, double y, double x1, double y1, double x2, double y2); double AlongDist(double x, double y, double x1, double y1, double x2, double y2); diff --git a/source/lib_wad.cc b/source/lib_wad.cc index 931041d59..1d09de79f 100644 --- a/source/lib_wad.cc +++ b/source/lib_wad.cc @@ -298,7 +298,7 @@ void WAD_FinishLump(void) const int len = ftell(wad_W_fp) - wad_W_lump.pos; // pad lumps to a multiple of four bytes - int padding = ALIGN_LEN(len) - len; + int padding = (((len) + 3) & ~3) - len; if (padding > 0) { diff --git a/source/m_about.cc b/source/m_about.cc index 17c478444..9df411f19 100644 --- a/source/m_about.cc +++ b/source/m_about.cc @@ -92,9 +92,9 @@ UI_About::UI_About(int W, int H, const char *label) : Fl_Window(W, H, label), wa callback(callback_Quit, this); - int cy = kf_h(6); + int cy = KromulentHeight(6); - Fl_Box *box = new Fl_Box(0, cy, W, kf_h(50), ""); + Fl_Box *box = new Fl_Box(0, cy, W, KromulentHeight(50), ""); box->copy_label(StringFormat("%s %s\n\"%s\" Build %s", OBSIDIAN_TITLE.c_str(), OBSIDIAN_SHORT_VERSION, OBSIDIAN_CODE_NAME.c_str(), OBSIDIAN_VERSION) .c_str()); @@ -102,10 +102,10 @@ UI_About::UI_About(int W, int H, const char *label) : Fl_Window(W, H, label), wa box->labelsize(FL_NORMAL_SIZE * 5 / 3); box->labelfont(font_style); - cy += box->h() + kf_h(6); + cy += box->h() + KromulentHeight(6); // the very informative text - int pad = kf_w(22); + int pad = KromulentWidth(22); int text_h = H * 0.55; // clang-format off @@ -119,17 +119,17 @@ UI_About::UI_About(int W, int H, const char *label) : Fl_Window(W, H, label), wa box->labelfont(font_style); box->labelcolor(FONT2_COLOR); - cy += box->h() + kf_h(10); + cy += box->h() + KromulentHeight(10); // website address - pad = kf_w(8); + pad = KromulentWidth(8); - UI_HyperLink *link = new UI_HyperLink(pad, cy, W - pad * 2, kf_h(30), URL, URL); + UI_HyperLink *link = new UI_HyperLink(pad, cy, W - pad * 2, KromulentHeight(30), URL, URL); link->align(FL_ALIGN_CENTER); link->labelsize(FL_NORMAL_SIZE); link->labelfont(font_style); - cy += link->h() + kf_h(16); + cy += link->h() + KromulentHeight(16); SYS_ASSERT(cy < H); @@ -137,8 +137,8 @@ UI_About::UI_About(int W, int H, const char *label) : Fl_Window(W, H, label), wa Fl_Group *darkish = new Fl_Group(0, cy, W, H - cy); darkish->box(FL_FLAT_BOX); { - int bw = kf_w(60); - int bh = kf_h(30); + int bw = KromulentWidth(60); + int bh = KromulentHeight(30); int by = H - (H - cy + bh) / 2; Fl_Button *button = new Fl_Button(W - bw * 2, by, bw, bh, fl_ok); @@ -156,8 +156,8 @@ UI_About::UI_About(int W, int H, const char *label) : Fl_Window(W, H, label), wa void DLG_AboutText(void) { - int about_w = kf_w(400); - int about_h = kf_h(400) + KF * 20; + int about_w = KromulentWidth(400); + int about_h = KromulentHeight(400) + KF * 20; UI_About *about_window = new UI_About(about_w, about_h, _("About OBSIDIAN")); diff --git a/source/m_cookie.cc b/source/m_cookie.cc index 8e15c309c..ec0e2bc9d 100644 --- a/source/m_cookie.cc +++ b/source/m_cookie.cc @@ -149,7 +149,7 @@ static bool Cookie_ParseLine(std::string_view buf) return false; } - std::string value = std::string(buf.substr(pos+1)); + std::string value = std::string(buf.substr(pos + 1)); while (!name.empty() && IsSpaceASCII(name.back())) { @@ -375,7 +375,7 @@ void Cookie_ParseArguments(void) // RECENT FILE HANDLING //---------------------------------------------------------------------- -#define MAX_RECENT 10 +static constexpr uint8_t MAX_RECENT = 10; class RecentFiles_c { diff --git a/source/m_dialog.cc b/source/m_dialog.cc index 5153e542e..ca627ecd3 100644 --- a/source/m_dialog.cc +++ b/source/m_dialog.cc @@ -44,45 +44,37 @@ static void dialog_close_CB(Fl_Widget *w, void *data) dialog_result = 1; } -#define BTN_W kf_w(100) -#define BTN_H kf_h(30) - -#define ICON_W kf_w(40) -#define ICON_H ICON_W - -#define FONT_SIZE (18 + KF * 2) - static void DialogShowAndRun(const char *message, const char *title, const char *link_title, const char *link_url) { dialog_result = 0; // determine required size - int mesg_W = kf_w(480); // NOTE: fl_measure will wrap to this! + int mesg_W = KromulentWidth(480); // NOTE: fl_measure will wrap to this! int mesg_H = 0; - fl_font(FL_HELVETICA, FONT_SIZE); + fl_font(FL_HELVETICA, (18 + KF * 2)); fl_measure(message, mesg_W, mesg_H); - if (mesg_W < kf_w(200)) + if (mesg_W < KromulentWidth(200)) { - mesg_W = kf_w(200); + mesg_W = KromulentWidth(200); } - if (mesg_H < ICON_H) + if (mesg_H < KromulentWidth(40)) { - mesg_H = ICON_H; + mesg_H = KromulentWidth(40); } // add a little wiggle room - mesg_W += kf_w(16); - mesg_H += kf_h(8); + mesg_W += KromulentWidth(16); + mesg_H += KromulentHeight(8); - int total_W = ICON_W + mesg_W + kf_w(30); - int total_H = mesg_H + BTN_H + kf_h(30); + int total_W = KromulentWidth(40) + mesg_W + KromulentWidth(30); + int total_H = mesg_H + KromulentHeight(30) + KromulentHeight(30); if (link_title) { - total_H += FONT_SIZE + kf_h(10); + total_H += (18 + KF * 2) + KromulentHeight(10); } // create window... @@ -93,7 +85,7 @@ static void DialogShowAndRun(const char *message, const char *title, const char dialog->callback((Fl_Callback *)dialog_close_CB); // create the error icon... - Fl_Box *icon = new Fl_Box(kf_w(10), kf_h(15), ICON_W, ICON_H, "!"); + Fl_Box *icon = new Fl_Box(KromulentWidth(10), KromulentHeight(15), KromulentWidth(40), KromulentWidth(40), "!"); icon->box(FL_OVAL_BOX); icon->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); @@ -105,11 +97,11 @@ static void DialogShowAndRun(const char *message, const char *title, const char dialog->add(icon); // create the message area... - Fl_Box *box = new Fl_Box(ICON_W + kf_w(20), kf_h(10), mesg_W, mesg_H, message); + Fl_Box *box = new Fl_Box(KromulentWidth(40) + KromulentWidth(20), KromulentHeight(10), mesg_W, mesg_H, message); box->align(FL_ALIGN_LEFT | FL_ALIGN_TOP | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); box->labelfont(font_style); - box->labelsize(FONT_SIZE); + box->labelsize((18 + KF * 2)); dialog->add(box); @@ -118,21 +110,23 @@ static void DialogShowAndRun(const char *message, const char *title, const char { SYS_ASSERT(link_url); - UI_HyperLink *link = new UI_HyperLink(ICON_W + kf_w(20), kf_h(10) + mesg_H, mesg_W, 24, link_title, link_url); + UI_HyperLink *link = new UI_HyperLink(KromulentWidth(40) + KromulentWidth(20), KromulentHeight(10) + mesg_H, + mesg_W, 24, link_title, link_url); link->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT); link->labelfont(font_style); - link->labelsize(FONT_SIZE); + link->labelsize((18 + KF * 2)); dialog->add(link); } // create button... - Fl_Button *button = new Fl_Button(total_W - BTN_W - kf_w(20), total_H - BTN_H - kf_h(12), BTN_W, BTN_H, fl_close); + Fl_Button *button = new Fl_Button(total_W - KromulentWidth(100) - KromulentWidth(20), + total_H - KromulentHeight(30) - KromulentHeight(12), KromulentWidth(100), + KromulentHeight(30), fl_close); button->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); button->callback((Fl_Callback *)dialog_close_CB); button->labelfont(font_style); - // button->labelsize(FONT_SIZE - 2); dialog->add(button); @@ -427,7 +421,7 @@ UI_LogViewer::UI_LogViewer(int W, int H, const char *l) : Fl_Double_Window(W, H, callback(quit_callback, this); - int ey = h() - kf_h(65); + int ey = h() - KromulentHeight(65); browser = new Fl_Multi_Browser(0, 0, w(), ey); browser->color(WINDOW_BG); @@ -446,16 +440,16 @@ UI_LogViewer::UI_LogViewer(int W, int H, const char *l) : Fl_Double_Window(W, H, resizable(browser); - int button_w = kf_w(80); - int button_h = kf_h(35); + int button_w = KromulentWidth(80); + int button_h = KromulentHeight(35); - int button_y = ey + (kf_h(65) - button_h) / 2; + int button_y = ey + (KromulentHeight(65) - button_h) / 2; { Fl_Group *o = new Fl_Group(0, ey, w(), h() - ey); o->box(FL_FLAT_BOX); - int bx = w() - button_w - kf_w(25); + int bx = w() - button_w - KromulentWidth(25); int bx2 = bx; { Fl_Button *but = new Fl_Button(bx, button_y, button_w, button_h, fl_close); @@ -467,7 +461,7 @@ UI_LogViewer::UI_LogViewer(int W, int H, const char *l) : Fl_Double_Window(W, H, but->callback(quit_callback, this); } - bx = kf_w(25); + bx = KromulentWidth(25); { Fl_Button *but = new Fl_Button(bx, button_y, button_w, button_h, _("Save")); but->box(button_style); @@ -478,7 +472,7 @@ UI_LogViewer::UI_LogViewer(int W, int H, const char *l) : Fl_Double_Window(W, H, but->labelfont(font_style); } - bx += kf_w(140); + bx += KromulentWidth(140); { copy_but = new Fl_Button(bx, button_y, button_w, button_h, _("Copy")); copy_but->box(button_style); @@ -735,7 +729,7 @@ UI_GlossaryViewer::UI_GlossaryViewer(int W, int H, const char *l) : Fl_Double_Wi callback(quit_callback, this); - int ey = h() - kf_h(65); + int ey = h() - KromulentHeight(65); browser = new Fl_Browser(0, 0, w(), ey); browser->color(WINDOW_BG); @@ -748,16 +742,16 @@ UI_GlossaryViewer::UI_GlossaryViewer(int W, int H, const char *l) : Fl_Double_Wi resizable(browser); - int button_w = kf_w(80); - int button_h = kf_h(35); + int button_w = KromulentWidth(80); + int button_h = KromulentHeight(35); - int button_y = ey + (kf_h(65) - button_h) / 2; + int button_y = ey + (KromulentHeight(65) - button_h) / 2; { Fl_Group *o = new Fl_Group(0, ey, w(), h() - ey); o->box(FL_FLAT_BOX); - int bx = w() - button_w - kf_w(25); + int bx = w() - button_w - KromulentWidth(25); int bx2 = bx; { Fl_Button *but = new Fl_Button(bx, button_y, button_w, button_h, fl_close); @@ -839,8 +833,8 @@ void UI_GlossaryViewer::quit_callback(Fl_Widget *w, void *data) void DLG_ViewLogs(void) { - int log_w = kf_w(560); - int log_h = kf_h(380); + int log_w = KromulentWidth(560); + int log_h = KromulentHeight(380); UI_LogViewer *log_viewer = new UI_LogViewer(log_w, log_h, _("OBSIDIAN Log Viewer")); @@ -860,8 +854,8 @@ void DLG_ViewLogs(void) void DLG_ViewGlossary(void) { - int gloss_w = kf_w(640); - int gloss_h = kf_h(480); + int gloss_w = KromulentWidth(640); + int gloss_h = KromulentHeight(480); UI_GlossaryViewer *gloss_viewer = new UI_GlossaryViewer(gloss_w, gloss_h, _("OBSIDIAN Glossary Viewer")); diff --git a/source/m_lua.cc b/source/m_lua.cc index 698a4e1be..c3c3c2f9a 100644 --- a/source/m_lua.cc +++ b/source/m_lua.cc @@ -462,7 +462,7 @@ int gui_add_choice(lua_State *L) SYS_ASSERT(!button.empty() && !id.empty() && !label.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -493,7 +493,7 @@ int gui_enable_choice(lua_State *L) SYS_ASSERT(!button.empty() && !id.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -516,7 +516,7 @@ int gui_set_button(lua_State *L) SYS_ASSERT(!button.empty() && !id.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -534,7 +534,7 @@ int gui_set_button(lua_State *L) // int gui_check_simple_mode(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY int value = (gui_simple_mode) ? 1 : 0; lua_pushboolean(L, value); #else @@ -558,7 +558,7 @@ int gui_add_module(lua_State *L) SYS_ASSERT(!where.empty() && !id.empty() && !label.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -634,7 +634,7 @@ int gui_set_module(lua_State *L) SYS_ASSERT(!module.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -664,7 +664,7 @@ int gui_show_module(lua_State *L) SYS_ASSERT(!module.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -695,7 +695,7 @@ int gui_add_module_header(lua_State *L) int gap = luaL_optinteger(L, 4, 0); SYS_ASSERT(!module.empty() && !option.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -741,7 +741,7 @@ int gui_add_module_url(lua_State *L) int gap = luaL_optinteger(L, 5, 0); SYS_ASSERT(!module.empty() && !option.empty() && !url.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -791,7 +791,7 @@ int gui_add_module_option(lua_State *L) std::string default_value = luaL_checkstring(L, 8); SYS_ASSERT(!module.empty() && !option.empty() && !default_value.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -849,7 +849,7 @@ int gui_add_module_slider_option(lua_State *L) std::string default_value = luaL_checkstring(L, 14); SYS_ASSERT(!module.empty() && !option.empty() && !default_value.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -900,7 +900,7 @@ int gui_add_module_button_option(lua_State *L) std::string default_value = luaL_checkstring(L, 8); SYS_ASSERT(!module.empty() && !option.empty() && !default_value.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -944,7 +944,7 @@ int gui_add_option_choice(lua_State *L) SYS_ASSERT(!module.empty() && !option.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -978,7 +978,7 @@ int gui_set_module_option(lua_State *L) SYS_ASSERT(!module.empty() && !option.empty() && !value.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -1012,7 +1012,7 @@ int gui_set_module_slider_option(lua_State *L) std::string value = luaL_optstring(L, 3, ""); SYS_ASSERT(!module.empty() && !option.empty() && !value.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -1046,7 +1046,7 @@ int gui_set_module_button_option(lua_State *L) int value = luaL_checkinteger(L, 3); SYS_ASSERT(!module.empty() && !option.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -1079,7 +1079,7 @@ int gui_get_module_slider_value(lua_State *L) SYS_ASSERT(!module.empty() && !option.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -1128,7 +1128,7 @@ int gui_get_module_button_value(lua_State *L) SYS_ASSERT(!module.empty() && !option.empty()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!main_win) { return 0; @@ -1165,7 +1165,7 @@ int gui_at_level(lua_State *L) int total = luaL_checkinteger(L, 3); ProgStatus("%s %s", _("Making"), name.c_str()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_AtLevel(index, total); @@ -1179,7 +1179,7 @@ int gui_at_level(lua_State *L) int gui_prog_step(lua_State *L) { const char *name = luaL_checkstring(L, 1); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Step(name); @@ -1192,7 +1192,7 @@ int gui_prog_step(lua_State *L) // int gui_ticker(lua_State * /*L*/) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Main::Ticker(); #endif return 0; @@ -1203,7 +1203,7 @@ int gui_ticker(lua_State * /*L*/) int gui_abort(lua_State *L) { int value = (main_action >= MAIN_CANCEL) ? 1 : 0; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Main::Ticker(); #endif lua_pushboolean(L, value); @@ -1290,7 +1290,7 @@ int gui_bit_not(lua_State *L) int gui_minimap_enable(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->alt_disp->label(""); @@ -1301,7 +1301,7 @@ int gui_minimap_enable(lua_State *L) int gui_minimap_disable(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->EmptyMap(); @@ -1321,7 +1321,7 @@ int gui_minimap_begin(lua_State *L) // dummy size when running in batch mode int map_W = 50; int map_H = 50; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { map_W = main_win->build_box->mini_map->GetWidth(); @@ -1338,7 +1338,7 @@ int gui_minimap_begin(lua_State *L) int gui_minimap_finish(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->MapFinish(); @@ -1350,7 +1350,7 @@ int gui_minimap_finish(lua_State *L) int gui_minimap_gif_start(lua_State *L) { int delay = luaL_optinteger(L, 1, 10); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->GifStart(gif_filename, delay); @@ -1361,7 +1361,7 @@ int gui_minimap_gif_start(lua_State *L) int gui_minimap_gif_frame(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->GifFrame(); @@ -1372,7 +1372,7 @@ int gui_minimap_gif_frame(lua_State *L) int gui_minimap_gif_finish(lua_State *L) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->GifFinish(); @@ -1397,7 +1397,7 @@ int gui_minimap_draw_line(lua_State *L) sscanf(color_str, "#%2x%2x%2x", &r, &g, &b); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->DrawLine(x1, y1, x2, y2, (uint8_t)r, (uint8_t)g, (uint8_t)b); @@ -1423,7 +1423,7 @@ int gui_minimap_fill_box(lua_State *L) sscanf(color_str, "#%2x%2x%2x", &r, &g, &b); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->mini_map->DrawBox(x1, y1, x2, y2, (uint8_t)r, (uint8_t)g, (uint8_t)b); @@ -1436,7 +1436,7 @@ int gui_minimap_fill_box(lua_State *L) int generate_midi_track(lua_State *L) { const char *midi_config = luaL_checkstring(L, 1); - const char *midi_file = luaL_checkstring(L, 2); + const char *midi_file = luaL_checkstring(L, 2); int value = steve_generate(midi_config, midi_file) ? 1 : 0; lua_pushinteger(L, value); @@ -1732,7 +1732,7 @@ static bool Script_CallFunc(const std::string &func_name, int nresult = 0, const } int nargs = 0; - for (const std::string& param : params) + for (const std::string ¶m : params) { lua_pushstring(LUA_ST, param.c_str()); nargs++; @@ -1760,7 +1760,7 @@ static bool Script_CallFunc(const std::string &func_name, int nresult = 0, const } // this will appear in the log file too -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->label(StringFormat("%s %s %s \"%s\"", _("[ ERROR ]"), OBSIDIAN_TITLE.c_str(), @@ -2180,7 +2180,7 @@ bool ob_build_cool_shit() { if (!Script_CallFunc("ob_build_cool_shit", 1)) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->label(StringFormat("%s %s %s \"%s\"", _("[ ERROR ]"), OBSIDIAN_TITLE.c_str(), @@ -2189,7 +2189,7 @@ bool ob_build_cool_shit() } #endif ProgStatus("%s", _("Script Error")); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->label( diff --git a/source/m_lua.h b/source/m_lua.h index a35d4463a..a7e20b3ca 100644 --- a/source/m_lua.h +++ b/source/m_lua.h @@ -29,8 +29,8 @@ void Script_Open(); void Script_Close(); -#define MAX_COLOR_MAPS 9 // 1 to 9 (from Lua) -#define MAX_COLORS_PER_MAP 260 +constexpr uint8_t MAX_COLOR_MAPS = 9; // 1 to 9 (from Lua) +constexpr uint16_t MAX_COLORS_PER_MAP = 260; typedef struct { diff --git a/source/m_manage.cc b/source/m_manage.cc index c46b7d0f5..97a7e4d02 100644 --- a/source/m_manage.cc +++ b/source/m_manage.cc @@ -36,7 +36,7 @@ class UI_Manage_Config; // The text is appended into the given text buffer. // Returns false if no config can be found in the file. // -#define LOOKAHEAD_SIZE 1024 +static constexpr uint16_t LOOKAHEAD_SIZE = 1024; class Lookahead_Stream_c { @@ -703,10 +703,10 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ text_buf = new Fl_Text_Buffer(); - int conf_w = kf_w(420); + int conf_w = KromulentWidth(420); int conf_h = H * 0.75; - int conf_x = W - conf_w - kf_w(10); - int conf_y = kf_h(30); + int conf_x = W - conf_w - KromulentWidth(10); + int conf_y = KromulentHeight(30); conf_disp = new Fl_Text_Display_NoSelect(conf_x, conf_y, conf_w, conf_h, ""); conf_disp->align(Fl_Align(FL_ALIGN_TOP)); @@ -720,9 +720,9 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ /* Main Buttons */ - int button_x = kf_w(20); - int button_w = kf_w(100); - int button_h = kf_h(35); + int button_x = KromulentWidth(20); + int button_w = KromulentWidth(100); + int button_h = KromulentHeight(35); Fl_Box *o; Fl_Box *use_warn; @@ -732,7 +732,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ Fl_Group *g = new Fl_Group(0, 0, conf_disp->x(), conf_disp->h()); g->resizable(NULL); - load_but = new Fl_Button(button_x, kf_h(25), button_w, button_h, _("Load WAD/TXT")); + load_but = new Fl_Button(button_x, KromulentHeight(25), button_w, button_h, _("Load WAD/TXT")); load_but->box(button_style); load_but->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); load_but->visible_focus(0); @@ -742,7 +742,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ load_but->labelfont(font_style); load_but->labelcolor(FONT2_COLOR); - save_but = new Fl_Button(button_x, kf_h(75), button_w, button_h, _("Save")); + save_but = new Fl_Button(button_x, KromulentHeight(75), button_w, button_h, _("Save")); save_but->box(button_style); save_but->visible_focus(0); save_but->color(BUTTON_COLOR); @@ -751,7 +751,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ save_but->labelfont(font_style); save_but->labelcolor(FONT2_COLOR); - use_but = new Fl_Button(button_x, kf_h(125), button_w, button_h, _("Use")); + use_but = new Fl_Button(button_x, KromulentHeight(125), button_w, button_h, _("Use")); use_but->box(button_style); use_but->visible_focus(0); use_but->color(BUTTON_COLOR); @@ -759,12 +759,13 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ use_but->labelfont(font_style); use_but->labelcolor(FONT2_COLOR); - use_warn = new Fl_Box(0, kf_h(165), kf_w(140), kf_h(50), _("Note: This will replace\nall current settings!")); + use_warn = new Fl_Box(0, KromulentHeight(165), KromulentWidth(140), KromulentHeight(50), + _("Note: This will replace\nall current settings!")); use_warn->align(Fl_Align(FL_ALIGN_TOP | FL_ALIGN_INSIDE | FL_ALIGN_CLIP)); use_warn->labelsize(small_font_size); use_warn->labelfont(font_style); - defaults_but = new Fl_Button(button_x, kf_h(200), button_w, button_h, _("Reset to Default")); + defaults_but = new Fl_Button(button_x, KromulentHeight(200), button_w, button_h, _("Reset to Default")); defaults_but->box(button_style); defaults_but->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); defaults_but->visible_focus(0); @@ -773,7 +774,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ defaults_but->labelfont(font_style); defaults_but->labelcolor(FONT2_COLOR); // clang-format off - defaults_warn = new Fl_Box(0, kf_h(240), kf_w(140), kf_h(50), + defaults_warn = new Fl_Box(0, KromulentHeight(240), KromulentWidth(140), KromulentHeight(50), _("Note: This will delete\nthe current CONFIG.txt\nand restart Obsidian!")); // clang-format on defaults_warn->align(Fl_Align(FL_ALIGN_TOP | FL_ALIGN_INSIDE | FL_ALIGN_CLIP)); @@ -783,7 +784,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ g->end(); } - close_but = new Fl_Button(button_x, H - kf_h(50), button_w, button_h + 5, fl_close); + close_but = new Fl_Button(button_x, H - KromulentHeight(50), button_w, button_h + 5, fl_close); close_but->box(button_style); close_but->visible_focus(0); close_but->color(BUTTON_COLOR); @@ -796,23 +797,23 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ /* Clipboard buttons */ { - int cx = conf_x + kf_w(40); + int cx = conf_x + KromulentWidth(40); int base_y = conf_y + conf_h + 1; Fl_Group *g = new Fl_Group(conf_x, base_y, conf_w, H - base_y); g->resizable(NULL); - o = new Fl_Box(cx, base_y, W - cx - 10, kf_h(30), _(" Clipboard Operations")); + o = new Fl_Box(cx, base_y, W - cx - 10, KromulentHeight(30), _(" Clipboard Operations")); o->align(Fl_Align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE)); o->labelsize(small_font_size); o->labelfont(font_style); - cx += kf_w(30); - base_y += kf_h(30); + cx += KromulentWidth(30); + base_y += KromulentHeight(30); - button_w = kf_w(80); - button_h = kf_h(25); + button_w = KromulentWidth(80); + button_h = KromulentHeight(25); cut_but = new Fl_Button(cx, base_y, button_w, button_h, _("Cut")); cut_but->box(button_style); @@ -824,7 +825,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ cut_but->shortcut(FL_CTRL + 'x'); cut_but->callback(callback_Cut, this); - cx += kf_w(115); + cx += KromulentWidth(115); copy_but = new Fl_Button(cx, base_y, button_w, button_h, _("Copy")); copy_but->box(button_style); @@ -836,7 +837,7 @@ UI_Manage_Config::UI_Manage_Config(int W, int H, const char *label) : Fl_Double_ copy_but->shortcut(FL_CTRL + 'c'); copy_but->callback(callback_Copy, this); - cx += kf_w(115); + cx += KromulentWidth(115); paste_but = new Fl_Button(cx, base_y, button_w, button_h, _("Paste")); paste_but->box(button_style); @@ -865,8 +866,8 @@ UI_Manage_Config::~UI_Manage_Config() void DLG_ManageConfig(void) { - int manage_w = kf_w(600); - int manage_h = kf_h(380); + int manage_w = KromulentWidth(600); + int manage_h = KromulentHeight(380); UI_Manage_Config *config_window = new UI_Manage_Config(manage_w, manage_h, _("OBSIDIAN Config Manager")); diff --git a/source/m_options.cc b/source/m_options.cc index f43db5d0b..693b69fd3 100644 --- a/source/m_options.cc +++ b/source/m_options.cc @@ -19,7 +19,7 @@ // //---------------------------------------------------------------------- -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY #include #include #endif @@ -88,7 +88,7 @@ void Parse_Option(const std::string &name, const std::string &value) else if (StringCompare(name, "random_string_seeds") == 0) { random_string_seeds = StringToInt(value) ? true : false; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY } else if (StringCompare(name, "gui_simple_mode") == 0) { @@ -212,7 +212,7 @@ bool Options_Save(const std::string &filename) fprintf(option_fp, "randomize_pickups = %d\n", (randomize_pickups ? 1 : 0)); fprintf(option_fp, "randomize_misc = %d\n", (randomize_misc ? 1 : 0)); fprintf(option_fp, "random_string_seeds = %d\n", (random_string_seeds ? 1 : 0)); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY fprintf(option_fp, "gui_simple_mode = %d\n", (gui_simple_mode ? 1 : 0)); #endif fprintf(option_fp, "password_mode = %d\n", (password_mode ? 1 : 0)); @@ -236,7 +236,7 @@ bool Options_Save(const std::string &filename) } //---------------------------------------------------------------------- -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY class UI_OptionsWin : public Fl_Window { public: @@ -631,15 +631,15 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, box(FL_FLAT_BOX); - int y_step = kf_h(9); - int pad = kf_w(6); + int y_step = KromulentHeight(9); + int pad = KromulentWidth(6); - int cx = x() + kf_w(24); + int cx = x() + KromulentWidth(24); int cy = y() + (y_step * 3); - int listwidth = kf_w(160); + int listwidth = KromulentWidth(160); - opt_language = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_language = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_language->copy_label(_("Language: ")); opt_language->align(FL_ALIGN_LEFT); opt_language->callback(callback_Language, this); @@ -652,7 +652,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_language->h() + y_step; - opt_filename_prefix = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_filename_prefix = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_filename_prefix->copy_label(_("Filename Prefix: ")); opt_filename_prefix->align(FL_ALIGN_LEFT); opt_filename_prefix->callback(callback_FilenamePrefix, this); @@ -668,7 +668,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_filename_prefix->h() + y_step; - opt_custom_prefix = new Fl_Button(cx + W * .38, cy, listwidth, kf_h(24), _("Set Custom Prefix...")); + opt_custom_prefix = new Fl_Button(cx + W * .38, cy, listwidth, KromulentHeight(24), _("Set Custom Prefix...")); opt_custom_prefix->box(button_style); opt_custom_prefix->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); opt_custom_prefix->visible_focus(0); @@ -677,13 +677,15 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, opt_custom_prefix->labelfont(font_style); opt_custom_prefix->labelcolor(FONT2_COLOR); - custom_prefix_help = new UI_HelpLink(cx + W * .38 + this->opt_custom_prefix->w(), cy, W * 0.10, kf_h(24)); + custom_prefix_help = + new UI_HelpLink(cx + W * .38 + this->opt_custom_prefix->w(), cy, W * 0.10, KromulentHeight(24)); custom_prefix_help->labelfont(font_style); custom_prefix_help->callback(callback_PrefixHelp, this); cy += opt_custom_prefix->h() + y_step; - opt_default_output_path = new Fl_Button(cx + W * .38, cy, listwidth, kf_h(24), _("Set Default Output Path")); + opt_default_output_path = + new Fl_Button(cx + W * .38, cy, listwidth, KromulentHeight(24), _("Set Default Output Path")); opt_default_output_path->box(button_style); opt_default_output_path->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); opt_default_output_path->visible_focus(0); @@ -694,7 +696,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_default_output_path->h() + y_step; - opt_current_output_path = new Fl_Box(cx, cy, W - cx - pad, kf_h(36), ""); + opt_current_output_path = new Fl_Box(cx, cy, W - cx - pad, KromulentHeight(36), ""); opt_current_output_path->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER | FL_ALIGN_WRAP); opt_current_output_path->visible_focus(0); opt_current_output_path->color(BUTTON_COLOR); @@ -706,7 +708,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_current_output_path->h() + y_step; - opt_simple_mode = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_simple_mode = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_simple_mode->copy_label(_(" Simple Mode")); opt_simple_mode->value(gui_simple_mode ? 1 : 0); opt_simple_mode->callback(callback_Simple_Mode, this); @@ -714,13 +716,14 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, opt_simple_mode->selection_color(SELECTION); opt_simple_mode->down_box(button_style); - simple_mode_help = new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, kf_h(24)); + simple_mode_help = + new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, KromulentHeight(24)); simple_mode_help->labelfont(font_style); simple_mode_help->callback(callback_SimpleModeHelp, this); cy += opt_simple_mode->h() + y_step * .5; - opt_random_string_seeds = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_random_string_seeds = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_random_string_seeds->copy_label(_(" Random String Seeds")); opt_random_string_seeds->value(random_string_seeds ? 1 : 0); opt_random_string_seeds->callback(callback_Random_String_Seeds, this); @@ -728,13 +731,14 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, opt_random_string_seeds->selection_color(SELECTION); opt_random_string_seeds->down_box(button_style); - random_string_seeds_help = new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, kf_h(24)); + random_string_seeds_help = + new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, KromulentHeight(24)); random_string_seeds_help->labelfont(font_style); random_string_seeds_help->callback(callback_RandomStringSeedsHelp, this); cy += opt_random_string_seeds->h() + y_step * .5; - opt_password_mode = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_password_mode = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_password_mode->copy_label(_(" Password Mode")); opt_password_mode->value(password_mode ? 1 : 0); opt_password_mode->callback(callback_Password_Mode, this); @@ -746,13 +750,14 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, opt_password_mode->deactivate(); } - password_mode_help = new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, kf_h(24)); + password_mode_help = + new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, KromulentHeight(24)); password_mode_help->labelfont(font_style); password_mode_help->callback(callback_PasswordModeHelp, this); cy += opt_password_mode->h() + y_step * .5; - opt_mature_words = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_mature_words = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_mature_words->copy_label(_(" Use Mature Wordlists")); opt_mature_words->value(mature_word_lists ? 1 : 0); opt_mature_words->callback(callback_MatureWords, this); @@ -760,13 +765,14 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, opt_mature_words->selection_color(SELECTION); opt_mature_words->down_box(button_style); - mature_words_help = new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, kf_h(24)); + mature_words_help = + new UI_HelpLink(cx + W * .38 + this->opt_filename_prefix->w(), cy, W * 0.10, KromulentHeight(24)); mature_words_help->labelfont(font_style); mature_words_help->callback(callback_MatureWordsHelp, this); cy += opt_mature_words->h() + y_step * .5; - opt_backups = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_backups = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_backups->copy_label(_(" Create Backups")); opt_backups->value(create_backups ? 1 : 0); opt_backups->callback(callback_Backups, this); @@ -776,7 +782,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_backups->h() + y_step * .5; - opt_overwrite = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_overwrite = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_overwrite->copy_label(_(" Overwrite File Warning")); opt_overwrite->value(overwrite_warning ? 1 : 0); opt_overwrite->callback(callback_Overwrite, this); @@ -786,7 +792,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_overwrite->h() + y_step * .5; - opt_debug = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_debug = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_debug->copy_label(_(" Debugging Messages")); opt_debug->value(debug_messages ? 1 : 0); opt_debug->callback(callback_Debug, this); @@ -796,7 +802,7 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, cy += opt_debug->h() + y_step * .5; - opt_limit_break = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_limit_break = new UI_CustomCheckBox(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_limit_break->copy_label(_(" Ignore Slider Limits")); opt_limit_break->value(limit_break ? 1 : 0); opt_limit_break->callback(callback_LimitBreak, this); @@ -806,11 +812,11 @@ UI_OptionsWin::UI_OptionsWin(int W, int H, const char *label) : Fl_Window(W, H, //---------------- - int dh = kf_h(60); + int dh = KromulentHeight(60); - int bw = kf_w(60); - int bh = kf_h(30); - int bx = W - kf_w(40) - bw; + int bw = KromulentWidth(60); + int bh = KromulentHeight(30); + int bx = W - KromulentWidth(40) - bw; int by = H - dh / 2 - bh / 2; Fl_Group *darkish = new Fl_Group(0, H - dh, W, dh); @@ -861,8 +867,8 @@ int UI_OptionsWin::handle(int event) void DLG_OptionsEditor(void) { - int opt_w = kf_w(500); - int opt_h = kf_h(475); + int opt_w = KromulentWidth(500); + int opt_h = KromulentHeight(475); UI_OptionsWin *option_window = new UI_OptionsWin(opt_w, opt_h, _("OBSIDIAN Misc Options")); diff --git a/source/m_theme.cc b/source/m_theme.cc index 5ec608c2d..a192c1cd3 100644 --- a/source/m_theme.cc +++ b/source/m_theme.cc @@ -1700,17 +1700,17 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe box(FL_FLAT_BOX); - int y_step = kf_h(9); - int pad = kf_w(6); + int y_step = KromulentHeight(9); + int pad = KromulentWidth(6); - int cx = x() + kf_w(24); + int cx = x() + KromulentWidth(24); int cy = y() + (y_step * 2); - int listwidth = kf_w(160); // [McM]: Some font names was shown truncated. + int listwidth = KromulentWidth(160); // [McM]: Some font names was shown truncated. Fl_Box *heading; - opt_window_scaling = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_window_scaling = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_window_scaling->copy_label(_("Window Scaling: ")); opt_window_scaling->align(FL_ALIGN_LEFT); opt_window_scaling->add(_("AUTO|Tiny|Small|Medium|Large|Huge")); @@ -1723,7 +1723,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_window_scaling->h() + y_step; - opt_font_scaling = new Fl_Simple_Counter(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_font_scaling = new Fl_Simple_Counter(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_font_scaling->copy_label(_("Font Size: ")); opt_font_scaling->align(FL_ALIGN_LEFT); opt_font_scaling->step(2); @@ -1739,7 +1739,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_font_scaling->h() + y_step; - opt_font_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_font_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_font_theme->copy_label(_("Font: ")); opt_font_theme->align(FL_ALIGN_LEFT); opt_font_theme->callback(callback_FontTheme, this); @@ -1753,7 +1753,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_font_theme->h() + y_step; - opt_widget_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_widget_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_widget_theme->copy_label(_("Widget Theme: ")); opt_widget_theme->align(FL_ALIGN_LEFT); opt_widget_theme->add(_("Default|Gleam|Win95|Plastic|Oxy")); @@ -1766,7 +1766,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_widget_theme->h() + y_step; - opt_box_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_box_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_box_theme->copy_label(_("Box Theme: ")); opt_box_theme->align(FL_ALIGN_LEFT); opt_box_theme->add(_("Default|Shadow|Embossed|Engraved|Inverted|Raised")); @@ -1779,7 +1779,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_box_theme->h() + y_step; - opt_button_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_button_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_button_theme->copy_label(_("Button Theme: ")); opt_button_theme->align(FL_ALIGN_LEFT); opt_button_theme->add(_("Default|Raised|Engraved|Embossed|Flat")); @@ -1792,7 +1792,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_button_theme->h() + y_step; - opt_color_scheme = new UI_CustomMenu(cx + W * .38, cy, listwidth, kf_h(24), ""); + opt_color_scheme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_color_scheme->copy_label(_("Color Scheme: ")); opt_color_scheme->align(FL_ALIGN_LEFT); opt_color_scheme->add(_("Default|Custom")); @@ -1805,7 +1805,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_color_scheme->h() + y_step; - opt_text_color = new Fl_Button(cx + W * .05, cy, W * .15, kf_h(24), _("Panel Font")); + opt_text_color = new Fl_Button(cx + W * .05, cy, W * .15, KromulentHeight(24), _("Panel Font")); opt_text_color->visible_focus(0); opt_text_color->box(FL_BORDER_BOX); opt_text_color->color(fl_rgb_color(text_red, text_green, text_blue)); @@ -1813,8 +1813,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_text_color->callback(callback_TextColor, this); opt_text_color->labelfont(font_style); - opt_text2_color = - new Fl_Button(cx + W * .05 + opt_text_color->w() + (5 * pad), cy, W * .15, kf_h(24), _("Button Font")); + opt_text2_color = new Fl_Button(cx + W * .05 + opt_text_color->w() + (5 * pad), cy, W * .15, KromulentHeight(24), + _("Button Font")); opt_text2_color->visible_focus(0); opt_text2_color->box(FL_BORDER_BOX); opt_text2_color->color(fl_rgb_color(text2_red, text2_green, text2_blue)); @@ -1822,8 +1822,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_text2_color->callback(callback_Text2Color, this); opt_text2_color->labelfont(font_style); - opt_bg_color = - new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 2, cy, W * .15, kf_h(24), _("Panels")); + opt_bg_color = new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 2, cy, W * .15, KromulentHeight(24), + _("Panels")); opt_bg_color->visible_focus(0); opt_bg_color->box(FL_BORDER_BOX); opt_bg_color->color(fl_rgb_color(bg_red, bg_green, bg_blue)); @@ -1831,8 +1831,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_bg_color->callback(callback_BgColor, this); opt_bg_color->labelfont(font_style); - opt_bg2_color = - new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 3, cy, W * .15, kf_h(24), _("Highlights")); + opt_bg2_color = new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 3, cy, W * .15, + KromulentHeight(24), _("Highlights")); opt_bg2_color->visible_focus(0); opt_bg2_color->box(FL_BORDER_BOX); opt_bg2_color->color(fl_rgb_color(bg2_red, bg2_green, bg2_blue)); @@ -1842,7 +1842,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_text_color->h() + y_step * 3; - opt_button_color = new Fl_Button(cx + W * .05, cy, W * .15, kf_h(24), _("Buttons")); + opt_button_color = new Fl_Button(cx + W * .05, cy, W * .15, KromulentHeight(24), _("Buttons")); opt_button_color->visible_focus(0); opt_button_color->box(FL_BORDER_BOX); opt_button_color->color(fl_rgb_color(button_red, button_green, button_blue)); @@ -1851,7 +1851,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_button_color->labelfont(font_style); opt_gradient_color = - new Fl_Button(cx + W * .05 + opt_text_color->w() + (5 * pad), cy, W * .15, kf_h(24), _("Gradient")); + new Fl_Button(cx + W * .05 + opt_text_color->w() + (5 * pad), cy, W * .15, KromulentHeight(24), _("Gradient")); opt_gradient_color->visible_focus(0); opt_gradient_color->box(FL_BORDER_BOX); opt_gradient_color->color(fl_rgb_color(gradient_red, gradient_green, gradient_blue)); @@ -1859,8 +1859,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_gradient_color->callback(callback_GradientColor, this); opt_gradient_color->labelfont(font_style); - opt_border_color = - new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 2, cy, W * .15, kf_h(24), _("Borders")); + opt_border_color = new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 2, cy, W * .15, + KromulentHeight(24), _("Borders")); opt_border_color->visible_focus(0); opt_border_color->box(FL_BORDER_BOX); opt_border_color->color(fl_rgb_color(border_red, border_green, border_blue)); @@ -1868,8 +1868,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_border_color->callback(callback_BorderColor, this); opt_border_color->labelfont(font_style); - opt_gap_color = - new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 3, cy, W * .15, kf_h(24), _("Gaps")); + opt_gap_color = new Fl_Button(cx + W * .05 + (opt_text_color->w() + (5 * pad)) * 3, cy, W * .15, + KromulentHeight(24), _("Gaps")); opt_gap_color->visible_focus(0); opt_gap_color->box(FL_BORDER_BOX); opt_gap_color->color(fl_rgb_color(gap_red, gap_green, gap_blue)); @@ -1879,7 +1879,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe cy += opt_text_color->h() + y_step * 3; - load_defaults = new Fl_Button(cx + W * .05, cy, W * .25, kf_h(24), _("Load Defaults")); + load_defaults = new Fl_Button(cx + W * .05, cy, W * .25, KromulentHeight(24), _("Load Defaults")); load_defaults->visible_focus(0); load_defaults->box(button_style); load_defaults->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); @@ -1888,7 +1888,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe load_defaults->labelfont(font_style); load_defaults->labelcolor(FONT2_COLOR); - load_theme = new Fl_Button(cx + W * .05 + (load_defaults->w() + pad), cy, W * .25, kf_h(24), _("Load Theme")); + load_theme = + new Fl_Button(cx + W * .05 + (load_defaults->w() + pad), cy, W * .25, KromulentHeight(24), _("Load Theme")); load_theme->visible_focus(0); load_theme->box(button_style); load_theme->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); @@ -1898,7 +1899,7 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe load_theme->labelcolor(FONT2_COLOR); save_theme = new Fl_Button(cx + W * .05 + (load_defaults->w() + pad) + (load_theme->w() + pad), cy, W * .25, - kf_h(24), _("Save Theme")); + KromulentHeight(24), _("Save Theme")); save_theme->visible_focus(0); save_theme->box(button_style); save_theme->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); @@ -1909,11 +1910,11 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe //---------------- - int dh = kf_h(60); + int dh = KromulentHeight(60); - int bw = kf_w(60); - int bh = kf_h(30); - int bx = W - kf_w(40) - bw; + int bw = KromulentWidth(60); + int bh = KromulentHeight(30); + int bx = W - KromulentWidth(40) - bw; int by = H - dh / 2 - bh / 2; Fl_Group *darkish = new Fl_Group(0, H - dh, W, dh); @@ -1932,8 +1933,8 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe darkish->end(); // restart needed warning - heading = new Fl_Box(FL_NO_BOX, x() + pad - kf_w(5), H - dh - kf_h(3), W - pad * 2, kf_h(16), - _("Note: Most settings will only affect tabs after a restart.")); + heading = new Fl_Box(FL_NO_BOX, x() + pad - KromulentWidth(5), H - dh - KromulentHeight(3), W - pad * 2, + KromulentHeight(16), _("Note: Most settings will only affect tabs after a restart.")); heading->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP); heading->labelsize(small_font_size); heading->labelfont(font_style); @@ -1971,8 +1972,8 @@ int UI_ThemeWin::handle(int event) void DLG_ThemeEditor(void) { - int theme_w = kf_w(500); - int theme_h = kf_h(450); + int theme_w = KromulentWidth(500); + int theme_h = KromulentHeight(450); UI_ThemeWin *theme_window = new UI_ThemeWin(theme_w, theme_h, _("OBSIDIAN Theme Options")); diff --git a/source/m_trans.cc b/source/m_trans.cc index da3570712..e60403a2f 100644 --- a/source/m_trans.cc +++ b/source/m_trans.cc @@ -33,6 +33,8 @@ #include #endif +#include + #include #include "lib_util.h" @@ -48,7 +50,7 @@ // #include -static std::map trans_store; +static std::map trans_store; static std::map::iterator trans_iter; // current Options setting @@ -57,7 +59,7 @@ std::string t_language = _("AUTO"); //---------------------------------------------------------------------- // largest string we can load -#define MAX_TRANS_STRING 65536 +static constexpr int MAX_TRANS_STRING = 65536; /* Mingw headers don't have latest language and sublanguage codes. */ #ifdef _WIN32 diff --git a/source/m_trans.h b/source/m_trans.h index f69684c92..6528ca79d 100644 --- a/source/m_trans.h +++ b/source/m_trans.h @@ -36,8 +36,7 @@ void Trans_UnInit(); std::string Trans_GetAvailCode(int idx); std::string Trans_GetAvailLanguage(int idx); -#define _(s) ob_gettext(s) -#define N_(s) (s) +#define _(s) ob_gettext(s) const char *ob_gettext(const char *s); diff --git a/source/main.cc b/source/main.cc index bac03b13d..ac09218e8 100644 --- a/source/main.cc +++ b/source/main.cc @@ -39,13 +39,14 @@ #include "m_trans.h" #include "physfs.h" #include "sys_xoshiro.h" -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY #ifndef _WIN32 #include #endif #include #include #include + #include "ui_boxes.h" #include "ui_window.h" #endif @@ -88,7 +89,7 @@ std::string numeric_locale; std::vector batch_randomize_groups; // options -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY uchar text_red = 225; uchar text_green = 225; uchar text_blue = 225; @@ -171,11 +172,11 @@ game_interface_c *game_object = NULL; extern bool ExtractPresetData(FILE *fp, std::string &buf); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Fl_Pixmap *clippy; #ifdef _WIN32 -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY static FLASHWINFO *blinker; static int i_load_private_font(const char *path) { @@ -187,7 +188,7 @@ int v_unload_private_font(const char *path) } #endif #else -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY #ifndef __APPLE__ #include static int i_load_private_font(const char *path) @@ -413,7 +414,7 @@ void Determine_OptionsFile() options_file = PathAppend(home_dir, OPTIONS_FILENAME); } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY void Determine_ThemeFile() { theme_file = PathAppend(home_dir, THEME_FILENAME); @@ -449,7 +450,7 @@ bool Main::BackupFile(const std::string &filename) return true; } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY int Main::DetermineScaling() { /* computation of the Kromulent factor */ @@ -499,7 +500,7 @@ int Main::DetermineScaling() return 0; } #endif -#if !defined(CONSOLE_ONLY) && !defined(__APPLE__) +#if !defined(OBSIDIAN_CONSOLE_ONLY) && !defined(__APPLE__) bool Main::LoadInternalFont(const char *fontpath, const int fontnum, const char *fontname) { /* set the extra font */ @@ -512,7 +513,7 @@ bool Main::LoadInternalFont(const char *fontpath, const int fontnum, const char } #endif -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY void Main::PopulateFontMap() { if (font_menu_items.empty()) @@ -928,7 +929,7 @@ void Main::Ticker() void Main::Shutdown(const bool error) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { // on fatal error we cannot risk calling into the Lua runtime @@ -961,7 +962,7 @@ void Main::Shutdown(const bool error) LogClose(); } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY int Main_key_handler(int event) { if (event != FL_SHORTCUT) @@ -1026,7 +1027,7 @@ void Main_SetSeed() xoshiro_Reseed(next_rand_seed); std::string seed = NumToString(next_rand_seed); ob_set_config("seed", seed.c_str()); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (!batch_mode) { main_win->build_box->seed_disp->copy_label(StringFormat("%s %s", _("Seed:"), seed.c_str()).c_str()); @@ -1047,7 +1048,7 @@ static void Module_Defaults() bool Build_Cool_Shit() { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // clear the map if (main_win) { @@ -1080,7 +1081,7 @@ bool Build_Cool_Shit() const std::string def_filename = ob_default_filename(); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // lock most widgets of user interface if (main_win) { @@ -1129,7 +1130,7 @@ bool Build_Cool_Shit() was_ok = game_object->Start(def_filename.c_str()); } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // coerce FLTK to redraw the main window for (int r_loop = 0; r_loop < 6; r_loop++) { @@ -1156,7 +1157,7 @@ bool Build_Cool_Shit() string_seed.clear(); #ifdef _WIN32 -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) Main::Blinker(); #endif @@ -1165,7 +1166,7 @@ bool Build_Cool_Shit() else { string_seed.clear(); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->seed_disp->copy_label(_("Seed: -")); @@ -1176,7 +1177,7 @@ bool Build_Cool_Shit() #endif } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->Prog_Finish(); @@ -1188,7 +1189,7 @@ bool Build_Cool_Shit() if (main_action == MAIN_CANCEL) { main_action = 0; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->label( @@ -1294,7 +1295,7 @@ hardrestart:; if (argv::Find('?', NULL) >= 0 || argv::Find('h', "help") >= 0) { -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (AllocConsole()) { freopen("CONOUT$", "r", stdin); @@ -1303,7 +1304,7 @@ hardrestart:; } #endif ShowInfo(); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do { @@ -1313,7 +1314,7 @@ hardrestart:; } else if (argv::Find(0, "version") >= 0) { -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (AllocConsole()) { freopen("CONOUT$", "r", stdin); @@ -1322,7 +1323,7 @@ hardrestart:; } #endif ShowVersion(); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do { @@ -1332,7 +1333,7 @@ hardrestart:; exit(EXIT_SUCCESS); } -#ifdef CONSOLE_ONLY +#ifdef OBSIDIAN_CONSOLE_ONLY batch_mode = true; #endif @@ -1347,7 +1348,7 @@ hardrestart:; batch_mode = true; batch_output_file = argv::list[batch_arg + 1]; -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (AllocConsole()) { freopen("CONOUT$", "r", stdin); @@ -1360,7 +1361,7 @@ hardrestart:; if (argv::Find('p', "printref") >= 0) { batch_mode = true; -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (AllocConsole()) { freopen("CONOUT$", "r", stdin); @@ -1399,7 +1400,7 @@ hardrestart:; if (argv::Find(0, "printref-json") >= 0) { batch_mode = true; -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (AllocConsole()) { freopen("CONOUT$", "r", stdin); @@ -1414,7 +1415,7 @@ hardrestart:; Trans_Init(); Determine_ConfigFile(); Determine_OptionsFile(); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Determine_ThemeFile(); #endif Determine_LoggingFile(); @@ -1444,7 +1445,7 @@ hardrestart:; LogPrint("********************************************************\n"); LogPrint("\n"); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY LogPrint("Library versions: FLTK %d.%d.%d\n\n", FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); #endif @@ -1454,13 +1455,13 @@ hardrestart:; if (!batch_mode) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Theme_Options_Load(theme_file); #endif Trans_SetLanguage(); OBSIDIAN_TITLE = _("OBSIDIAN Level Maker"); OBSIDIAN_CODE_NAME = _("Unstable"); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Main::SetupFLTK(); #endif } @@ -1522,7 +1523,7 @@ softrestart:; { ob_print_reference(); RefClose(); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do @@ -1536,7 +1537,7 @@ softrestart:; if (argv::Find(0, "printref-json") >= 0) { ob_print_reference_json(); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do @@ -1593,7 +1594,7 @@ softrestart:; "parameter?\n"); Main::Shutdown(false); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do { @@ -1609,7 +1610,7 @@ softrestart:; LogPrint("FAILED!\n"); Main::Shutdown(false); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY printf("\nClose window when finished..."); do { @@ -1637,7 +1638,7 @@ softrestart:; VFS_ScanForPresets(); // create the main window -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY fl_register_images(); // Needed for Unix window icon and Clippy if (!clippy) @@ -1684,7 +1685,7 @@ softrestart:; Cookie_ParseArguments(); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { if (StringCompare(main_win->game_box->engine->GetID(), "idtech_0") == 0) @@ -1700,7 +1701,7 @@ softrestart:; if (main_action != MAIN_SOFT_RESTART) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // Have to add these after reading existing settings - Dasho if (main_win) { @@ -1842,7 +1843,7 @@ softrestart:; if (main_action != MAIN_SOFT_RESTART) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // draw an empty map (must be done after main window is // shown() because that is when FLTK finalises the colors). main_win->build_box->mini_map->EmptyMap(); @@ -1882,7 +1883,7 @@ softrestart:; // run the GUI until the user quits for (;;) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Fl::wait(0.2); #endif @@ -1915,7 +1916,7 @@ softrestart:; did_specify_seed = false; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (result) { old_seed = string_seed.empty() ? NumToString(next_rand_seed) : string_seed; @@ -1953,14 +1954,14 @@ softrestart:; { LogPrint("\nQuit......\n\n"); } -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY Theme_Options_Save(theme_file); #endif Options_Save(options_file); if (main_action == MAIN_HARD_RESTART || main_action == MAIN_SOFT_RESTART) { -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { // on fatal error we cannot risk calling into the Lua runtime diff --git a/source/main.h b/source/main.h index cb14d3f2d..19180145e 100644 --- a/source/main.h +++ b/source/main.h @@ -27,7 +27,7 @@ #include #include -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY #include "ui_window.h" #endif #include "lib_util.h" @@ -54,7 +54,7 @@ constexpr const char *THEME_FILENAME = "THEME.txt"; constexpr const char *LOG_FILENAME = "LOGS.txt"; constexpr const char *REF_FILENAME = "REFERENCE.txt"; -#if !defined CONSOLE_ONLY && !defined __APPLE__ +#if !defined OBSIDIAN_CONSOLE_ONLY && !defined __APPLE__ extern int v_unload_private_font(const char *path); #endif @@ -86,7 +86,7 @@ enum main_action_kind_e extern int main_action; // Misc Options -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY extern uchar text_red; extern uchar text_green; extern uchar text_blue; @@ -157,7 +157,7 @@ extern std::string last_directory; extern std::string numeric_locale; extern std::vector batch_randomize_groups; -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY // Dialog Windows void DLG_ShowError(const char *msg, ...); @@ -174,7 +174,7 @@ extern std::string string_seed; extern std::string selected_lang; // Clippy/program menu stuff -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY extern Fl_Pixmap *clippy; void DLG_AboutText(); @@ -193,15 +193,15 @@ namespace Main void Shutdown(bool error); bool BackupFile(const std::string &filename); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY void Blinker(); #endif -#if !defined(CONSOLE_ONLY) && !defined(__APPLE__) +#if !defined(OBSIDIAN_CONSOLE_ONLY) && !defined(__APPLE__) bool LoadInternalFont(const char *fontpath, int fontnum, const char *fontname); #endif -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY void SetupFLTK(); int DetermineScaling(); void PopulateFontMap(); diff --git a/source/poly.cc b/source/poly.cc index 392db96fe..50c610e04 100644 --- a/source/poly.cc +++ b/source/poly.cc @@ -23,7 +23,7 @@ #include "sys_debug.h" #include "sys_macro.h" -#define DEBUG_POLY 0 +#define AJPOLY_DEBUG_POLY 0 namespace ajpoly { @@ -99,7 +99,7 @@ void InsertEdge(edge_c **list_ptr, edge_c *E) (*list_ptr) = E; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY void DumpEdges(edge_c *edge_list) { for (edge_c *cur = edge_list; cur; cur = cur->next) @@ -154,7 +154,7 @@ void edge_c::CopyInfo(const edge_c *other) edge_c *SplitEdge(edge_c *old_edge, double x, double y) { -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Splitting Edge #%d (line #%d) at (%1.1f,%1.1f)\n", old_edge->index, old_edge->linedef ? old_edge->linedef->index : -1, x, y); #endif @@ -171,7 +171,7 @@ edge_c *SplitEdge(edge_c *old_edge, double x, double y) new_edge->start = vert; new_edge->Recompute(); -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Splitting Vertex is %04X at (%1.1f,%1.1f)\n", vert->index, vert->x, vert->y); #endif @@ -179,7 +179,7 @@ edge_c *SplitEdge(edge_c *old_edge, double x, double y) if (old_edge->partner) { -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Splitting partner #%d\n", old_edge->partner->index); #endif @@ -302,24 +302,6 @@ int EvalPartition(edge_c *part, edge_c *edge_list) double qnty; -#define ADD_LEFT() \ - do \ - { \ - if (check->linedef) \ - real_left += 1; \ - else \ - mini_left += 1; \ - } while (0) - -#define ADD_RIGHT() \ - do \ - { \ - if (check->linedef) \ - real_right += 1; \ - else \ - mini_right += 1; \ - } while (0) - /* check partition against all the edges */ for (edge_c *check = edge_list; check; check = check->next) @@ -336,19 +318,25 @@ int EvalPartition(edge_c *part, edge_c *edge_list) double fa = fabs(a); double fb = fabs(b); - int a_side = (fa <= OBSIDIAN_DIST_EPSILON) ? 0 : (a < 0) ? -1 : +1; - int b_side = (fb <= OBSIDIAN_DIST_EPSILON) ? 0 : (b < 0) ? -1 : +1; + int a_side = (fa <= OBSIDIAN_POLY_EPSILON) ? 0 : (a < 0) ? -1 : +1; + int b_side = (fb <= OBSIDIAN_POLY_EPSILON) ? 0 : (b < 0) ? -1 : +1; // check for being on the same line if (a_side == 0 && b_side == 0) { if (check->pdx * part->pdx + check->pdy * part->pdy < 0) { - ADD_LEFT(); + if (check->linedef) + real_left += 1; + else + mini_left += 1; } else { - ADD_RIGHT(); + if (check->linedef) + real_right += 1; + else + mini_right += 1; } continue; @@ -379,14 +367,20 @@ int EvalPartition(edge_c *part, edge_c *edge_list) // check for right side if (a_side >= 0 && b_side >= 0) { - ADD_RIGHT(); + if (check->linedef) + real_right += 1; + else + mini_right += 1; continue; } // check for left side if (a_side <= 0 && b_side <= 0) { - ADD_LEFT(); + if (check->linedef) + real_left += 1; + else + mini_left += 1; continue; } @@ -401,7 +395,7 @@ int EvalPartition(edge_c *part, edge_c *edge_list) // make sure there is at least one linedef on each side if (real_left == 0 || real_right == 0) { -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Eval : No linedefs on %s%sside\n", real_left ? "" : "left ", real_right ? "" : "right "); #endif @@ -419,7 +413,7 @@ int EvalPartition(edge_c *part, edge_c *edge_list) cost += 60; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Eval %p: splits=%d near_miss=%d left=%d+%d right=%d+%d " "cost=%d.%02d\n", part, splits, near_miss, real_left, mini_left, real_right, mini_right, cost / 100, cost % 100); @@ -441,8 +435,8 @@ void DivideAnEdge(edge_c *cur, edge_c *part, edge_c **left_list, edge_c **right_ a = b = 0; } - int a_side = (fabs(a) <= OBSIDIAN_DIST_EPSILON) ? 0 : (a < 0) ? -1 : +1; - int b_side = (fabs(b) <= OBSIDIAN_DIST_EPSILON) ? 0 : (b < 0) ? -1 : +1; + int a_side = (fabs(a) <= OBSIDIAN_POLY_EPSILON) ? 0 : (a < 0) ? -1 : +1; + int b_side = (fabs(b) <= OBSIDIAN_POLY_EPSILON) ? 0 : (b < 0) ? -1 : +1; // check for being on the same line if (a_side == 0 && b_side == 0) @@ -526,7 +520,7 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) int best_cost = 1 << 30; -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("ChoosePartition: BEGUN (depth %d)\n", depth); #endif @@ -540,7 +534,7 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) int cost = EvalPartition(part, edge_list); -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("ChoosePartition: EDGE #%d -> cost:%d | sector:%d (%1.1f %1.1f) " "-> (%1.1f %1.1f)\n", part->index, cost, part->sector->index, part->start->x, part->start->y, part->end->x, part->end->y); @@ -556,7 +550,7 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) best_cost = cost; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY if (!best) { LogPrint("ChoosePartition: NO BEST FOUND\n"); @@ -594,7 +588,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, return; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("CUT LIST:\n"); LogPrint("PARTITION: (%1.1f %1.1f) += (%1.1f %1.1f)\n", part->psx, part->psy, part->pdx, part->pdy); @@ -628,7 +622,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, // merge the two intersections into one -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Merging cut (%1.0f,%1.0f) [%d/%d] with %p (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, cur->before, cur->after, next->vertex, next->vertex->x, next->vertex->y, next->before, next->after); #endif @@ -643,7 +637,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, cur->after = next->after; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("---> merged (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, cur->before, cur->after); #endif @@ -704,7 +698,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, InsertEdge(right_list, edge); InsertEdge(left_list, buddy); -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("EdgesAlongPartition: %p RIGHT sector %d (%1.1f %1.1f) -> (%1.1f " "%1.1f)\n", edge, edge->sector ? edge->sector->index : -1, edge->start->x, edge->start->y, edge->end->x, @@ -790,7 +784,7 @@ void polygon_c::ClockwiseOrder() int i; int total = 0; -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Polygon: Clockwising #%d (sector #%d)\n", index, sector->index); #endif @@ -890,7 +884,7 @@ polygon_c *CreatePolygon(edge_c *edge_list) poly->CalcMiddle(); -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Created Polygon #%d @ (%1.1f %1.1f)\n", poly->index, poly->mid_x, poly->mid_y); DumpEdges(edge_list); #endif @@ -900,7 +894,7 @@ polygon_c *CreatePolygon(edge_c *edge_list) bool RecursiveDivideEdges(edge_c *edge_list, int depth) { -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: BEGUN @ %d\n", depth); DumpEdges(edge_list); @@ -912,14 +906,14 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) if (!part) { -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: CONVEX\n"); #endif CreatePolygon(edge_list); return true; // OK } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: PARTITION %p (%1.0f,%1.0f) -> (%1.0f,%1.0f)\n", part, part->start->x, part->start->y, part->end->x, part->end->y); #endif @@ -946,7 +940,7 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) EdgesAlongPartition(part, &lefts, &rights, cut_list); -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: Going LEFT\n"); #endif @@ -955,7 +949,7 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) return false; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: Going RIGHT\n"); #endif @@ -964,7 +958,7 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) return false; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("Build: DONE\n"); #endif @@ -998,7 +992,7 @@ bool ProcessSectors() continue; } -#if DEBUG_POLY +#if AJPOLY_DEBUG_POLY LogPrint("-------------------------------\n"); LogPrint("Processing Sector #%d\n", i); LogPrint("-------------------------------\n"); diff --git a/source/poly.h b/source/poly.h index b7d646938..fb174e9db 100644 --- a/source/poly.h +++ b/source/poly.h @@ -61,7 +61,7 @@ class vertex_c }; // this bit in the index value differentiates normal vertices from split ones -#define SPLIT_VERTEX (1 << 24) +constexpr int SPLIT_VERTEX = (1 << 24); class sector_c { @@ -102,7 +102,7 @@ class sector_c linedef_c *getExtraFloor(int index); }; -#define VOID_SECTOR_IDX 0xFFFF +constexpr uint16_t VOID_SECTOR_IDX = 0xFFFF; class sidedef_c { diff --git a/source/poly_map.cc b/source/poly_map.cc index b9718f364..37dec364f 100644 --- a/source/poly_map.cc +++ b/source/poly_map.cc @@ -21,7 +21,7 @@ #include "poly_local.h" #include "sys_macro.h" -#define DEBUG_LOAD 0 +#define AJPOLY_DEBUG_LOAD 0 namespace ajpoly { @@ -53,8 +53,8 @@ int num_polygons; int num_wall_tips; // EDGE line specials for 3D floors -#define SOLID_EXTRA_FLOOR 400 -#define LIQUID_EXTRA_FLOOR 405 +static constexpr uint16_t SOLID_EXTRA_FLOOR = 400; +static constexpr uint16_t LIQUID_EXTRA_FLOOR = 405; /* ----- UDMF reading routines ------------------------- */ @@ -89,11 +89,11 @@ static inline sidedef_c *SafeLookupSidedef(uint16_t num) return all_sidedefs[num]; } -#define UDMF_THING 1 -#define UDMF_VERTEX 2 -#define UDMF_SECTOR 3 -#define UDMF_SIDEDEF 4 -#define UDMF_LINEDEF 5 +static constexpr uint8_t UDMF_THING = 1; +static constexpr uint8_t UDMF_VERTEX = 2; +static constexpr uint8_t UDMF_SECTOR = 3; +static constexpr uint8_t UDMF_SIDEDEF = 4; +static constexpr uint8_t UDMF_LINEDEF = 5; void ParseThingField(thing_c *thing, const std::string &key, ajparse::token_kind_e kind, const std::string &value) { @@ -758,7 +758,7 @@ bool LoadVertices() int count = length / sizeof(raw_vertex_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadVertices: num = %d\n", count); #endif @@ -789,7 +789,7 @@ bool LoadSectors() int count = length / sizeof(raw_sector_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadSectors: num = %d\n", count); #endif @@ -832,7 +832,7 @@ bool LoadThings() int count = length / sizeof(raw_thing_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadThings: num = %d\n", count); #endif @@ -867,7 +867,7 @@ bool LoadThingsHexen() int count = length / sizeof(raw_hexen_thing_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadThingsHexen: num = %d\n", count); #endif @@ -909,7 +909,7 @@ bool LoadSidedefs() int count = length / sizeof(raw_sidedef_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadSidedefs: num = %d\n", count); #endif @@ -952,7 +952,7 @@ bool LoadLinedefs() int count = length / sizeof(raw_linedef_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadLinedefs: num = %d\n", count); #endif @@ -972,7 +972,7 @@ bool LoadLinedefs() end->ref_count++; /* check for zero-length line */ - if ((fabs(start->x - end->x) < OBSIDIAN_DIST_EPSILON) && (fabs(start->y - end->y) < OBSIDIAN_DIST_EPSILON)) + if ((fabs(start->x - end->x) < OBSIDIAN_POLY_EPSILON) && (fabs(start->y - end->y) < OBSIDIAN_POLY_EPSILON)) { FatalError("Linedef #%d has zero length.\n", i); } @@ -1002,7 +1002,7 @@ bool LoadLinedefsHexen() int count = length / sizeof(raw_hexen_linedef_t); -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD LogPrint("LoadLinedefsHexen: num = %d\n", count); #endif @@ -1022,7 +1022,7 @@ bool LoadLinedefsHexen() end->ref_count++; /* check for zero-length line */ - if ((fabs(start->x - end->x) < OBSIDIAN_DIST_EPSILON) && (fabs(start->y - end->y) < OBSIDIAN_DIST_EPSILON)) + if ((fabs(start->x - end->x) < OBSIDIAN_POLY_EPSILON) && (fabs(start->y - end->y) < OBSIDIAN_POLY_EPSILON)) { FatalError("Linedef #%d has zero length.\n", i); } @@ -1599,7 +1599,7 @@ bool CalculateWallTips() } } -#if DEBUG_LOAD +#if AJPOLY_DEBUG_LOAD for (i = 0; i < num_vertices; i++) { vertex_c *vert = Vertex(i); diff --git a/source/poly_wad.cc b/source/poly_wad.cc index 22c52449f..df88d8cc6 100644 --- a/source/poly_wad.cc +++ b/source/poly_wad.cc @@ -20,7 +20,7 @@ #include "poly_local.h" #include "sys_debug.h" -#define DEBUG_WAD 0 +#define AJPOLY_DEBUG_WAD 0 namespace ajpoly { @@ -117,7 +117,7 @@ bool wad_c::ReadDirEntry() lump_c *lump = new lump_c(name_buf, start, length); -#if DEBUG_WAD +#if AJPOLY_DEBUG_WAD LogPrint("Read dir... %s\n", lump->name); #endif @@ -201,7 +201,7 @@ void wad_c::DetermineLevels() continue; } -#if DEBUG_WAD +#if AJPOLY_DEBUG_WAD LogPrint("Found level name: %s\n", L->name); #endif @@ -306,7 +306,7 @@ uint8_t *wad_c::ReadLump(const char *name, int *length, int level) lump_c *L = lumps[index]; -#if DEBUG_WAD +#if AJPOLY_DEBUG_WAD LogPrint("Reading lump: %s (%d bytes)\n", L->name, L->length); #endif diff --git a/source/raw_def.h b/source/raw_def.h index 9de2967ab..0245439fa 100644 --- a/source/raw_def.h +++ b/source/raw_def.h @@ -20,8 +20,8 @@ /* ----- The wad structures ---------------------- */ -#define WAD_TEX_NAME 8 -#define WAD_FLAT_NAME 8 +constexpr uint8_t WAD_TEX_NAME = 8; +constexpr uint8_t WAD_FLAT_NAME = 8; // wad header #pragma pack(push, 1) @@ -469,11 +469,6 @@ typedef enum MLF_ZDoom_BlockEverything = 0x8000, } zdoom_lineflag_e; -#define BOOM_GENLINE_FIRST 0x2f80 -#define BOOM_GENLINE_LAST 0x7fff - -#define is_genline(tp) ((tp) >= BOOM_GENLINE_FIRST && (tp) <= BOOM_GENLINE_LAST) - typedef enum { SPAC_Cross = 0, // when line is crossed (W1 / WR) @@ -500,8 +495,6 @@ typedef enum BoomSF_QuietPlane = 0x0800 } boom_sectorflag_e; -#define MSF_BoomFlags 0x0FE0 - // // Thing attributes. // @@ -522,9 +515,6 @@ typedef enum MTF_Reserved = 256, } thing_option_e; -#define MTF_EXFLOOR_MASK 0x3C00 -#define MTF_EXFLOOR_SHIFT 10 - typedef enum { MTF_Hexen_Dormant = 16, @@ -541,18 +531,18 @@ typedef enum // // Polyobject stuff // -#define HEXTYPE_POLY_START 1 -#define HEXTYPE_POLY_EXPLICIT 5 +constexpr uint8_t HEXTYPE_POLY_START = 1; +constexpr uint8_t HEXTYPE_POLY_EXPLICIT = 5; // -JL- Hexen polyobj thing types -#define PO_ANCHOR_TYPE 3000 -#define PO_SPAWN_TYPE 3001 -#define PO_SPAWNCRUSH_TYPE 3002 +constexpr uint16_t PO_ANCHOR_TYPE = 3000; +constexpr uint16_t PO_SPAWN_TYPE = 3001; +constexpr uint16_t PO_SPAWNCRUSH_TYPE = 3002; // -JL- ZDoom polyobj thing types -#define ZDOOM_PO_ANCHOR_TYPE 9300 -#define ZDOOM_PO_SPAWN_TYPE 9301 -#define ZDOOM_PO_SPAWNCRUSH_TYPE 9302 +constexpr uint16_t ZDOOM_PO_ANCHOR_TYPE = 9300; +constexpr uint16_t ZDOOM_PO_SPAWN_TYPE = 9301; +constexpr uint16_t ZDOOM_PO_SPAWNCRUSH_TYPE = 9302; //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/slump.cc b/source/slump.cc index 70c9fbbbb..83a63ea22 100644 --- a/source/slump.cc +++ b/source/slump.cc @@ -147,17 +147,17 @@ short new_key(level *l) if ((!l->used_red) && rollpercent(33)) { // still using the 'red' check for green key here l->used_red = SLUMP_TRUE; - return ID_HERETICGREENKEY; + return SLUMP_ID_HERETICGREENKEY; } else if ((!l->used_blue) && rollpercent(50)) { l->used_blue = SLUMP_TRUE; - return ID_HERETICBLUEKEY; + return SLUMP_ID_HERETICBLUEKEY; } else if ((!l->used_yellow)) { l->used_yellow = SLUMP_TRUE; - return ID_HERETICYELLOWKEY; + return SLUMP_ID_HERETICYELLOWKEY; } else return 0; @@ -167,17 +167,17 @@ short new_key(level *l) if ((!l->used_red) && rollpercent(33)) { l->used_red = SLUMP_TRUE; - return (l->skullkeys) ? ID_REDKEY : ID_REDCARD; + return (l->skullkeys) ? SLUMP_ID_REDKEY : SLUMP_ID_REDCARD; } else if ((!l->used_blue) && rollpercent(50)) { l->used_blue = SLUMP_TRUE; - return (l->skullkeys) ? ID_BLUEKEY : ID_BLUECARD; + return (l->skullkeys) ? SLUMP_ID_BLUEKEY : SLUMP_ID_BLUECARD; } else if ((!l->used_yellow)) { l->used_yellow = SLUMP_TRUE; - return (l->skullkeys) ? ID_YELLOWKEY : ID_YELLOWCARD; + return (l->skullkeys) ? SLUMP_ID_YELLOWKEY : SLUMP_ID_YELLOWCARD; } else return 0; @@ -256,7 +256,7 @@ linedef *new_linedef(level *l, vertex *from, vertex *to) answer->from = from; answer->to = to; answer->flags = 0; - answer->type = LINEDEF_NORMAL; + answer->type = SLUMP_LINEDEF_NORMAL; answer->tag = 0; answer->left = NULL; answer->right = NULL; @@ -274,7 +274,7 @@ sector *new_sector(level *l, short fh, short ch, flat *ft, flat *ct) sector *answer; if ((ft == NULL) || (ct == NULL)) - announce(WARNING, "Null flat in new_sector."); + announce(SLUMP_WARNING, "Null flat in new_sector."); answer = (sector *)malloc(sizeof(*answer)); answer->floor_height = fh; answer->ceiling_height = ch; @@ -334,16 +334,16 @@ thing *new_thing(level *l, int x, int y, short angle, short type, short options, { thing *answer; - if (type == ID_ELEC) - announce(VERBOSE, "Tech column"); - if (type == ID_CBRA) - announce(VERBOSE, "Candelabra"); - if (type == ID_LAMP2) - announce(VERBOSE, "Lamp2"); - if (type == ID_TLAMP2) - announce(VERBOSE, "Tlamp2"); - if (type == ID_LAMP) - announce(VERBOSE, "Lamp"); + if (type == SLUMP_ID_ELEC) + announce(SLUMP_VERBOSE, "Tech column"); + if (type == SLUMP_ID_CBRA) + announce(SLUMP_VERBOSE, "Candelabra"); + if (type == SLUMP_ID_LAMP2) + announce(SLUMP_VERBOSE, "Lamp2"); + if (type == SLUMP_ID_TLAMP2) + announce(SLUMP_VERBOSE, "Tlamp2"); + if (type == SLUMP_ID_LAMP) + announce(SLUMP_VERBOSE, "Lamp"); answer = (thing *)malloc(sizeof(*answer)); answer->x = (short)x; answer->y = (short)y; @@ -363,7 +363,7 @@ arena *new_arena(level *l, config *c) answer->boss_count = 1; /* Default */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { if (c->mission == 8) { /* Do episode-ends canonically */ @@ -413,7 +413,7 @@ arena *new_arena(level *l, config *c) else if (c->map == 7) { bossno = 3; -#ifdef USING_SPAWNER +#ifdef SLUMP_USING_SPAWNER } else if (c->map == 30) { /* Including the end of DooM II, eventually */ @@ -436,176 +436,176 @@ arena *new_arena(level *l, config *c) switch (bossno) { case 0: /* Baron Brothers */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_IRONLICH); + answer->boss = find_genus(c, SLUMP_ID_IRONLICH); answer->boss_count = 3; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_PHOENIXROD); - answer->ammo = find_genus(c, ID_INFERNOORB); + answer->weapon = find_genus(c, SLUMP_ID_PHOENIXROD); + answer->ammo = find_genus(c, SLUMP_ID_INFERNOORB); } else { - answer->weapon = find_genus(c, ID_DRAGONCLAW); - answer->ammo = find_genus(c, ID_ENERGYORB); + answer->weapon = find_genus(c, SLUMP_ID_DRAGONCLAW); + answer->ammo = find_genus(c, SLUMP_ID_ENERGYORB); } } else { - answer->boss = find_genus(c, ID_BARON); + answer->boss = find_genus(c, SLUMP_ID_BARON); answer->boss_count = 2; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); } else { - answer->weapon = find_genus(c, ID_CHAINGUN); - answer->ammo = find_genus(c, ID_BULBOX); + answer->weapon = find_genus(c, SLUMP_ID_CHAINGUN); + answer->ammo = find_genus(c, SLUMP_ID_BULBOX); } } break; case 1: /* Cybie */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_MAULOTAUR); + answer->boss = find_genus(c, SLUMP_ID_MAULOTAUR); if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_PHOENIXROD); - answer->ammo = find_genus(c, ID_INFERNOORB); + answer->weapon = find_genus(c, SLUMP_ID_PHOENIXROD); + answer->ammo = find_genus(c, SLUMP_ID_INFERNOORB); } else { - answer->weapon = find_genus(c, ID_FIREMACE); - answer->ammo = find_genus(c, ID_MACESPHEREPILE); + answer->weapon = find_genus(c, SLUMP_ID_FIREMACE); + answer->ammo = find_genus(c, SLUMP_ID_MACESPHEREPILE); } } else { - answer->boss = find_genus(c, ID_CYBER); + answer->boss = find_genus(c, SLUMP_ID_CYBER); if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); } else { - answer->weapon = find_genus(c, ID_BFG); - answer->ammo = find_genus(c, ID_CELLPACK); + answer->weapon = find_genus(c, SLUMP_ID_BFG); + answer->ammo = find_genus(c, SLUMP_ID_CELLPACK); } } break; case 2: /* Spiderboss */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_DSPARIL); + answer->boss = find_genus(c, SLUMP_ID_DSPARIL); if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_FIREMACE); - answer->ammo = find_genus(c, ID_MACESPHEREPILE); + answer->weapon = find_genus(c, SLUMP_ID_FIREMACE); + answer->ammo = find_genus(c, SLUMP_ID_MACESPHEREPILE); } else { - answer->weapon = find_genus(c, ID_PHOENIXROD); - answer->ammo = find_genus(c, ID_INFERNOORB); + answer->weapon = find_genus(c, SLUMP_ID_PHOENIXROD); + answer->ammo = find_genus(c, SLUMP_ID_INFERNOORB); } } else { - answer->boss = find_genus(c, ID_SPIDERBOSS); + answer->boss = find_genus(c, SLUMP_ID_SPIDERBOSS); if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_BFG); - answer->ammo = find_genus(c, ID_CELLPACK); + answer->weapon = find_genus(c, SLUMP_ID_BFG); + answer->ammo = find_genus(c, SLUMP_ID_CELLPACK); } else { - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); } } break; case 3: /* Two mancubi (for MAP07, random) */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_IRONLICH); + answer->boss = find_genus(c, SLUMP_ID_IRONLICH); answer->boss_count = 2; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_PHOENIXROD); - answer->ammo = find_genus(c, ID_INFERNOORB); + answer->weapon = find_genus(c, SLUMP_ID_PHOENIXROD); + answer->ammo = find_genus(c, SLUMP_ID_INFERNOORB); } else { - answer->weapon = find_genus(c, ID_HELLSTAFF); - answer->ammo = find_genus(c, ID_GREATERRUNES); + answer->weapon = find_genus(c, SLUMP_ID_HELLSTAFF); + answer->ammo = find_genus(c, SLUMP_ID_GREATERRUNES); } } else { - answer->boss = find_genus(c, ID_MANCUB); + answer->boss = find_genus(c, SLUMP_ID_MANCUB); answer->boss_count = 2; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); } else { - answer->weapon = find_genus(c, ID_PLASMA); - answer->ammo = find_genus(c, ID_CELLPACK); + answer->weapon = find_genus(c, SLUMP_ID_PLASMA); + answer->ammo = find_genus(c, SLUMP_ID_CELLPACK); } } break; case 4: /* Two pains */ - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_WEREDRAGON); + answer->boss = find_genus(c, SLUMP_ID_WEREDRAGON); answer->boss_count = 4; if (rollpercent(50)) { - answer->weapon = find_genus(c, ID_DRAGONCLAW); - answer->ammo = find_genus(c, ID_ENERGYORB); + answer->weapon = find_genus(c, SLUMP_ID_DRAGONCLAW); + answer->ammo = find_genus(c, SLUMP_ID_ENERGYORB); } else { - answer->weapon = find_genus(c, ID_HELLSTAFF); - answer->ammo = find_genus(c, ID_GREATERRUNES); + answer->weapon = find_genus(c, SLUMP_ID_HELLSTAFF); + answer->ammo = find_genus(c, SLUMP_ID_GREATERRUNES); } } else { - answer->boss = find_genus(c, ID_PAIN); + answer->boss = find_genus(c, SLUMP_ID_PAIN); answer->boss_count = 2; if (rollpercent(50)) { - answer->weapon = find_genus(c, ID_CHAINGUN); - answer->ammo = find_genus(c, ID_BULBOX); + answer->weapon = find_genus(c, SLUMP_ID_CHAINGUN); + answer->ammo = find_genus(c, SLUMP_ID_BULBOX); } else { - answer->weapon = find_genus(c, ID_PLASMA); - answer->ammo = find_genus(c, ID_CELLPACK); + answer->weapon = find_genus(c, SLUMP_ID_PLASMA); + answer->ammo = find_genus(c, SLUMP_ID_CELLPACK); } } break; case 5: case 6: - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { - answer->boss = find_genus(c, ID_MAULOTAUR); + answer->boss = find_genus(c, SLUMP_ID_MAULOTAUR); answer->boss_count = 1; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_PHOENIXROD); - answer->ammo = find_genus(c, ID_INFERNOORB); + answer->weapon = find_genus(c, SLUMP_ID_PHOENIXROD); + answer->ammo = find_genus(c, SLUMP_ID_INFERNOORB); } else { - answer->weapon = find_genus(c, ID_HELLSTAFF); - answer->ammo = find_genus(c, ID_GREATERRUNES); + answer->weapon = find_genus(c, SLUMP_ID_HELLSTAFF); + answer->ammo = find_genus(c, SLUMP_ID_GREATERRUNES); } } else @@ -613,30 +613,30 @@ arena *new_arena(level *l, config *c) switch (roll(2)) { case 0: - answer->boss = find_genus(c, ID_ARCHIE); + answer->boss = find_genus(c, SLUMP_ID_ARCHIE); break; default: - answer->boss = find_genus(c, ID_ARACH); + answer->boss = find_genus(c, SLUMP_ID_ARACH); break; } answer->boss_count = 2; if (rollpercent(75)) { - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); } else { - answer->weapon = find_genus(c, ID_PLASMA); - answer->ammo = find_genus(c, ID_CELLPACK); + answer->weapon = find_genus(c, SLUMP_ID_PLASMA); + answer->ammo = find_genus(c, SLUMP_ID_CELLPACK); } } break; case 666: /* Just what are we going to do here? */ - /* answer->boss = find_genus(c,ID_BRAIN); */ - answer->weapon = find_genus(c, ID_LAUNCHER); - answer->ammo = find_genus(c, ID_ROCKBOX); + /* answer->boss = find_genus(c,SLUMP_ID_BRAIN); */ + answer->weapon = find_genus(c, SLUMP_ID_LAUNCHER); + answer->ammo = find_genus(c, SLUMP_ID_ROCKBOX); break; default: announce(SLUMP_ERROR, "Arena missing a boss?"); @@ -644,25 +644,25 @@ arena *new_arena(level *l, config *c) answer->props = 0; if (rollpercent(20)) - answer->props |= ARENA_ROOF; + answer->props |= SLUMP_ARENA_ROOF; if (rollpercent(20)) - answer->props |= ARENA_PORCH; + answer->props |= SLUMP_ARENA_PORCH; if (rollpercent(20)) - answer->props |= ARENA_LAMPS; + answer->props |= SLUMP_ARENA_LAMPS; if (rollpercent(20)) - answer->props |= ARENA_ARRIVAL_HOLE; + answer->props |= SLUMP_ARENA_ARRIVAL_HOLE; if (rollpercent(10 + l->p_force_nukage)) - answer->props |= ARENA_NUKAGE; + answer->props |= SLUMP_ARENA_NUKAGE; - if (answer->props & ARENA_ROOF) + if (answer->props & SLUMP_ARENA_ROOF) { - answer->floor = random_flat0(FLOOR, c, NULL); /* These NULLs OK? */ - answer->walls = random_texture0(WALL, c, NULL); + answer->floor = random_flat0(SLUMP_FLOOR, c, NULL); /* These NULLs OK? */ + answer->walls = random_texture0(SLUMP_WALL, c, NULL); } else { - answer->floor = random_flat0(OUTDOOR, c, NULL); - answer->walls = random_texture0(OUTDOOR, c, NULL); + answer->floor = random_flat0(SLUMP_OUTDOOR, c, NULL); + answer->walls = random_texture0(SLUMP_OUTDOOR, c, NULL); } answer->placed_health = SLUMP_FALSE; answer->placed_armor = SLUMP_FALSE; @@ -716,10 +716,10 @@ quest *starting_quest(level *l, config *c) quest *answer; answer = (quest *)malloc(sizeof(*answer)); - answer->goal = LEVEL_END_GOAL; + answer->goal = SLUMP_LEVEL_END_GOAL; answer->room = NULL; /* won't be used, because this is always stack bottom */ answer->tag = 0; /* not a linedef goal */ - answer->type = LINEDEF_S1_END_LEVEL; + answer->type = SLUMP_LINEDEF_S1_END_LEVEL; answer->count = 0; /* no rooms yet! */ answer->minrooms = c->minrooms; answer->auxtag = 0; @@ -738,7 +738,7 @@ haa *starting_haa(void) answer = (haa *)malloc(sizeof(*answer)); - for (i = ITYTD; i <= UV; i++) + for (i = SLUMP_ITYTD; i <= SLUMP_UV; i++) { answer->haas[i].health = (float)100; answer->haas[i].ammo = (float)500; @@ -851,7 +851,7 @@ unsigned short psi_sqrt(int v) { int t = 1L << 30, r = 0, s; -#define PSISTEP(k) \ +#define SLUMP_PSISTEP(k) \ s = t + r; \ r >>= 1; \ if (s <= v) \ @@ -860,37 +860,37 @@ unsigned short psi_sqrt(int v) r |= t; \ } - PSISTEP(15); + SLUMP_PSISTEP(15); t >>= 2; - PSISTEP(14); + SLUMP_PSISTEP(14); t >>= 2; - PSISTEP(13); + SLUMP_PSISTEP(13); t >>= 2; - PSISTEP(12); + SLUMP_PSISTEP(12); t >>= 2; - PSISTEP(11); + SLUMP_PSISTEP(11); t >>= 2; - PSISTEP(10); + SLUMP_PSISTEP(10); t >>= 2; - PSISTEP(9); + SLUMP_PSISTEP(9); t >>= 2; - PSISTEP(8); + SLUMP_PSISTEP(8); t >>= 2; - PSISTEP(7); + SLUMP_PSISTEP(7); t >>= 2; - PSISTEP(6); + SLUMP_PSISTEP(6); t >>= 2; - PSISTEP(5); + SLUMP_PSISTEP(5); t >>= 2; - PSISTEP(4); + SLUMP_PSISTEP(4); t >>= 2; - PSISTEP(3); + SLUMP_PSISTEP(3); t >>= 2; - PSISTEP(2); + SLUMP_PSISTEP(2); t >>= 2; - PSISTEP(1); + SLUMP_PSISTEP(1); t >>= 2; - PSISTEP(0); + SLUMP_PSISTEP(0); return (unsigned short)r; } @@ -915,8 +915,9 @@ flat *new_flat(config *c, const char *name) answer = (flat *)malloc(sizeof(*answer)); memset(answer->name, 0, 9); memcpy(answer->name, name, strlen(name)); - answer->gamemask = DOOM0_BIT | DOOM1_BIT | DOOM2_BIT | DOOMC_BIT | DOOMI_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | - HARMONY_BIT | STRIFE_BIT | REKKR_BIT; + answer->gamemask = SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT | + SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT | + SLUMP_REKKR_BIT; answer->compatible = 0; answer->props = 0; answer->used = SLUMP_FALSE; @@ -990,8 +991,8 @@ genus *new_monster(config *c, int thingid) int i; answer = new_genus(c, thingid); - answer->bits |= MONSTER; - answer->bits &= ~PICKABLE; /* Can't pick up a monster! */ + answer->bits |= SLUMP_MONSTER; + answer->bits &= ~SLUMP_PICKABLE; /* Can't pick up a monster! */ for (i = 0; i < 3; i++) { answer->ammo_to_kill[i] = (float)1000; /* Any reason to have defaults? */ @@ -1009,15 +1010,16 @@ genus *new_genus(config *c, int thingid) answer = (genus *)malloc(sizeof(*answer)); /* Default mask */ - answer->gamemask = DOOM0_BIT | DOOM1_BIT | DOOM2_BIT | DOOMC_BIT | DOOMI_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | - HARMONY_BIT | STRIFE_BIT | REKKR_BIT; + answer->gamemask = SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT | + SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT | + SLUMP_REKKR_BIT; answer->compatible = ~(unsigned int)0; /* Assume all themes OK */ answer->thingid = thingid; answer->width = 65; /* Sort of sensible default */ answer->height = 56; /* Just "not tall" */ answer->marked = 0; answer->next = c->genus_anchor; - answer->bits = PICKABLE; /* A plausible default? */ + answer->bits = SLUMP_PICKABLE; /* A plausible default? */ c->genus_anchor = answer; return answer; } @@ -1071,8 +1073,9 @@ texture *new_texture(config *c, const char *name) memset(answer->name, 0, 9); memcpy(answer->name, name, strlen(name)); answer->realname = answer->name; - answer->gamemask = DOOM0_BIT | DOOM1_BIT | DOOM2_BIT | DOOMC_BIT | DOOMI_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | - HARMONY_BIT | STRIFE_BIT | REKKR_BIT; + answer->gamemask = SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT | + SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT | + SLUMP_REKKR_BIT; answer->compatible = 0; answer->core = 0; answer->props = 0; /* Filled in later */ @@ -1104,7 +1107,7 @@ linedef *split_linedef(level *l, linedef *ld, int len, config *c) affect the output of these functions otherwise. The original code looked like this: - ratio = (double)len / (double)linelen(ld); + ratio = (double)len / (double)SLUMP_linelen(ld); dx = (int)(ratio * (double)(ld->to->x - ld->from->x)); dy = (int)(ratio * (double)(ld->to->y - ld->from->y)); @@ -1113,7 +1116,7 @@ linedef *split_linedef(level *l, linedef *ld, int len, config *c) the same seed and flags generate the same levels, I had to change this code to not be affected by optimization. - Sam */ q1 = (double)len; - q2 = (double)linelen(ld); + q2 = (double)SLUMP_linelen(ld); if (q2 > 0) { ratio = q1 / q2; @@ -1177,7 +1180,7 @@ linedef *split_linedef(level *l, linedef *ld, int len, config *c) /* Put in any upper textures required */ void patch_upper(linedef *ld, texture *t, config *c) { -#ifdef TOLERATE_SLUMP_ERRORS +#ifdef SLUMP_TOLERATE_SLUMP_ERRORS if (ld->left == NULL) return; #endif @@ -1186,7 +1189,7 @@ void patch_upper(linedef *ld, texture *t, config *c) if ((ld->right->upper_texture == NULL) || (ld->right->upper_texture->name[0] == '-')) { ld->right->upper_texture = t; - ld->flags |= UPPER_UNPEGGED; /* Seems a good default */ + ld->flags |= SLUMP_UPPER_UNPEGGED; /* Seems a good default */ } } if (ld->left->psector->ceiling_height > ld->right->psector->ceiling_height) @@ -1194,7 +1197,7 @@ void patch_upper(linedef *ld, texture *t, config *c) if ((ld->left->upper_texture == NULL) || (ld->left->upper_texture->name[0] == '-')) { ld->left->upper_texture = t; - ld->flags |= UPPER_UNPEGGED; /* Seems a good default */ + ld->flags |= SLUMP_UPPER_UNPEGGED; /* Seems a good default */ } } } @@ -1202,7 +1205,7 @@ void patch_upper(linedef *ld, texture *t, config *c) /* Put in any lower textures required */ void patch_lower(linedef *ld, texture *t, config *c) { -#ifdef TOLERATE_SLUMP_ERRORS +#ifdef SLUMP_TOLERATE_SLUMP_ERRORS if (ld->left == NULL) return; #endif @@ -1211,7 +1214,7 @@ void patch_lower(linedef *ld, texture *t, config *c) if ((ld->right->lower_texture == NULL) || (ld->right->lower_texture->name[0] == '-')) { ld->right->lower_texture = t; - ld->flags |= LOWER_UNPEGGED; /* Seems a good default */ + ld->flags |= SLUMP_LOWER_UNPEGGED; /* Seems a good default */ } } if (ld->left->psector->floor_height < ld->right->psector->floor_height) @@ -1219,7 +1222,7 @@ void patch_lower(linedef *ld, texture *t, config *c) if ((ld->left->lower_texture == NULL) || (ld->left->lower_texture->name[0] == '-')) { ld->left->lower_texture = t; - ld->flags |= LOWER_UNPEGGED; /* Seems a good default */ + ld->flags |= SLUMP_LOWER_UNPEGGED; /* Seems a good default */ } } } @@ -1276,7 +1279,8 @@ void secretize_config(config *c) if (rollpercent(25)) c->force_biggest = SLUMP_TRUE; /* stub */ c->big_monsters = SLUMP_TRUE; - if (!(c->gamemask & CHEX_BIT || c->gamemask & HARMONY_BIT || c->gamemask & STRIFE_BIT || c->gamemask & HACX_BIT)) + if (!(c->gamemask & SLUMP_CHEX_BIT || c->gamemask & SLUMP_HARMONY_BIT || c->gamemask & SLUMP_STRIFE_BIT || + c->gamemask & SLUMP_HACX_BIT)) { c->secret_themes = SLUMP_TRUE; } @@ -1293,24 +1297,25 @@ void secretize_config(config *c) { c->major_nukage = SLUMP_TRUE; something_special = SLUMP_TRUE; - announce(VERBOSE, "Nukage everywhere"); + announce(SLUMP_VERBOSE, "Nukage everywhere"); } /* Sometimes some DooM II nazis */ - if (rollpercent(80) && !(c->gamemask & (DOOM0_BIT | DOOM1_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | - HARMONY_BIT | STRIFE_BIT | REKKR_BIT))) + if (rollpercent(80) && + !(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | + SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT | SLUMP_REKKR_BIT))) { - c->forbidden_monster_bits &= ~SPECIAL; + c->forbidden_monster_bits &= ~SLUMP_SPECIAL; something_special = SLUMP_TRUE; if (rollpercent(50)) { - c->required_monster_bits |= SPECIAL; - c->required_monster_bits &= ~BIG; - announce(VERBOSE, "All nazis"); + c->required_monster_bits |= SLUMP_SPECIAL; + c->required_monster_bits &= ~SLUMP_BIG; + announce(SLUMP_VERBOSE, "All nazis"); } else { - announce(VERBOSE, "Some nazis"); + announce(SLUMP_VERBOSE, "Some nazis"); } } @@ -1319,17 +1324,17 @@ void secretize_config(config *c) { if (rollpercent(50)) { - c->required_monster_bits |= BIG; - c->required_monster_bits &= ~SPECIAL; + c->required_monster_bits |= SLUMP_BIG; + c->required_monster_bits &= ~SLUMP_SPECIAL; c->big_monsters = SLUMP_TRUE; - announce(VERBOSE, "All big monsters"); + announce(SLUMP_VERBOSE, "All big monsters"); something_special = SLUMP_TRUE; } else { /* Put in a favorite monster here! */ /* and set something_special */ - announce(VERBOSE, "Someday a favorite monster"); + announce(SLUMP_VERBOSE, "Someday a favorite monster"); } } @@ -1376,7 +1381,7 @@ config *get_config(const std::string &filename) answer->major_nukage = StringToInt(nukage) ? SLUMP_TRUE : SLUMP_FALSE; if (ob_mod_enabled("slump_all_nazis")) { - answer->required_monster_bits = SPECIAL; + answer->required_monster_bits = SLUMP_SPECIAL; answer->forbidden_monster_bits = 0; } else @@ -1385,22 +1390,22 @@ config *get_config(const std::string &filename) if (StringCompare(monvariety, "normal") == 0) { answer->required_monster_bits = 0; - answer->forbidden_monster_bits = SPECIAL; + answer->forbidden_monster_bits = SLUMP_SPECIAL; } else if (StringCompare(monvariety, "shooters") == 0) { - answer->required_monster_bits = SHOOTS; - answer->forbidden_monster_bits = SPECIAL; + answer->required_monster_bits = SLUMP_SHOOTS; + answer->forbidden_monster_bits = SLUMP_SPECIAL; } else if (StringCompare(monvariety, "noflyzone") == 0) { answer->required_monster_bits = 0; - answer->forbidden_monster_bits = FLIES + SPECIAL; + answer->forbidden_monster_bits = SLUMP_FLIES + SLUMP_SPECIAL; } else { // Fallback answer->required_monster_bits = 0; - answer->forbidden_monster_bits = SPECIAL; + answer->forbidden_monster_bits = SLUMP_SPECIAL; } } std::string levelsize = ob_get_param("float_minrooms_slump"); @@ -1417,56 +1422,56 @@ config *get_config(const std::string &filename) std::string current_game = ob_get_param("game"); if (StringCompare(current_game, "doom1") == 0 || StringCompare(current_game, "ultdoom") == 0) { - answer->gamemask = (DOOM1_BIT | DOOMI_BIT); + answer->gamemask = (SLUMP_DOOM1_BIT | SLUMP_DOOMI_BIT); answer->map = 0; answer->episode = 1; answer->mission = 1; } else if (StringCompare(current_game, "chex1") == 0) { - answer->gamemask = (DOOM1_BIT | DOOMI_BIT | DOOMC_BIT | CHEX_BIT); + answer->gamemask = (SLUMP_DOOM1_BIT | SLUMP_DOOMI_BIT | SLUMP_DOOMC_BIT | SLUMP_CHEX_BIT); answer->map = 0; answer->episode = 1; answer->mission = 1; } else if (StringCompare(current_game, "rekkr") == 0) { - answer->gamemask = (DOOM1_BIT | DOOMI_BIT | DOOMC_BIT | REKKR_BIT); + answer->gamemask = (SLUMP_DOOM1_BIT | SLUMP_DOOMI_BIT | SLUMP_DOOMC_BIT | SLUMP_REKKR_BIT); answer->map = 0; answer->episode = 1; answer->mission = 1; } else if (StringCompare(current_game, "heretic") == 0) { - answer->gamemask = HERETIC_BIT; + answer->gamemask = SLUMP_HERETIC_BIT; answer->map = 0; answer->episode = 1; answer->mission = 1; } else if (StringCompare(current_game, "hacx") == 0) { - answer->gamemask = (DOOM2_BIT | DOOMI_BIT | HACX_BIT); + answer->gamemask = (SLUMP_DOOM2_BIT | SLUMP_DOOMI_BIT | SLUMP_HACX_BIT); answer->map = 1; answer->episode = 0; answer->mission = 0; } else if (StringCompare(current_game, "harmony") == 0) { - answer->gamemask = (DOOM2_BIT | DOOMI_BIT | HARMONY_BIT); + answer->gamemask = (SLUMP_DOOM2_BIT | SLUMP_DOOMI_BIT | SLUMP_HARMONY_BIT); answer->map = 1; answer->episode = 0; answer->mission = 0; } else if (StringCompare(current_game, "strife") == 0) { - answer->gamemask = (DOOM2_BIT | DOOMI_BIT | STRIFE_BIT); + answer->gamemask = (SLUMP_DOOM2_BIT | SLUMP_DOOMI_BIT | SLUMP_STRIFE_BIT); answer->map = 2; answer->episode = 0; answer->mission = 0; } else { // Doom 2 / Final Doom - answer->gamemask = (DOOM2_BIT | DOOMI_BIT); + answer->gamemask = (SLUMP_DOOM2_BIT | SLUMP_DOOMI_BIT); answer->map = 1; answer->episode = 0; answer->mission = 0; @@ -1571,7 +1576,7 @@ config *get_config(const std::string &filename) answer->norm_vary = 25; if (rollpercent(15)) { /* Some older settings */ - announce(VERBOSE, "Old themeing"); + announce(SLUMP_VERBOSE, "Old themeing"); answer->rad_newtheme = 12; answer->norm_newtheme = 4; answer->rad_vary = 60; @@ -1579,7 +1584,7 @@ config *get_config(const std::string &filename) } if (rollpercent(15)) { /* Sometimes never change themes! */ - announce(VERBOSE, "One theme"); + announce(SLUMP_VERBOSE, "One theme"); answer->rad_newtheme = 0; answer->norm_newtheme = 0; answer->rad_vary = 100; /* But change other stuff more */ @@ -1597,7 +1602,7 @@ config *get_config(const std::string &filename) { char s[80]; sprintf(s, "Homogenization %d.", answer->homogenize_monsters); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } answer->weapons_are_special = SLUMP_FALSE; answer->recess_switches = rollpercent(95); @@ -1643,14 +1648,14 @@ config *get_config(const std::string &filename) /* And figure some resultants */ for (m = answer->genus_anchor; m; m = m->next) { /* Apply macho factors */ - if (!(m->bits & MONSTER)) + if (!(m->bits & SLUMP_MONSTER)) continue; - m->ammo_to_kill[HMP] *= answer->machoh; - m->damage[HMP] *= answer->machoh; - m->altdamage[HMP] *= answer->machoh; - m->ammo_to_kill[UV] *= answer->machou; - m->damage[UV] *= answer->machou; - m->altdamage[UV] *= answer->machou; + m->ammo_to_kill[SLUMP_HMP] *= answer->machoh; + m->damage[SLUMP_HMP] *= answer->machoh; + m->altdamage[SLUMP_HMP] *= answer->machoh; + m->ammo_to_kill[SLUMP_UV] *= answer->machou; + m->damage[SLUMP_UV] *= answer->machou; + m->altdamage[SLUMP_UV] *= answer->machou; } if (answer->force_secret) @@ -1670,7 +1675,7 @@ config *get_config(const std::string &filename) vertex *make_watermark_path(level *l, vertex *v1, vertex *v2, sidedef *rsd, sidedef *lsd) { linedef *ld = new_linedef(l, v1, v2); - ld->flags = TWO_SIDED; + ld->flags = SLUMP_TWO_SIDED; ld->left = lsd; ld->right = rsd; return v2; @@ -1794,14 +1799,14 @@ int random_theme(config *c) else { answer = roll(c->themecount); -#ifdef THEME_INVERTER_HACK +#ifdef SLUMP_THEME_INVERTER_HACK answer = (answer == 2) ? answer : 1 - answer; /* Just an experiment */ #endif } { char s[80]; sprintf(s, "Theme %d.", answer); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } return answer; } @@ -1813,16 +1818,16 @@ short random_doortype(level *l, config *c, style *s) { short answer; - answer = LINEDEF_NORMAL_DOOR; + answer = SLUMP_LINEDEF_NORMAL_DOOR; if (rollpercent(l->p_s1_door)) - answer = LINEDEF_NORMAL_S1_DOOR; - if (!((DOOM0_BIT | HERETIC_BIT) & c->gamemask) && rollpercent(20)) + answer = SLUMP_LINEDEF_NORMAL_S1_DOOR; + if (!((SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT) & c->gamemask) && rollpercent(20)) { - if (answer == LINEDEF_NORMAL_DOOR) - answer = LINEDEF_BLAZE_DOOR; - if (answer == LINEDEF_NORMAL_S1_DOOR) - answer = LINEDEF_BLAZE_S1_DOOR; - announce(VERBOSE, "Blaze door type"); + if (answer == SLUMP_LINEDEF_NORMAL_DOOR) + answer = SLUMP_LINEDEF_BLAZE_DOOR; + if (answer == SLUMP_LINEDEF_NORMAL_S1_DOOR) + answer = SLUMP_LINEDEF_BLAZE_S1_DOOR; + announce(SLUMP_VERBOSE, "Blaze door type"); } return answer; } @@ -1831,9 +1836,9 @@ short random_slifttype(config *c, style *s) { short answer; - answer = LINEDEF_SR_LOWER_LIFT; - if (!((DOOM0_BIT | HERETIC_BIT) & c->gamemask) && rollpercent(20)) - answer = LINEDEF_SR_TURBO_LIFT; + answer = SLUMP_LINEDEF_SR_LOWER_LIFT; + if (!((SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT) & c->gamemask) && rollpercent(20)) + answer = SLUMP_LINEDEF_SR_TURBO_LIFT; return answer; } @@ -1869,13 +1874,13 @@ int random_windowdecor(config *c, style *s) { case 0: case 1: - return WINDOW_NORMAL; + return SLUMP_WINDOW_NORMAL; case 2: - return WINDOW_JAMBS; + return SLUMP_WINDOW_JAMBS; case 3: - return WINDOW_SUPPORT; + return SLUMP_WINDOW_SUPPORT; default: - return WINDOW_LIGHT; + return SLUMP_WINDOW_LIGHT; } } @@ -1884,12 +1889,12 @@ int random_lightboxlighting(config *c, style *s) switch (roll(4)) { case 0: - return LIGHTBOX_NORMAL; + return SLUMP_LIGHTBOX_NORMAL; case 1: case 2: - return LIGHTBOX_LIGHTED; + return SLUMP_LIGHTBOX_LIGHTED; default: - return LIGHTBOX_DARK; + return SLUMP_LIGHTBOX_DARK; } } @@ -1899,48 +1904,48 @@ genus *random_plant(config *c, style *s) genus *answer; int tcount; - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { tcount = 2; switch (roll(tcount)) { case 0: - answer = find_genus(c, ID_SMSTALAGMITE); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_SMSTALAGMITE); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 33; break; case 1: default: - answer = find_genus(c, ID_LGSTALAGMITE); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_LGSTALAGMITE); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 33; break; } } else { - tcount = (c->gamemask & DOOM1_BIT) ? 3 : 4; + tcount = (c->gamemask & SLUMP_DOOM1_BIT) ? 3 : 4; switch (roll(tcount)) { case 0: - answer = find_genus(c, ID_SMIT); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_SMIT); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 33; break; case 1: - answer = find_genus(c, ID_TREE1); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_TREE1); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 33; break; case 2: - answer = find_genus(c, ID_TREE2); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_TREE2); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 65; break; case 3: default: - answer = find_genus(c, ID_FBARREL); - answer->bits &= ~PICKABLE; + answer = find_genus(c, SLUMP_ID_FBARREL); + answer->bits &= ~SLUMP_PICKABLE; answer->width = 33; break; } @@ -1952,34 +1957,34 @@ genus *random_plant(config *c, style *s) /* compatible with the theme. */ genus *random_barrel(config *c, style *s) { - return random_thing0(EXPLODES, c, s, 0, 10000); + return random_thing0(SLUMP_EXPLODES, c, s, 0, 10000); } /* A lamp or similar decoration, tall or short */ genus *random_lamp0(config *c, style *s) { - if (c->gamemask & CHEX_BIT) + if (c->gamemask & SLUMP_CHEX_BIT) { - return find_genus(c, ID_LAMP); + return find_genus(c, SLUMP_ID_LAMP); } genus *answer; - answer = random_thing0(LIGHT, c, s, 70, 10000); + answer = random_thing0(SLUMP_LIGHT, c, s, 70, 10000); if (answer == NULL) - answer = random_thing0(LIGHT, c, s, 0, 10000); + answer = random_thing0(SLUMP_LIGHT, c, s, 0, 10000); return answer; } /* A lamp or similar decoration, no taller than a player */ genus *random_shortlamp0(config *c, style *s) { - if (c->gamemask & CHEX_BIT) + if (c->gamemask & SLUMP_CHEX_BIT) { - return find_genus(c, ID_LAMP); + return find_genus(c, SLUMP_ID_LAMP); } - return random_thing0(LIGHT, c, s, 0, 56); + return random_thing0(SLUMP_LIGHT, c, s, 0, 56); } /* Return the number of a random construct family that contains at */ @@ -1988,8 +1993,8 @@ int construct_family_for(config *c, style *s) { construct *cs; int tmask = 0x01 << s->theme_number; -#define MAX_COMPATIBLE_FAMILIES (5) - int compats[MAX_COMPATIBLE_FAMILIES]; +#define SLUMP_MAX_COMPATIBLE_FAMILIES (5) + int compats[SLUMP_MAX_COMPATIBLE_FAMILIES]; int compat_count = 0; boolean already; int i; @@ -2010,8 +2015,8 @@ int construct_family_for(config *c, style *s) if (compat_count == 0) { -#ifdef REQUIRE_CONSTRUCTS_IN_ALL_THEMES - announce(WARNING, "No compatible constructs for theme."); +#ifdef SLUMP_REQUIRE_CONSTRUCTS_IN_ALL_THEMES + announce(SLUMP_WARNING, "No compatible constructs for theme."); #endif return -1; /* Whatever */ } @@ -2295,7 +2300,7 @@ style *copy_style(level *l, style *old, int themenumber, int vary, config *c) if (!rollpercent(vary)) answer->auxspecial = old->auxspecial; else - answer->auxspecial = rollpercent(80) ? 0 : RANDOM_BLINK; + answer->auxspecial = rollpercent(80) ? 0 : SLUMP_RANDOM_BLINK; if (!rollpercent(vary)) answer->doortype = old->doortype; else @@ -2361,7 +2366,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c) { /* A monster */ m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1); if (m && levels) - if (NULL != place_object_in_region(l, minx, miny, tlx, maxy, c, m->thingid, MONSTER_WIDTH(m), -1, + if (NULL != place_object_in_region(l, minx, miny, tlx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)) update_haa_for_monster(haa, m, levels, 1, c); } @@ -2376,7 +2381,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c) { /* A monster */ m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1); if (m && levels) - if (NULL != place_object_in_region(l, thx, miny, maxx, maxy, c, m->thingid, MONSTER_WIDTH(m), -1, + if (NULL != place_object_in_region(l, thx, miny, maxx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)) update_haa_for_monster(haa, m, levels, 1, c); } @@ -2393,7 +2398,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c) { /* A monster */ m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1); if (m && levels) - if (NULL != place_object_in_region(l, minx, miny, maxx, tly, c, m->thingid, MONSTER_WIDTH(m), -1, + if (NULL != place_object_in_region(l, minx, miny, maxx, tly, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)) update_haa_for_monster(haa, m, levels, 1, c); } @@ -2408,7 +2413,7 @@ void gate_populate(level *l, sector *s, haa *haa, boolean first, config *c) { /* A monster */ m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1); if (m && levels) - if (NULL != place_object_in_region(l, minx, thy, maxx, maxy, c, m->thingid, MONSTER_WIDTH(m), -1, + if (NULL != place_object_in_region(l, minx, thy, maxx, maxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)) update_haa_for_monster(haa, m, levels, 1, c); } @@ -2441,23 +2446,23 @@ void populate(level *l, sector *s, config *c, haa *haa, boolean first_room) /* to do special end-stuff, like arenas. */ boolean enough_quest(level *l, sector *s, quest *ThisQuest, config *c) { - if (!(c->gamemask & CHEX_BIT)) + if (!(c->gamemask & SLUMP_CHEX_BIT)) { /* Perhaps an arena? */ - if ((ThisQuest->goal == LEVEL_END_GOAL) && (s != l->first_room) && (!c->do_dm) && + if ((ThisQuest->goal == SLUMP_LEVEL_END_GOAL) && (s != l->first_room) && (!c->do_dm) && ((l->sl_tag != 0) || !need_secret_level(c)) && ((l->sl_tag == 0) || l->sl_done) && (ThisQuest->count >= (ThisQuest->minrooms - 5))) { if ((c->mission == 8) || (c->map == 30) || ((c->map == 7) && (c->last_mission)) || (c->last_mission && (c->force_arena || rollpercent(3 * c->levelcount)))) { - ThisQuest->goal = ARENA_GOAL; + ThisQuest->goal = SLUMP_ARENA_GOAL; return 1; } } } /* Don't stop a GATE_QUEST at an already-gate room */ - if (ThisQuest->goal == GATE_GOAL) + if (ThisQuest->goal == SLUMP_GATE_GOAL) if (s->pgate) return 0; /* Otherwise the ordinary check. */ @@ -2486,16 +2491,16 @@ thing *place_required_small_pickable(level *l, sector *s, config *c) if (l->heretic_level) { // Don't really know what to put here if (rollpercent(50)) - tid = ID_WANDCRYSTAL; + tid = SLUMP_ID_WANDCRYSTAL; else - tid = ID_ETHEREALARROWS; + tid = SLUMP_ID_ETHEREALARROWS; } else { if (rollpercent(50)) - tid = ID_POTION; + tid = SLUMP_ID_POTION; else - tid = ID_HELMET; /* More choices? */ + tid = SLUMP_ID_HELMET; /* More choices? */ } return place_required_pickable(l, s, c, tid); @@ -2555,7 +2560,7 @@ void global_align_forward(level *l, linedef *ld) if (ld2->from == v) if (common_texture(ld->right, ld2->right)) { - newoff = ld->right->x_offset + linelen(ld); + newoff = ld->right->x_offset + SLUMP_linelen(ld); newoff = newoff % 256; if (newoff < 0) newoff += 256; @@ -2586,7 +2591,7 @@ void global_align_backward(level *l, linedef *ld) if (ld2->to == v) if (common_texture(ld->right, ld2->right)) { - newoff = ld->right->x_offset - linelen(ld2); + newoff = ld->right->x_offset - SLUMP_linelen(ld2); newoff = newoff % 256; if (newoff < 0) newoff += 256; @@ -2622,10 +2627,10 @@ void global_align_group_backbone_forward(level *l, linedef *ld) if (NULL != (ldnext = ld->group_next)) { if (ld->to != ldnext->from) - announce(LOG, "Yow forward!"); + announce(SLUMP_LOG, "Yow forward!"); if (common_texture(ld->right, ldnext->right)) { - newoff = ld->right->x_offset + linelen(ld); + newoff = ld->right->x_offset + SLUMP_linelen(ld); newoff = newoff % 256; if (newoff < 0) newoff += 256; @@ -2637,7 +2642,7 @@ void global_align_group_backbone_forward(level *l, linedef *ld) } else { - announce(LOG, "Found a locked linedef in g_a_g_b_f?"); + announce(SLUMP_LOG, "Found a locked linedef in g_a_g_b_f?"); if (ldnext->right->x_offset != newoff) ldnext->f_misaligned = 1; } @@ -2671,10 +2676,10 @@ void global_align_group_backbone_backward(level *l, linedef *ld) if (NULL != (ldprev = ld->group_previous)) { if (ld->from != ldprev->to) - announce(LOG, "Yow backward!"); + announce(SLUMP_LOG, "Yow backward!"); if (common_texture(ld->right, ldprev->right)) { - newoff = ld->right->x_offset - linelen(ldprev); + newoff = ld->right->x_offset - SLUMP_linelen(ldprev); newoff = newoff % 256; if (newoff < 0) newoff += 256; @@ -2686,7 +2691,7 @@ void global_align_group_backbone_backward(level *l, linedef *ld) } else { - announce(LOG, "Found a locked linedef in g_a_g_b_b?"); + announce(SLUMP_LOG, "Found a locked linedef in g_a_g_b_b?"); if (ldprev->right->x_offset != newoff) ldprev->b_misaligned = 1; } @@ -2703,9 +2708,9 @@ void global_align_textures(level *l, config *c) linedef *ld1, *ld2; int newoff; - announce(LOG, "Globally aligning..."); + announce(SLUMP_LOG, "Globally aligning..."); -#define DONT_MARK_MISALIGNS +#define SLUMP_DONT_MARK_MISALIGNS 0 for (ld1 = l->linedef_anchor; ld1; ld1 = ld1->next) { @@ -2732,14 +2737,14 @@ void global_align_textures(level *l, config *c) /* This actually looks pretty terrible! Think about it more */ if (l->support_misaligns) { - announce(LOG, "Prettying up misalignments..."); + announce(SLUMP_LOG, "Prettying up misalignments..."); for (ld1 = l->linedef_anchor; ld1; ld1 = ld1->next) { if (ld1->right) if (ld1->right->psector->pstyle) if (ld1->b_misaligned) { - newoff = linelen(ld1); + newoff = SLUMP_linelen(ld1); if (newoff > 8) split_linedef(l, ld1, 8, c); if (ld1->right->upper_texture->name[0] != '-') @@ -2751,7 +2756,7 @@ void global_align_textures(level *l, config *c) } if (ld1->f_misaligned) { - newoff = linelen(ld1); + newoff = SLUMP_linelen(ld1); if (newoff > 8) ld2 = split_linedef(l, ld1, newoff - 8, c); else @@ -2766,14 +2771,14 @@ void global_align_textures(level *l, config *c) } /* end for ld1 */ } /* end if supporting */ -#ifdef MARK_MISALIGNS +#ifdef SLUMP_MARK_MISALIGNS /* And finally for debugging mark the places we know still didn't align */ for (ld1 = l->linedef_anchor; ld1; ld1 = ld1->next) { if (ld1->right) if (ld1->b_misaligned) { - newoff = linelen(ld1); + newoff = SLUMP_linelen(ld1); if (newoff > 8) split_linedef(l, ld1, 8, c); if (ld1->right->upper_texture->name[0] != '-') @@ -2785,7 +2790,7 @@ void global_align_textures(level *l, config *c) } if (ld1->f_misaligned) { - newoff = linelen(ld1); + newoff = SLUMP_linelen(ld1); if (newoff > 8) ld2 = split_linedef(l, ld1, newoff - 8, c); else @@ -2810,7 +2815,7 @@ void global_fixups(level *l) for (ld = l->linedef_anchor; ld; ld = ld->next) if (ld->left == NULL) - ld->flags |= IMPASSIBLE; + ld->flags |= SLUMP_IMPASSIBLE; } /* This just paints all one-sided boundary sidddefs of the sector */ @@ -2846,7 +2851,7 @@ linedef *make_parallel(level *l, linedef *ld, int depth, linedef *old) vertex *v1, *v2; int x, y; - point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, LEFT_TURN, depth, &x, &y); + point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, SLUMP_LEFT_TURN, depth, &x, &y); if (old) { old->to->x = x; /* Assumes no one else is using */ @@ -2899,7 +2904,7 @@ sector *make_box_ext(level *l, linedef *ldf1, linedef *ldf2, style *ThisStyle, c answer->light_level = oldsec->light_level; /* default */ answer->special = oldsec->special; /* or zero? */ ldf1->right->middle_texture = c->null_texture; - ldf1->flags |= TWO_SIDED; + ldf1->flags |= SLUMP_TWO_SIDED; } ldf1->left = new_sidedef(l, answer, c); ldf2->right = new_sidedef(l, answer, c); @@ -2940,8 +2945,8 @@ void find_rec(level *l, sector *s, int *minx, int *miny, int *maxx, int *maxy) if (!s->findrec_data_valid) { int lx, ly, hx, hy; - lx = ly = HUGE_NUMBER; - hx = hy = 0 - HUGE_NUMBER; + lx = ly = SLUMP_HUGE_NUMBER; + hx = hy = 0 - SLUMP_HUGE_NUMBER; for (ld = l->linedef_anchor; ld; ld = ld->next) { if (ld->right) @@ -2985,16 +2990,17 @@ void dump_link(linedef *ldf1, linedef *ldf2, link *ThisLink, const char *s1) sprintf(s, "%s Link between (%d,%d)-(%d,%d) and (%d,%d)-(%d,%d).", s1, ldf1->from->x, ldf1->from->y, ldf1->to->x, ldf1->to->y, ldf2->from->x, ldf2->from->y, ldf2->to->x, ldf2->to->y); } - announce(VERBOSE, s); - announce(VERBOSE, "T W R ND FD C A S L M h1 w1 w2 d1 d2 d3 fd sc "); + announce(SLUMP_VERBOSE, s); + announce(SLUMP_VERBOSE, "T W R ND FD C A S L M h1 w1 w2 d1 d2 d3 fd sc "); sprintf(s, "%1d %1d %1d %1d %1d %1d %1d %1d %1d %03d %03d %03d %03d %03d %03d %04d %03d %03d", - (ThisLink->bits & LINK_TWIN) != 0, (ThisLink->bits & LINK_WINDOW) != 0, (ThisLink->bits & LINK_RECESS) != 0, - (ThisLink->bits & LINK_NEAR_DOOR) != 0, (ThisLink->bits & LINK_FAR_DOOR) != 0, - (ThisLink->bits & LINK_CORE) != 0, (ThisLink->bits & LINK_ALCOVE) != 0, (ThisLink->bits & LINK_STEPS) != 0, - (ThisLink->bits & LINK_LIFT) != 0, (ThisLink->bits & LINK_MAX_CEILING) != 0, ThisLink->height1, + (ThisLink->bits & SLUMP_LINK_TWIN) != 0, (ThisLink->bits & SLUMP_LINK_WINDOW) != 0, + (ThisLink->bits & SLUMP_LINK_RECESS) != 0, (ThisLink->bits & SLUMP_LINK_NEAR_DOOR) != 0, + (ThisLink->bits & SLUMP_LINK_FAR_DOOR) != 0, (ThisLink->bits & SLUMP_LINK_CORE) != 0, + (ThisLink->bits & SLUMP_LINK_ALCOVE) != 0, (ThisLink->bits & SLUMP_LINK_STEPS) != 0, + (ThisLink->bits & SLUMP_LINK_LIFT) != 0, (ThisLink->bits & SLUMP_LINK_MAX_CEILING) != 0, ThisLink->height1, ThisLink->width1, ThisLink->width2, ThisLink->depth1, ThisLink->depth2, ThisLink->depth3, ThisLink->floordelta, ThisLink->stepcount); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } /* Push a new (defaulty) quest onto the given stack */ @@ -3004,7 +3010,7 @@ quest *push_quest(quest *old) answer = (quest *)malloc(sizeof(*answer)); - answer->goal = NULL_GOAL; + answer->goal = SLUMP_NULL_GOAL; answer->tag = 0; answer->type = 0; answer->count = 0; @@ -3151,12 +3157,12 @@ boolean empty_rectangle(level *l, int x1, int y1, int x2, int y2, int x3, int y3 /* Given a linedef and a point, return the distance from the */ /* linedef to the point, positive if the point is on the right */ -/* side, negative if to the left. May return HUGE_NUMBER if */ +/* side, negative if to the left. May return SLUMP_HUGE_NUMBER if */ /* the point is not in either axis-shadow of the linedef, and */ /* may assume that the linedef is basically axis-parallel. */ int point_from_linedef(level *l, int x, int y, linedef *ld) { - int answer = HUGE_NUMBER; + int answer = SLUMP_HUGE_NUMBER; int candidate; int parity = 1; @@ -3263,15 +3269,15 @@ boolean no_monsters_stuck_on(level *l, linedef *ld) for (m = l->thing_anchor; m; m = m->next) { - if (!(m->pgenus->bits & MONSTER)) + if (!(m->pgenus->bits & SLUMP_MONSTER)) continue; /* Only monsters */ - if (m->pgenus->bits & FLIES) + if (m->pgenus->bits & SLUMP_FLIES) continue; /* Fliers can escape */ dist = abs(point_from_linedef(l, m->x, m->y, ld)); - if (dist <= (MONSTER_WIDTH(m) / 2)) + if (dist <= (SLUMP_MONSTER_WIDTH(m) / 2)) { -#ifdef ALLOW_STUCK_MONSTERS_IN_BATHS - announce(LOG, "Bath Bug!"); +#ifdef SLUMP_ALLOW_STUCK_MONSTERS_IN_BATHS + announce(SLUMP_LOG, "Bath Bug!"); return SLUMP_TRUE; #endif return SLUMP_FALSE; @@ -3294,12 +3300,12 @@ sector *point_sector(level *l, int x, int y, int *dist, boolean *danger) if (danger != NULL) *danger = SLUMP_FALSE; - closest = HUGE_NUMBER; + closest = SLUMP_HUGE_NUMBER; for (ld = l->linedef_anchor; ld; ld = ld->next) { thisdist = point_from_linedef(l, x, y, ld); if (abs(thisdist) < 49) - if (ld->type != LINEDEF_NORMAL) + if (ld->type != SLUMP_LINEDEF_NORMAL) if (danger != NULL) *danger = SLUMP_TRUE; if (abs(thisdist) < closest) @@ -3562,11 +3568,11 @@ void basic_background3(uint8_t *fbuf, byte bottom, int range) /* Should there be a secret level after the current level? */ boolean need_secret_level(config *c) { - if (c->gamemask & (CHEX_BIT | HACX_BIT | HARMONY_BIT | STRIFE_BIT)) + if (c->gamemask & (SLUMP_CHEX_BIT | SLUMP_HACX_BIT | SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT)) return SLUMP_FALSE; if (c->do_seclevels == SLUMP_FALSE) return SLUMP_FALSE; - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { switch (c->episode) { @@ -3614,25 +3620,25 @@ boolean link_fitsq(link *ThisLink, quest *ThisQuest) if (ThisQuest == NULL) return SLUMP_TRUE; /* Nothing to fit */ - if (ThisQuest->goal == GATE_GOAL) + if (ThisQuest->goal == SLUMP_GATE_GOAL) { - if (ThisLink->type == OPEN_LINK) + if (ThisLink->type == SLUMP_OPEN_LINK) return SLUMP_TRUE; /* Easy */ return SLUMP_FALSE; /* else punt */ } /* Keys and switches require doors */ - if ((ThisQuest->goal == KEY_GOAL) || (ThisQuest->goal == SWITCH_GOAL)) + if ((ThisQuest->goal == SLUMP_KEY_GOAL) || (ThisQuest->goal == SLUMP_SWITCH_GOAL)) { - if (!(ThisLink->bits & LINK_NEAR_DOOR)) + if (!(ThisLink->bits & SLUMP_LINK_NEAR_DOOR)) return SLUMP_FALSE; - if (!(ThisLink->type == BASIC_LINK)) + if (!(ThisLink->type == SLUMP_BASIC_LINK)) return SLUMP_FALSE; } /* Actually because of nukage locks, SWITCH_GOALs don't require */ /* doors. Do something about that here. */ - /* For that matter, there are kinds of OPEN_LINK and GATE_LINK */ - /* that can fit a SWITCH_GOAL, also. So fix that, too. */ + /* For that matter, there are kinds of SLUMP_OPEN_LINK and SLUMP_GATE_LINK */ + /* that can fit a SLUMP_SWITCH_GOAL, also. So fix that, too. */ return SLUMP_TRUE; } @@ -3641,25 +3647,25 @@ boolean link_fitsh(linedef *ldf, link *ThisLink, config *c) { int available, required; - available = linelen(ldf); + available = SLUMP_linelen(ldf); required = ThisLink->width1; switch (ThisLink->type) { - case BASIC_LINK: + case SLUMP_BASIC_LINK: if (required == 0) required = 64; /* Minimum to pass, eh? */ - if ((ThisLink->bits) & LINK_TWIN) + if ((ThisLink->bits) & SLUMP_LINK_TWIN) available = (available / 2) - 16; - if ((ThisLink->bits) & LINK_ALCOVE) + if ((ThisLink->bits) & SLUMP_LINK_ALCOVE) required = required * 2 + ThisLink->depth3; break; - case OPEN_LINK: + case SLUMP_OPEN_LINK: if (required == 0) required = 33; required += 66; break; - case GATE_LINK: + case SLUMP_GATE_LINK: /* No gate-links outgoing from a gate room, eh? */ if (ldf->right->psector->pgate) { @@ -3667,7 +3673,7 @@ boolean link_fitsh(linedef *ldf, link *ThisLink, config *c) } return SLUMP_TRUE; default: - announce(WARNING, "Funny type in link_fitsh"); + announce(SLUMP_WARNING, "Funny type in link_fitsh"); return SLUMP_FALSE; } @@ -3688,7 +3694,7 @@ void barify(level *l, linedef *ldf1, linedef *ldf2, quest *ThisQuest, int barwid texture *t1; short type1; - if (linelen(ldf1) <= 32) + if (SLUMP_linelen(ldf1) <= 32) return; /* Already impassable */ /* Get a handle on the sectors involved */ oldsector = ldf1->left->psector; @@ -3697,9 +3703,9 @@ void barify(level *l, linedef *ldf1, linedef *ldf2, quest *ThisQuest, int barwid newsector = clone_sector(l, oldsector); newsector->ceiling_height = newsector->floor_height; /* close it! */ if (ThisQuest) - if (ThisQuest->goal == SWITCH_GOAL) + if (ThisQuest->goal == SLUMP_SWITCH_GOAL) newsector->tag = ThisQuest->tag; - announce(VERBOSE, "Multiple"); + announce(SLUMP_VERBOSE, "Multiple"); } /* Then recurse to get the side bars, if needed */ ld1a = centerpart(l, ldf1, &ld1b, barwidth, ThisStyle, c); @@ -3711,30 +3717,30 @@ void barify(level *l, linedef *ldf1, linedef *ldf2, quest *ThisQuest, int barwid ldedge2 = new_linedef(l, ld1a->to, ld2a->from); /* Fix up existing sidedefs */ ld1a->left->psector = newsector; - ld1a->flags &= ~UPPER_UNPEGGED; + ld1a->flags &= ~SLUMP_UPPER_UNPEGGED; ld1a->right->x_offset = 0; ld2a->left->psector = newsector; - ld2a->flags &= ~UPPER_UNPEGGED; + ld2a->flags &= ~SLUMP_UPPER_UNPEGGED; ld2a->right->x_offset = 0; /* And make some new ones */ ldedge1->left = new_sidedef(l, newsector, c); ldedge1->right = new_sidedef(l, oldsector, c); - ldedge1->flags |= TWO_SIDED; + ldedge1->flags |= SLUMP_TWO_SIDED; ldedge2->left = new_sidedef(l, newsector, c); ldedge2->right = new_sidedef(l, oldsector, c); - ldedge2->flags |= TWO_SIDED; + ldedge2->flags |= SLUMP_TWO_SIDED; /* Decide on a texture for the bar faces */ t1 = ThisStyle->support0; /* Or wall0? */ if (ThisQuest) - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) t1 = texture_for_key(ThisQuest->type, ThisStyle, c); /* and the opening linedef type */ type1 = ThisStyle->doortype; if (ThisQuest) - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) type1 = type_for_key(ThisQuest->type); - else if (ThisQuest->goal == SWITCH_GOAL) - type1 = (c->do_dm) ? LINEDEF_NORMAL_S1_DOOR : LINEDEF_NORMAL; + else if (ThisQuest->goal == SLUMP_SWITCH_GOAL) + type1 = (c->do_dm) ? SLUMP_LINEDEF_NORMAL_S1_DOOR : SLUMP_LINEDEF_NORMAL; /* Now fill in all the textures and stuff */ ld1a->type = type1; ld2a->type = type1; @@ -3762,7 +3768,7 @@ boolean slitify(level *l, linedef *ldf1, linedef *ldf2, int slitwidth, sector *n linedef *ld1a, *ld2a, *ldedge1, *ldedge2; sector *nearsector, *farsector; short newch, newch2, newfh, newfh2; - int len = linelen(ldf1); + int len = SLUMP_linelen(ldf1); /* Get a handle on the sectors involved */ nearsector = ldf1->right->psector; @@ -3816,9 +3822,9 @@ boolean slitify(level *l, linedef *ldf1, linedef *ldf2, int slitwidth, sector *n ldedge2 = new_linedef(l, ld1a->from, ld2a->to); /* Fix up existing sidedefs */ ld1a->right->middle_texture = c->null_texture; /* Or grating? */ - ld1a->flags |= TWO_SIDED; + ld1a->flags |= SLUMP_TWO_SIDED; ld2a->right->middle_texture = c->null_texture; /* Or grating? */ - ld2a->flags |= TWO_SIDED; + ld2a->flags |= SLUMP_TWO_SIDED; /* and make new ones */ ldedge1->right = new_sidedef(l, newsector, c); ldedge1->right->middle_texture = ldf1->right->middle_texture; @@ -3833,7 +3839,7 @@ boolean slitify(level *l, linedef *ldf1, linedef *ldf2, int slitwidth, sector *n ld2a->left->middle_texture = c->null_texture; patch_upper(ld2a, ldf2->right->psector->pstyle->wall0, c); patch_lower(ld2a, ldf2->right->psector->pstyle->support0, c); - announce(VERBOSE, "Slit"); + announce(SLUMP_VERBOSE, "Slit"); } return SLUMP_TRUE; @@ -3853,12 +3859,12 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld sector *s, *nearsec; int len, stepdepth, i; int minstepcount, maxstepcount, stepcount, stepheight; - boolean need_lock = (ThisQuest != NULL) && (ThisQuest->goal == SWITCH_GOAL); + boolean need_lock = (ThisQuest != NULL) && (ThisQuest->goal == SLUMP_SWITCH_GOAL); texture *front = ThisStyle->kickplate; boolean do_edges = SLUMP_FALSE; nearsec = ldf1->right->psector; - len = linelen(lde1); + len = SLUMP_linelen(lde1); /* Need at least enough steps to get up, 24 at a time */ minstepcount = (farheight - nearheight) / 24; @@ -3880,7 +3886,7 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld announce(SLUMP_ERROR, "Step too high to climb!"); if (need_lock) { - announce(LOG, "Locked stairs"); + announce(SLUMP_LOG, "Locked stairs"); stepheight = 8; stepcount = (farheight - nearheight) / stepheight; stepdepth = len / stepcount; @@ -3890,9 +3896,9 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld char s[100]; sprintf(s, "%d steps from [%d-%d], each %d deep and %d high.\n", stepcount, minstepcount, maxstepcount, stepdepth, stepheight); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); sprintf(s, "Total: %d deep, %d high.\n", len, farheight - nearheight); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } if (ThisStyle->stepfront) @@ -3905,20 +3911,20 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld { front = ThisStyle->walllight; } - else if (ThisStyle->light_edges && (linelen(ldf1) >= (64 * l->hugeness)) && (stepheight > 7)) + else if (ThisStyle->light_edges && (SLUMP_linelen(ldf1) >= (64 * l->hugeness)) && (stepheight > 7)) { do_edges = SLUMP_TRUE; - announce(VERBOSE, "Step-edge lights"); + announce(SLUMP_VERBOSE, "Step-edge lights"); } } if (need_lock) { - ThisQuest->type = LINEDEF_S1_RAISE_STAIRS; + ThisQuest->type = SLUMP_LINEDEF_S1_RAISE_STAIRS; } ldf1->right->lower_texture = front; - ldf1->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; for (i = 0; i < (stepcount - 1); i++) { /* Minus one, since one's already made */ @@ -3936,7 +3942,7 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld ldf1->left->psector = s; if (do_edges) { - ldl = split_linedef(l, ldf1, linelen(ldf1) - 16 * l->hugeness, c); + ldl = split_linedef(l, ldf1, SLUMP_linelen(ldf1) - 16 * l->hugeness, c); ldl->right->lower_texture = ThisStyle->walllight; split_linedef(l, ldf1, 16 * l->hugeness, c); ldf1->right->lower_texture = ThisStyle->walllight; @@ -3946,11 +3952,11 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld ldf1 = new_linedef(l, ldn1->from, ldn2->to); ldf1->right = new_sidedef(l, s, c); ldf1->right->lower_texture = front; - ldf1->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; ldf1->right->middle_texture = c->null_texture; ldf1->left = new_sidedef(l, s, c); /* s is wrong; fixed above/below */ ldf1->left->middle_texture = c->null_texture; - ldf1->flags |= TWO_SIDED; + ldf1->flags |= SLUMP_TWO_SIDED; if (need_lock) s->floor_height = nearsec->floor_height; if (!need_lock) @@ -3962,10 +3968,10 @@ void stairify(level *l, linedef *ldf1, linedef *ldf2, linedef *lde1, linedef *ld } ldf1->left->psector = ldf2->left->psector; patch_lower(ldf1, front, c); - ldf1->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; if (do_edges) { - ldl = split_linedef(l, ldf1, linelen(ldf1) - 16 * l->hugeness, c); + ldl = split_linedef(l, ldf1, SLUMP_linelen(ldf1) - 16 * l->hugeness, c); ldl->right->lower_texture = ThisStyle->walllight; split_linedef(l, ldf1, 16 * l->hugeness, c); ldf1->right->lower_texture = ThisStyle->walllight; @@ -3997,10 +4003,10 @@ void doorify(sector *s, linedef *ldf1, linedef *ldf2, style *ThisStyle, style *N ldf1->right->upper_texture = ThisStyle->twdoorface; else ldf1->right->upper_texture = ThisStyle->widedoorface; - if (lensq < (128 * 128)) /* "128" is wrong */ - ldf1->right->x_offset = (128 - linelen(ldf1)) / 2; /* All of these */ + if (lensq < (128 * 128)) /* "128" is wrong */ + ldf1->right->x_offset = (128 - SLUMP_linelen(ldf1)) / 2; /* All of these */ else - ldf1->right->x_offset = 128 - (linelen(ldf1) % 128) / 2; + ldf1->right->x_offset = 128 - (SLUMP_linelen(ldf1) % 128) / 2; /* Avoid TFE! */ if (ldf1->right->upper_texture->height < 128) if (ldf1->right->psector->ceiling_height - ldf1->right->psector->floor_height > @@ -4013,10 +4019,10 @@ void doorify(sector *s, linedef *ldf1, linedef *ldf2, style *ThisStyle, style *N ldf1->right->upper_texture = ThisStyle->tndoorface; else ldf1->right->upper_texture = ThisStyle->narrowdoorface; - if (lensq < (64 * 64)) /* Also "64" */ - ldf1->right->x_offset = (64 - linelen(ldf1)) / 2; /* All of these */ + if (lensq < (64 * 64)) /* Also "64" */ + ldf1->right->x_offset = (64 - SLUMP_linelen(ldf1)) / 2; /* All of these */ else - ldf1->right->x_offset = 64 - (linelen(ldf1) % 64) / 2; + ldf1->right->x_offset = 64 - (SLUMP_linelen(ldf1) % 64) / 2; /* Avoid TFE! */ if (ldf1->right->upper_texture->height < 128) if (ldf1->right->psector->ceiling_height - ldf1->right->psector->floor_height > @@ -4033,9 +4039,9 @@ void doorify(sector *s, linedef *ldf1, linedef *ldf2, style *ThisStyle, style *N else ldf2->right->upper_texture = NewStyle->widedoorface; if (lensq < (128 * 128)) - ldf2->right->x_offset = (128 - linelen(ldf2)) / 2; + ldf2->right->x_offset = (128 - SLUMP_linelen(ldf2)) / 2; else - ldf2->right->x_offset = 128 - (linelen(ldf2) % 128) / 2; + ldf2->right->x_offset = 128 - (SLUMP_linelen(ldf2) % 128) / 2; /* Avoid TFE! */ if (ldf2->right->upper_texture->height < 128) if (ldf2->right->psector->ceiling_height - ldf2->right->psector->floor_height > @@ -4049,30 +4055,30 @@ void doorify(sector *s, linedef *ldf1, linedef *ldf2, style *ThisStyle, style *N else ldf2->right->upper_texture = NewStyle->narrowdoorface; if (lensq < (64 * 64)) - ldf2->right->x_offset = (64 - linelen(ldf2)) / 2; + ldf2->right->x_offset = (64 - SLUMP_linelen(ldf2)) / 2; else - ldf2->right->x_offset = 64 - (linelen(ldf2) % 64) / 2; + ldf2->right->x_offset = 64 - (SLUMP_linelen(ldf2) % 64) / 2; /* Avoid TFE! */ if (ldf2->right->upper_texture->height < 128) if (ldf2->right->psector->ceiling_height - ldf2->right->psector->floor_height > ldf2->right->upper_texture->height) ldf2->right->upper_texture = NewStyle->tndoorface; } -#ifdef SOMETIMES_UNPEG_DOORFACES +#ifdef SLUMP_SOMETIMES_UNPEG_DOORFACES if (!ThisStyle->secret_doors) /* Doors secret-flavor? */ #endif { - ldf1->flags &= ~UPPER_UNPEGGED; - ldf2->flags &= ~UPPER_UNPEGGED; + ldf1->flags &= ~SLUMP_UPPER_UNPEGGED; + ldf2->flags &= ~SLUMP_UPPER_UNPEGGED; } if (ThisStyle->soundproof_doors) { - ldf1->flags |= BLOCK_SOUND; - ldf2->flags |= BLOCK_SOUND; + ldf1->flags |= SLUMP_BLOCK_SOUND; + ldf2->flags |= SLUMP_BLOCK_SOUND; } /* And in any case avoid stoop silliness */ - ldf1->flags &= ~LOWER_UNPEGGED; - ldf2->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; + ldf2->flags &= ~SLUMP_LOWER_UNPEGGED; } /* end doorify */ @@ -4085,7 +4091,7 @@ boolean make_window_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink texture *t1, *t2; int len; - announce(VERBOSE, "Making a window"); + announce(SLUMP_VERBOSE, "Making a window"); nearsec = ldf1->right->psector; farsec = ldf2->right->psector; @@ -4105,10 +4111,10 @@ boolean make_window_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink /* Put a little border on it. Very simple version for now. */ ldf1 = split_linedef(l, ldf1, ThisStyle->windowborder, c); - len = linelen(ldf1); + len = SLUMP_linelen(ldf1); split_linedef(l, ldf1, len - ThisStyle->windowborder, c); ldf2 = split_linedef(l, ldf2, ThisStyle->windowborder, c); - len = linelen(ldf2); + len = SLUMP_linelen(ldf2); split_linedef(l, ldf2, len - ThisStyle->windowborder, c); flip_linedef(ldf2); /* parallelize, for make_box */ @@ -4123,21 +4129,21 @@ boolean make_window_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink /* Various possibilities for window decor */ switch (ThisStyle->window_decor) { - case WINDOW_JAMBS: + case SLUMP_WINDOW_JAMBS: ldnew1->right->middle_texture = ThisStyle->doorjamb; ldnew2->right->middle_texture = ThisStyle->doorjamb; break; - case WINDOW_SUPPORT: + case SLUMP_WINDOW_SUPPORT: ldnew1->right->middle_texture = ThisStyle->support0; ldnew2->right->middle_texture = ThisStyle->support0; break; - case WINDOW_LIGHT: + case SLUMP_WINDOW_LIGHT: make_lighted(l, newsec, c); if (ThisStyle->walllight) { ldnew1->right->middle_texture = ThisStyle->walllight; ldnew2->right->middle_texture = ThisStyle->walllight; - announce(VERBOSE, "Lit window"); + announce(SLUMP_VERBOSE, "Lit window"); } else { @@ -4153,22 +4159,22 @@ boolean make_window_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink { ldf1->right->middle_texture = ThisStyle->grating; /* Unpeg, to keep the texture from floating away, eh? */ - ldf1->flags |= LOWER_UNPEGGED; - ldf1->flags |= TWO_SIDED | IMPASSIBLE; -#ifdef OLD_FUNNY_WINDOWGRATES + ldf1->flags |= SLUMP_LOWER_UNPEGGED; + ldf1->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; +#ifdef SLUMP_OLD_FUNNY_WINDOWGRATES ldf2->right->middle_texture = NewStyle->grating; - ldf2->flags |= LOWER_UNPEGGED; - ldf2->flags |= TWO_SIDED | IMPASSIBLE; + ldf2->flags |= SLUMP_LOWER_UNPEGGED; + ldf2->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; #else ldf1->left->middle_texture = ThisStyle->grating; - ldf2->flags |= TWO_SIDED; + ldf2->flags |= SLUMP_TWO_SIDED; #endif - announce(VERBOSE, "Window grate"); + announce(SLUMP_VERBOSE, "Window grate"); } else { - ldf1->flags |= TWO_SIDED | IMPASSIBLE; - ldf2->flags |= TWO_SIDED | IMPASSIBLE; + ldf1->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; + ldf2->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; } ldf1->left->y_offset = ldf1->right->y_offset = ldf2->left->y_offset = ldf2->right->y_offset = 0; @@ -4224,10 +4230,10 @@ boolean make_window(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, styl if (farsec->ceiling_height > newch) newch = farsec->ceiling_height; newch += 16 + 8 * roll(10); - newsec = new_sector(l, newfh, newch, random_flat0(OUTDOOR, c, NULL), nearsec->ceiling_flat); - newsec->pstyle = copy_style(l, nearsec->pstyle, nearsec->pstyle->theme_number, 0, c); + newsec = new_sector(l, newfh, newch, random_flat0(SLUMP_OUTDOOR, c, NULL), nearsec->ceiling_flat); + newsec->pstyle = copy_style(l, nearsec->pstyle, nearsec->pstyle->theme_number, 0, c); newsec->pstyle->roomlight0 = l->outside_light_level; - /* Do we want to make the walls OUTDOOR here? */ + /* Do we want to make the walls SLUMP_OUTDOOR here? */ ld1n->right = new_sidedef(l, newsec, c); ld2n->right = new_sidedef(l, newsec, c); lde1->right = new_sidedef(l, newsec, c); @@ -4241,10 +4247,10 @@ boolean make_window(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, styl if (rollpercent(l->p_force_nukage)) { newsec->floor_flat = newsec->pstyle->nukage1; - newsec->special = NUKAGE1_SPECIAL; + newsec->special = SLUMP_NUKAGE1_SPECIAL; } if (rc1 || rc2) - announce(LOG, "Window airshaft"); + announce(SLUMP_LOG, "Window airshaft"); return rc1 || rc2; } else @@ -4269,10 +4275,10 @@ boolean make_decroom(level *l, linedef *ldf1, linedef *ldf2, config *c) /* Put a little border on it. Very simple version for now. */ /* Don't really need at all if recesses etc, eh? */ ldf1 = split_linedef(l, ldf1, ThisStyle->windowborder, c); - len = linelen(ldf1); + len = SLUMP_linelen(ldf1); split_linedef(l, ldf1, len - ThisStyle->windowborder, c); ldf2 = split_linedef(l, ldf2, ThisStyle->windowborder, c); - len = linelen(ldf2); + len = SLUMP_linelen(ldf2); split_linedef(l, ldf2, len - ThisStyle->windowborder, c); flip_linedef(ldf2); /* parallelize, for make_box */ @@ -4286,12 +4292,12 @@ boolean make_decroom(level *l, linedef *ldf1, linedef *ldf2, config *c) if (rollpercent(10) || rollpercent(l->p_force_nukage)) { newsec->floor_flat = ThisStyle->nukage1; - newsec->special = NUKAGE1_SPECIAL; /* Not that you can get in there! */ - announce(LOG, "Intertwin nukage"); + newsec->special = SLUMP_NUKAGE1_SPECIAL; /* Not that you can get in there! */ + announce(SLUMP_LOG, "Intertwin nukage"); } else { - newsec->floor_flat = random_flat0(OUTDOOR, c, NULL); + newsec->floor_flat = random_flat0(SLUMP_OUTDOOR, c, NULL); } newsec->pstyle = ThisStyle; @@ -4301,11 +4307,11 @@ boolean make_decroom(level *l, linedef *ldf1, linedef *ldf2, config *c) ldf2->right->middle_texture = ThisStyle->grating; ldf2->left->middle_texture = ThisStyle->grating; /* Unpeg, to keep the texture from floating away, eh? */ - ldf1->flags |= LOWER_UNPEGGED; - ldf2->flags |= LOWER_UNPEGGED; + ldf1->flags |= SLUMP_LOWER_UNPEGGED; + ldf2->flags |= SLUMP_LOWER_UNPEGGED; - ldf1->flags |= TWO_SIDED | IMPASSIBLE; - ldf2->flags |= TWO_SIDED | IMPASSIBLE; + ldf1->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; + ldf2->flags |= SLUMP_TWO_SIDED | SLUMP_IMPASSIBLE; ldf1->left->y_offset = ldf1->right->y_offset = ldf2->left->y_offset = ldf2->right->y_offset = 0; patch_upper(ldf1, t1, c); @@ -4313,7 +4319,7 @@ boolean make_decroom(level *l, linedef *ldf1, linedef *ldf2, config *c) patch_lower(ldf1, t1, c); patch_lower(ldf2, t1, c); - len = linelen(ldnew1); + len = SLUMP_linelen(ldnew1); if (len > 31) { /* Inset a bit */ linedef *lt1, *lt2; @@ -4367,20 +4373,20 @@ texture *texture_for_key(short key, style *s, config *c) { switch (key) { - case ID_BLUEKEY: - case ID_BLUECARD: - case ID_HERETICBLUEKEY: + case SLUMP_ID_BLUEKEY: + case SLUMP_ID_BLUECARD: + case SLUMP_ID_HERETICBLUEKEY: return s->blueface; - case ID_REDKEY: - case ID_REDCARD: - case ID_HERETICGREENKEY: + case SLUMP_ID_REDKEY: + case SLUMP_ID_REDCARD: + case SLUMP_ID_HERETICGREENKEY: return s->redface; - case ID_YELLOWKEY: - case ID_YELLOWCARD: - case ID_HERETICYELLOWKEY: + case SLUMP_ID_YELLOWKEY: + case SLUMP_ID_YELLOWCARD: + case SLUMP_ID_HERETICYELLOWKEY: return s->yellowface; } - announce(WARNING, "Unknown key in texture_for_key()"); + announce(SLUMP_WARNING, "Unknown key in texture_for_key()"); return c->error_texture; } @@ -4390,16 +4396,16 @@ texture *texture_for_bits(propertybits pb, style *s, config *c) switch (pb) { - case BLUE: + case SLUMP_BLUE: answer = s->blueface; break; - case RED: + case SLUMP_RED: answer = s->redface; break; - case YELLOW: + case SLUMP_YELLOW: answer = s->yellowface; break; - case LIGHT: + case SLUMP_LIGHT: answer = s->walllight; break; } @@ -4412,21 +4418,21 @@ short type_for_key(short key) { switch (key) { - case ID_BLUEKEY: - case ID_BLUECARD: - case ID_HERETICBLUEKEY: - return LINEDEF_BLUE_S1_DOOR; - case ID_REDKEY: - case ID_REDCARD: - case ID_HERETICGREENKEY: - return LINEDEF_RED_S1_DOOR; - case ID_YELLOWKEY: - case ID_YELLOWCARD: - case ID_HERETICYELLOWKEY: - return LINEDEF_YELLOW_S1_DOOR; + case SLUMP_ID_BLUEKEY: + case SLUMP_ID_BLUECARD: + case SLUMP_ID_HERETICBLUEKEY: + return SLUMP_LINEDEF_BLUE_S1_DOOR; + case SLUMP_ID_REDKEY: + case SLUMP_ID_REDCARD: + case SLUMP_ID_HERETICGREENKEY: + return SLUMP_LINEDEF_RED_S1_DOOR; + case SLUMP_ID_YELLOWKEY: + case SLUMP_ID_YELLOWCARD: + case SLUMP_ID_HERETICYELLOWKEY: + return SLUMP_LINEDEF_YELLOW_S1_DOOR; } - announce(WARNING, "Unknown key in type_for_key()"); - return LINEDEF_NORMAL_S1_DOOR; + announce(SLUMP_WARNING, "Unknown key in type_for_key()"); + return SLUMP_LINEDEF_NORMAL_S1_DOOR; } /* Mark the given door of the given level to look like it's locked */ @@ -4438,7 +4444,7 @@ void mark_door_for_key(level *l, linedef *ldf1, short key, style *ThisStyle, con if (ThisStyle->gaudy_locks) { - announce(VERBOSE, "Gaudy door"); + announce(SLUMP_VERBOSE, "Gaudy door"); ldf1->right->upper_texture = texture_for_key(key, ThisStyle, c); } else @@ -4446,7 +4452,7 @@ void mark_door_for_key(level *l, linedef *ldf1, short key, style *ThisStyle, con t1 = texture_for_key(key, ThisStyle, c); ldf2 = split_linedef(l, ldf1, 16, c); /* '16' is wrong, but not bad */ ldf1->right->upper_texture = t1; - ldf2 = split_linedef(l, ldf2, linelen(ldf2) - 16, c); + ldf2 = split_linedef(l, ldf2, SLUMP_linelen(ldf2) - 16, c); ldf2->right->upper_texture = t1; } } @@ -4460,7 +4466,7 @@ void mark_door_for_lock(level *l, linedef *ldf1, style *ThisStyle, config *c) (ldf1->right->psector->ceiling_height - ldf1->right->psector->floor_height)) return; ldf1->right->upper_texture = ThisStyle->lockdoorface; - announce(VERBOSE, "Specially marked door"); + announce(SLUMP_VERBOSE, "Specially marked door"); } /* Given a linedef type, return the equivalent linedef type, */ @@ -4469,20 +4475,20 @@ short locked_linedef_for(short type, short key, config *c) { switch (type) { - case LINEDEF_S1_OPEN_DOOR: - if ((DOOM0_BIT | HERETIC_BIT) & c->gamemask) + case SLUMP_LINEDEF_S1_OPEN_DOOR: + if ((SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT) & c->gamemask) return 0; /* Not in ancient DooMs (or Heretic) */ switch (key) { - case ID_BLUEKEY: - case ID_BLUECARD: - return LINEDEF_S1_OPEN_DOOR_BLUE; - case ID_REDKEY: - case ID_REDCARD: - return LINEDEF_S1_OPEN_DOOR_RED; - case ID_YELLOWKEY: - case ID_YELLOWCARD: - return LINEDEF_S1_OPEN_DOOR_YELLOW; + case SLUMP_ID_BLUEKEY: + case SLUMP_ID_BLUECARD: + return SLUMP_LINEDEF_S1_OPEN_DOOR_BLUE; + case SLUMP_ID_REDKEY: + case SLUMP_ID_REDCARD: + return SLUMP_LINEDEF_S1_OPEN_DOOR_RED; + case SLUMP_ID_YELLOWKEY: + case SLUMP_ID_YELLOWCARD: + return SLUMP_LINEDEF_S1_OPEN_DOOR_YELLOW; default: announce(SLUMP_ERROR, "Unknown key in l_l_f"); return 0; @@ -4500,7 +4506,7 @@ void make_lighted(level *l, sector *s, config *c) if (s->light_level < l->lit_light_level) s->light_level = l->lit_light_level; if (rollpercent(10)) - s->special = RANDOM_BLINK; + s->special = SLUMP_RANDOM_BLINK; } /* Make a nice box with a thing to the left of the linedef */ @@ -4511,15 +4517,15 @@ linedef *lightbox(level *l, linedef *ld, genus *g, style *ThisStyle, config *c) int x, y; sector *oldsec, *newsec; - len = linelen(ld); + len = SLUMP_linelen(ld); if (len < 48) return NULL; /* All these "48"s should vary, eh? */ /* Hugeness? */ if (!empty_left_side(l, ld, 48)) return NULL; - announce(VERBOSE, "lightbox"); + announce(SLUMP_VERBOSE, "lightbox"); if (len > 48) ld = centerpart(l, ld, NULL, 48, ThisStyle, c); - ldb = lefthand_box(l, ld, 48, ThisStyle, c); /* This one too */ + ldb = SLUMP_lefthand_box(l, ld, 48, ThisStyle, c); /* This one too */ ldb->right->middle_texture = ThisStyle->wall0; oldsec = ld->right->psector; newsec = ldb->right->psector; @@ -4528,13 +4534,13 @@ linedef *lightbox(level *l, linedef *ld, genus *g, style *ThisStyle, config *c) if (newsec->ceiling_height - newsec->floor_height < 64) newsec->floor_height = newsec->ceiling_height - 64; patch_lower(ld, ThisStyle->wall0, c); - point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, LEFT_TURN, 24, &x, &y); - point_from(ld->to->x, ld->to->y, x, y, LEFT_TURN, 24, &x, &y); + point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, SLUMP_LEFT_TURN, 24, &x, &y); + point_from(ld->to->x, ld->to->y, x, y, SLUMP_LEFT_TURN, 24, &x, &y); if (g->height > (newsec->ceiling_height - newsec->floor_height)) g = ThisStyle->shortlamp0; new_thing(l, x, y, 0, g->thingid, 7, c); - if (g->bits & EXPLODES) - announce(VERBOSE, "Barrelbox"); + if (g->bits & SLUMP_EXPLODES) + announce(SLUMP_VERBOSE, "Barrelbox"); return ld; } @@ -4546,14 +4552,14 @@ void lightbar(level *l, linedef *ld, propertybits pb, style *ThisStyle, config * linedef *ldb, *lde1, *lde2; sector *oldsec, *newsec; - len = linelen(ld); + len = SLUMP_linelen(ld); if (len < 16) return; wid = 12 + roll(len - 17); dep = 8 + 4 * roll(5); if (!empty_left_side(l, ld, dep)) return; - announce(VERBOSE, "lightbar"); + announce(SLUMP_VERBOSE, "lightbar"); if (len > wid) ld = centerpart(l, ld, NULL, wid, ThisStyle, c); ldb = lefthand_box_ext(l, ld, dep, ThisStyle, c, &lde1, &lde2); @@ -4562,8 +4568,8 @@ void lightbar(level *l, linedef *ld, propertybits pb, style *ThisStyle, config * { texture *t = lde1->right->middle_texture; if (t != ThisStyle->wall0) - if (!(t->props & LIGHT)) - announce(LOG, "Colorbar"); + if (!(t->props & SLUMP_LIGHT)) + announce(SLUMP_LOG, "Colorbar"); } oldsec = ld->right->psector; newsec = ldb->right->psector; @@ -4581,7 +4587,7 @@ linedef *centerpart(level *l, linedef *ld, linedef **ld2, int width, style *This int len, border; linedef *answer, *answer2; - len = linelen(ld); + len = SLUMP_linelen(ld); border = (len - width) / 2; border += (len - (width + 2 * border)); /* Fix roundoff errors */ if (border <= 0) @@ -4623,7 +4629,7 @@ linedef *borderize(level *l, linedef *ld, int width, boolean fancy, style *ThisS if (ld != ld2) if (fancy) if (ThisStyle->lightboxes) - if ((linelen(ld) >= 64)) + if ((SLUMP_linelen(ld) >= 64)) { short box_light_level = nearsec->light_level; short box_special = 0; @@ -4635,15 +4641,15 @@ linedef *borderize(level *l, linedef *ld, int width, boolean fancy, style *ThisS if (g == NULL) g = ThisStyle->lamp0; } - if (g->bits & LIGHT) + if (g->bits & SLUMP_LIGHT) { - if (ThisStyle->lightbox_lighting == LIGHTBOX_LIGHTED) + if (ThisStyle->lightbox_lighting == SLUMP_LIGHTBOX_LIGHTED) if (box_light_level < l->lit_light_level) box_light_level = l->lit_light_level; - if (ThisStyle->lightbox_lighting == LIGHTBOX_DARK) + if (ThisStyle->lightbox_lighting == SLUMP_LIGHTBOX_DARK) box_light_level = c->minlight; if (rollpercent(20)) - box_special = RANDOM_BLINK; /* 20? */ + box_special = SLUMP_RANDOM_BLINK; /* 20? */ } ldt = lightbox(l, ld, g, ThisStyle, c); /* Maybe do the cool keybox thing! */ @@ -4654,13 +4660,13 @@ linedef *borderize(level *l, linedef *ld, int width, boolean fancy, style *ThisS lsec->ceiling_height = lsec->floor_height + 32; patch_upper(ldt, nearsec->pstyle->wall0, c); patch_lower(ldt, nearsec->pstyle->wall0, c); - ldt->flags |= IMPASSIBLE; - lsec->special = GLOW_BLINK; + ldt->flags |= SLUMP_IMPASSIBLE; + lsec->special = SLUMP_GLOW_BLINK; if (lsec->light_level < l->lit_light_level) lsec->light_level = l->lit_light_level; if (painted_door) *painted_door = SLUMP_TRUE; - announce(LOG, "Keybox"); + announce(SLUMP_LOG, "Keybox"); } else if (ldt) { @@ -4675,13 +4681,13 @@ linedef *borderize(level *l, linedef *ld, int width, boolean fancy, style *ThisS lsec->ceiling_height = lsec->floor_height + 32; patch_upper(ldt, nearsec->pstyle->wall0, c); patch_lower(ldt, nearsec->pstyle->wall0, c); - ldt->flags |= IMPASSIBLE; - lsec->special = GLOW_BLINK; + ldt->flags |= SLUMP_IMPASSIBLE; + lsec->special = SLUMP_GLOW_BLINK; if (lsec->light_level < l->lit_light_level) lsec->light_level = l->lit_light_level; if (painted_door) *painted_door = SLUMP_TRUE; - announce(LOG, "Keybox"); + announce(SLUMP_LOG, "Keybox"); } else if (ldt) { @@ -4689,9 +4695,9 @@ linedef *borderize(level *l, linedef *ld, int width, boolean fancy, style *ThisS ldt->left->psector->special = box_special; } -#ifdef LIGHTBAR_STUFF +#ifdef SLUMP_LIGHTBAR_STUFF } - else if (linelen(ld) > 16) + else if (SLUMP_linelen(ld) > 16) { /* These actually look very silly; don't use! */ lightbar(l, ld, pb, ThisStyle, c); @@ -4716,7 +4722,7 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) oldsec = ld1->right->psector; depth = l->hugeness * (1 + 16 * (4 + roll(6))); - len = linelen(ld1) - (16 * l->hugeness); + len = SLUMP_linelen(ld1) - (16 * l->hugeness); ld1 = split_linedef(l, ld1, 8 * l->hugeness, c); split_linedef(l, ld1, len, c); room1 = empty_left_side(l, ld1, depth); @@ -4733,13 +4739,13 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) downspec = 0; break; case 3: - downspec = RANDOM_BLINK; + downspec = SLUMP_RANDOM_BLINK; break; case 4: - downspec = SYNC_FAST_BLINK; + downspec = SLUMP_SYNC_FAST_BLINK; break; case 5: - downspec = SYNC_SLOW_BLINK; + downspec = SLUMP_SYNC_SLOW_BLINK; break; default: downspec = 0; @@ -4753,8 +4759,8 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) ldn1->left->middle_texture = c->null_texture; ldn1->right->middle_texture = c->null_texture; ldn1->right->lower_texture = ldn2->right->lower_texture = coresec->pstyle->support0; - ldn1->flags |= TWO_SIDED; - ldn2->flags |= TWO_SIDED; + ldn1->flags |= SLUMP_TWO_SIDED; + ldn2->flags |= SLUMP_TWO_SIDED; ld1->right->psector = coresec; ld2->right->psector = coresec; if (room1) @@ -4765,11 +4771,11 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) downsec1 = ld1->left->psector; ld1->right->middle_texture = c->null_texture; ld1->left->middle_texture = c->null_texture; - ld1->flags |= TWO_SIDED | SECRET_LINEDEF; + ld1->flags |= SLUMP_TWO_SIDED | SLUMP_SECRET_LINEDEF; ldn1->tag = coresec->tag; - ldn1->type = LINEDEF_SR_LOWER_LIFT; + ldn1->type = SLUMP_LINEDEF_SR_LOWER_LIFT; ldn2->tag = coresec->tag; - ldn2->type = LINEDEF_SR_LOWER_LIFT; + ldn2->type = SLUMP_LINEDEF_SR_LOWER_LIFT; ldfar->right->middle_texture = ldn1->right->middle_texture = ldn2->right->middle_texture = ld1->left->lower_texture = coresec->pstyle->support0; downsec1->floor_height = coresec->floor_height - 128; @@ -4785,11 +4791,11 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) downsec2 = ld2->left->psector; ld2->right->middle_texture = c->null_texture; ld2->left->middle_texture = c->null_texture; - ld2->flags |= TWO_SIDED | SECRET_LINEDEF; + ld2->flags |= SLUMP_TWO_SIDED | SLUMP_SECRET_LINEDEF; ldn1->tag = coresec->tag; - ldn1->type = LINEDEF_SR_LOWER_LIFT; + ldn1->type = SLUMP_LINEDEF_SR_LOWER_LIFT; ldn2->tag = coresec->tag; - ldn2->type = LINEDEF_SR_LOWER_LIFT; + ldn2->type = SLUMP_LINEDEF_SR_LOWER_LIFT; ldfar->right->middle_texture = ldn1->right->middle_texture = ldn2->right->middle_texture = ld2->left->lower_texture = coresec->pstyle->support0; downsec2->floor_height = coresec->floor_height - 128; @@ -4813,14 +4819,14 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) ldn1 = new_linedef(l, ld1->to, ld2->to); ldn1->left = ldn1->right = new_sidedef(l, coresec, c); ldn1->left->middle_texture = c->null_texture; - ldn1->flags |= TWO_SIDED; - if (!(c->gamemask & (DOOM0_BIT | HERETIC_BIT))) + ldn1->flags |= SLUMP_TWO_SIDED; + if (!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT))) { - ldn1->type = LINEDEF_WR_TURBO_LIFT; + ldn1->type = SLUMP_LINEDEF_WR_TURBO_LIFT; } else { - ldn1->type = LINEDEF_WR_LOWER_LIFT; + ldn1->type = SLUMP_LINEDEF_WR_LOWER_LIFT; } ldn1->tag = coresec->tag; @@ -4839,7 +4845,7 @@ void try_falling_core(level *l, linedef *ld1, linedef *ld2, haa *haa, config *c) } /* and that's all */ - announce(VERBOSE, "Falling core"); + announce(SLUMP_VERBOSE, "Falling core"); } /* Implement the given link between the given linedefs. */ @@ -4849,13 +4855,13 @@ void establish_link(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, ques { switch (ThisLink->type) { - case BASIC_LINK: + case SLUMP_BASIC_LINK: establish_basic_link(l, ldf1, ldf2, ThisLink, ThisQuest, ThisStyle, NewStyle, haa, c); break; - case OPEN_LINK: + case SLUMP_OPEN_LINK: establish_open_link(l, ldf1, ldf2, ThisLink, ThisQuest, ThisStyle, NewStyle, haa, c); break; - case GATE_LINK: { + case SLUMP_GATE_LINK: { short tag1, tag2; tag1 = new_tag(l); tag2 = new_tag(l); @@ -4865,11 +4871,11 @@ void establish_link(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, ques { if (rollpercent(50)) { - ThisQuest->type = LINEDEF_S1_OPEN_DOOR; + ThisQuest->type = SLUMP_LINEDEF_S1_OPEN_DOOR; } else { - ThisQuest->type = LINEDEF_S1_LOWER_FLOOR; + ThisQuest->type = SLUMP_LINEDEF_S1_LOWER_FLOOR; } ThisQuest->tag = tag1; ldf1->right->psector->pgate->gate_lock = ThisQuest->type; @@ -4891,7 +4897,7 @@ void establish_open_link(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, sector *nearsec, *farsec; boolean need_lock; - need_lock = (ThisQuest) && ((ThisQuest->goal == SWITCH_GOAL) || (ThisQuest->goal == GATE_GOAL)); + need_lock = (ThisQuest) && ((ThisQuest->goal == SLUMP_SWITCH_GOAL) || (ThisQuest->goal == SLUMP_GATE_GOAL)); nearsec = ldf1->right->psector; farsec = ldf2->right->psector; @@ -4909,7 +4915,7 @@ void establish_open_link(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, if (newfloor - nearsec->floor_height > 128) newfloor = nearsec->floor_height + 128; /* Limit step steepness */ - if (ThisLink->bits & LINK_STEPS) + if (ThisLink->bits & SLUMP_LINK_STEPS) if (newfloor - nearsec->floor_height > ThisLink->depth1) newfloor = nearsec->floor_height + ThisLink->depth1; /* OK, now set far sector, and do it */ @@ -4925,7 +4931,7 @@ void establish_open_link(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, if (nearsec->floor_height - newfloor > 128) newfloor = nearsec->floor_height - 128; /* Limit step steepness */ - if (ThisLink->bits & LINK_STEPS) + if (ThisLink->bits & SLUMP_LINK_STEPS) if (nearsec->floor_height - newfloor > ThisLink->depth1) newfloor = nearsec->floor_height - ThisLink->depth1; farsec->floor_height = newfloor; @@ -4948,15 +4954,15 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T boolean high_sides = SLUMP_FALSE; boolean sidesteps = SLUMP_FALSE; - if (ThisLink->bits & LINK_LIFT) - announce(VERBOSE, "Open lift"); + if (ThisLink->bits & SLUMP_LINK_LIFT) + announce(SLUMP_VERBOSE, "Open lift"); - if ((!(ThisLink->bits & LINK_LIFT)) && (!(ThisLink->bits & LINK_STEPS))) - announce(WARNING, "Non-lift non-stair open link; oops!"); + if ((!(ThisLink->bits & SLUMP_LINK_LIFT)) && (!(ThisLink->bits & SLUMP_LINK_STEPS))) + announce(SLUMP_WARNING, "Non-lift non-stair open link; oops!"); if (rollpercent(l->p_force_nukage) || rollpercent(10)) nukage = SLUMP_TRUE; - if ((ThisLink->bits & LINK_STEPS) && (ThisLink->bits & LINK_ALCOVE)) + if ((ThisLink->bits & SLUMP_LINK_STEPS) && (ThisLink->bits & SLUMP_LINK_ALCOVE)) nukage = SLUMP_FALSE; nearsec = ldf1->right->psector; @@ -4964,7 +4970,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* If a teleporter-goal, just make a simple air-connection. */ /* Would(n't) this be more simply expressed as a BASIC link? */ - if (ThisQuest && (ThisQuest->goal == GATE_GOAL) && l->use_gates) + if (ThisQuest && (ThisQuest->goal == SLUMP_GATE_GOAL) && l->use_gates) { midsec = clone_sector(l, farsec); midsec->floor_height = nearsec->floor_height; @@ -4973,14 +4979,14 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ldf1->left = new_sidedef(l, midsec, c); ldf1->left->middle_texture = c->null_texture; ldf1->left->upper_texture = farsec->pstyle->wall0; - ldf1->flags |= TWO_SIDED | UPPER_UNPEGGED; + ldf1->flags |= SLUMP_TWO_SIDED | SLUMP_UPPER_UNPEGGED; patch_upper(ldf1, ThisStyle->wall0, c); patch_lower(ldf1, ThisStyle->support0, c); ldf2->right->middle_texture = c->null_texture; ldf2->left = new_sidedef(l, midsec, c); ldf2->left->middle_texture = c->null_texture; ldf2->left->lower_texture = farsec->pstyle->wall0; - ldf2->flags |= TWO_SIDED; + ldf2->flags |= SLUMP_TWO_SIDED; patch_upper(ldf2, NewStyle->wall0, c); patch_lower(ldf2, NewStyle->support0, c); lde1 = new_linedef(l, ldf1->from, ldf2->to); @@ -4993,7 +4999,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T { ldf1->left->lower_texture = ThisStyle->support0; midsec->floor_flat = ThisStyle->nukage1; - midsec->special = NUKAGE1_SPECIAL; + midsec->special = SLUMP_NUKAGE1_SPECIAL; if (midsec->light_level < 160) midsec->light_level = 160; /* visible */ midsec->floor_height -= 8; @@ -5009,22 +5015,22 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ThisQuest->tag2 = new_tag(l); ldf2->right->middle_texture = ThisStyle->grating; ldf2->left->middle_texture = ThisStyle->grating; - ldf2->flags |= IMPASSIBLE | LOWER_UNPEGGED; /* Lower the grating, eh? */ + ldf2->flags |= SLUMP_IMPASSIBLE | SLUMP_LOWER_UNPEGGED; /* Lower the grating, eh? */ } farsec->pgate = new_gate(l, ThisQuest->tag, ThisQuest->tag2, 0, SLUMP_TRUE, c); - announce(LOG, "OL Gate quest"); + announce(SLUMP_LOG, "OL Gate quest"); return; /* and that's it */ } /* Otherwise it's (even) more complicated */ /* Figure how wide */ - len = linelen(ldf1); + len = SLUMP_linelen(ldf1); if (len < 100) - announce(WARNING, "Open link on a too-narrow linedef!"); + announce(SLUMP_WARNING, "Open link on a too-narrow linedef!"); midwidth = ThisLink->width1; if (midwidth == 0) - midwidth = linelen(ldf1) / 3; + midwidth = SLUMP_linelen(ldf1) / 3; if (midwidth < 64) midwidth = 64; if (((len - midwidth) / 2) < 33) @@ -5033,7 +5039,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T midwidth = 33; /* Decide if doing the sideways-step thing */ - if ((ThisLink->bits & LINK_STEPS) && (ThisLink->bits & LINK_ALCOVE) && + if ((ThisLink->bits & SLUMP_LINK_STEPS) && (ThisLink->bits & SLUMP_LINK_ALCOVE) && (midwidth >= (farsec->floor_height - nearsec->floor_height))) { sidesteps = SLUMP_TRUE; @@ -5069,9 +5075,9 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } } - ldf1->flags |= TWO_SIDED; + ldf1->flags |= SLUMP_TWO_SIDED; ldf1->right->middle_texture = c->null_texture; - ldf2->flags |= TWO_SIDED; + ldf2->flags |= SLUMP_TWO_SIDED; ldf2->right->middle_texture = c->null_texture; ldf1a = ldf1; @@ -5082,7 +5088,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ldf2a = split_linedef(l, ldf2, midwidth, c); midsec = clone_sector(l, farsec); - if (ThisLink->bits & LINK_LIFT) + if (ThisLink->bits & SLUMP_LINK_LIFT) { midsec->tag = new_tag(l); ldf1->type = NewStyle->slifttype; @@ -5091,26 +5097,26 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ldf1->left = new_sidedef(l, midsec, c); ldf1->left->middle_texture = c->null_texture; - if (nukage && (ThisLink->bits & LINK_LIFT)) + if (nukage && (ThisLink->bits & SLUMP_LINK_LIFT)) ldf1->left->lower_texture = ThisStyle->support0; ldf2->left = new_sidedef(l, midsec, c); ldf2->left->middle_texture = c->null_texture; - if (ThisLink->bits & LINK_LIFT) + if (ThisLink->bits & SLUMP_LINK_LIFT) { ldf2->left->lower_texture = NewStyle->support0; - ldf2->flags |= LOWER_UNPEGGED; + ldf2->flags |= SLUMP_LOWER_UNPEGGED; } patch_upper(ldf1, ThisStyle->wall0, c); patch_lower(ldf1, ThisStyle->support0, c); - if ((ThisLink->bits & LINK_LIFT) && (ThisStyle->liftface) && + if ((ThisLink->bits & SLUMP_LINK_LIFT) && (ThisStyle->liftface) && (farsec->floor_height - nearsec->floor_height <= ThisStyle->liftface->height) && (midwidth == ThisStyle->liftface->width)) { ldf1->right->lower_texture = ThisStyle->liftface; ldf1->right->x_offset = 0; - announce(VERBOSE, "Lift texture"); + announce(SLUMP_VERBOSE, "Lift texture"); } - ldf1->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; patch_upper(ldf2, NewStyle->wall0, c); patch_lower(ldf2, NewStyle->wall0, c); @@ -5122,7 +5128,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T sideseca->ceiling_flat = midsec->ceiling_flat; lde1->right->middle_texture = NewStyle->wall0; lde2->left = new_sidedef(l, midsec, c); - lde2->flags |= TWO_SIDED; + lde2->flags |= SLUMP_TWO_SIDED; lde2->left->middle_texture = c->null_texture; lde2->left->lower_texture = NewStyle->support0; lde2->right->lower_texture = NewStyle->wall0; @@ -5135,21 +5141,21 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T patch_lower(ldf2a, NewStyle->wall0, c); if (nukage) { - announce(VERBOSE, "Open nukage"); + announce(SLUMP_VERBOSE, "Open nukage"); sideseca->floor_height -= 8; sideseca->floor_flat = ThisStyle->nukage1; - sideseca->special = NUKAGE1_SPECIAL; + sideseca->special = SLUMP_NUKAGE1_SPECIAL; patch_lower(ldf1a, ThisStyle->support0, c); patch_lower(ldf2a, ThisStyle->support0, c); nearsec->marked = farsec->marked = SLUMP_TRUE; if (c->gunk_channels && empty_left_side(l, lde1, 32)) { - lefthand_box(l, lde1, 32, ThisStyle, c)->right->middle_texture = ThisStyle->support0; - lde1->left->psector->ceiling_height = lde1->left->psector->floor_height + 8; - lde1->left->psector->light_level = lde1->right->psector->light_level - 20; - lde1->left->psector->floor_flat = ThisStyle->nukage1; + SLUMP_lefthand_box(l, lde1, 32, ThisStyle, c)->right->middle_texture = ThisStyle->support0; + lde1->left->psector->ceiling_height = lde1->left->psector->floor_height + 8; + lde1->left->psector->light_level = lde1->right->psector->light_level - 20; + lde1->left->psector->floor_flat = ThisStyle->nukage1; patch_upper(lde1, NewStyle->wall0, c); - announce(VERBOSE, "Channel"); + announce(SLUMP_VERBOSE, "Channel"); } nearsec->marked = farsec->marked = SLUMP_FALSE; } @@ -5162,7 +5168,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T sidesecb->ceiling_flat = midsec->ceiling_flat; lde2->right->middle_texture = NewStyle->wall0; lde1->left = new_sidedef(l, midsec, c); - lde1->flags |= TWO_SIDED; + lde1->flags |= SLUMP_TWO_SIDED; lde1->left->middle_texture = c->null_texture; lde1->left->lower_texture = NewStyle->support0; lde1->right->lower_texture = NewStyle->wall0; @@ -5176,18 +5182,18 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T { sidesecb->floor_height -= 8; sidesecb->floor_flat = ThisStyle->nukage1; - sidesecb->special = NUKAGE1_SPECIAL; + sidesecb->special = SLUMP_NUKAGE1_SPECIAL; patch_lower(ldf1b, ThisStyle->support0, c); patch_lower(ldf2b, ThisStyle->support0, c); nearsec->marked = farsec->marked = SLUMP_TRUE; if (c->gunk_channels && empty_left_side(l, lde2, 32)) { - lefthand_box(l, lde2, 32, ThisStyle, c)->right->middle_texture = ThisStyle->support0; - lde2->left->psector->ceiling_height = lde2->left->psector->floor_height + 8; - lde2->left->psector->light_level = lde2->right->psector->light_level - 20; - lde2->left->psector->floor_flat = ThisStyle->nukage1; + SLUMP_lefthand_box(l, lde2, 32, ThisStyle, c)->right->middle_texture = ThisStyle->support0; + lde2->left->psector->ceiling_height = lde2->left->psector->floor_height + 8; + lde2->left->psector->light_level = lde2->right->psector->light_level - 20; + lde2->left->psector->floor_flat = ThisStyle->nukage1; patch_upper(lde2, NewStyle->wall0, c); - announce(VERBOSE, "Channel"); + announce(SLUMP_VERBOSE, "Channel"); } nearsec->marked = farsec->marked = SLUMP_FALSE; } @@ -5196,9 +5202,9 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T midsec->light_level = sideseca->light_level = sidesecb->light_level = ThisStyle->roomlight0; /* Make center into stairs if we need them */ - if ((ThisLink->bits & LINK_STEPS) && !sidesteps) + if ((ThisLink->bits & SLUMP_LINK_STEPS) && !sidesteps) { - announce(VERBOSE, "Open stairs"); + announce(SLUMP_VERBOSE, "Open stairs"); /* Maybe stick on some lights */ if (rollpercent(50)) { /* 50 should vary? */ @@ -5207,7 +5213,7 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T g = ThisStyle->shortlamp0; if ((high_sides && ((len - midwidth) / 2 >= 2 * g->width)) || ((len - midwidth) / 2 >= g->width + 69)) { - announce(VERBOSE, "and lights"); + announce(SLUMP_VERBOSE, "and lights"); new_thing(l, (ldf1a->to->x + ldf1a->from->x + ldf2a->to->x + ldf2a->from->x) / 4, (ldf1a->to->y + ldf1a->from->y + ldf2a->to->y + ldf2a->from->y) / 4, 0, g->thingid, 7, c); new_thing(l, (ldf1b->to->x + ldf1b->from->x + ldf2b->to->x + ldf2b->from->x) / 4, @@ -5226,10 +5232,10 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* Change a few details */ lde1->right->y_offset = 0; lde1->left->lower_texture = NewStyle->wall0; - lde1->flags |= LOWER_UNPEGGED; + lde1->flags |= SLUMP_LOWER_UNPEGGED; ldes->right->y_offset = 0; ldes->left->lower_texture = NewStyle->wall0; - ldes->flags |= LOWER_UNPEGGED; + ldes->flags |= SLUMP_LOWER_UNPEGGED; if (ThisStyle->light_steps && ThisStyle->walllight) { ldf1->right->lower_texture = ThisStyle->walllight; @@ -5244,15 +5250,15 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } /* Or make the center into *sideways* stairs */ - if ((ThisLink->bits & LINK_STEPS) && sidesteps) + if ((ThisLink->bits & SLUMP_LINK_STEPS) && sidesteps) { - announce(NONE, "Open side-stairs"); + announce(SLUMP_NONE, "Open side-stairs"); ldf1->right->lower_texture = ThisStyle->wall0; ldf2->left->lower_texture = NewStyle->wall0; ldf1->right->y_offset = 0; ldf1->left->lower_texture = NewStyle->wall0; - ldf1->flags |= LOWER_UNPEGGED; - if (ThisLink->bits & LINK_LEFT) + ldf1->flags |= SLUMP_LOWER_UNPEGGED; + if (ThisLink->bits & SLUMP_LINK_LEFT) { if (ThisStyle->light_steps && ThisStyle->walllight) { @@ -5284,10 +5290,10 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } ldf2->right->y_offset = 0; ldf2->left->lower_texture = NewStyle->wall0; - ldf2->flags |= LOWER_UNPEGGED; + ldf2->flags |= SLUMP_LOWER_UNPEGGED; patch_lower(ldf1a, ThisStyle->wall0, c); patch_lower(ldf1b, ThisStyle->wall0, c); - if (ThisLink->bits & LINK_LEFT) + if (ThisLink->bits & SLUMP_LINK_LEFT) { stairify(l, ldes, lde1, ldf2, ldf1, nearsec->floor_height, farsec->floor_height, ThisQuest, ThisStyle, c); } @@ -5298,9 +5304,9 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } /* Bells and whistles! */ - if ((farsec->floor_height - sideseca->floor_height == 128) && (linelen(ldf2a) >= 128)) + if ((farsec->floor_height - sideseca->floor_height == 128) && (SLUMP_linelen(ldf2a) >= 128)) { - if (linelen(ldf2a) > 128) + if (SLUMP_linelen(ldf2a) > 128) { ldf2a = centerpart(l, ldf2a, NULL, 128, ThisStyle, c); ldf2b = centerpart(l, ldf2b, NULL, 128, ThisStyle, c); @@ -5308,12 +5314,12 @@ void e_ol_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ldf2a->left->lower_texture = ThisStyle->plaque; ldf2a->left->x_offset = 0; ldf2a->left->y_offset = 0; - ldf2a->flags &= ~LOWER_UNPEGGED; + ldf2a->flags &= ~SLUMP_LOWER_UNPEGGED; ldf2b->left->lower_texture = ThisStyle->plaque; ldf2b->left->x_offset = 0; ldf2b->left->y_offset = 0; - ldf2b->flags &= ~LOWER_UNPEGGED; - announce(VERBOSE, "Open-link plaques"); + ldf2b->flags &= ~SLUMP_LOWER_UNPEGGED; + announce(SLUMP_VERBOSE, "Open-link plaques"); } /* and so on */ @@ -5353,54 +5359,55 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T boolean trigger_door = SLUMP_FALSE; boolean painted_door = SLUMP_FALSE; int mminx, mminy, mmaxx, mmaxy, mangle; - propertybits effective_left = ThisLink->bits & LINK_LEFT; - propertybits litecol = LIGHT; + propertybits effective_left = ThisLink->bits & SLUMP_LINK_LEFT; + propertybits litecol = SLUMP_LIGHT; - if ((ThisLink->bits & LINK_CORE) && (ThisLink->bits & LINK_ANY_DOOR)) - announce(VERBOSE, "Core and door(s)"); + if ((ThisLink->bits & SLUMP_LINK_CORE) && (ThisLink->bits & SLUMP_LINK_ANY_DOOR)) + announce(SLUMP_VERBOSE, "Core and door(s)"); - if ((ThisQuest) && (ThisQuest->goal == KEY_GOAL)) + if ((ThisQuest) && (ThisQuest->goal == SLUMP_KEY_GOAL)) { switch (ThisQuest->type) { - case ID_BLUEKEY: - case ID_BLUECARD: - case ID_HERETICBLUEKEY: - litecol = BLUE; + case SLUMP_ID_BLUEKEY: + case SLUMP_ID_BLUECARD: + case SLUMP_ID_HERETICBLUEKEY: + litecol = SLUMP_BLUE; break; - case ID_REDKEY: - case ID_REDCARD: - case ID_HERETICGREENKEY: - litecol = RED; + case SLUMP_ID_REDKEY: + case SLUMP_ID_REDCARD: + case SLUMP_ID_HERETICGREENKEY: + litecol = SLUMP_RED; break; - case ID_YELLOWKEY: - case ID_YELLOWCARD: - case ID_HERETICYELLOWKEY: - litecol = YELLOW; + case SLUMP_ID_YELLOWKEY: + case SLUMP_ID_YELLOWCARD: + case SLUMP_ID_HERETICYELLOWKEY: + litecol = SLUMP_YELLOW; break; } } else { - litecol = LIGHT; + litecol = SLUMP_LIGHT; } - /* The type of a SWITCH_GOAL isn't set until the link's established */ + /* The type of a SLUMP_SWITCH_GOAL isn't set until the link's established */ if (ThisQuest) - if (ThisQuest->goal == SWITCH_GOAL) - if (ThisLink->bits & LINK_LOCK_CORE) + if (ThisQuest->goal == SLUMP_SWITCH_GOAL) + if (ThisLink->bits & SLUMP_LINK_LOCK_CORE) { - ThisQuest->type = LINEDEF_S1_RAISE_AND_CLEAN_FLOOR; + ThisQuest->type = SLUMP_LINEDEF_S1_RAISE_AND_CLEAN_FLOOR; } else { - ThisQuest->type = LINEDEF_S1_OPEN_DOOR; + ThisQuest->type = SLUMP_LINEDEF_S1_OPEN_DOOR; } dump_link(ldf1, ldf2, ThisLink, "Establishing"); - if ((ThisLink->bits & LINK_ALCOVE) && (ThisLink->bits & LINK_TWIN) && (ThisLink->bits & LINK_ANY_DOOR)) - announce(VERBOSE, "Twin door alcoves!"); + if ((ThisLink->bits & SLUMP_LINK_ALCOVE) && (ThisLink->bits & SLUMP_LINK_TWIN) && + (ThisLink->bits & SLUMP_LINK_ANY_DOOR)) + announce(SLUMP_VERBOSE, "Twin door alcoves!"); nearsec = ldf1->right->psector; farsec = ldf2->right->psector; @@ -5410,38 +5417,38 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T farsec->ceiling_height = farsec->floor_height + NewStyle->wallheight0; /* Make sure we don't overdo the bar thing and crash the engine... */ - if (l->barcount > LEVEL_MAX_BARS) - ThisLink->bits &= ~LINK_BARS; + if (l->barcount > SLUMP_LEVEL_MAX_BARS) + ThisLink->bits &= ~SLUMP_LINK_BARS; /* See if we need to force the floordelta toward zero to avoid */ /* impassable doorways. */ - if (ThisLink->bits & LINK_STEPS) + if (ThisLink->bits & SLUMP_LINK_STEPS) { int need; /* The clearance we need is 56 plus the step height times */ /* the number of steps our 64ish-wide shadow is on at once */ need = 64 + (1 + (64 / (ThisLink->depth3 / (ThisLink->stepcount)))) * abs(ThisLink->floordelta / (ThisLink->stepcount - 1)); - if (ThisLink->bits & LINK_ANY_DOOR) + if (ThisLink->bits & SLUMP_LINK_ANY_DOOR) need += 8; /* Doors don't open all the way */ if ((farsec->ceiling_height - farsec->floor_height < need) || (nearsec->ceiling_height - nearsec->floor_height < need)) { /* There's probably something less drastic we can do here... */ ThisLink->floordelta = 0; - ThisLink->bits &= ~LINK_STEPS; + ThisLink->bits &= ~SLUMP_LINK_STEPS; farsec->floor_height = nearsec->floor_height + ThisLink->floordelta; farsec->ceiling_height = farsec->floor_height + NewStyle->wallheight0; } } /* If we need to twin, split and recurse, or do the window thing */ - if ((flipstate == 0) && (ThisLink->bits & LINK_TWIN)) + if ((flipstate == 0) && (ThisLink->bits & SLUMP_LINK_TWIN)) { - len = linelen(ldf1) / 2; + len = SLUMP_linelen(ldf1) / 2; ldnew1 = split_linedef(l, ldf1, len, c); ldnew2 = split_linedef(l, ldf2, len, c); - if (!(ThisLink->bits & LINK_WINDOW)) + if (!(ThisLink->bits & SLUMP_LINK_WINDOW)) { /* make twin links */ e_bl_inner(l, ldf1, ldnew2, ThisLink, ThisQuest, ThisStyle, NewStyle, 1, haa, c); /* Lefthand one */ e_bl_inner(l, ldnew1, ldf2, ThisLink, ThisQuest, ThisStyle, NewStyle, 2, haa, c); /* Righthand one */ @@ -5465,37 +5472,37 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* If this isn't supposed to be passable at all, just winowify. */ /* Another fun thing would be to make the door, but bar it. */ - if (ThisQuest && (ThisQuest->goal == GATE_GOAL) && l->use_gates) + if (ThisQuest && (ThisQuest->goal == SLUMP_GATE_GOAL) && l->use_gates) { make_window(l, ldf1, ldf2, ThisLink, ThisStyle, NewStyle, c); /* Now arrange for the gate and stuff */ ThisQuest->tag = new_tag(l); ThisQuest->tag2 = new_tag(l); farsec->pgate = new_gate(l, ThisQuest->tag, ThisQuest->tag2, 0, SLUMP_TRUE, c); - announce(LOG, "BL Gate quest"); + announce(SLUMP_LOG, "BL Gate quest"); return; /* and that's it */ } - /* Figure out maxtop, for MAX_CEILING */ + /* Figure out maxtop, for MAX_SLUMP_CEILING */ maxtop = nearsec->floor_height + ThisLink->height1; if (ThisLink->floordelta > 0) maxtop += ThisLink->floordelta; /* If not the whole wall, center it, or do alcove things, or etc */ - len = linelen(ldf1); /* Really assumes lens are == */ + len = SLUMP_linelen(ldf1); /* Really assumes lens are == */ if (ThisLink->width1 > len) { - announce(WARNING, "Link-width > linedef size! Reducing..."); + announce(SLUMP_WARNING, "Link-width > linedef size! Reducing..."); ThisLink->width1 = len; } if ((ThisLink->width1 != 0) && (ThisLink->width1 < len)) { - if (ThisLink->bits & LINK_ALCOVE) + if (ThisLink->bits & SLUMP_LINK_ALCOVE) { border = (len - (ThisLink->width1 * 2 + ThisLink->depth3)) / 2; if (border < 0) { /* This should never happen */ - announce(WARNING, "A-link width too big! Reducing..."); + announce(SLUMP_WARNING, "A-link width too big! Reducing..."); ThisLink->width1 = (len - ThisLink->depth3) / 2; border = 0; /* May not actually help enough... */ @@ -5503,8 +5510,8 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } if ((border != 0) && (flipstate == 2) && rollpercent(50)) { - effective_left ^= LINK_LEFT; - announce(VERBOSE, "Flipping twinned alcove"); + effective_left ^= SLUMP_LINK_LEFT; + announce(SLUMP_VERBOSE, "Flipping twinned alcove"); } if (effective_left) { @@ -5525,20 +5532,20 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T split_linedef(l, ldf2, ThisLink->width1, c); } } - else if ((flipstate == 1) && (ThisLink->bits & LINK_FAR_TWINS)) + else if ((flipstate == 1) && (ThisLink->bits & SLUMP_LINK_FAR_TWINS)) { split_linedef(l, ldf1, ThisLink->width1, c); ldf2 = split_linedef(l, ldf2, len - ThisLink->width1, c); - announce(NONE, "Far twins"); + announce(SLUMP_NONE, "Far twins"); } - else if ((flipstate == 2) && (ThisLink->bits & LINK_FAR_TWINS)) + else if ((flipstate == 2) && (ThisLink->bits & SLUMP_LINK_FAR_TWINS)) { split_linedef(l, ldf2, ThisLink->width1, c); ldf1 = split_linedef(l, ldf1, len - ThisLink->width1, c); } else { /* No alcove or farness; simple centered borders */ - if (ThisQuest && ThisQuest->goal == KEY_GOAL && l->skullkeys) + if (ThisQuest && ThisQuest->goal == SLUMP_KEY_GOAL && l->skullkeys) { ldf1 = borderize(l, ldf1, ThisLink->width1, SLUMP_TRUE, ThisStyle, litecol, find_genus(c, ThisQuest->type), &painted_door, c); @@ -5553,8 +5560,8 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } else { - if (ThisLink->bits & LINK_ALCOVE) - announce(WARNING, "ALCOVE with width zero, or width == linelen"); + if (ThisLink->bits & SLUMP_LINK_ALCOVE) + announce(SLUMP_WARNING, "ALCOVE with width zero, or width == linelen"); /* yikes! */ } @@ -5566,67 +5573,68 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* Get any tags we need for triggered links, and put them on */ /* the linedefs we're currently working on. */ /* Trigger alcoved lifts. */ - if ((ThisLink->bits & LINK_LIFT) && (ThisLink->bits & LINK_ALCOVE) && (!(ThisLink->bits & LINK_ANY_DOOR)) && - (ThisLink->bits & LINK_TRIGGERED)) + if ((ThisLink->bits & SLUMP_LINK_LIFT) && (ThisLink->bits & SLUMP_LINK_ALCOVE) && + (!(ThisLink->bits & SLUMP_LINK_ANY_DOOR)) && (ThisLink->bits & SLUMP_LINK_TRIGGERED)) { trigger_lift = SLUMP_TRUE; - announce(VERBOSE, "Walking lift"); + announce(SLUMP_VERBOSE, "Walking lift"); tag1 = new_tag(l); if (ThisLink->floordelta > 0) { ldf1->tag = tag1; - ldf1->type = LINEDEF_WR_LOWER_LIFT; + ldf1->type = SLUMP_LINEDEF_WR_LOWER_LIFT; } else { ldf2->tag = tag1; - ldf2->type = LINEDEF_WR_LOWER_LIFT; + ldf2->type = SLUMP_LINEDEF_WR_LOWER_LIFT; } } /* Trigger deeply-recessed liftless doors also */ - if (((ThisQuest == NULL) || ((ThisQuest->goal != SWITCH_GOAL) && (ThisQuest->goal != KEY_GOAL))) && - (ThisLink->bits & LINK_ANY_DOOR) && (!(ThisLink->bits & LINK_BARS)) && (ThisLink->bits & LINK_RECESS) && - (ThisLink->depth2 > 16) && (ThisLink->bits & LINK_TRIGGERED)) + if (((ThisQuest == NULL) || ((ThisQuest->goal != SLUMP_SWITCH_GOAL) && (ThisQuest->goal != SLUMP_KEY_GOAL))) && + (ThisLink->bits & SLUMP_LINK_ANY_DOOR) && (!(ThisLink->bits & SLUMP_LINK_BARS)) && + (ThisLink->bits & SLUMP_LINK_RECESS) && (ThisLink->depth2 > 16) && (ThisLink->bits & SLUMP_LINK_TRIGGERED)) { trigger_door = SLUMP_TRUE; tag1 = new_tag(l); /* Don't always need both of these, but couldn't hurt... */ ldf1->tag = tag1; - ldf1->type = LINEDEF_WR_OC_DOOR; /* Or WR_OPEN_DOOR? */ + ldf1->type = SLUMP_LINEDEF_WR_OC_DOOR; /* Or WR_OPEN_DOOR? */ ldf2->tag = tag1; - ldf2->type = LINEDEF_WR_OC_DOOR; /* Or WR_OPEN_DOOR? */ + ldf2->type = SLUMP_LINEDEF_WR_OC_DOOR; /* Or WR_OPEN_DOOR? */ } /* and deeply-recessed lifts */ - if (((ThisQuest == NULL) || ((ThisQuest->goal != SWITCH_GOAL) && (ThisQuest->goal != KEY_GOAL))) && - (ThisLink->bits & LINK_LIFT) && (ThisLink->bits & LINK_RECESS) && (!(ThisLink->bits & LINK_ALCOVE)) && - (!(ThisLink->bits & LINK_ANY_DOOR)) && (ThisLink->depth2 > 16) && (ThisLink->bits & LINK_TRIGGERED)) + if (((ThisQuest == NULL) || ((ThisQuest->goal != SLUMP_SWITCH_GOAL) && (ThisQuest->goal != SLUMP_KEY_GOAL))) && + (ThisLink->bits & SLUMP_LINK_LIFT) && (ThisLink->bits & SLUMP_LINK_RECESS) && + (!(ThisLink->bits & SLUMP_LINK_ALCOVE)) && (!(ThisLink->bits & SLUMP_LINK_ANY_DOOR)) && + (ThisLink->depth2 > 16) && (ThisLink->bits & SLUMP_LINK_TRIGGERED)) { trigger_lift = SLUMP_TRUE; tag1 = new_tag(l); if (ThisLink->floordelta > 0) { ldf1->tag = tag1; - ldf1->type = LINEDEF_WR_LOWER_LIFT; + ldf1->type = SLUMP_LINEDEF_WR_LOWER_LIFT; } else { ldf2->tag = tag1; - ldf2->type = LINEDEF_WR_LOWER_LIFT; + ldf2->type = SLUMP_LINEDEF_WR_LOWER_LIFT; } } /* Remember these for later */ t1 = ldf1->right->middle_texture; t2 = NewStyle->wall0; - len = linelen(ldf1); /* Really assumes lens are == */ + len = SLUMP_linelen(ldf1); /* Really assumes lens are == */ /* If recessed, make recess sectors and stuff */ - if (ThisLink->bits & LINK_RECESS) + if (ThisLink->bits & SLUMP_LINK_RECESS) { ldnew1 = lefthand_box_ext(l, ldf1, ThisLink->depth2, ThisStyle, c, &ldedge1, &ldedge2); /* The near recess copies the near room */ ldnew1->right->psector->floor_height = ldf1->right->psector->floor_height; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) { ldnew1->right->psector->ceiling_height = maxtop; } @@ -5638,37 +5646,38 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (c->clights) { /* Too often? */ ldnew1->right->psector->ceiling_flat = nearsec->pstyle->ceilinglight; - announce(VERBOSE, "rcl"); + announce(SLUMP_VERBOSE, "rcl"); } /* Paint key-color, or adjust y-offsets, for recess edges */ - if ((ThisQuest) && (ThisStyle->paint_recesses) && (!painted_door) && (ThisQuest->goal == KEY_GOAL) && + if ((ThisQuest) && (ThisStyle->paint_recesses) && (!painted_door) && (ThisQuest->goal == SLUMP_KEY_GOAL) && (ThisLink->depth2 >= (texture_for_key(ThisQuest->type, ThisStyle, c)->width))) { ldedge1->right->middle_texture = ldedge2->right->middle_texture = texture_for_key(ThisQuest->type, ThisStyle, c); if (l->scrolling_keylights) { - ldedge1->type = LINEDEF_SCROLL; - ldedge2->type = LINEDEF_SCROLL; + ldedge1->type = SLUMP_LINEDEF_SCROLL; + ldedge2->type = SLUMP_LINEDEF_SCROLL; } /* Make sure the paint is visible! */ if (ldedge1->right->psector->light_level < l->lit_light_level) ldedge1->right->psector->light_level = l->lit_light_level; - announce(VERBOSE, "painted recess"); + announce(SLUMP_VERBOSE, "painted recess"); if (rollpercent(75)) { painted_door = SLUMP_TRUE; } else { - announce(VERBOSE, "Extra-painted recess"); /* Paint the door, too */ - ldedge1->flags |= LOWER_UNPEGGED; /* and make it all line up */ - ldedge2->flags |= LOWER_UNPEGGED; + announce(SLUMP_VERBOSE, "Extra-painted recess"); /* Paint the door, too */ + ldedge1->flags |= SLUMP_LOWER_UNPEGGED; /* and make it all line up */ + ldedge2->flags |= SLUMP_LOWER_UNPEGGED; } } - else if ((ThisLink->bits & LINK_NEAR_DOOR) && (ThisStyle->light_recesses) && (ThisStyle->walllight != NULL)) + else if ((ThisLink->bits & SLUMP_LINK_NEAR_DOOR) && (ThisStyle->light_recesses) && + (ThisStyle->walllight != NULL)) { - announce(VERBOSE, "Lit recess"); + announce(SLUMP_VERBOSE, "Lit recess"); ldedge1->right->middle_texture = ldedge2->right->middle_texture = ThisStyle->walllight; make_lighted(l, ldedge1->right->psector, c); } @@ -5681,7 +5690,7 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* and the far the far */ ldnew2 = lefthand_box_ext(l, ldf2, ThisLink->depth2, NewStyle, c, &ldedge1, &ldedge2); ldnew2->right->psector->floor_height = farsec->floor_height; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) { ldnew2->right->psector->ceiling_height = maxtop; } @@ -5694,11 +5703,11 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (c->clights) { /* Too often? */ ldnew2->right->psector->ceiling_flat = farsec->pstyle->ceilinglight; - announce(VERBOSE, "rcl"); + announce(SLUMP_VERBOSE, "rcl"); } - if ((ThisLink->bits & LINK_FAR_DOOR) && (NewStyle->light_recesses) && (NewStyle->walllight != NULL)) + if ((ThisLink->bits & SLUMP_LINK_FAR_DOOR) && (NewStyle->light_recesses) && (NewStyle->walllight != NULL)) { - announce(VERBOSE, "Lit recess"); + announce(SLUMP_VERBOSE, "Lit recess"); ldedge1->right->middle_texture = ldedge2->right->middle_texture = NewStyle->walllight; make_lighted(l, ldedge1->right->psector, c); } @@ -5714,27 +5723,27 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } /* If no core or alcoves, make the one arch/door sector */ - if (!(ThisLink->bits & (LINK_CORE | LINK_ALCOVE))) + if (!(ThisLink->bits & (SLUMP_LINK_CORE | SLUMP_LINK_ALCOVE))) { flip_linedef(ldf2); newsec = make_box_ext(l, ldf1, ldf2, ThisStyle, c, &ldnew1, &ldnew2); flip_linedef(ldf2); ldnew2->right->y_offset = ldnew1->right->y_offset = (nearsec->ceiling_height - nearsec->floor_height) - ThisLink->height1; - if ((ThisLink->bits & (LINK_ANY_DOOR)) || c->doorless_jambs) + if ((ThisLink->bits & (SLUMP_LINK_ANY_DOOR)) || c->doorless_jambs) { ldnew1->right->middle_texture = ThisStyle->doorjamb; ldnew2->right->middle_texture = ThisStyle->doorjamb; } newsec->floor_height = nearsec->floor_height; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) { newsec->ceiling_height = maxtop; } else { -#ifdef STRANGE_THINGS +#ifdef SLUMP_STRANGE_THINGS newsec->ceiling_height = nearsec->ceiling_height; #else newsec->ceiling_height = newsec->floor_height + ThisLink->height1; @@ -5749,40 +5758,40 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T patch_lower(ldf1, ThisStyle->kickplate, c); /* or stepfronts? */ patch_lower(ldf2, NewStyle->kickplate, c); - ldf1->flags |= TWO_SIDED; - ldf2->flags |= TWO_SIDED; + ldf1->flags |= SLUMP_TWO_SIDED; + ldf2->flags |= SLUMP_TWO_SIDED; } /* If no core, and a door, doorify the middle sector (s) */ - if ((!(ThisLink->bits & (LINK_CORE | LINK_ALCOVE))) && (ThisLink->bits & LINK_ANY_DOOR)) + if ((!(ThisLink->bits & (SLUMP_LINK_CORE | SLUMP_LINK_ALCOVE))) && (ThisLink->bits & SLUMP_LINK_ANY_DOOR)) { - if (!(ThisLink->bits & LINK_BARS)) + if (!(ThisLink->bits & SLUMP_LINK_BARS)) { doorify(newsec, ldf1, ldf2, ThisStyle, NewStyle, c); if (trigger_door) { - ldf1->type = LINEDEF_NORMAL; - ldf2->type = (c->do_dm) ? LINEDEF_NORMAL_S1_DOOR : LINEDEF_NORMAL; + ldf1->type = SLUMP_LINEDEF_NORMAL; + ldf2->type = (c->do_dm) ? SLUMP_LINEDEF_NORMAL_S1_DOOR : SLUMP_LINEDEF_NORMAL; newsec->tag = tag1; } if (!ThisStyle->moving_jambs) { - ldnew1->flags |= LOWER_UNPEGGED; - ldnew2->flags |= LOWER_UNPEGGED; + ldnew1->flags |= SLUMP_LOWER_UNPEGGED; + ldnew2->flags |= SLUMP_LOWER_UNPEGGED; } if (ThisQuest) { - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) { ldf1->type = type_for_key(ThisQuest->type); if (!painted_door) mark_door_for_key(l, ldf1, ThisQuest->type, ThisStyle, c); ldf2->type = type_for_key(ThisQuest->type); /* Prevent monsters! */ } - else if (ThisQuest->goal == SWITCH_GOAL && !(ThisLink->bits & LINK_LOCK_CORE)) + else if (ThisQuest->goal == SLUMP_SWITCH_GOAL && !(ThisLink->bits & SLUMP_LINK_LOCK_CORE)) { - ldf1->type = LINEDEF_NORMAL; - ldf2->type = (c->do_dm) ? LINEDEF_NORMAL_S1_DOOR : LINEDEF_NORMAL; + ldf1->type = SLUMP_LINEDEF_NORMAL; + ldf2->type = (c->do_dm) ? SLUMP_LINEDEF_NORMAL_S1_DOOR : SLUMP_LINEDEF_NORMAL; newsec->tag = ThisQuest->tag; mark_door_for_lock(l, ldf1, ThisStyle, c); } /* end else if tag goal */ @@ -5790,8 +5799,8 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } else { - announce(VERBOSE, "Barred door"); - if (ThisLink->bits & LINK_LOCK_CORE) + announce(SLUMP_VERBOSE, "Barred door"); + if (ThisLink->bits & SLUMP_LINK_LOCK_CORE) barify(l, ldf1, ldf2, NULL, 16 * l->hugeness, NULL, ThisStyle, c); else barify(l, ldf1, ldf2, ThisQuest, 16 * l->hugeness, NULL, ThisStyle, c); @@ -5799,31 +5808,31 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } /* If a core, and door(s), need to make the door sector(s) */ - if (((ThisLink->bits & LINK_CORE)) && (ThisLink->bits & LINK_ANY_DOOR)) + if (((ThisLink->bits & SLUMP_LINK_CORE)) && (ThisLink->bits & SLUMP_LINK_ANY_DOOR)) { - if (ThisLink->bits & LINK_NEAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_NEAR_DOOR) { ldnew1 = lefthand_box_ext(l, ldf1, ThisLink->depth1, ThisStyle, c, &ldedge1, &ldedge2); ldedge1->right->middle_texture = ThisStyle->doorjamb; ldedge2->right->middle_texture = ThisStyle->doorjamb; if (!ThisStyle->moving_jambs) { - ldedge1->flags |= LOWER_UNPEGGED; - ldedge2->flags |= LOWER_UNPEGGED; + ldedge1->flags |= SLUMP_LOWER_UNPEGGED; + ldedge2->flags |= SLUMP_LOWER_UNPEGGED; } /* Does the y offset of the doorjambs actually matter? */ ldedge2->right->y_offset = ldedge1->right->y_offset = (nearsec->ceiling_height - nearsec->floor_height) - ThisLink->height1; } - if (ThisLink->bits & LINK_FAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_FAR_DOOR) { ldnew2 = lefthand_box_ext(l, ldf2, ThisLink->depth1, NewStyle, c, &ldedge1, &ldedge2); ldedge1->right->middle_texture = NewStyle->doorjamb; ldedge2->right->middle_texture = NewStyle->doorjamb; if (!NewStyle->moving_jambs) { - ldedge1->flags |= LOWER_UNPEGGED; - ldedge2->flags |= LOWER_UNPEGGED; + ldedge1->flags |= SLUMP_LOWER_UNPEGGED; + ldedge2->flags |= SLUMP_LOWER_UNPEGGED; } ldedge2->right->y_offset = ldedge1->right->y_offset = (farsec->ceiling_height - farsec->floor_height) - ThisLink->height1; @@ -5834,13 +5843,13 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* for the rest of the alg to work. So record fixup info */ /* for later. */ need_to_doorify = SLUMP_TRUE; /* Need to flip when done */ - if (ThisLink->bits & LINK_NEAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_NEAR_DOOR) { ldflip1a = ldf1; ldflip1b = ldnew1; sflip1 = ldf1->left->psector; } - if (ThisLink->bits & LINK_FAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_FAR_DOOR) { ldflip2a = ldf2; ldflip2b = ldnew2; @@ -5849,17 +5858,17 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T sflip2->light_level = NewStyle->doorlight0; } /* Now we're working on the far sides of the (future) door(s) */ - if (ThisLink->bits & LINK_NEAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_NEAR_DOOR) ldf1 = ldnew1; - if (ThisLink->bits & LINK_FAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_FAR_DOOR) ldf2 = ldnew2; } /* If alcoves, make them now, and take new linedefs */ - if (ThisLink->bits & LINK_ALCOVE) + if (ThisLink->bits & SLUMP_LINK_ALCOVE) { linedef *ldedgeopen, *ldedgeclosed; - announce(VERBOSE, "Making alcoves"); + announce(SLUMP_VERBOSE, "Making alcoves"); ldnew1 = lefthand_box_ext(l, ldf1, ThisLink->width2, ThisStyle, c, &ldedge1, &ldedge2); if (effective_left) { @@ -5874,9 +5883,9 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* The near alcove copies the near room */ ldnew1->right->middle_texture = ldedgeopen->right->middle_texture; ldedgeopen->right->middle_texture = c->null_texture; - ldedgeopen->flags |= TWO_SIDED; + ldedgeopen->flags |= SLUMP_TWO_SIDED; ldnew1->right->psector->floor_height = ldf1->right->psector->floor_height; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) { ldnew1->right->psector->ceiling_height = maxtop; } @@ -5902,9 +5911,9 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* and the far the far */ ldnew2->right->middle_texture = ldedgeopen->right->middle_texture; ldedgeopen->right->middle_texture = c->null_texture; - ldedgeopen->flags |= TWO_SIDED; + ldedgeopen->flags |= SLUMP_TWO_SIDED; ldnew2->right->psector->floor_height = farsec->floor_height; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) { ldnew2->right->psector->ceiling_height = maxtop; } @@ -5954,7 +5963,7 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T mangle = facing_right_from_ld(ldf1); /* If the core is stairs, put in all but the last */ - if (ThisLink->bits & LINK_STEPS) + if (ThisLink->bits & SLUMP_LINK_STEPS) { int i, depth, stepdelta, x, y; texture *front = ThisStyle->kickplate; @@ -5963,10 +5972,10 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (g->height > ThisLink->height1) g = ThisStyle->shortlamp0; depth = ThisLink->depth3 / (ThisLink->stepcount + 1); - if ((ThisLink->bits & LINK_LAMPS) && (g->width <= depth) && (g->width * 2 + 64 <= len)) + if ((ThisLink->bits & SLUMP_LINK_LAMPS) && (g->width <= depth) && (g->width * 2 + 64 <= len)) { add_lamps = SLUMP_TRUE; - announce(VERBOSE, "stair lamps"); + announce(SLUMP_VERBOSE, "stair lamps"); } stepdelta = ThisLink->floordelta / ThisLink->stepcount; if (ThisStyle->light_steps && ThisStyle->walllight) @@ -5983,17 +5992,17 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T ldnew1 = lefthand_box_ext(l, ldf1, depth, ThisStyle, c, &ldedge1, &ldedge2); if ((add_lamps) && (i & 0x01)) { - point_from(ldedge1->from->x, ldedge1->from->y, ldedge1->to->x, ldedge1->to->y, RIGHT_TURN, g->width / 2, - &x, &y); - point_from(ldedge1->to->x, ldedge1->to->y, x, y, RIGHT_TURN, depth / 2, &x, &y); + point_from(ldedge1->from->x, ldedge1->from->y, ldedge1->to->x, ldedge1->to->y, SLUMP_RIGHT_TURN, + g->width / 2, &x, &y); + point_from(ldedge1->to->x, ldedge1->to->y, x, y, SLUMP_RIGHT_TURN, depth / 2, &x, &y); new_thing(l, x, y, 0, g->thingid, 7, c); - point_from(ldedge2->from->x, ldedge2->from->y, ldedge2->to->x, ldedge2->to->y, RIGHT_TURN, g->width / 2, - &x, &y); - point_from(ldedge2->to->x, ldedge2->to->y, x, y, RIGHT_TURN, depth / 2, &x, &y); + point_from(ldedge2->from->x, ldedge2->from->y, ldedge2->to->x, ldedge2->to->y, SLUMP_RIGHT_TURN, + g->width / 2, &x, &y); + point_from(ldedge2->to->x, ldedge2->to->y, x, y, SLUMP_RIGHT_TURN, depth / 2, &x, &y); new_thing(l, x, y, 0, g->thingid, 7, c); } ldnew1->right->psector->floor_height = ldf1->right->psector->floor_height + stepdelta; - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) ldnew1->right->psector->ceiling_height = maxtop; else ldnew1->right->psector->ceiling_height = ldnew1->right->psector->floor_height + ThisLink->height1; @@ -6002,45 +6011,45 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T nearsec->ceiling_height - ldedge1->right->psector->ceiling_height; patch_upper(ldf1, t1, c); patch_lower(ldf1, front, c); - ldf1->flags &= ~LOWER_UNPEGGED; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; ldf1 = ldnew1; } /* end for each step */ /* The core-making step will do the top (bottom) (far) step */ } /* end if each steps */ /* If a core, need to make it */ - if (ThisLink->bits & LINK_CORE) + if (ThisLink->bits & SLUMP_LINK_CORE) { flip_linedef(ldf2); newsec = make_box_ext(l, ldf1, ldf2, ThisStyle, c, &ldedge1, &ldedge2); flip_linedef(ldf2); - if (ThisLink->bits & LINK_MAX_CEILING) + if (ThisLink->bits & SLUMP_LINK_MAX_CEILING) newsec->ceiling_height = maxtop; if (newsec->ceiling_height - ldf1->right->psector->floor_height < 64) newsec->ceiling_height = ldf1->right->psector->floor_height + 64; if (newsec->ceiling_height - ldf2->right->psector->floor_height < 64) newsec->ceiling_height = ldf2->right->psector->floor_height + 64; ldedge2->right->y_offset = ldedge1->right->y_offset = nearsec->ceiling_height - newsec->ceiling_height; - if ((ThisQuest != NULL) && (ThisLink->bits & LINK_LOCK_CORE)) + if ((ThisQuest != NULL) && (ThisLink->bits & SLUMP_LINK_LOCK_CORE)) { newsec->floor_flat = ThisStyle->nukage1; - newsec->special = NUKAGE1_SPECIAL; + newsec->special = SLUMP_NUKAGE1_SPECIAL; newsec->tag = ThisQuest->tag; newsec->floor_height -= 24 - roll(ThisLink->floordelta); if (newsec->light_level < 160) newsec->light_level = 160; /* Visible */ patch_lower(ldf1, ThisStyle->kickplate, c); /* Or stepfront? */ if (rollpercent(50)) - ldf2->flags |= BLOCK_MONSTERS; /* Can't decide! */ - haa->haas[ITYTD].health -= 10; - haa->haas[HMP].health -= 5; - announce(VERBOSE, "Nukage lock"); + ldf2->flags |= SLUMP_BLOCK_MONSTERS; /* Can't decide! */ + haa->haas[SLUMP_ITYTD].health -= 10; + haa->haas[SLUMP_HMP].health -= 5; + announce(SLUMP_VERBOSE, "Nukage lock"); } - else if (rollpercent(l->p_force_nukage) && !(ThisLink->bits & LINK_LIFT) && !(ThisLink->bits & LINK_STEPS) && - (ThisLink->depth3 >= 64) && (ThisLink->depth3 <= 196)) + else if (rollpercent(l->p_force_nukage) && !(ThisLink->bits & SLUMP_LINK_LIFT) && + !(ThisLink->bits & SLUMP_LINK_STEPS) && (ThisLink->depth3 >= 64) && (ThisLink->depth3 <= 196)) { newsec->floor_flat = ThisStyle->nukage1; - newsec->special = NUKAGE1_SPECIAL; + newsec->special = SLUMP_NUKAGE1_SPECIAL; if (ThisLink->floordelta < 0) { newsec->floor_height += ThisLink->floordelta; /* Fixed +- bug here */ @@ -6053,16 +6062,16 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (newsec->light_level < 160) newsec->light_level = 160; /* Visible */ patch_lower(ldf1, ThisStyle->kickplate, c); - haa->haas[ITYTD].health -= 10; - haa->haas[HMP].health -= 5; - announce(VERBOSE, "Nukage link"); + haa->haas[SLUMP_ITYTD].health -= 10; + haa->haas[SLUMP_HMP].health -= 5; + announce(SLUMP_VERBOSE, "Nukage link"); } - else if ((rollpercent(l->p_falling_core)) && (linelen(ldedge1) >= (120 * l->hugeness)) && - (!(ThisLink->bits & LINK_LIFT)) && (flipstate == 0)) + else if ((rollpercent(l->p_falling_core)) && (SLUMP_linelen(ldedge1) >= (120 * l->hugeness)) && + (!(ThisLink->bits & SLUMP_LINK_LIFT)) && (flipstate == 0)) { /* Maybe a fun trap */ try_falling_core(l, ldedge1, ldedge2, haa, c); } - ldf2->flags |= TWO_SIDED; + ldf2->flags |= SLUMP_TWO_SIDED; patch_upper(ldf1, t1, c); /* This is where the level-change actually happens, eh? */ @@ -6073,8 +6082,8 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* core, so that the second pass can make a decorative room. */ if (flipstate == 1) { - if ((!(ThisLink->bits & (LINK_LIFT | LINK_ALCOVE))) && (ThisLink->bits & LINK_DECROOM) && - (linelen(ldedge2) > 63)) + if ((!(ThisLink->bits & (SLUMP_LINK_LIFT | SLUMP_LINK_ALCOVE))) && (ThisLink->bits & SLUMP_LINK_DECROOM) && + (SLUMP_linelen(ldedge2) > 63)) { ThisLink->cld = ldedge2; } @@ -6089,19 +6098,19 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (rollpercent(10)) { if (make_window(l, ldedge1, ThisLink->cld, ThisLink, ThisStyle, NewStyle, c)) - announce(LOG, "Intertwin window"); + announce(SLUMP_LOG, "Intertwin window"); } else { if (make_decroom(l, ldedge1, ThisLink->cld, c)) - announce(LOG, "Intertwin decroom"); + announce(SLUMP_LOG, "Intertwin decroom"); } } } /* end if a core */ /* If the core is a lift, make that happen */ - if (ThisLink->bits & LINK_LIFT) + if (ThisLink->bits & SLUMP_LINK_LIFT) { if (trigger_lift) newsec->tag = tag1; @@ -6114,19 +6123,19 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T if (nearsec->floor_height > farsec->floor_height) { newsec->floor_height = nearsec->floor_height; - ldf1->type = LINEDEF_WR_LOWER_LIFT; + ldf1->type = SLUMP_LINEDEF_WR_LOWER_LIFT; ldf1->left->lower_texture = ThisStyle->support0; /* yes? */ if (!trigger_lift) ldf2->type = NewStyle->slifttype; patch_lower(ldf2, NewStyle->support0, c); if ((NewStyle->liftface) && (nearsec->floor_height - farsec->floor_height <= NewStyle->liftface->height) && - (linelen(ldf2) == NewStyle->liftface->width)) + (SLUMP_linelen(ldf2) == NewStyle->liftface->width)) { ldf2->right->lower_texture = NewStyle->liftface; ldf2->right->x_offset = 0; - announce(VERBOSE, "Lift texture"); + announce(SLUMP_VERBOSE, "Lift texture"); } - ldf2->flags &= ~LOWER_UNPEGGED; /* Lift-falling must be visible! */ + ldf2->flags &= ~SLUMP_LOWER_UNPEGGED; /* Lift-falling must be visible! */ } else { @@ -6136,14 +6145,14 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T patch_lower(ldf1, ThisStyle->support0, c); if ((ThisStyle->liftface) && (farsec->floor_height - nearsec->floor_height <= ThisStyle->liftface->height) && - (linelen(ldf1) == ThisStyle->liftface->width)) + (SLUMP_linelen(ldf1) == ThisStyle->liftface->width)) { ldf1->right->lower_texture = ThisStyle->liftface; ldf1->right->x_offset = 0; - announce(VERBOSE, "Lift texture"); + announce(SLUMP_VERBOSE, "Lift texture"); } - ldf1->flags &= ~LOWER_UNPEGGED; /* Lift-falling must be visible! */ - ldf2->type = LINEDEF_WR_LOWER_LIFT; + ldf1->flags &= ~SLUMP_LOWER_UNPEGGED; /* Lift-falling must be visible! */ + ldf2->type = SLUMP_LINEDEF_WR_LOWER_LIFT; ldf2->left->lower_texture = NewStyle->support0; /* right? */ } /* end else lift that way */ newsec->ceiling_height = newsec->floor_height + ThisLink->height1; @@ -6154,7 +6163,7 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T } /* end if doing a lift */ /* Maybe put a monster in the link */ - if ((haa != NULL) && (ThisLink->bits & LINK_CORE) && (rollpercent(40))) + if ((haa != NULL) && (ThisLink->bits & SLUMP_LINK_CORE) && (rollpercent(40))) { int levels; genus *m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 0); @@ -6165,25 +6174,25 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* Try to place it */ if (!rollpercent(l->p_rational_facing)) mangle = 90 * roll(4); - if (NULL != place_object_in_region(l, mminx, mminy, mmaxx, mmaxy, c, m->thingid, MONSTER_WIDTH(m), mangle, - 0, 0, levels)) + if (NULL != place_object_in_region(l, mminx, mminy, mmaxx, mmaxy, c, m->thingid, SLUMP_MONSTER_WIDTH(m), + mangle, 0, 0, levels)) { - if (m->thingid == ID_SKULL) - announce(NONE, "Skull"); - if (m->thingid == ID_HEAD) - announce(VERBOSE, "HEAD"); - if (m->thingid == ID_SKEL) - announce(VERBOSE, "SKEL"); - if (m->thingid == ID_HELL) - announce(VERBOSE, "KNIGHT"); - if (m->thingid == ID_ARCHIE) - announce(VERBOSE, "VILE"); + if (m->thingid == SLUMP_ID_SKULL) + announce(SLUMP_NONE, "Skull"); + if (m->thingid == SLUMP_ID_HEAD) + announce(SLUMP_VERBOSE, "HEAD"); + if (m->thingid == SLUMP_ID_SKEL) + announce(SLUMP_VERBOSE, "SKEL"); + if (m->thingid == SLUMP_ID_HELL) + announce(SLUMP_VERBOSE, "KNIGHT"); + if (m->thingid == SLUMP_ID_ARCHIE) + announce(SLUMP_VERBOSE, "VILE"); update_haa_for_monster(haa, m, levels, 0, c); haa_unpend(haa); - announce(VERBOSE, "Link guard"); + announce(SLUMP_VERBOSE, "Link guard"); } /* end if placed it */ } /* end if timely one */ } /* end if a monster */ @@ -6191,42 +6200,42 @@ void e_bl_inner(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink, quest *T /* Finally, if we have unmade doors, make 'em */ if (need_to_doorify) { - if (ThisLink->bits & LINK_NEAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_NEAR_DOOR) { flip_linedef(ldflip1b); doorify(sflip1, ldflip1a, ldflip1b, ThisStyle, ThisStyle, c); if (trigger_door) { - ldflip1a->type = LINEDEF_NORMAL; - ldflip1b->type = LINEDEF_NORMAL_DOOR; /* S1 door would break! */ + ldflip1a->type = SLUMP_LINEDEF_NORMAL; + ldflip1b->type = SLUMP_LINEDEF_NORMAL_DOOR; /* S1 door would break! */ sflip1->tag = tag1; } if (ThisQuest) { - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) { ldflip1a->type = type_for_key(ThisQuest->type); if (!painted_door) mark_door_for_key(l, ldflip1a, ThisQuest->type, ThisStyle, c); ldflip1b->type = type_for_key(ThisQuest->type); /* Prevent monsters! */ } - else if ((ThisQuest->goal == SWITCH_GOAL) && !(ThisLink->bits & LINK_LOCK_CORE)) + else if ((ThisQuest->goal == SLUMP_SWITCH_GOAL) && !(ThisLink->bits & SLUMP_LINK_LOCK_CORE)) { - ldflip1a->type = LINEDEF_NORMAL; - ldflip1b->type = (c->do_dm) ? LINEDEF_NORMAL_S1_DOOR : LINEDEF_NORMAL; + ldflip1a->type = SLUMP_LINEDEF_NORMAL; + ldflip1b->type = (c->do_dm) ? SLUMP_LINEDEF_NORMAL_S1_DOOR : SLUMP_LINEDEF_NORMAL; sflip1->tag = ThisQuest->tag; mark_door_for_lock(l, ldflip1a, ThisStyle, c); } /* end else if tag goal */ } /* end else if ThisQuest */ } - if (ThisLink->bits & LINK_FAR_DOOR) + if (ThisLink->bits & SLUMP_LINK_FAR_DOOR) { flip_linedef(ldflip2b); doorify(sflip2, ldflip2a, ldflip2b, NewStyle, NewStyle, c); if (trigger_door) { - ldflip2a->type = LINEDEF_NORMAL; - ldflip2b->type = LINEDEF_NORMAL_DOOR; /* S1 door would break! */ + ldflip2a->type = SLUMP_LINEDEF_NORMAL; + ldflip2b->type = SLUMP_LINEDEF_NORMAL_DOOR; /* S1 door would break! */ sflip2->tag = tag1; } } @@ -6246,9 +6255,9 @@ linedef *starting_linedef(level *l, style *ThisStyle, config *c) first_room_size = l->hugeness * 64 * (2 + roll(9)); /* We don't want rooms to be too small if we can have teleports on the level - SET */ - if (l->use_gates && first_room_size < TELEPORT_MINROOMSIZE) + if (l->use_gates && first_room_size < SLUMP_TELEPORT_MINROOMSIZE) { - first_room_size = TELEPORT_MINROOMSIZE; + first_room_size = SLUMP_TELEPORT_MINROOMSIZE; } v1 = new_vertex(l, 0, 0); /* Might as well */ /* Should consult the style/config? */ @@ -6288,7 +6297,7 @@ void point_from(int x1, int y1, int x2, int y2, int angle, int len, int *x3, int newdy = 1; } } - if (angle == LEFT_TURN) + if (angle == SLUMP_LEFT_TURN) { newdx = 0 - newdx; newdy = 0 - newdy; @@ -6303,21 +6312,21 @@ void announce(int announcelevel, const char *s) { switch (announcelevel) { - case NONE: + case SLUMP_NONE: return; - case VERBOSE: + case SLUMP_VERBOSE: if (global_verbosity == 0) return; /** fallthrough **/ - case LOG: + case SLUMP_LOG: break; - case NOTE: + case SLUMP_NOTE: printf("NOTE: "); break; - case WARNING: + case SLUMP_WARNING: printf("WARNING: "); break; case SLUMP_ERROR: - printf("SLUMP_ERROR: "); + printf("ERROR: "); break; default: printf("HEY: "); @@ -6341,9 +6350,9 @@ linedef *install_switch(level *l, linedef *ld, boolean recess, boolean fancy, sh if (fancy) { ThisStyle->lightboxes = SLUMP_TRUE; - announce(VERBOSE, "fancy switch"); + announce(SLUMP_VERBOSE, "fancy switch"); } - ld = borderize(l, ld, 64, SLUMP_TRUE, ThisStyle, LIGHT, NULL, NULL, c); + ld = borderize(l, ld, 64, SLUMP_TRUE, ThisStyle, SLUMP_LIGHT, NULL, NULL, c); if (xld) *xld = ld; ThisStyle->lightboxes = SLUMP_FALSE; @@ -6368,7 +6377,7 @@ linedef *install_switch(level *l, linedef *ld, boolean recess, boolean fancy, sh } else if ((ThisStyle->light_recesses) && (ThisStyle->walllight != NULL)) { - announce(VERBOSE, "Lit switch"); + announce(SLUMP_VERBOSE, "Lit switch"); ldedge2->right->middle_texture = ldedge1->right->middle_texture = ThisStyle->walllight; make_lighted(l, ld2->right->psector, c); } @@ -6383,7 +6392,7 @@ linedef *install_switch(level *l, linedef *ld, boolean recess, boolean fancy, sh ld->right->middle_texture = ThisStyle->switch0; ld->right->x_offset = 0; ld->right->y_offset = ThisStyle->switch0->y_bias; - ld->flags |= LOWER_UNPEGGED; + ld->flags |= SLUMP_LOWER_UNPEGGED; return ld; } @@ -6396,7 +6405,7 @@ boolean maybe_add_dm_start(level *l, sector *s, config *c, boolean force) return SLUMP_FALSE; if (s->has_dm && !force) return SLUMP_FALSE; - if (place_object(l, s, c, ID_DM, 34, -1, s->entry_x, s->entry_y, 7)) + if (place_object(l, s, c, SLUMP_ID_DM, 34, -1, s->entry_x, s->entry_y, 7)) { s->has_dm = SLUMP_TRUE; l->dm_count++; @@ -6404,12 +6413,12 @@ boolean maybe_add_dm_start(level *l, sector *s, config *c, boolean force) { if (l->heretic_level) { - if (place_object(l, s, c, ID_CROSSBOW, 24, 0, 0, 0, 0x17)) + if (place_object(l, s, c, SLUMP_ID_CROSSBOW, 24, 0, 0, 0, 0x17)) s->has_dm_weapon = SLUMP_TRUE; } else { - if (place_object(l, s, c, ID_SHOTGUN, 24, 0, 0, 0, 0x17)) + if (place_object(l, s, c, SLUMP_ID_SHOTGUN, 24, 0, 0, 0, 0x17)) s->has_dm_weapon = SLUMP_TRUE; } } @@ -6430,13 +6439,13 @@ void close_quest_final(level *l, sector *s, quest *q, haa *haa, config *c) if (t && (q->auxtag) && (q->surprise)) { - trigger_box(l, t, s, q->auxtag, LINEDEF_WR_OPEN_DOOR, c); + trigger_box(l, t, s, q->auxtag, SLUMP_LINEDEF_WR_OPEN_DOOR, c); populate_linedef(l, q->surprise, haa, c, SLUMP_FALSE); } /* If we've put in the SL exit, but not yet the thing that */ /* opens it, do one last try at that. */ - if ((q->goal == LEVEL_END_GOAL) && (l->sl_open_ok)) + if ((q->goal == SLUMP_LEVEL_END_GOAL) && (l->sl_open_ok)) { t = place_required_small_pickable(l, s, c); if (t) @@ -6444,13 +6453,13 @@ void close_quest_final(level *l, sector *s, quest *q, haa *haa, config *c) trigger_box(l, t, s, l->sl_tag, l->sl_type, c); l->sl_done = SLUMP_TRUE; l->sl_open_ok = SLUMP_FALSE; - announce(VERBOSE, "Did sl triggerbox"); + announce(SLUMP_VERBOSE, "Did sl triggerbox"); } } /* On the other hand, if we haven't even put in the SL exit yet, */ /* we're really desparate! */ - if (need_secret_level(c) && !l->sl_done && !l->sl_tag && q->goal == LEVEL_END_GOAL) + if (need_secret_level(c) && !l->sl_done && !l->sl_tag && q->goal == SLUMP_LEVEL_END_GOAL) { int i; linedef *ldf; @@ -6463,8 +6472,8 @@ void close_quest_final(level *l, sector *s, quest *q, haa *haa, config *c) ldf->right->middle_texture = ldf->right->middle_texture->subtle; else ldf->right->middle_texture = s->pstyle->support0; - ldf->type = LINEDEF_S1_SEC_LEVEL; - announce(LOG, "Last-ditch SL exit!"); + ldf->type = SLUMP_LINEDEF_S1_SEC_LEVEL; + announce(SLUMP_LOG, "Last-ditch SL exit!"); l->sl_done = SLUMP_TRUE; } } @@ -6484,7 +6493,7 @@ short death_room(level *l, linedef *ld, style *ThisStyle, config *c) ldnew = make_linkto(l, ld, gatelink, ThisStyle, c, NULL); if (ldnew == NULL) return 0; - for (; linelen(ldnew) < 320;) + for (; SLUMP_linelen(ldnew) < 320;) { ldnew->to->x = ldnew->from->x + 2 * (ldnew->to->x - ldnew->from->x); ldnew->to->y = ldnew->from->y + 2 * (ldnew->to->y - ldnew->from->y); @@ -6495,29 +6504,29 @@ short death_room(level *l, linedef *ld, style *ThisStyle, config *c) newsector->tag = new_tag(l); if (l->heretic_level) { - newsector->special = HERETIC_LAVA; + newsector->special = SLUMP_HERETIC_LAVA; } else { - newsector->special = DEATH_SECTOR; + newsector->special = SLUMP_DEATH_SECTOR; } newsector->light_level = 80; find_rec(l, newsector, &minx, &miny, &maxx, &maxy); - new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, (short)(90 * roll(4)), ID_GATEOUT, 7, c); + new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, (short)(90 * roll(4)), SLUMP_ID_GATEOUT, 7, c); /* Worry about having *too many* sergeants? */ for (x = minx + 22; x <= maxx - 22; x += 44) { if (l->heretic_level) { - new_thing(l, x, miny + 22, 90, ID_UNDEADWARRIOR, 7, c); - new_thing(l, x, maxy - 22, 270, ID_UNDEADWARRIOR, 7, c); + new_thing(l, x, miny + 22, 90, SLUMP_ID_UNDEADWARRIOR, 7, c); + new_thing(l, x, maxy - 22, 270, SLUMP_ID_UNDEADWARRIOR, 7, c); } else { - new_thing(l, x, miny + 22, 90, ID_SERGEANT, 7, c); - new_thing(l, x, maxy - 22, 270, ID_SERGEANT, 7, c); + new_thing(l, x, miny + 22, 90, SLUMP_ID_SERGEANT, 7, c); + new_thing(l, x, maxy - 22, 270, SLUMP_ID_SERGEANT, 7, c); } } @@ -6550,7 +6559,7 @@ void prepare_arena_gate(level *l, sector *s, arena *a, haa *haa, config *c) /* and stuff for the arena. */ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) { - int maxx = 0 - HUGE_NUMBER; + int maxx = 0 - SLUMP_HUGE_NUMBER; vertex *v, *v1, *v2, *v3, *v4; vertex *vt1, *vt2; int upness, acrossness, border, i, n; @@ -6571,7 +6580,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) maxx += 256; upness = 750 + roll(501); acrossness = 3 * upness; - if (a->props & ARENA_PORCH) + if (a->props & SLUMP_ARENA_PORCH) { border = 72 + 32 * roll(11); } @@ -6586,7 +6595,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) a->maxy = upness / 2; /* Make the outer walls */ - if (a->props & ARENA_PORCH) + if (a->props & SLUMP_ARENA_PORCH) { /* Flat with promenade */ newsec->ceiling_flat = newsec->pstyle->ceiling0; @@ -6611,7 +6620,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) ld->right = new_sidedef(l, newsec, c); ld->right->middle_texture = a->walls; - if (a->props & ARENA_LAMPS) + if (a->props & SLUMP_ARENA_LAMPS) { lamp = newsec->pstyle->lamp0; if (lamp->height >= ch) @@ -6693,7 +6702,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) newsec = new_sector(l, 0, ch, a->floor, c->sky_flat); newsec->light_level = a->outersec->light_level; newsec->pstyle = s->pstyle; - if (a->props & ARENA_ROOF) + if (a->props & SLUMP_ARENA_ROOF) { newsec->ceiling_flat = newsec->pstyle->ceiling0; a->outersec->ceiling_flat = newsec->pstyle->ceiling0; @@ -6705,27 +6714,27 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) } /* Some sector adjustments... */ - if (rollpercent(30) && (a->props & ARENA_PORCH)) + if (rollpercent(30) && (a->props & SLUMP_ARENA_PORCH)) { flat *light_flat; - a->outersec->special = RANDOM_BLINK; + a->outersec->special = SLUMP_RANDOM_BLINK; a->outersec->light_level += 20; if (a->outersec->light_level > l->bright_light_level) a->outersec->light_level = l->bright_light_level; - light_flat = random_flat0(CEILING | LIGHT, c, NULL); + light_flat = random_flat0(SLUMP_CEILING | SLUMP_LIGHT, c, NULL); if (light_flat) a->outersec->ceiling_flat = light_flat; } - if (a->props & ARENA_NUKAGE) + if (a->props & SLUMP_ARENA_NUKAGE) { a->outersec->floor_height -= 8; - if (a->props & ARENA_PORCH) + if (a->props & SLUMP_ARENA_PORCH) a->outersec->ceiling_height -= 8; a->outersec->floor_flat = a->outersec->pstyle->nukage1; - a->outersec->special = NUKAGE1_SPECIAL; + a->outersec->special = SLUMP_NUKAGE1_SPECIAL; } - else if ((a->props & ARENA_PORCH) && rollpercent(50)) + else if ((a->props & SLUMP_ARENA_PORCH) && rollpercent(50)) { short d = 8 + 8 * roll(3); a->outersec->floor_height += d; @@ -6740,7 +6749,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) v4 = new_vertex(l, a->maxx, a->miny); ld = new_linedef(l, v1, v2); - ld->flags |= TWO_SIDED; + ld->flags |= SLUMP_TWO_SIDED; ld->right = new_sidedef(l, newsec, c); ld->right->middle_texture = c->null_texture; ld->left = new_sidedef(l, a->outersec, c); @@ -6749,7 +6758,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) patch_lower(ld, a->walls, c); ld = new_linedef(l, v2, v3); - ld->flags |= TWO_SIDED; + ld->flags |= SLUMP_TWO_SIDED; ld->right = new_sidedef(l, newsec, c); ld->right->middle_texture = c->null_texture; ld->left = new_sidedef(l, a->outersec, c); @@ -6758,7 +6767,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) patch_lower(ld, a->walls, c); ld = new_linedef(l, v3, v4); - ld->flags |= TWO_SIDED; + ld->flags |= SLUMP_TWO_SIDED; ld->right = new_sidedef(l, newsec, c); ld->right->middle_texture = c->null_texture; ld->left = new_sidedef(l, a->outersec, c); @@ -6767,7 +6776,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) patch_lower(ld, a->walls, c); ld = new_linedef(l, v4, v1); - ld->flags |= TWO_SIDED; + ld->flags |= SLUMP_TWO_SIDED; ld->right = new_sidedef(l, newsec, c); ld->right->middle_texture = c->null_texture; ld->left = new_sidedef(l, a->outersec, c); @@ -6775,7 +6784,7 @@ void install_arena(level *l, arena *a, sector *s, haa *haa, config *c) patch_upper(ld, a->walls, c); patch_lower(ld, a->walls, c); - if ((a->props & ARENA_LAMPS) && (!(a->props & ARENA_PORCH))) + if ((a->props & SLUMP_ARENA_LAMPS) && (!(a->props & SLUMP_ARENA_PORCH))) { lamp = newsec->pstyle->lamp0; if (lamp->height >= ch) @@ -6806,13 +6815,13 @@ void arena_arrival(level *l, arena *a, haa *haa, config *c) cy = (a->miny + a->maxy) / 2; /* a simple version */ - new_thing(l, cx, cy, (short)(90 * roll(4)), ID_GATEOUT, 7, c); + new_thing(l, cx, cy, (short)(90 * roll(4)), SLUMP_ID_GATEOUT, 7, c); a->innersec->tag = a->fromtag; a->innersec->entry_x = cx; a->innersec->entry_y = cy; /* except for this */ - if (a->props & ARENA_ARRIVAL_HOLE) + if (a->props & SLUMP_ARENA_ARRIVAL_HOLE) { linedef *ld1, *ld2, *ld3, *ld4; newsec = clone_sector(l, a->innersec); @@ -6827,13 +6836,13 @@ void arena_arrival(level *l, arena *a, haa *haa, config *c) flip_linedef(ld2); flip_linedef(ld3); flip_linedef(ld4); - ld1->type = LINEDEF_S1_RAISE_FLOOR; + ld1->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld1->tag = newsec->tag; - ld2->type = LINEDEF_S1_RAISE_FLOOR; + ld2->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld2->tag = newsec->tag; - ld3->type = LINEDEF_S1_RAISE_FLOOR; + ld3->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld3->tag = newsec->tag; - ld4->type = LINEDEF_S1_RAISE_FLOOR; + ld4->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld4->tag = newsec->tag; } @@ -6841,7 +6850,7 @@ void arena_arrival(level *l, arena *a, haa *haa, config *c) if (!place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, a->weapon->thingid, 24, 0, 0, 0, 7)) if (!place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, a->weapon->thingid, 1, 0, 0, 0, 7)) announce(SLUMP_ERROR, "No room for important weapon!"); - place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, ID_SOUL, 24, 0, 0, 0, 1); + place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, SLUMP_ID_SOUL, 24, 0, 0, 0, 1); ammo_value(a->weapon->thingid, haa, &f0, &f1, &f2); na0 = (a->boss_count * a->boss->ammo_to_kill[0]) - (float)f0; na1 = (a->boss_count * a->boss->ammo_to_kill[1]) - (float)f1; @@ -6862,15 +6871,15 @@ void arena_arrival(level *l, arena *a, haa *haa, config *c) if (na2 <= 0) mask &= ~0x04; } - if (a->props & ARENA_NUKAGE) + if (a->props & SLUMP_ARENA_NUKAGE) { /* Little stub health */ if (l->heretic_level) { - place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, ID_QUARTZFLASK, 16, 0, 0, 0, 7); + place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, SLUMP_ID_QUARTZFLASK, 16, 0, 0, 0, 7); } else { - place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, ID_MEDIKIT, 16, 0, 0, 0, 7); + place_object_in_region(l, minx, a->miny, maxx, a->maxy, c, SLUMP_ID_MEDIKIT, 16, 0, 0, 0, 7); } } } @@ -6907,7 +6916,7 @@ void arena_decor(level *l, arena *a, haa *haa, config *c) newsec->floor_height = (short)(a->innersec->floor_height + zmult * 128); cx = (a->minx + a->maxx) / 2 - 64 * xmult; cy = (a->miny + a->maxy) / 2 - 64 * ymult; - if ((a->innersec->pstyle->plaque->props & VTILES) || (zmult == 1)) + if ((a->innersec->pstyle->plaque->props & SLUMP_VTILES) || (zmult == 1)) { tm = a->innersec->pstyle->plaque; } @@ -6917,11 +6926,11 @@ void arena_decor(level *l, arena *a, haa *haa, config *c) } parallel_innersec_ex(l, a->innersec, newsec, c->null_texture, a->innersec->pstyle->wall0, tm, cx, cy, cx + 128 * xmult, cy + 128 * ymult, c, &ld1, &ld2, &ld3, &ld4); - ld1->flags &= ~LOWER_UNPEGGED; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->flags &= ~LOWER_UNPEGGED; - if ((a->props & ARENA_LAMPS) && rollpercent(50)) + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; + if ((a->props & SLUMP_ARENA_LAMPS) && rollpercent(50)) { genus *lamp; lamp = a->innersec->pstyle->lamp0; @@ -6959,7 +6968,7 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) if (a->boss_count > 1) /* Only 1 and 2 supported! */ new_thing(l, cx, cy - (a->boss->width + 8), facing, a->boss->thingid, 7, c); - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { if (c->mission == 8) { @@ -6974,18 +6983,18 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) random_gate(c, a->innersec->pstyle), a->innersec->ceiling_flat); newsec->pstyle = a->innersec->pstyle; newsec->light_level = 250; - newsec->special = GLOW_BLINK; + newsec->special = SLUMP_GLOW_BLINK; newsec->tag = 666; parallel_innersec_ex(l, a->innersec, newsec, NULL, NULL, a->innersec->pstyle->wall0, cx, cy, cx + 64, cy + 64, c, &ld1, &ld2, &ld3, &ld4); - ld1->type = LINEDEF_W1_END_LEVEL; - ld1->flags &= ~LOWER_UNPEGGED; - ld2->type = LINEDEF_W1_END_LEVEL; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->type = LINEDEF_W1_END_LEVEL; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->type = LINEDEF_W1_END_LEVEL; - ld4->flags &= ~LOWER_UNPEGGED; + ld1->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; } } else @@ -7007,18 +7016,18 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) random_gate(c, a->innersec->pstyle), a->innersec->ceiling_flat); newsec->pstyle = a->innersec->pstyle; newsec->light_level = 250; - newsec->special = GLOW_BLINK; + newsec->special = SLUMP_GLOW_BLINK; newsec->tag = 666; parallel_innersec_ex(l, a->innersec, newsec, NULL, NULL, a->innersec->pstyle->wall0, cx, cy, cx + 64, cy + 64, c, &ld1, &ld2, &ld3, &ld4); - ld1->type = LINEDEF_W1_END_LEVEL; - ld1->flags &= ~LOWER_UNPEGGED; - ld2->type = LINEDEF_W1_END_LEVEL; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->type = LINEDEF_W1_END_LEVEL; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->type = LINEDEF_W1_END_LEVEL; - ld4->flags &= ~LOWER_UNPEGGED; + ld1->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->type = SLUMP_LINEDEF_W1_END_LEVEL; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; } if ((c->episode == 1) && (c->mission == 8)) { @@ -7036,22 +7045,22 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) random_gate(c, a->innersec->pstyle), a->innersec->ceiling_flat); newsec->pstyle = a->innersec->pstyle; newsec->light_level = 250; - newsec->special = GLOW_BLINK; + newsec->special = SLUMP_GLOW_BLINK; newsec->tag = 666; parallel_innersec_ex(l, a->innersec, newsec, NULL, NULL, a->innersec->pstyle->wall0, cx, cy, cx + 64, cy + 64, c, &ld1, &ld2, &ld3, &ld4); - ld1->type = LINEDEF_TELEPORT; + ld1->type = SLUMP_LINEDEF_TELEPORT; ld1->tag = tag; - ld1->flags &= ~LOWER_UNPEGGED; - ld2->type = LINEDEF_TELEPORT; + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->type = SLUMP_LINEDEF_TELEPORT; ld2->tag = tag; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->type = LINEDEF_TELEPORT; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->type = SLUMP_LINEDEF_TELEPORT; ld3->tag = tag; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->type = LINEDEF_TELEPORT; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->type = SLUMP_LINEDEF_TELEPORT; ld4->tag = tag; - ld4->flags &= ~LOWER_UNPEGGED; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; } } } @@ -7070,8 +7079,8 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) a->outersec->marked = 1; ld = install_switch(l, ld, SLUMP_TRUE, SLUMP_FALSE, 0, a->innersec->pstyle, c, NULL); a->outersec->marked = 0; - ld->type = LINEDEF_S1_END_LEVEL; - tm = random_texture0(EXITSWITCH, c, a->innersec->pstyle); + ld->type = SLUMP_LINEDEF_S1_END_LEVEL; + tm = random_texture0(SLUMP_EXITSWITCH, c, a->innersec->pstyle); if (tm) { ld->right->middle_texture = tm; @@ -7083,7 +7092,7 @@ void arena_boss(level *l, arena *a, haa *haa, config *c) } /* Gate out to a big place to fight bosses. */ -/* NOTE: this renders the haa invalid at the moment, and so can only */ +/* SLUMP_NOTE: this renders the haa invalid at the moment, and so can only */ /* be used in an Episode 8, or the end of a PWAD. */ void arena_gate(level *l, sector *s, haa *haa, config *c) { @@ -7107,7 +7116,7 @@ void arena_gate(level *l, sector *s, haa *haa, config *c) arena_boss(l, ThisArena, haa, c); /* and we're done */ - announce(VERBOSE, "Arena"); + announce(SLUMP_VERBOSE, "Arena"); return; } @@ -7121,10 +7130,10 @@ boolean rising_room(level *l, sector *s, config *c, haa *haa, quest *ThisQuest) boolean did_trigger = SLUMP_FALSE; linedef *ld1, *ld2, *ld3, *ld4; thing *t; - short tid = rollpercent(50) ? ID_POTION : ID_HELMET; + short tid = rollpercent(50) ? SLUMP_ID_POTION : SLUMP_ID_HELMET; if (l->heretic_level) { - tid = rollpercent(50) ? ID_WANDCRYSTAL : ID_ETHEREALARROWS; + tid = rollpercent(50) ? SLUMP_ID_WANDCRYSTAL : SLUMP_ID_ETHEREALARROWS; } if (s->pgate) @@ -7166,42 +7175,42 @@ boolean rising_room(level *l, sector *s, config *c, haa *haa, quest *ThisQuest) flip_linedef(ld3); flip_linedef(ld4); - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) { t = new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 0, ThisQuest->type, 7, c); ThisQuest->pthing = t; /* For later */ if (ThisQuest->auxtag == 0) - if (!(c->gamemask & (DOOM0_BIT | HERETIC_BIT))) + if (!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT))) if (rollpercent(80)) { did_trigger = SLUMP_TRUE; - trigger_box(l, t, newsec, newsec->tag, LINEDEF_W1_RAISE_FLOOR, c); - announce(VERBOSE, "Zlooty"); + trigger_box(l, t, newsec, newsec->tag, SLUMP_LINEDEF_W1_RAISE_FLOOR, c); + announce(SLUMP_VERBOSE, "Zlooty"); } } - if (ThisQuest->goal == NULL_GOAL) + if (ThisQuest->goal == SLUMP_NULL_GOAL) { ThisQuest->pthing = place_required_small_pickable(l, newsec, c); if (ThisQuest->auxtag == 0) - if (!(c->gamemask & (DOOM0_BIT | HERETIC_BIT))) + if (!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT))) if (rollpercent(50)) { t = new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 0, tid, 7, c); did_trigger = SLUMP_TRUE; - trigger_box(l, t, newsec, newsec->tag, LINEDEF_W1_RAISE_FLOOR, c); + trigger_box(l, t, newsec, newsec->tag, SLUMP_LINEDEF_W1_RAISE_FLOOR, c); } } if (!did_trigger) { - ld1->type = LINEDEF_S1_RAISE_FLOOR; + ld1->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld1->tag = newsec->tag; - ld2->type = LINEDEF_S1_RAISE_FLOOR; + ld2->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld2->tag = newsec->tag; - ld3->type = LINEDEF_S1_RAISE_FLOOR; + ld3->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld3->tag = newsec->tag; - ld4->type = LINEDEF_S1_RAISE_FLOOR; + ld4->type = SLUMP_LINEDEF_S1_RAISE_FLOOR; ld4->tag = newsec->tag; } @@ -7221,10 +7230,10 @@ boolean rising_room(level *l, sector *s, config *c, haa *haa, quest *ThisQuest) if (rollpercent(20)) { newsec->floor_flat = c->water_flat; /* Eli's idea */ - announce(VERBOSE, "Water"); + announce(SLUMP_VERBOSE, "Water"); } - announce(VERBOSE, "Rising room"); + announce(SLUMP_VERBOSE, "Rising room"); return SLUMP_TRUE; } @@ -7242,7 +7251,7 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) switch (q->goal) { - case SWITCH_GOAL: + case SLUMP_SWITCH_GOAL: /* Could decide to use a walkthrough linedef or whatever */ /* instead of a switch for a tag goal. */ i = mark_decent_boundary_linedefs(l, s, 64); @@ -7262,7 +7271,7 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) t = place_required_small_pickable(l, s, c); q->pthing = t; /* For later */ break; - case LEVEL_END_GOAL: + case SLUMP_LEVEL_END_GOAL: /* Just alter some non-tiny boundary linedef to be a switch, */ /* and try to make it obvious via some light stuff. Or, */ /* sometimes, do the floor-hole thing, or a gate, or... */ @@ -7284,7 +7293,7 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) { /* Try a fun thing! */ if (e1m8_gate(l, ld, s, haa, c)) { - announce(VERBOSE, "e1m8 finale"); + announce(SLUMP_VERBOSE, "e1m8 finale"); break; } } @@ -7292,15 +7301,15 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) { /* Try a floor-hole */ if (empty_left_side(l, ld, 128)) { /* 128? Hugeness? */ - if (linelen(ld) > 192) + if (SLUMP_linelen(ld) > 192) split_linedef(l, ld, 128, c); - lefthand_box(l, ld, 128, s->pstyle, c)->right->middle_texture = s->pstyle->wall0; - ld->type = LINEDEF_W1_END_LEVEL; + SLUMP_lefthand_box(l, ld, 128, s->pstyle, c)->right->middle_texture = s->pstyle->wall0; + ld->type = SLUMP_LINEDEF_W1_END_LEVEL; if (ld->left->psector->light_level < 160) ld->left->psector->light_level = 160; ld->left->psector->floor_flat = c->sky_flat; ld->left->psector->floor_height -= 16; - announce(VERBOSE, "Hole ends level"); + announce(SLUMP_VERBOSE, "Hole ends level"); done = SLUMP_TRUE; } } @@ -7313,7 +7322,7 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) s->middle_enhanced = SLUMP_TRUE; if (s->light_level > 130) s->light_level = 130; /* To see "EXIT" */ - announce(VERBOSE, "Gate ends level"); + announce(SLUMP_VERBOSE, "Gate ends level"); done = SLUMP_TRUE; } /* Switch with recess, sometimes fancied-up */ @@ -7322,17 +7331,17 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) ld = install_switch(l, ld, SLUMP_TRUE, rollpercent(10), 0, s->pstyle, c, NULL); ld->type = q->type; ld->tag = q->tag; /* Will be zero, actually */ - ld->right->psector->special = GLOW_BLINK; + ld->right->psector->special = SLUMP_GLOW_BLINK; if (s->light_level > 190) s->light_level = 190; /* So the glow shows */ ld->right->psector->light_level = 255; done = SLUMP_TRUE; - tm = random_texture0(EXITSWITCH, c, s->pstyle); + tm = random_texture0(SLUMP_EXITSWITCH, c, s->pstyle); if (tm) { ld->right->middle_texture = tm; ld->right->y_offset = tm->y_bias; - announce(VERBOSE, "Custom exit switch"); + announce(SLUMP_VERBOSE, "Custom exit switch"); } } if (need_secret_level(c) && !l->sl_done && !l->sl_tag) @@ -7342,15 +7351,15 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) } } break; - case ARENA_GOAL: + case SLUMP_ARENA_GOAL: /* A teleporter to a big arena in which to fight bosses */ arena_gate(l, s, haa, c); break; - case GATE_GOAL: + case SLUMP_GATE_GOAL: /* A teleporter to, and perhaps from, the goal room. */ s->pgate = new_gate(l, q->tag2, q->tag, 0, SLUMP_FALSE, c); break; - case KEY_GOAL: + case SLUMP_KEY_GOAL: if (rollpercent(l->p_rising_room)) { done = rising_room(l, s, c, haa, q); @@ -7361,7 +7370,7 @@ void close_quest(level *l, sector *s, quest *q, haa *haa, config *c) q->pthing = t; /* For later */ } break; - case NULL_GOAL: + case SLUMP_NULL_GOAL: if (rollpercent(2 * l->p_rising_room)) { done = rising_room(l, s, c, haa, q); @@ -7390,7 +7399,7 @@ void maybe_push_quest(level *l, sector *s, quest *q, config *c) if (!rollpercent(c->p_pushquest)) return; /* Do we want to? */ - if (q->goal != SWITCH_GOAL) + if (q->goal != SLUMP_SWITCH_GOAL) return; /* Do we know how? */ newkey = new_key(l); /* Get an unused key */ @@ -7415,12 +7424,12 @@ void maybe_push_quest(level *l, sector *s, quest *q, config *c) ld->tag = q->tag; /* Now modify the quest */ - q->goal = KEY_GOAL; + q->goal = SLUMP_KEY_GOAL; q->type = newkey; q->tag = 0; /* and we're done... */ - announce(LOG, "Quest push"); + announce(SLUMP_LOG, "Quest push"); return; } @@ -7435,45 +7444,45 @@ linedef *make_linkto(level *l, linedef *ld, link *ThisLink, style *ThisStyle, co switch (ThisLink->type) { - case BASIC_LINK: + case SLUMP_BASIC_LINK: depth = 0; /* Account for any recesses */ - if (ThisLink->bits & LINK_RECESS) + if (ThisLink->bits & SLUMP_LINK_RECESS) depth += 2 * ThisLink->depth2; /* Account for single door/arch, if any */ - if (!(ThisLink->bits & (LINK_CORE | LINK_ALCOVE))) + if (!(ThisLink->bits & (SLUMP_LINK_CORE | SLUMP_LINK_ALCOVE))) depth += ThisLink->depth1; /* Account for double doors around the core, if any */ - if (((ThisLink->bits & LINK_CORE)) && (ThisLink->bits & LINK_NEAR_DOOR)) + if (((ThisLink->bits & SLUMP_LINK_CORE)) && (ThisLink->bits & SLUMP_LINK_NEAR_DOOR)) depth += ThisLink->depth1; - if (((ThisLink->bits & LINK_CORE)) && (ThisLink->bits & LINK_FAR_DOOR)) + if (((ThisLink->bits & SLUMP_LINK_CORE)) && (ThisLink->bits & SLUMP_LINK_FAR_DOOR)) depth += ThisLink->depth1; /* Alcove width */ - if (ThisLink->bits & LINK_ALCOVE) + if (ThisLink->bits & SLUMP_LINK_ALCOVE) { depth += ThisLink->width2; } else { /* Straight-through core */ - if (ThisLink->bits & LINK_CORE) + if (ThisLink->bits & SLUMP_LINK_CORE) depth += ThisLink->depth3; } break; - case OPEN_LINK: + case SLUMP_OPEN_LINK: depth = ThisLink->depth1; break; - case GATE_LINK: { + case SLUMP_GATE_LINK: { linedef *ldnew; vertex *v, *v1; int newsize; - int minx = HUGE_NUMBER; + int minx = SLUMP_HUGE_NUMBER; for (v = l->vertex_anchor; v; v = v->next) if (v->x < minx) minx = v->x; minx -= 64; if (ld) { - newsize = linelen(ld); + newsize = SLUMP_linelen(ld); } else { @@ -7511,7 +7520,7 @@ boolean link_fitsv(level *l, linedef *ldf1, linedef *ldf2, link *ThisLink) { boolean answer; - if (ThisLink->type == GATE_LINK) + if (ThisLink->type == SLUMP_GATE_LINK) return SLUMP_TRUE; /* These don't care */ ldf1->from->marked = SLUMP_TRUE; @@ -7586,7 +7595,7 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t int x1, y1, x2, y2, len1, len2; /* Very simple squarish rooms */ - len1 = linelen(ld); + len1 = SLUMP_linelen(ld); if (roll(2)) { len2 = len1; @@ -7605,9 +7614,9 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t } /* We need to make rooms bigger on levels with teleports - SET */ - if (l->use_gates && len2 < TELEPORT_MINROOMSIZE) + if (l->use_gates && len2 < SLUMP_TELEPORT_MINROOMSIZE) { - len2 = TELEPORT_MINROOMSIZE; + len2 = SLUMP_TELEPORT_MINROOMSIZE; } /* Bigify. */ @@ -7618,8 +7627,8 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t for (;;) { /* Until we find one that fits */ - point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, RIGHT_TURN, len2, &x1, &y1); - point_from(ld->to->x, ld->to->y, x1, y1, RIGHT_TURN, len1, &x2, &y2); + point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, SLUMP_RIGHT_TURN, len2, &x1, &y1); + point_from(ld->to->x, ld->to->y, x1, y1, SLUMP_RIGHT_TURN, len1, &x2, &y2); ld->from->marked = 1; ld->to->marked = 1; if (empty_rectangle(l, ld->from->x, ld->from->y, ld->to->x, ld->to->y, x1, y1, x2, y2)) @@ -7629,7 +7638,7 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t len2 -= 32; /* If failed, try again with smaller room */ if (len2 < (l->hugeness * 64)) { - announce(VERBOSE, "No possible rectangle fits in the space."); + announce(SLUMP_VERBOSE, "No possible rectangle fits in the space."); ld->to->marked = 0; ld->from->marked = 0; return NULL; @@ -7644,7 +7653,7 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t char s[200]; sprintf(s, "New room, corners (%d %d) (%d %d) (%d %d) (%d %d).", ld->from->x, ld->from->y, ld->to->x, ld->to->y, x1, y1, x2, y2); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } answer = new_sector(l, 0, ThisStyle->wallheight0, ThisStyle->floor0, ThisStyle->ceiling0); @@ -7658,25 +7667,25 @@ sector *generate_room_outline(level *l, linedef *ld, style *ThisStyle, boolean t newld->right = new_sidedef(l, answer, c); /* If the wall is long, sometimes split it, for more outlinks */ /* Should use styles here and stuff too (and config) */ - if (linelen(newld) > (l->hugeness * 256)) + if (SLUMP_linelen(newld) > (l->hugeness * 256)) if (rollpercent(25)) - split_linedef(l, newld, linelen(newld) / 2, c); + split_linedef(l, newld, SLUMP_linelen(newld) / 2, c); v1 = v2; v2 = new_vertex(l, x2, y2); newld = new_linedef(l, v1, v2); newld->right = new_sidedef(l, answer, c); - if (linelen(newld) > (l->hugeness * 256)) + if (SLUMP_linelen(newld) > (l->hugeness * 256)) if (rollpercent(25)) - split_linedef(l, newld, linelen(newld) / 2, c); + split_linedef(l, newld, SLUMP_linelen(newld) / 2, c); v1 = v2; v2 = ld->from; newld = new_linedef(l, v1, v2); newld->right = new_sidedef(l, answer, c); - if (linelen(newld) > (l->hugeness * 256)) + if (SLUMP_linelen(newld) > (l->hugeness * 256)) if (rollpercent(25)) - split_linedef(l, newld, linelen(newld) / 2, c); + split_linedef(l, newld, SLUMP_linelen(newld) / 2, c); return answer; } @@ -7690,19 +7699,19 @@ link *random_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQuest, con boolean open_ok = SLUMP_TRUE; if (ld) - if (linelen(ld) < 100) + if (SLUMP_linelen(ld) < 100) open_ok = SLUMP_FALSE; if (ThisQuest) - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) open_ok = SLUMP_FALSE; if (l->use_gates) if (ThisQuest) if (rollpercent(20)) /* Should vary */ - if (ThisQuest->goal == SWITCH_GOAL) + if (ThisQuest->goal == SLUMP_SWITCH_GOAL) if (!(ld->right->psector->pgate)) if (ld->right->psector != l->first_room) - if (linelen(ld) > 1000) + if (SLUMP_linelen(ld) > 1000) if (ok_to_block_mid_tile(l, ld->right->psector)) if (!(c->do_dm)) return gate_link(l, c); /* Already in link_anchor */ @@ -7732,23 +7741,23 @@ link *random_open_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQuest link *answer = (link *)malloc(sizeof(*answer)); answer->bits = 0; - answer->type = OPEN_LINK; + answer->type = SLUMP_OPEN_LINK; if ((ThisQuest == NULL) && rollpercent(40)) { /* 40 should vary */ - answer->bits |= LINK_LIFT; + answer->bits |= SLUMP_LINK_LIFT; } else { - answer->bits |= LINK_STEPS; + answer->bits |= SLUMP_LINK_STEPS; if (rollpercent(30)) - answer->bits |= LINK_ALCOVE; /* sidesteps */ + answer->bits |= SLUMP_LINK_ALCOVE; /* sidesteps */ if (rollpercent(50)) - answer->bits |= LINK_LEFT; + answer->bits |= SLUMP_LINK_LEFT; } if (ld) - len = linelen(ld); + len = SLUMP_linelen(ld); /* Primary width; need more variety! */ dieroll = roll(100); @@ -7772,11 +7781,11 @@ link *random_open_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQuest /* We must have a minimum room size for levels which can have teleports - SET */ - if (l->use_gates && answer->width1 < TELEPORT_MINROOMSIZE) + if (l->use_gates && answer->width1 < SLUMP_TELEPORT_MINROOMSIZE) { - if (len > TELEPORT_MINROOMSIZE) + if (len > SLUMP_TELEPORT_MINROOMSIZE) { - answer->width1 = TELEPORT_MINROOMSIZE; + answer->width1 = SLUMP_TELEPORT_MINROOMSIZE; } else { @@ -7785,16 +7794,16 @@ link *random_open_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQuest } /* Primary depth */ - if (answer->bits & LINK_LIFT) + if (answer->bits & SLUMP_LINK_LIFT) { answer->depth1 = l->hugeness * 32 * (1 + roll(5)); } else { - if ((answer->bits & LINK_ALCOVE) && rollpercent(50)) + if ((answer->bits & SLUMP_LINK_ALCOVE) && rollpercent(50)) { answer->depth1 = l->hugeness * 32 * (1 + roll(4)); - announce(VERBOSE, "Narrow side-steps?"); + announce(SLUMP_VERBOSE, "Narrow side-steps?"); } else { @@ -7823,21 +7832,21 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues boolean nukage_core_trap = SLUMP_FALSE; if (ld) - len = linelen(ld); + len = SLUMP_linelen(ld); answer = (link *)malloc(sizeof(*answer)); /* Should use style and config more here and there */ - answer->type = BASIC_LINK; + answer->type = SLUMP_BASIC_LINK; answer->bits = 0; if (ThisQuest) { - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) need_door = SLUMP_TRUE; /* So far the only tags we know of are door-opens and nukage traps */ - if (ThisQuest->goal == SWITCH_GOAL) + if (ThisQuest->goal == SLUMP_SWITCH_GOAL) if (rollpercent(30) || rollpercent(l->p_force_nukage)) /* Huh? */ need_door = SLUMP_TRUE; else @@ -7901,11 +7910,11 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues /* We must have a minimum room size for levels which can have teleports - SET */ - if (l->use_gates && answer->width1 < TELEPORT_MINROOMSIZE) + if (l->use_gates && answer->width1 < SLUMP_TELEPORT_MINROOMSIZE) { - if (len > TELEPORT_MINROOMSIZE) + if (len > SLUMP_TELEPORT_MINROOMSIZE) { - answer->width1 = TELEPORT_MINROOMSIZE; + answer->width1 = SLUMP_TELEPORT_MINROOMSIZE; } else { @@ -7960,7 +7969,7 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues dieroll = roll(100); if (dieroll < 20) { /* Nice recessed door */ - answer->bits = LINK_ANY_DOOR | LINK_RECESS; + answer->bits = SLUMP_LINK_ANY_DOOR | SLUMP_LINK_RECESS; } else if (dieroll < 65) { /* Nice arch */ @@ -7968,7 +7977,7 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues } else { /* Simple stairs */ - answer->bits = LINK_CORE | LINK_STEPS; + answer->bits = SLUMP_LINK_CORE | SLUMP_LINK_STEPS; answer->depth3 *= 3; answer->floordelta = answer->stepcount * (2 + roll(20)); } @@ -7977,52 +7986,52 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues { /* Make something up */ answer->bits = 0; if (roll(2)) - answer->bits |= LINK_RECESS; + answer->bits |= SLUMP_LINK_RECESS; if (rollpercent(40)) { if (rollpercent(40) || c->both_doors) { - answer->bits |= LINK_ANY_DOOR; + answer->bits |= SLUMP_LINK_ANY_DOOR; } else if (rollpercent(30)) { - answer->bits |= LINK_NEAR_DOOR; + answer->bits |= SLUMP_LINK_NEAR_DOOR; } else { - answer->bits |= LINK_FAR_DOOR; + answer->bits |= SLUMP_LINK_FAR_DOOR; } } if (rollpercent(10)) - answer->bits |= LINK_BARS; + answer->bits |= SLUMP_LINK_BARS; if (answer->width1 != 0) /* Twinning a full-wall link is ugly */ if ((!ld) || ((len / 2 - 16) > answer->width1)) if (rollpercent(30)) { - answer->bits |= LINK_TWIN; + answer->bits |= SLUMP_LINK_TWIN; if (rollpercent(60)) - answer->bits |= LINK_WINDOW; + answer->bits |= SLUMP_LINK_WINDOW; } if (rollpercent(30)) - answer->bits |= LINK_ALCOVE; + answer->bits |= SLUMP_LINK_ALCOVE; if ((ld) && ((len / 2 - 16) < answer->width1)) - answer->bits &= ~LINK_ALCOVE; - if ((ld) && ((len / 4 - 32) < answer->width1) && (answer->bits & LINK_TWIN)) - answer->bits &= ~LINK_ALCOVE; + answer->bits &= ~SLUMP_LINK_ALCOVE; + if ((ld) && ((len / 4 - 32) < answer->width1) && (answer->bits & SLUMP_LINK_TWIN)) + answer->bits &= ~SLUMP_LINK_ALCOVE; if (rollpercent(40)) { - answer->bits |= LINK_CORE; + answer->bits |= SLUMP_LINK_CORE; if (rollpercent(40)) { - answer->bits |= LINK_STEPS; + answer->bits |= SLUMP_LINK_STEPS; answer->depth3 *= 3; answer->floordelta = answer->stepcount * (2 + roll(20)); } else if (l->lift_rho && !need_door) { - answer->bits |= LINK_LIFT; - if (!(answer->bits & LINK_ALCOVE)) - answer->bits &= ~LINK_ANY_DOOR; /* not currently compatible */ + answer->bits |= SLUMP_LINK_LIFT; + if (!(answer->bits & SLUMP_LINK_ALCOVE)) + answer->bits &= ~SLUMP_LINK_ANY_DOOR; /* not currently compatible */ if (rollpercent(50)) { answer->floordelta = 32 + 8 * roll(51); /* Potentially big */ @@ -8037,17 +8046,17 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues } } if (l->no_doors) - answer->bits &= ~LINK_ANY_DOOR; + answer->bits &= ~SLUMP_LINK_ANY_DOOR; /* Make sure we have a door if we need one (to lock, etc) */ if (need_door) - answer->bits |= LINK_NEAR_DOOR; + answer->bits |= SLUMP_LINK_NEAR_DOOR; /* Fewer unrecessed and/or really high doors */ - if (answer->bits | LINK_ANY_DOOR) + if (answer->bits | SLUMP_LINK_ANY_DOOR) { if (rollpercent(75)) - answer->bits |= LINK_RECESS; + answer->bits |= SLUMP_LINK_RECESS; if (rollpercent(75)) if (answer->height1 > 72) answer->height1 = 72; /* Hugeness? */ @@ -8059,39 +8068,39 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues /* More random fun stuff */ if (rollpercent(l->p_stair_lamps)) - answer->bits |= LINK_LAMPS; + answer->bits |= SLUMP_LINK_LAMPS; if (rollpercent(50)) - answer->bits |= LINK_MAX_CEILING; + answer->bits |= SLUMP_LINK_MAX_CEILING; if (rollpercent(50)) - answer->bits |= LINK_LEFT; + answer->bits |= SLUMP_LINK_LEFT; if (rollpercent(75)) - answer->bits |= LINK_FAR_TWINS; + answer->bits |= SLUMP_LINK_FAR_TWINS; if (rollpercent(75)) - answer->bits |= LINK_TRIGGERED; + answer->bits |= SLUMP_LINK_TRIGGERED; if (rollpercent(l->p_force_sky) || rollpercent(l->p_force_sky) || rollpercent(50)) - answer->bits |= LINK_DECROOM; /* 50? */ + answer->bits |= SLUMP_LINK_DECROOM; /* 50? */ /* If nukage_core_trap, override much of the above! */ if (nukage_core_trap) { /* A relatively simple core */ - answer->bits &= ~(LINK_STEPS | LINK_ALCOVE | LINK_TWIN | LINK_LIFT); - answer->bits |= LINK_CORE; + answer->bits &= ~(SLUMP_LINK_STEPS | SLUMP_LINK_ALCOVE | SLUMP_LINK_TWIN | SLUMP_LINK_LIFT); + answer->bits |= SLUMP_LINK_CORE; /* At least 128 long */ if (answer->depth3 < 128) answer->depth3 = 128; /* And going up a bit */ answer->floordelta = 4 + roll(18); - answer->bits |= LINK_LOCK_CORE; + answer->bits |= SLUMP_LINK_LOCK_CORE; } /* If a gate quest, override much of the above also. All we want */ /* is a recessed archway-thing, walkable, etc, to make_window() on */ - if ((ThisQuest) && (ThisQuest->goal == GATE_GOAL)) + if ((ThisQuest) && (ThisQuest->goal == SLUMP_GATE_GOAL)) { - answer->bits &= ~(LINK_STEPS | LINK_ALCOVE | LINK_LIFT | LINK_CORE); - answer->bits &= ~(LINK_ANY_DOOR | LINK_TRIGGERED); - answer->bits |= LINK_RECESS; + answer->bits &= ~(SLUMP_LINK_STEPS | SLUMP_LINK_ALCOVE | SLUMP_LINK_LIFT | SLUMP_LINK_CORE); + answer->bits &= ~(SLUMP_LINK_ANY_DOOR | SLUMP_LINK_TRIGGERED); + answer->bits |= SLUMP_LINK_RECESS; if (rollpercent(50)) { answer->floordelta = 0; @@ -8104,25 +8113,25 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues /* Alcoves require either a door or a recess, and a non-whole width, */ /* and for now at least a tiny core. */ - if (answer->bits & LINK_ALCOVE) + if (answer->bits & SLUMP_LINK_ALCOVE) { - if (LINK_ANY_DOOR != (answer->bits & LINK_ANY_DOOR)) + if (SLUMP_LINK_ANY_DOOR != (answer->bits & SLUMP_LINK_ANY_DOOR)) { - answer->bits |= LINK_RECESS; + answer->bits |= SLUMP_LINK_RECESS; if (answer->depth2 < (8 * l->hugeness)) answer->depth2 = 8 * l->hugeness; } if (answer->width1 == 0) answer->width1 = 64 * l->hugeness; - if (!(answer->bits & LINK_CORE)) + if (!(answer->bits & SLUMP_LINK_CORE)) { - answer->bits |= LINK_CORE; + answer->bits |= SLUMP_LINK_CORE; answer->depth3 = 4 * l->hugeness; } } /* Some final sanity checks on stair-sector heights and stuff */ - if (answer->bits & LINK_STEPS) + if (answer->bits & SLUMP_LINK_STEPS) { int need; /* The clearance we need is 56 plus the step height times */ @@ -8130,12 +8139,12 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues /* (plus eight more in case of doors). Roughly! */ need = 64 + (1 + (64 / (answer->depth3 / (answer->stepcount)))) * abs(answer->floordelta / (answer->stepcount - 1)); - if (answer->bits & LINK_ANY_DOOR) + if (answer->bits & SLUMP_LINK_ANY_DOOR) need += 8; /* Doors don't open all the way */ if (answer->height1 < need) answer->height1 = need; } - else if (!(answer->bits & LINK_LIFT)) + else if (!(answer->bits & SLUMP_LINK_LIFT)) { if (answer->height1 + answer->floordelta < 64) answer->height1 = 64 - answer->floordelta; @@ -8151,31 +8160,31 @@ link *random_basic_link(level *l, linedef *ld, style *ThisStyle, quest *ThisQues if (ld) { if (len < 144) - answer->bits &= ~(LINK_TWIN | LINK_ALCOVE); + answer->bits &= ~(SLUMP_LINK_TWIN | SLUMP_LINK_ALCOVE); if (len < (2 * answer->width1)) - answer->bits &= ~(LINK_TWIN | LINK_ALCOVE); - if (answer->bits & LINK_ALCOVE) + answer->bits &= ~(SLUMP_LINK_TWIN | SLUMP_LINK_ALCOVE); + if (answer->bits & SLUMP_LINK_ALCOVE) if (!link_fitsh(ld, answer, c)) /* Try the Official Checker! */ - answer->bits &= ~LINK_ALCOVE; + answer->bits &= ~SLUMP_LINK_ALCOVE; } if (answer->width1 == 0) - answer->bits &= ~LINK_ALCOVE; + answer->bits &= ~SLUMP_LINK_ALCOVE; - if ((answer->bits & LINK_LIFT) && (!(answer->bits & LINK_ALCOVE))) - answer->bits &= ~LINK_ANY_DOOR; /* not currently compatible */ + if ((answer->bits & SLUMP_LINK_LIFT) && (!(answer->bits & SLUMP_LINK_ALCOVE))) + answer->bits &= ~SLUMP_LINK_ANY_DOOR; /* not currently compatible */ /* Only make a window if not too much floordelta */ if (answer->floordelta + 16 > ThisStyle->sillheight + ThisStyle->windowheight) - answer->bits &= ~LINK_WINDOW; + answer->bits &= ~SLUMP_LINK_WINDOW; /* We don't know a ceiling-delta, so guess here */ if ((56 + answer->floordelta) < (ThisStyle->sillheight)) - answer->bits &= ~LINK_WINDOW; + answer->bits &= ~SLUMP_LINK_WINDOW; /* If two doors are too close together, they won't work. */ /* Could just turn off NEAR or FAR, eh? */ - if ((answer->bits & LINK_ANY_DOOR) && (answer->bits & LINK_CORE) && !(answer->bits & LINK_ALCOVE) && - (answer->depth3 < 24)) + if ((answer->bits & SLUMP_LINK_ANY_DOOR) && (answer->bits & SLUMP_LINK_CORE) && + !(answer->bits & SLUMP_LINK_ALCOVE) && (answer->depth3 < 24)) answer->depth3 = 24; return answer; @@ -8191,7 +8200,7 @@ void make_lightstrip(level *l, linedef *ld, style *ThisStyle, int ll, int depth, /* should do an empty_area check here */ t = ld->right->middle_texture; - ldnew = lefthand_box(l, ld, 4, ThisStyle, c); + ldnew = SLUMP_lefthand_box(l, ld, 4, ThisStyle, c); /* Have to shorten ldnew a bit here, for tapered edges, to */ /* avoid colliding with orthogonal doors and stuff, if we're */ /* not gonna do a full area check. Use rather silly shortening */ @@ -8218,7 +8227,7 @@ void make_lightstrip(level *l, linedef *ld, style *ThisStyle, int ll, int depth, ldnew->right->middle_texture = ThisStyle->walllight; /* Sometimes use bottom of lights. */ if (!ThisStyle->peg_lightstrips) - ldnew->flags |= LOWER_UNPEGGED; + ldnew->flags |= SLUMP_LOWER_UNPEGGED; s = ldnew->right->psector; s->light_level = ll; s->special = spec; @@ -8236,7 +8245,7 @@ boolean empty_left_side(level *l, linedef *ld, int sdepth) int newx1, newy1, newx2, newy2; boolean rc; - point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, LEFT_TURN, sdepth, &newx1, &newy1); + point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, SLUMP_LEFT_TURN, sdepth, &newx1, &newy1); newx2 = newx1 - ld->to->x + ld->from->x; newy2 = newy1 - ld->to->y + ld->from->y; ld->from->marked = 1; @@ -8267,27 +8276,28 @@ void swell_linedef(level *l, linedef *ld, style *ThisStyle, config *c, int sno, return; /* oh, well! */ sprintf(logstring, "Swelling (%d,%d)-(%d,%d)...\n", ld->from->x, ld->from->y, ld->to->x, ld->to->y); - announce(VERBOSE, logstring); + announce(SLUMP_VERBOSE, logstring); /* Now split the linedef, and jiggle the result(s) */ - len = linelen(ld) / sno; + len = SLUMP_linelen(ld) / sno; ldnew1 = split_linedef(l, ld, len, c); if (sno == 3) ldnew2 = split_linedef(l, ldnew1, len, c); - point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, LEFT_TURN, sdepth, &newx1, &newy1); + point_from(ld->from->x, ld->from->y, ld->to->x, ld->to->y, SLUMP_LEFT_TURN, sdepth, &newx1, &newy1); if (sno == 3) - point_from(ldnew1->from->x, ldnew1->from->y, ldnew1->to->x, ldnew1->to->y, LEFT_TURN, sdepth, &newx2, &newy2); + point_from(ldnew1->from->x, ldnew1->from->y, ldnew1->to->x, ldnew1->to->y, SLUMP_LEFT_TURN, sdepth, &newx2, + &newy2); ld->to->x = newx1; ld->to->y = newy1; sprintf(logstring, "Swol to (%d,%d)-(%d,%d)...\n", ld->from->x, ld->from->y, ld->to->x, ld->to->y); - announce(VERBOSE, logstring); + announce(SLUMP_VERBOSE, logstring); if (sno == 3) { ldnew1->to->x = newx2; ldnew1->to->y = newy2; sprintf(logstring, " and (%d,%d)-(%d,%d)...\n", ldnew1->from->x, ldnew1->from->y, ldnew1->to->x, ldnew1->to->y); - announce(VERBOSE, logstring); + announce(SLUMP_VERBOSE, logstring); } } /* end swell_linedef */ @@ -8314,10 +8324,10 @@ boolean room_at(level *l, genus *g, int x, int y, int width, config *c) if (infinity_norm(t->x, t->y, x, y) < width) return SLUMP_FALSE; /* If it's not pickable, make sure not stuck-together */ - if (!(g->bits & PICKABLE)) + if (!(g->bits & SLUMP_PICKABLE)) for (t = l->thing_anchor; t; t = t->next) { - if (t->pgenus->bits & PICKABLE) + if (t->pgenus->bits & SLUMP_PICKABLE) continue; /* This is overly conservative; the real check should */ /* be against g->width/2 + t->pgenus->width/2, eh? */ @@ -8368,12 +8378,12 @@ thing *place_object_in_region(level *l, int minx, int miny, int maxx, int maxy, { char s[200]; sprintf(s, "place_object trying to place a %04x.", thingid); - announce(NONE, s); + announce(SLUMP_NONE, s); } g = find_genus(c, thingid); - if (!(g->bits & PICKABLE)) + if (!(g->bits & SLUMP_PICKABLE)) { if (maxx - minx < g->width) return NULL; @@ -8438,14 +8448,14 @@ thing *place_object_in_region(level *l, int minx, int miny, int maxx, int maxy, { char s[200]; sprintf(s, "place_object placed it at (%d,%d).", x, y); - announce(NONE, s); + announce(SLUMP_NONE, s); } return answer; } deck[n].tried = SLUMP_TRUE; } /* end for ten probes */ - announce(NONE, "place_object failed"); + announce(SLUMP_NONE, "place_object failed"); return NULL; } @@ -8472,7 +8482,7 @@ void place_barrels(level *l, sector *s, config *c, haa *haa) if (NULL == place_object(l, s, c, g->thingid, g->width, 0, 0, 0, (short)7)) return; - announce(VERBOSE, "Barrel"); + announce(SLUMP_VERBOSE, "Barrel"); } /* end forever */ @@ -8497,7 +8507,7 @@ void place_plants(level *l, int allow, sector *s, config *c) if (NULL == place_object(l, s, c, g->thingid, g->width, 0, 0, 0, (short)7)) return; - announce(VERBOSE, "Plant"); + announce(SLUMP_VERBOSE, "Plant"); } /* end forever */ @@ -8526,15 +8536,15 @@ int timely_armor(haa *haa, int *rlevels, config *c) /* Should be less primitive? */ if (rollpercent(50)) { - armortype = (c->gamemask & HERETIC_BIT) ? 0 : ID_HELMET; + armortype = (c->gamemask & SLUMP_HERETIC_BIT) ? 0 : SLUMP_ID_HELMET; } else if (rollpercent(70)) { - armortype = (c->gamemask & HERETIC_BIT) ? ID_SILVERSHIELD : ID_GREENSUIT; + armortype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_SILVERSHIELD : SLUMP_ID_GREENSUIT; } else { - armortype = (c->gamemask & HERETIC_BIT) ? ID_ENCHANTEDSHIELD : ID_BLUESUIT; + armortype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_ENCHANTEDSHIELD : SLUMP_ID_BLUESUIT; } return armortype; @@ -8548,57 +8558,57 @@ void update_haa_for_armor(haa *haa, int levels, short armortype) switch (armortype) { - case ID_HELMET: + case SLUMP_ID_HELMET: if (levels & 0x01) - haa->haas[ITYTD].armor++; + haa->haas[SLUMP_ITYTD].armor++; if (levels & 0x02) - haa->haas[HMP].armor++; + haa->haas[SLUMP_HMP].armor++; if (levels & 0x04) - haa->haas[UV].armor++; + haa->haas[SLUMP_UV].armor++; break; - case ID_GREENSUIT: - case ID_SILVERSHIELD: + case SLUMP_ID_GREENSUIT: + case SLUMP_ID_SILVERSHIELD: if (levels & 0x01) { - haa->haas[ITYTD].armor += 20; - if (haa->haas[ITYTD].armor < 100) - haa->haas[ITYTD].armor = (float)100; + haa->haas[SLUMP_ITYTD].armor += 20; + if (haa->haas[SLUMP_ITYTD].armor < 100) + haa->haas[SLUMP_ITYTD].armor = (float)100; } if (levels & 0x02) { - haa->haas[HMP].armor += 30; - if (haa->haas[HMP].armor < 100) - haa->haas[HMP].armor = (float)100; + haa->haas[SLUMP_HMP].armor += 30; + if (haa->haas[SLUMP_HMP].armor < 100) + haa->haas[SLUMP_HMP].armor = (float)100; } if (levels & 0x04) { - haa->haas[UV].armor += 50; - if (haa->haas[UV].armor < 100) - haa->haas[UV].armor = (float)100; + haa->haas[SLUMP_UV].armor += 50; + if (haa->haas[SLUMP_UV].armor < 100) + haa->haas[SLUMP_UV].armor = (float)100; } break; - case ID_BLUESUIT: - case ID_ENCHANTEDSHIELD: + case SLUMP_ID_BLUESUIT: + case SLUMP_ID_ENCHANTEDSHIELD: if (levels & 0x01) { - haa->haas[ITYTD].armor += 40; - if (haa->haas[ITYTD].armor < 200) - haa->haas[ITYTD].armor = (float)200; + haa->haas[SLUMP_ITYTD].armor += 40; + if (haa->haas[SLUMP_ITYTD].armor < 200) + haa->haas[SLUMP_ITYTD].armor = (float)200; } if (levels & 0x02) { - haa->haas[HMP].armor += 60; - if (haa->haas[HMP].armor < 200) - haa->haas[HMP].armor = (float)200; + haa->haas[SLUMP_HMP].armor += 60; + if (haa->haas[SLUMP_HMP].armor < 200) + haa->haas[SLUMP_HMP].armor = (float)200; } if (levels & 0x04) { - haa->haas[UV].armor += 100; - if (haa->haas[UV].armor < 200) - haa->haas[UV].armor = (float)200; + haa->haas[SLUMP_UV].armor += 100; + if (haa->haas[SLUMP_UV].armor < 200) + haa->haas[SLUMP_UV].armor = (float)200; } break; - case 0: // This is for Heretic as it has no ID_HELMET equivalent + case 0: // This is for Heretic as it has no SLUMP_ID_HELMET equivalent break; default: announce(SLUMP_ERROR, "Odd armortype in u_h_f_armor"); @@ -8616,14 +8626,14 @@ void place_armor(level *l, sector *s, config *c, haa *haa) for (;;) { - announce(NONE, "place_armor looking for needy levels"); + announce(SLUMP_NONE, "place_armor looking for needy levels"); armortype = timely_armor(haa, &levels, c); if (levels == 0) return; /* Done if none */ - announce(NONE, "place_armor found some needy levels"); + announce(SLUMP_NONE, "place_armor found some needy levels"); if (NULL == place_object(l, s, c, (short)armortype, 48, 0, 0, 0, (short)levels)) return; - announce(NONE, "place_armor placed some armor"); + announce(SLUMP_NONE, "place_armor placed some armor"); update_haa_for_armor(haa, levels, (short)armortype); if (rollpercent(25)) return; /* Reasonable? */ @@ -8673,23 +8683,24 @@ int timely_ammo(haa *haa, int *rlevels, config *c) if ((!c->weapons_are_special) && (need_shotgun)) { - if ((!(c->gamemask & (DOOM0_BIT | DOOM1_BIT | HERETIC_BIT | HARMONY_BIT))) && rollpercent(30)) + if ((!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_HERETIC_BIT | SLUMP_HARMONY_BIT))) && + rollpercent(30)) { - ammotype = ID_SSGUN; + ammotype = SLUMP_ID_SSGUN; } - else if (c->gamemask & HERETIC_BIT) + else if (c->gamemask & SLUMP_HERETIC_BIT) { - ammotype = ID_CROSSBOW; + ammotype = SLUMP_ID_CROSSBOW; } else { - ammotype = ID_SHOTGUN; + ammotype = SLUMP_ID_SHOTGUN; } } else if ((!c->weapons_are_special) && rollpercent(15)) { int weapcount; - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { weapcount = 5; switch (roll(weapcount)) @@ -8697,37 +8708,37 @@ int timely_ammo(haa *haa, int *rlevels, config *c) case 0: if (c->big_weapons) { - ammotype = ID_HELLSTAFF; + ammotype = SLUMP_ID_HELLSTAFF; } else { - ammotype = ID_CROSSBOW; + ammotype = SLUMP_ID_CROSSBOW; } break; case 1: - ammotype = ID_CROSSBOW; + ammotype = SLUMP_ID_CROSSBOW; break; case 2: - ammotype = ID_DRAGONCLAW; + ammotype = SLUMP_ID_DRAGONCLAW; break; case 3: if (c->big_weapons) { - ammotype = ID_PHOENIXROD; + ammotype = SLUMP_ID_PHOENIXROD; } else { - ammotype = ID_CROSSBOW; + ammotype = SLUMP_ID_CROSSBOW; } break; case 4: - ammotype = ID_FIREMACE; + ammotype = SLUMP_ID_FIREMACE; break; } } else { - if (c->gamemask & (DOOM0_BIT | DOOM1_BIT | HARMONY_BIT)) + if (c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_HARMONY_BIT)) weapcount = 4; else weapcount = 5; @@ -8736,31 +8747,31 @@ int timely_ammo(haa *haa, int *rlevels, config *c) case 0: if (c->big_weapons) { - ammotype = ID_PLASMA; + ammotype = SLUMP_ID_PLASMA; } else { - ammotype = ID_SHOTGUN; + ammotype = SLUMP_ID_SHOTGUN; } break; case 1: - ammotype = ID_SHOTGUN; + ammotype = SLUMP_ID_SHOTGUN; break; case 2: - ammotype = ID_CHAINGUN; + ammotype = SLUMP_ID_CHAINGUN; break; case 3: if (c->big_weapons) { - ammotype = ID_LAUNCHER; + ammotype = SLUMP_ID_LAUNCHER; } else { - ammotype = ID_SHOTGUN; + ammotype = SLUMP_ID_SHOTGUN; } break; case 4: - ammotype = ID_SSGUN; + ammotype = SLUMP_ID_SSGUN; break; } } @@ -8768,43 +8779,43 @@ int timely_ammo(haa *haa, int *rlevels, config *c) } else if (rollpercent(10)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_WANDCRYSTAL : ID_CLIP; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_WANDCRYSTAL : SLUMP_ID_CLIP; } else if (haa->haas[0].can_use_cells && rollpercent(10)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_LESSERRUNES : ID_CELL; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_LESSERRUNES : SLUMP_ID_CELL; } else if (haa->haas[0].can_use_cells && rollpercent(15)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_GREATERRUNES : ID_CELLPACK; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_GREATERRUNES : SLUMP_ID_CELLPACK; } else if (haa->haas[0].can_use_rockets && rollpercent(12)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_FLAMEORB : ID_ROCKET; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_FLAMEORB : SLUMP_ID_ROCKET; } else if (haa->haas[0].can_use_rockets && rollpercent(15)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_INFERNOORB : ID_ROCKBOX; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_INFERNOORB : SLUMP_ID_ROCKBOX; } else if (rollpercent(10)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_CRYSTALGEODE : ID_BULBOX; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_CRYSTALGEODE : SLUMP_ID_BULBOX; } else if (rollpercent(60)) { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_ETHEREALARROWS : ID_SHELLS; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_ETHEREALARROWS : SLUMP_ID_SHELLS; } else { - ammotype = (c->gamemask & HERETIC_BIT) ? ID_ETHEREALQUIVER : ID_SHELLBOX; + ammotype = (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_ETHEREALQUIVER : SLUMP_ID_SHELLBOX; } - if ((ammotype == (c->gamemask & HERETIC_BIT) ? ID_HELLSTAFF : ID_PLASMA) && (need_plasgun)) + if ((ammotype == (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_HELLSTAFF : SLUMP_ID_PLASMA) && (need_plasgun)) { levels |= 0x07; /* All, if any */ } - if ((ammotype == (c->gamemask & HERETIC_BIT) ? ID_PHOENIXROD : ID_LAUNCHER) && (need_launcher)) + if ((ammotype == (c->gamemask & SLUMP_HERETIC_BIT) ? SLUMP_ID_PHOENIXROD : SLUMP_ID_LAUNCHER) && (need_launcher)) { levels |= 0x07; /* All, if any */ } @@ -8823,83 +8834,83 @@ void ammo_value(short ammotype, haa *haa, int *f0, int *f1, int *f2) /* These numbers should just be stored in the config, in the genus */ switch (ammotype) { - case ID_SSGUN: - case ID_SHOTGUN: + case SLUMP_ID_SSGUN: + case SLUMP_ID_SHOTGUN: answer = 560; special_case = SLUMP_TRUE; break; - case ID_SHELLS: + case SLUMP_ID_SHELLS: answer = 280; special_case = SLUMP_TRUE; break; - case ID_SHELLBOX: + case SLUMP_ID_SHELLBOX: answer = 1400; special_case = SLUMP_TRUE; break; - case ID_PLASMA: + case SLUMP_ID_PLASMA: answer = 880; break; - case ID_BFG: + case SLUMP_ID_BFG: answer = 880; break; /* but a BFG is better, eh? */ - case ID_CHAINGUN: + case SLUMP_ID_CHAINGUN: answer = 200; break; - case ID_LAUNCHER: + case SLUMP_ID_LAUNCHER: answer = 200; break; - case ID_CLIP: + case SLUMP_ID_CLIP: answer = 100; break; - case ID_BULBOX: + case SLUMP_ID_BULBOX: answer = 500; break; - case ID_CELL: + case SLUMP_ID_CELL: answer = 440; break; - case ID_CELLPACK: + case SLUMP_ID_CELLPACK: answer = 2200; break; - case ID_ROCKET: + case SLUMP_ID_ROCKET: answer = 100; break; - case ID_ROCKBOX: + case SLUMP_ID_ROCKBOX: answer = 500; break; - case ID_WANDCRYSTAL: + case SLUMP_ID_WANDCRYSTAL: answer = 100; break; - case ID_CRYSTALGEODE: + case SLUMP_ID_CRYSTALGEODE: answer = 500; break; - case ID_ETHEREALARROWS: + case SLUMP_ID_ETHEREALARROWS: answer = 225; break; - case ID_ETHEREALQUIVER: + case SLUMP_ID_ETHEREALQUIVER: answer = 900; break; - case ID_CLAWORB: + case SLUMP_ID_CLAWORB: answer = 180; break; - case ID_ENERGYORB: + case SLUMP_ID_ENERGYORB: answer = 450; break; - case ID_LESSERRUNES: + case SLUMP_ID_LESSERRUNES: answer = 280; break; - case ID_GREATERRUNES: + case SLUMP_ID_GREATERRUNES: answer = 1400; break; - case ID_FLAMEORB: + case SLUMP_ID_FLAMEORB: answer = 90; break; - case ID_INFERNOORB: + case SLUMP_ID_INFERNOORB: answer = 900; break; - case ID_MACESPHERES: + case SLUMP_ID_MACESPHERES: answer = 180; break; - case ID_MACESPHEREPILE: + case SLUMP_ID_MACESPHEREPILE: answer = 900; break; default: @@ -8909,11 +8920,11 @@ void ammo_value(short ammotype, haa *haa, int *f0, int *f1, int *f2) *f0 = *f1 = *f2 = answer; if (special_case) { /* Sort of a hack! Make more general? */ - if ((ammotype == ID_SSGUN) || (haa->haas[0].has_ssgun)) + if ((ammotype == SLUMP_ID_SSGUN) || (haa->haas[0].has_ssgun)) *f0 = (int)((double)answer * 10.0 / 7.0); - if ((ammotype == ID_SSGUN) || (haa->haas[1].has_ssgun)) + if ((ammotype == SLUMP_ID_SSGUN) || (haa->haas[1].has_ssgun)) *f1 = (int)((double)answer * 10.0 / 7.0); - if ((ammotype == ID_SSGUN) || (haa->haas[2].has_ssgun)) + if ((ammotype == SLUMP_ID_SSGUN) || (haa->haas[2].has_ssgun)) *f2 = (int)((double)answer * 10.0 / 7.0); } return; @@ -8927,55 +8938,55 @@ void update_haa_for_ammo(haa *haa, int levels, short ammotype) ammo_value(ammotype, haa, &a0, &a1, &a2); if (levels & 0x01) - haa->haas[ITYTD].ammo += a0; + haa->haas[SLUMP_ITYTD].ammo += a0; if (levels & 0x02) - haa->haas[HMP].ammo += a1; + haa->haas[SLUMP_HMP].ammo += a1; if (levels & 0x04) - haa->haas[UV].ammo += a2; - if ((ammotype == ID_SHOTGUN) || (ammotype == ID_SSGUN)) + haa->haas[SLUMP_UV].ammo += a2; + if ((ammotype == SLUMP_ID_SHOTGUN) || (ammotype == SLUMP_ID_SSGUN)) { if (levels & 0x01) - haa->haas[ITYTD].can_use_shells = 1; + haa->haas[SLUMP_ITYTD].can_use_shells = 1; if (levels & 0x02) - haa->haas[HMP].can_use_shells = 1; + haa->haas[SLUMP_HMP].can_use_shells = 1; if (levels & 0x04) - haa->haas[UV].can_use_shells = 1; + haa->haas[SLUMP_UV].can_use_shells = 1; } - if (ammotype == ID_CHAINGUN) + if (ammotype == SLUMP_ID_CHAINGUN) { if (levels & 0x01) - haa->haas[ITYTD].has_chaingun = 1; + haa->haas[SLUMP_ITYTD].has_chaingun = 1; if (levels & 0x02) - haa->haas[HMP].has_chaingun = 1; + haa->haas[SLUMP_HMP].has_chaingun = 1; if (levels & 0x04) - haa->haas[UV].has_chaingun = 1; + haa->haas[SLUMP_UV].has_chaingun = 1; } - if (ammotype == ID_PLASMA) + if (ammotype == SLUMP_ID_PLASMA) { if (levels & 0x01) - haa->haas[ITYTD].can_use_cells = 1; + haa->haas[SLUMP_ITYTD].can_use_cells = 1; if (levels & 0x02) - haa->haas[HMP].can_use_cells = 1; + haa->haas[SLUMP_HMP].can_use_cells = 1; if (levels & 0x04) - haa->haas[UV].can_use_cells = 1; + haa->haas[SLUMP_UV].can_use_cells = 1; } - if (ammotype == ID_LAUNCHER) + if (ammotype == SLUMP_ID_LAUNCHER) { if (levels & 0x01) - haa->haas[ITYTD].can_use_rockets = 1; + haa->haas[SLUMP_ITYTD].can_use_rockets = 1; if (levels & 0x02) - haa->haas[HMP].can_use_rockets = 1; + haa->haas[SLUMP_HMP].can_use_rockets = 1; if (levels & 0x04) - haa->haas[UV].can_use_rockets = 1; + haa->haas[SLUMP_UV].can_use_rockets = 1; } - if (ammotype == ID_SSGUN) + if (ammotype == SLUMP_ID_SSGUN) { if (levels & 0x01) - haa->haas[ITYTD].has_ssgun = 1; + haa->haas[SLUMP_ITYTD].has_ssgun = 1; if (levels & 0x02) - haa->haas[HMP].has_ssgun = 1; + haa->haas[SLUMP_HMP].has_ssgun = 1; if (levels & 0x04) - haa->haas[UV].has_ssgun = 1; + haa->haas[SLUMP_UV].has_ssgun = 1; } } @@ -8984,14 +8995,14 @@ boolean is_weapon(short thingid) { switch (thingid) { - case ID_SHOTGUN: - case ID_SSGUN: - case ID_CHAINGUN: - case ID_CHAINSAW: - case ID_PLASMA: - case ID_BFG: - case ID_LAUNCHER: - case ID_DRAGONCLAW: + case SLUMP_ID_SHOTGUN: + case SLUMP_ID_SSGUN: + case SLUMP_ID_CHAINGUN: + case SLUMP_ID_CHAINSAW: + case SLUMP_ID_PLASMA: + case SLUMP_ID_BFG: + case SLUMP_ID_LAUNCHER: + case SLUMP_ID_DRAGONCLAW: return SLUMP_TRUE; default: return SLUMP_FALSE; @@ -9009,16 +9020,16 @@ void place_ammo(level *l, sector *s, config *c, haa *haa) for (;;) { - announce(NONE, "place_ammo looking for needy levels"); + announce(SLUMP_NONE, "place_ammo looking for needy levels"); ammotype = timely_ammo(haa, &levels, c); if (levels == 0) return; /* Done if none */ - announce(NONE, "place_ammo found some needy levels"); + announce(SLUMP_NONE, "place_ammo found some needy levels"); /* The 48 is just to avoid bunching-up and wall-illusions, */ /* as well as the grab-through-wall effect. */ if (NULL == place_object(l, s, c, ammotype, 48, 0, 0, 0, levels)) return; - announce(NONE, "place_ammo placed some ammo"); + announce(SLUMP_NONE, "place_ammo placed some ammo"); if (levels == 7) if (is_weapon(ammotype)) s->has_dm_weapon = SLUMP_TRUE; @@ -9033,77 +9044,77 @@ void update_haa_for_health(haa *haa, int levels, short healthtype) { int amount; - if (healthtype == ID_TOMEOFPOWER) + if (healthtype == SLUMP_ID_TOMEOFPOWER) { - announce(VERBOSE, "Put in a tome of power!"); + announce(SLUMP_VERBOSE, "Put in a tome of power!"); if (levels & 0x01) { - haa->haas[ITYTD].has_berserk = SLUMP_TRUE; + haa->haas[SLUMP_ITYTD].has_berserk = SLUMP_TRUE; } if (levels & 0x02) { - haa->haas[HMP].has_berserk = SLUMP_TRUE; + haa->haas[SLUMP_HMP].has_berserk = SLUMP_TRUE; } if (levels & 0x04) { - haa->haas[UV].has_berserk = SLUMP_TRUE; + haa->haas[SLUMP_UV].has_berserk = SLUMP_TRUE; } } - else if (healthtype == ID_BERSERK) + else if (healthtype == SLUMP_ID_BERSERK) { - announce(VERBOSE, "Put in a berserk pack!"); + announce(SLUMP_VERBOSE, "Put in a berserk pack!"); if (levels & 0x01) { - if (haa->haas[ITYTD].health < 100) - haa->haas[ITYTD].health = (float)100; - haa->haas[ITYTD].has_berserk = SLUMP_TRUE; + if (haa->haas[SLUMP_ITYTD].health < 100) + haa->haas[SLUMP_ITYTD].health = (float)100; + haa->haas[SLUMP_ITYTD].has_berserk = SLUMP_TRUE; } if (levels & 0x02) { - if (haa->haas[HMP].health < 100) - haa->haas[HMP].health = (float)100; - haa->haas[HMP].has_berserk = SLUMP_TRUE; + if (haa->haas[SLUMP_HMP].health < 100) + haa->haas[SLUMP_HMP].health = (float)100; + haa->haas[SLUMP_HMP].has_berserk = SLUMP_TRUE; } if (levels & 0x04) { - if (haa->haas[UV].health < 100) - haa->haas[UV].health = (float)100; - haa->haas[UV].has_berserk = SLUMP_TRUE; + if (haa->haas[SLUMP_UV].health < 100) + haa->haas[SLUMP_UV].health = (float)100; + haa->haas[SLUMP_UV].has_berserk = SLUMP_TRUE; } } else { switch (healthtype) { - case ID_STIMPACK: - case ID_CRYSTALVIAL: + case SLUMP_ID_STIMPACK: + case SLUMP_ID_CRYSTALVIAL: amount = 10; break; - case ID_MEDIKIT: - case ID_QUARTZFLASK: + case SLUMP_ID_MEDIKIT: + case SLUMP_ID_QUARTZFLASK: amount = 25; break; - case ID_POTION: + case SLUMP_ID_POTION: amount = 1; break; - case ID_SOUL: - case ID_MYSTICURN: + case SLUMP_ID_SOUL: + case SLUMP_ID_MYSTICURN: amount = 100; break; - case 0: // Heretic - No equivalent to ID_POTION - case ID_WANDCRYSTAL: // Heretic - Sometimes placed where an ID_POTION would occur + case 0: // Heretic - No equivalent to SLUMP_ID_POTION + case SLUMP_ID_WANDCRYSTAL: // Heretic - Sometimes placed where an SLUMP_ID_POTION would occur amount = 0; break; default: - announce(WARNING, "Odd healthtype in u_h_f_h"); + announce(SLUMP_WARNING, "Odd healthtype in u_h_f_h"); amount = 0; } if (levels & 0x01) - haa->haas[ITYTD].health += amount; + haa->haas[SLUMP_ITYTD].health += amount; if (levels & 0x02) - haa->haas[HMP].health += amount; + haa->haas[SLUMP_HMP].health += amount; if (levels & 0x04) - haa->haas[UV].health += amount; + haa->haas[SLUMP_UV].health += amount; } } @@ -9122,53 +9133,53 @@ short timely_health(haa *haa, int *levels, config *c) (*levels) >>= 1; if (haa->haas[i].health < c->usualhealth[i]) (*levels) |= 0x04; - if (haa->haas[i].has_berserk == SLUMP_FALSE && !(c->gamemask & CHEX_BIT)) + if (haa->haas[i].has_berserk == SLUMP_FALSE && !(c->gamemask & SLUMP_CHEX_BIT)) berserk_ok = SLUMP_TRUE; } if ((*levels) == 0) return 0; - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) { if (rollpercent(50)) { - healthtype = ID_CRYSTALVIAL; + healthtype = SLUMP_ID_CRYSTALVIAL; } else if (rollpercent(50)) { - healthtype = ID_QUARTZFLASK; + healthtype = SLUMP_ID_QUARTZFLASK; } else if (berserk_ok && rollpercent(50)) { - healthtype = ID_TOMEOFPOWER; + healthtype = SLUMP_ID_TOMEOFPOWER; } else { - healthtype = ID_MYSTICURN; + healthtype = SLUMP_ID_MYSTICURN; } } else { if (rollpercent(50)) { - healthtype = ID_STIMPACK; + healthtype = SLUMP_ID_STIMPACK; } else if (rollpercent(50)) { - healthtype = ID_MEDIKIT; + healthtype = SLUMP_ID_MEDIKIT; } else if (rollpercent(90)) { - healthtype = ID_POTION; + healthtype = SLUMP_ID_POTION; } else if (berserk_ok && rollpercent(50)) { - healthtype = ID_BERSERK; + healthtype = SLUMP_ID_BERSERK; } else { - healthtype = ID_SOUL; + healthtype = SLUMP_ID_SOUL; } } return healthtype; @@ -9303,18 +9314,18 @@ genus *proper_monster(float health, float ammo, int bits, haa *haa, int mno, pro { char s[200]; sprintf(s, "proper_monster looking for %f health, %f ammo, levels %d", health, ammo, bits); - announce(NONE, s); + announce(SLUMP_NONE, s); } - require |= MONSTER; /* Duh! */ + require |= SLUMP_MONSTER; /* Duh! */ /* This is disabled; with min_level, we just start having boss creatures * show up in later levels */ - forbid |= BOSS; /* No wandering bosses */ + forbid |= SLUMP_BOSS; /* No wandering bosses */ /* (Wandering bosses would be nice for the later levels. Alas, the * bosses are too big to really fit where SLUMP wants to put them, * so we have to do without them */ /* With min_level, we just have big monsters show up in later levels */ - /* if (!c->big_monsters) forbid |= BIG; */ + /* if (!c->big_monsters) forbid |= SLUMP_BIG; */ /* Mark eligible monsters, and find wimpiest and biggest just in case */ count = 0; @@ -9333,7 +9344,8 @@ genus *proper_monster(float health, float ammo, int bits, haa *haa, int mno, pro /* Levels above 15 are more likely to have big meanies */ if (current_level_number > 15 && current_level_number <= 30) { - if (rollpercent((6 * (current_level_number - 15))) && (m->bits & BOSS) == 0 && (m->bits & BIG) == 0) + if (rollpercent((6 * (current_level_number - 15))) && (m->bits & SLUMP_BOSS) == 0 && + (m->bits & SLUMP_BIG) == 0) { continue; } @@ -9341,13 +9353,13 @@ genus *proper_monster(float health, float ammo, int bits, haa *haa, int mno, pro /* Disabled: Too buggy */ /* if(current_level_number > 25 && rollpercent((13 * (current_level_number - 25))) && - m->thingid != ID_ARACH) { + m->thingid != SLUMP_ID_ARACH) { continue; } */ } if (m->min_level > current_level_number) continue; /* Progression */ -#ifdef IMPOSSIBLE_MONSTERS_IN_CONFIG +#ifdef SLUMP_IMPOSSIBLE_MONSTERS_IN_CONFIG if ((m->gamemask & c->gamemask) != c->gamemask) continue; #endif @@ -9437,7 +9449,7 @@ void haa_unpend(haa *haa) { int i; - for (i = ITYTD; i <= UV; i++) + for (i = SLUMP_ITYTD; i <= SLUMP_UV; i++) { if (haa->haas[i].shells_pending) { @@ -9486,27 +9498,27 @@ void update_haa_for_monster(haa *haa, genus *m, int levels, int mno, config *c) haa->haas[i].armor -= damage / 2; } if (haa->haas[i].health < 0) - announce(VERBOSE, "Health estimate negative?"); + announce(SLUMP_VERBOSE, "Health estimate negative?"); damage = m->ammo_to_kill[i]; /* Takes more ammo, if no good weapons */ if (!(haa->haas[i].can_use_shells || haa->haas[i].can_use_cells)) damage *= 2; /* But less ammo if we can saw it or punch it! */ - if (haa->haas[i].has_chainsaw && !(m->bits & (FLIES | SHOOTS))) + if (haa->haas[i].has_chainsaw && !(m->bits & (SLUMP_FLIES | SLUMP_SHOOTS))) { damage /= 2; } - else if (haa->haas[i].has_berserk && !(m->bits & (FLIES | SHOOTS))) + else if (haa->haas[i].has_berserk && !(m->bits & (SLUMP_FLIES | SLUMP_SHOOTS))) { damage *= (float)0.80; } haa->haas[i].ammo -= damage; haa->haas[i].ammo += m->ammo_provides; /* Should be in stage two? */ if (haa->haas[i].ammo < 0) - announce(VERBOSE, "Ammo estimate negative?"); - if (m->thingid == ID_SERGEANT) + announce(SLUMP_VERBOSE, "Ammo estimate negative?"); + if (m->thingid == SLUMP_ID_SERGEANT) haa->haas[i].shells_pending = SLUMP_TRUE; - if (m->thingid == ID_COMMANDO) + if (m->thingid == SLUMP_ID_COMMANDO) haa->haas[i].chaingun_pending = SLUMP_TRUE; } /* end for levels adjusting haa */ @@ -9531,10 +9543,10 @@ genus *timely_monster_ex(haa *haa, config *c, int *levels, boolean biggest, int /* Find how big a monster we can tolerate */ if (!haa_monster_data(haa, c, &monster_size_health, &monster_size_ammo, levels)) - return NULL; /* Not enough excess health in any level */ + return NULL; /* Not enough excess health in any level */ - if (c->required_monster_bits == SPECIAL) // Just return a Nazi - return find_monster(c, ID_NAZI); + if (c->required_monster_bits == SLUMP_SPECIAL) // Just return a Nazi + return find_monster(c, SLUMP_ID_NAZI); else return proper_monster(monster_size_health, monster_size_ammo, *levels, haa, mno, c->required_monster_bits + req, c->forbidden_monster_bits, biggest, c); @@ -9576,26 +9588,26 @@ void place_monsters(level *l, sector *s, config *c, haa *haa) if (rollpercent(15)) levels |= 0x08; /* deaf */ - announce(NONE, "Trying to place a monster"); + announce(SLUMP_NONE, "Trying to place a monster"); /* Try to place it */ - rc = (NULL != place_object(l, s, c, m->thingid, MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)); + rc = (NULL != place_object(l, s, c, m->thingid, SLUMP_MONSTER_WIDTH(m), -1, s->entry_x, s->entry_y, levels)); if (!rc) { - announce(NONE, "Placement failed"); + announce(SLUMP_NONE, "Placement failed"); goto done_monsters; /* Might as well give up entirely */ } - if (m->thingid == ID_SKULL) - announce(NONE, "Skull"); - if (m->thingid == ID_HEAD) - announce(VERBOSE, "HEAD"); - if (m->thingid == ID_SKEL) - announce(VERBOSE, "SKEL"); - if (m->thingid == ID_HELL) - announce(VERBOSE, "KNIGHT"); - if (m->thingid == ID_ARCHIE) - announce(VERBOSE, "VILE"); + if (m->thingid == SLUMP_ID_SKULL) + announce(SLUMP_NONE, "Skull"); + if (m->thingid == SLUMP_ID_HEAD) + announce(SLUMP_VERBOSE, "HEAD"); + if (m->thingid == SLUMP_ID_SKEL) + announce(SLUMP_VERBOSE, "SKEL"); + if (m->thingid == SLUMP_ID_HELL) + announce(SLUMP_VERBOSE, "KNIGHT"); + if (m->thingid == SLUMP_ID_ARCHIE) + announce(SLUMP_VERBOSE, "VILE"); update_haa_for_monster(haa, m, levels, mno, c); @@ -9603,7 +9615,7 @@ void place_monsters(level *l, sector *s, config *c, haa *haa) done_monsters: - /* NOTE: tempting as it is, we don't do this *within* the */ + /* SLUMP_NOTE: tempting as it is, we don't do this *within* the */ /* loop, because the model is that the player doesn't pick */ /* up the objects in the room (including dropped weapons) */ /* until after everything is dead. So we don't use the */ @@ -9625,7 +9637,7 @@ boolean isAdequate(level *l, linedef *ld, style *ThisStyle, config *c) /* Assume all 1S longish linedefs are OK; very dangerous! */ if (ld->left) return 0; - if (ld->flags & TWO_SIDED) + if (ld->flags & SLUMP_TWO_SIDED) return 0; if (lengthsquared(ld) >= (128 * 128)) { /* Why 128? */ @@ -9701,8 +9713,9 @@ construct *new_construct(config *c) construct *answer = (construct *)malloc(sizeof(*answer)); answer->height = 64; - answer->gamemask = DOOM1_BIT | DOOM0_BIT | DOOM2_BIT | DOOMI_BIT | DOOMC_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | - HARMONY_BIT | STRIFE_BIT | REKKR_BIT; + answer->gamemask = SLUMP_DOOM1_BIT | SLUMP_DOOM0_BIT | SLUMP_DOOM2_BIT | SLUMP_DOOMI_BIT | SLUMP_DOOMC_BIT | + SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | SLUMP_HARMONY_BIT | SLUMP_STRIFE_BIT | + SLUMP_REKKR_BIT; answer->compatible = 0; answer->texture_cell_anchor = NULL; answer->flat_cell_anchor = NULL; @@ -9738,9 +9751,9 @@ texture_cell *add_texture_cell(construct *cn, char *name, boolean primary, short return answer; } -#ifdef CONFIG_DUMP +#ifdef SLUMP_CONFIG_DUMP -#ifndef CONFIG_DUMP_VERBOSE_NOT +#ifndef SLUMP_CONFIG_DUMP_VERBOSE_NOT void dump_foo_themebits(themebits yes, themebits no, char *tag, config *c) { @@ -9760,41 +9773,41 @@ void dump_foo_texture(texture *t, config *c) printf("Texture %s ", t->name); if ((t->width != 256) || (t->height != 128)) printf("size %d %d ", t->width, t->height); - if (t->props & WALL) + if (t->props & SLUMP_WALL) printf("wall "); - if (t->props & SWITCH) + if (t->props & SLUMP_SWITCH) printf("isswitch "); - if (t->props & LIFT_TEXTURE) + if (t->props & SLUMP_LIFT_TEXTURE) printf("lift "); - if (t->props & SUPPORT) + if (t->props & SLUMP_SUPPORT) printf("support "); - if (t->props & JAMB) + if (t->props & SLUMP_JAMB) printf("jamb "); - if (t->props & STEP) + if (t->props & SLUMP_STEP) printf("step "); - if (t->props & GRATING) + if (t->props & SLUMP_GRATING) printf("grating "); - if (t->props & PLAQUE) + if (t->props & SLUMP_PLAQUE) printf("plaque "); - if (t->props & VTILES) + if (t->props & SLUMP_VTILES) printf("vtiles "); - if (t->props & HALF_PLAQUE) + if (t->props & SLUMP_HALF_PLAQUE) printf("half_plaque "); - if (t->props & LIGHT) + if (t->props & SLUMP_LIGHT) printf("light "); - if (t->props & EXITSWITCH) + if (t->props & SLUMP_EXITSWITCH) printf("exitswitch "); - if (t->props & DOOR) + if (t->props & SLUMP_DOOR) printf("door "); - if (t->props & GATE) + if (t->props & SLUMP_GATE) printf("locked "); - if (t->props & OUTDOOR) + if (t->props & SLUMP_OUTDOOR) printf("outside "); - if (t->props & RED) + if (t->props & SLUMP_RED) printf("red "); - if (t->props & BLUE) + if (t->props & SLUMP_BLUE) printf("blue "); - if (t->props & YELLOW) + if (t->props & SLUMP_YELLOW) printf("yellow "); if (t == c->error_texture) printf("error "); @@ -9812,15 +9825,15 @@ void dump_foo_texture(texture *t, config *c) printf("ybias %d ", t->y_bias); if (5 != t->y_hint) printf("yhint %d ", t->y_hint); - if (!(t->gamemask & DOOM0_BIT)) + if (!(t->gamemask & SLUMP_DOOM0_BIT)) printf("noDoom0 "); - if (!(t->gamemask & DOOM1_BIT)) + if (!(t->gamemask & SLUMP_DOOM1_BIT)) printf("noDoom1 "); - if (!(t->gamemask & DOOM2_BIT)) + if (!(t->gamemask & SLUMP_DOOM2_BIT)) printf("noDoom2 "); - if (!(t->gamemask & DOOMI_BIT)) + if (!(t->gamemask & SLUMP_DOOMI_BIT)) printf("custom "); - if (!(t->gamemask & DOOMC_BIT)) + if (!(t->gamemask & SLUMP_DOOMC_BIT)) printf("gross "); printf("\n"); } @@ -9829,34 +9842,34 @@ void dump_foo_flat(flat *f, config *c) { printf("Flat %s ", f->name); - if (f->props & FLOOR) + if (f->props & SLUMP_FLOOR) printf("floor "); - if (f->props & CEILING) + if (f->props & SLUMP_CEILING) printf("ceiling "); - if (f->props & LIGHT) + if (f->props & SLUMP_LIGHT) printf("light "); - if (f->props & NUKAGE) + if (f->props & SLUMP_NUKAGE) printf("nukage "); - if (f->props & OUTDOOR) + if (f->props & SLUMP_OUTDOOR) printf("outside "); - if (f->props & GATE) + if (f->props & SLUMP_GATE) printf("gate "); - if (f->props & RED) + if (f->props & SLUMP_RED) printf("red "); if (f == c->sky_flat) printf("sky "); if (f == c->water_flat) printf("water "); dump_foo_themebits(f->compatible, 0, "comp", c); - if (!(f->gamemask & DOOM0_BIT)) + if (!(f->gamemask & SLUMP_DOOM0_BIT)) printf("noDoom0 "); - if (!(f->gamemask & DOOM1_BIT)) + if (!(f->gamemask & SLUMP_DOOM1_BIT)) printf("noDoom1 "); - if (!(f->gamemask & DOOM2_BIT)) + if (!(f->gamemask & SLUMP_DOOM2_BIT)) printf("noDoom2 "); - if (!(f->gamemask & DOOMI_BIT)) + if (!(f->gamemask & SLUMP_DOOMI_BIT)) printf("custom "); - if (!(f->gamemask & DOOMC_BIT)) + if (!(f->gamemask & SLUMP_DOOMC_BIT)) printf("gross "); printf("\n"); } @@ -9879,15 +9892,15 @@ void dump_foo_construct(construct *x, config *c) printf("Construct family %d height %d ", x->family, x->height); dump_foo_themebits(x->compatible, 0, "comp", c); - if (!(x->gamemask & DOOM0_BIT)) + if (!(x->gamemask & SLUMP_DOOM0_BIT)) printf("noDoom0 "); - if (!(x->gamemask & DOOM1_BIT)) + if (!(x->gamemask & SLUMP_DOOM1_BIT)) printf("noDoom1 "); - if (!(x->gamemask & DOOM2_BIT)) + if (!(x->gamemask & SLUMP_DOOM2_BIT)) printf("noDoom2 "); - if (!(x->gamemask & DOOMI_BIT)) + if (!(x->gamemask & SLUMP_DOOMI_BIT)) printf("custom "); - if (!(x->gamemask & DOOMC_BIT)) + if (!(x->gamemask & SLUMP_DOOMC_BIT)) printf("gross "); printf("\n"); printf(" "); @@ -9914,41 +9927,41 @@ void dump_foo_texture(texture *t, config *c) printf("t %s ", t->name); if ((t->width != 256) || (t->height != 128)) printf("z %d %d ", t->width, t->height); - if (t->props & WALL) + if (t->props & SLUMP_WALL) printf("w "); - if (t->props & SWITCH) + if (t->props & SLUMP_SWITCH) printf("i "); - if (t->props & LIFT_TEXTURE) + if (t->props & SLUMP_LIFT_TEXTURE) printf("F "); - if (t->props & SUPPORT) + if (t->props & SLUMP_SUPPORT) printf("I "); - if (t->props & JAMB) + if (t->props & SLUMP_JAMB) printf("j "); - if (t->props & STEP) + if (t->props & SLUMP_STEP) printf("e "); - if (t->props & GRATING) + if (t->props & SLUMP_GRATING) printf("g "); - if (t->props & PLAQUE) + if (t->props & SLUMP_PLAQUE) printf("p "); - if (t->props & VTILES) + if (t->props & SLUMP_VTILES) printf("v "); - if (t->props & HALF_PLAQUE) + if (t->props & SLUMP_HALF_PLAQUE) printf("H "); - if (t->props & LIGHT) + if (t->props & SLUMP_LIGHT) printf("l "); - if (t->props & EXITSWITCH) + if (t->props & SLUMP_EXITSWITCH) printf("E "); - if (t->props & DOOR) + if (t->props & SLUMP_DOOR) printf("d "); - if (t->props & GATE) + if (t->props & SLUMP_GATE) printf("L "); - if (t->props & OUTDOOR) + if (t->props & SLUMP_OUTDOOR) printf("o "); - if (t->props & RED) + if (t->props & SLUMP_RED) printf("r "); - if (t->props & BLUE) + if (t->props & SLUMP_BLUE) printf("b "); - if (t->props & YELLOW) + if (t->props & SLUMP_YELLOW) printf("y "); if (t == c->error_texture) printf("! "); @@ -9966,15 +9979,15 @@ void dump_foo_texture(texture *t, config *c) printf("Y %d ", t->y_bias); if (5 != t->y_hint) printf("@ %d ", t->y_hint); - if (!(t->gamemask & DOOM0_BIT)) + if (!(t->gamemask & SLUMP_DOOM0_BIT)) printf("0 "); - if (!(t->gamemask & DOOM1_BIT)) + if (!(t->gamemask & SLUMP_DOOM1_BIT)) printf("1 "); - if (!(t->gamemask & DOOM2_BIT)) + if (!(t->gamemask & SLUMP_DOOM2_BIT)) printf("2 "); - if (!(t->gamemask & DOOMI_BIT)) + if (!(t->gamemask & SLUMP_DOOMI_BIT)) printf("u "); - if (!(t->gamemask & DOOMC_BIT)) + if (!(t->gamemask & SLUMP_DOOMC_BIT)) printf("Q "); printf("\n"); } @@ -9983,34 +9996,34 @@ void dump_foo_flat(flat *f, config *c) { printf("f %s ", f->name); - if (f->props & FLOOR) + if (f->props & SLUMP_FLOOR) printf("D "); - if (f->props & CEILING) + if (f->props & SLUMP_CEILING) printf("U "); - if (f->props & LIGHT) + if (f->props & SLUMP_LIGHT) printf("l "); - if (f->props & NUKAGE) + if (f->props & SLUMP_NUKAGE) printf("n "); - if (f->props & OUTDOOR) + if (f->props & SLUMP_OUTDOOR) printf("o "); - if (f->props & GATE) + if (f->props & SLUMP_GATE) printf("G "); - if (f->props & RED) + if (f->props & SLUMP_RED) printf("r "); if (f == c->sky_flat) printf("K "); if (f == c->water_flat) printf("W "); dump_foo_themebits(f->compatible, 0, "c", c); - if (!(f->gamemask & DOOM0_BIT)) + if (!(f->gamemask & SLUMP_DOOM0_BIT)) printf("0 "); - if (!(f->gamemask & DOOM1_BIT)) + if (!(f->gamemask & SLUMP_DOOM1_BIT)) printf("1 "); - if (!(f->gamemask & DOOM2_BIT)) + if (!(f->gamemask & SLUMP_DOOM2_BIT)) printf("2 "); - if (!(f->gamemask & DOOMI_BIT)) + if (!(f->gamemask & SLUMP_DOOMI_BIT)) printf("u "); - if (!(f->gamemask & DOOMC_BIT)) + if (!(f->gamemask & SLUMP_DOOMC_BIT)) printf("G "); printf("\n"); } @@ -10031,15 +10044,15 @@ void dump_foo_construct(construct *x, config *c) printf("x m %d h %d ", x->family, x->height); dump_foo_themebits(x->compatible, 0, "c", c); - if (!(x->gamemask & DOOM0_BIT)) + if (!(x->gamemask & SLUMP_DOOM0_BIT)) printf("0 "); - if (!(x->gamemask & DOOM1_BIT)) + if (!(x->gamemask & SLUMP_DOOM1_BIT)) printf("1 "); - if (!(x->gamemask & DOOM2_BIT)) + if (!(x->gamemask & SLUMP_DOOM2_BIT)) printf("2 "); - if (!(x->gamemask & DOOMI_BIT)) + if (!(x->gamemask & SLUMP_DOOMI_BIT)) printf("u "); - if (!(x->gamemask & DOOMC_BIT)) + if (!(x->gamemask & SLUMP_DOOMC_BIT)) printf("G "); printf("\n"); for (fc = x->flat_cell_anchor; fc; fc = fc->next) @@ -10085,116 +10098,116 @@ boolean hardwired_nonswitch_nontheme_config(config *c) genus *m; /* get these obstacles registered as non-pickables */ - if (c->gamemask & HACX_BIT) + if (c->gamemask & SLUMP_HACX_BIT) { // Hacx decor - m = find_genus(c, ID_BARREL); - m->bits &= ~PICKABLE; - m->bits |= EXPLODES; + m = find_genus(c, SLUMP_ID_BARREL); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_EXPLODES; m->width = 33; - m->gamemask = HACX_BIT; - m = find_genus(c, ID_CEILINGLAMP); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_HACX_BIT; + m = find_genus(c, SLUMP_ID_CEILINGLAMP); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 32; - m->gamemask = HACX_BIT; - m = find_genus(c, ID_TALLCEILINGLAMP); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_HACX_BIT; + m = find_genus(c, SLUMP_ID_TALLCEILINGLAMP); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 64; - m->gamemask = HACX_BIT; - m = find_genus(c, ID_FLOORLAMP); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_HACX_BIT; + m = find_genus(c, SLUMP_ID_FLOORLAMP); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 128; - m->gamemask = HACX_BIT; + m->gamemask = SLUMP_HACX_BIT; // Hacx ammo (pretty much the same as Doom ammo) - m = find_genus(c, ID_ROCKBOX); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_ROCKBOX); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_BULBOX); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_BULBOX); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_CELLPACK); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_CELLPACK); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)2000; /* Hoo-hoo! Same for BFG as plasgun? */ } - else if (!(c->gamemask & HERETIC_BIT)) + else if (!(c->gamemask & SLUMP_HERETIC_BIT)) { - m = find_genus(c, ID_LAMP); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_LAMP); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - if (!(c->gamemask & CHEX_BIT)) + if (!(c->gamemask & SLUMP_CHEX_BIT)) { - m = find_genus(c, ID_ELEC); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_ELEC); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 127; /* About */ } - m = find_genus(c, ID_LAMP2); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_LAMP2); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m->gamemask = DOOM2_BIT | DOOMC_BIT | DOOMI_BIT; - m = find_genus(c, ID_TLAMP2); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT; + m = find_genus(c, SLUMP_ID_TLAMP2); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 72; /* Very roughly */ - m->gamemask = DOOM2_BIT | DOOMC_BIT | DOOMI_BIT; - if (!(c->gamemask & CHEX_BIT)) + m->gamemask = SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT; + if (!(c->gamemask & SLUMP_CHEX_BIT)) { - m = find_genus(c, ID_SHORTRED); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_SHORTRED); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m = find_genus(c, ID_SHORTBLUE); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_SHORTBLUE); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m = find_genus(c, ID_SHORTGREEN); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_SHORTGREEN); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m = find_genus(c, ID_TALLRED); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_TALLRED); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 127; /* sure */ - m = find_genus(c, ID_TALLBLUE); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_TALLBLUE); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 127; /* sure */ - m = find_genus(c, ID_TALLGREEN); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_TALLGREEN); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 127; /* sure */ - m = find_genus(c, ID_CBRA); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_CBRA); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; m->height = 72; /* about */ - m = find_genus(c, ID_FBARREL); - m->gamemask = DOOM2_BIT | DOOMC_BIT | DOOMI_BIT; - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_FBARREL); + m->gamemask = SLUMP_DOOM2_BIT | SLUMP_DOOMC_BIT | SLUMP_DOOMI_BIT; + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m = find_genus(c, ID_BARREL); - m->bits &= ~PICKABLE; - m->bits |= EXPLODES; + m = find_genus(c, SLUMP_ID_BARREL); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_EXPLODES; m->width = 33; /* pretend the candle is pickable; really just "not blocking" */ - m = find_genus(c, ID_CANDLE); - m->bits |= PICKABLE; - m->bits |= LIGHT; + m = find_genus(c, SLUMP_ID_CANDLE); + m->bits |= SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 16; } @@ -10202,69 +10215,69 @@ boolean hardwired_nonswitch_nontheme_config(config *c) /* at least the ones that we need for arenas! */ // Doom ammo - m = find_genus(c, ID_ROCKBOX); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_ROCKBOX); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_BULBOX); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_BULBOX); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_CELLPACK); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_CELLPACK); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)2000; /* Hoo-hoo! Same for BFG as plasgun? */ } - else if (c->gamemask & HERETIC_BIT) + else if (c->gamemask & SLUMP_HERETIC_BIT) { // Heretic decor - m = find_genus(c, ID_POD); - m->bits &= ~PICKABLE; - m->bits |= EXPLODES; + m = find_genus(c, SLUMP_ID_POD); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_EXPLODES; m->width = 33; - m->gamemask = HERETIC_BIT; - m = find_genus(c, ID_SERPENTTORCH); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_HERETIC_BIT; + m = find_genus(c, SLUMP_ID_SERPENTTORCH); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m->gamemask = HERETIC_BIT; - m = find_genus(c, ID_FIREBRAZIER); - m->bits &= ~PICKABLE; - m->bits |= LIGHT; + m->gamemask = SLUMP_HERETIC_BIT; + m = find_genus(c, SLUMP_ID_FIREBRAZIER); + m->bits &= ~SLUMP_PICKABLE; + m->bits |= SLUMP_LIGHT; m->width = 33; - m->gamemask = HERETIC_BIT; + m->gamemask = SLUMP_HERETIC_BIT; // Heretic ammo (just the big ones?) - m = find_genus(c, ID_CRYSTALGEODE); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_CRYSTALGEODE); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_ETHEREALQUIVER); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_ETHEREALQUIVER); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_ENERGYORB); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_ENERGYORB); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_GREATERRUNES); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_GREATERRUNES); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_INFERNOORB); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_INFERNOORB); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; - m = find_genus(c, ID_MACESPHEREPILE); - m->bits |= AMMO; + m = find_genus(c, SLUMP_ID_MACESPHEREPILE); + m->bits |= SLUMP_AMMO; m->ammo_provides = (float)500; } /* violence and mayhem */ - c->usualammo[ITYTD] = 5000; - c->usualammo[HMP] = 3500; /* or 3k? */ - c->usualammo[UV] = 3500; /* or 2k? or 3k? */ - c->usualarmor[ITYTD] = 100; - c->usualarmor[HMP] = 50; - c->usualarmor[UV] = 30; /* or 20 */ - c->usualhealth[ITYTD] = 80; - c->usualhealth[HMP] = 65; - c->usualhealth[UV] = 55; - c->minhealth[ITYTD] = 50; - c->minhealth[HMP] = 35; - c->minhealth[UV] = 20; + c->usualammo[SLUMP_ITYTD] = 5000; + c->usualammo[SLUMP_HMP] = 3500; /* or 3k? */ + c->usualammo[SLUMP_UV] = 3500; /* or 2k? or 3k? */ + c->usualarmor[SLUMP_ITYTD] = 100; + c->usualarmor[SLUMP_HMP] = 50; + c->usualarmor[SLUMP_UV] = 30; /* or 20 */ + c->usualhealth[SLUMP_ITYTD] = 80; + c->usualhealth[SLUMP_HMP] = 65; + c->usualhealth[SLUMP_UV] = 55; + c->minhealth[SLUMP_ITYTD] = 50; + c->minhealth[SLUMP_HMP] = 35; + c->minhealth[SLUMP_UV] = 20; /* We have a level progression: * 1) Trooper (non-shooting zombie) * 1) Imp (cobra-like think in FreeDoom) @@ -10276,270 +10289,271 @@ boolean hardwired_nonswitch_nontheme_config(config *c) * 11) Head */ /* Description of monsters */ - if (!(c->gamemask & (HERETIC_BIT | HARMONY_BIT | HACX_BIT))) - { - m = find_monster(c, ID_TROOPER); - m->width = 42; - m->ammo_provides = (float)100; - m->ammo_to_kill[ITYTD] = (float)55; - m->ammo_to_kill[HMP] = (float)35; - m->ammo_to_kill[UV] = (float)30; - m->damage[ITYTD] = (float)15; - m->damage[HMP] = (float)3; - m->damage[UV] = (float)1; - m->altdamage[ITYTD] = (float)10; - m->altdamage[HMP] = (float)1; - m->altdamage[UV] = (float)1; - m->bits |= SHOOTS; + if (!(c->gamemask & (SLUMP_HERETIC_BIT | SLUMP_HARMONY_BIT | SLUMP_HACX_BIT))) + { + m = find_monster(c, SLUMP_ID_TROOPER); + m->width = 42; + m->ammo_provides = (float)100; + m->ammo_to_kill[SLUMP_ITYTD] = (float)55; + m->ammo_to_kill[SLUMP_HMP] = (float)35; + m->ammo_to_kill[SLUMP_UV] = (float)30; + m->damage[SLUMP_ITYTD] = (float)15; + m->damage[SLUMP_HMP] = (float)3; + m->damage[SLUMP_UV] = (float)1; + m->altdamage[SLUMP_ITYTD] = (float)10; + m->altdamage[SLUMP_HMP] = (float)1; + m->altdamage[SLUMP_UV] = (float)1; + m->bits |= SLUMP_SHOOTS; m->min_level = 1; /* Tropper with gun */ - m = find_monster(c, ID_SERGEANT); - m->width = 42; - m->ammo_provides = (float)280; - m->ammo_to_kill[ITYTD] = (float)80; - m->ammo_to_kill[HMP] = (float)50; - m->ammo_to_kill[UV] = (float)40; - m->damage[ITYTD] = (float)25; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)2; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)2; - m->altdamage[UV] = (float)1; - m->bits |= SHOOTS; + m = find_monster(c, SLUMP_ID_SERGEANT); + m->width = 42; + m->ammo_provides = (float)280; + m->ammo_to_kill[SLUMP_ITYTD] = (float)80; + m->ammo_to_kill[SLUMP_HMP] = (float)50; + m->ammo_to_kill[SLUMP_UV] = (float)40; + m->damage[SLUMP_ITYTD] = (float)25; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)2; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)2; + m->altdamage[SLUMP_UV] = (float)1; + m->bits |= SLUMP_SHOOTS; m->min_level = 2; /* Imp */ - m = find_monster(c, ID_IMP); - m->width = 42; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)160; - m->ammo_to_kill[HMP] = (float)95; - m->ammo_to_kill[UV] = (float)80; - m->damage[ITYTD] = (float)20; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)3; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)5; - m->altdamage[UV] = (float)2; - m->bits |= SHOOTS; + m = find_monster(c, SLUMP_ID_IMP); + m->width = 42; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)160; + m->ammo_to_kill[SLUMP_HMP] = (float)95; + m->ammo_to_kill[SLUMP_UV] = (float)80; + m->damage[SLUMP_ITYTD] = (float)20; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)3; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)5; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_SHOOTS; m->min_level = 1; /* Pinky */ - m = find_monster(c, ID_PINK); - m->width = 62; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)385; - m->ammo_to_kill[HMP] = (float)236; - m->ammo_to_kill[UV] = (float)195; - m->damage[ITYTD] = (float)25; - m->damage[HMP] = (float)10; - m->damage[UV] = (float)8; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)8; - m->altdamage[UV] = (float)4; - m->min_level = 3; - if (!(c->gamemask & (CHEX_BIT))) + m = find_monster(c, SLUMP_ID_PINK); + m->width = 62; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)385; + m->ammo_to_kill[SLUMP_HMP] = (float)236; + m->ammo_to_kill[SLUMP_UV] = (float)195; + m->damage[SLUMP_ITYTD] = (float)25; + m->damage[SLUMP_HMP] = (float)10; + m->damage[SLUMP_UV] = (float)8; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)8; + m->altdamage[SLUMP_UV] = (float)4; + m->min_level = 3; + if (!(c->gamemask & (SLUMP_CHEX_BIT))) { /* Invisible pinky */ - m = find_monster(c, ID_SPECTRE); - m->width = 62; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)410; - m->ammo_to_kill[HMP] = (float)260; - m->ammo_to_kill[UV] = (float)220; - m->damage[ITYTD] = (float)25; - m->damage[HMP] = (float)10; - m->damage[UV] = (float)8; - m->altdamage[ITYTD] = (float)25; - m->altdamage[HMP] = (float)8; - m->altdamage[UV] = (float)6; - m->min_level = 7; + m = find_monster(c, SLUMP_ID_SPECTRE); + m->width = 62; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)410; + m->ammo_to_kill[SLUMP_HMP] = (float)260; + m->ammo_to_kill[SLUMP_UV] = (float)220; + m->damage[SLUMP_ITYTD] = (float)25; + m->damage[SLUMP_HMP] = (float)10; + m->damage[SLUMP_UV] = (float)8; + m->altdamage[SLUMP_ITYTD] = (float)25; + m->altdamage[SLUMP_HMP] = (float)8; + m->altdamage[SLUMP_UV] = (float)6; + m->min_level = 7; /* Floating head */ - m = find_monster(c, ID_SKULL); + m = find_monster(c, SLUMP_ID_SKULL); m->width = 34; - m->bits |= BIG; /* Well, sort of! */ - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)260; - m->ammo_to_kill[HMP] = (float)165; - m->ammo_to_kill[UV] = (float)130; - m->damage[ITYTD] = (float)22; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)5; - m->altdamage[ITYTD] = (float)18; - m->altdamage[HMP] = (float)5; - m->altdamage[UV] = (float)2; - m->bits |= FLIES; + m->bits |= SLUMP_BIG; /* Well, sort of! */ + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)260; + m->ammo_to_kill[SLUMP_HMP] = (float)165; + m->ammo_to_kill[SLUMP_UV] = (float)130; + m->damage[SLUMP_ITYTD] = (float)22; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)5; + m->altdamage[SLUMP_ITYTD] = (float)18; + m->altdamage[SLUMP_HMP] = (float)5; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_FLIES; m->min_level = 6; /* Spider thing (I think) */ - m = find_monster(c, ID_HEAD); + m = find_monster(c, SLUMP_ID_HEAD); m->width = 63; /* Or 62 or maybe 64 */ - m->bits |= BIG; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1050; - m->ammo_to_kill[HMP] = (float)630; - m->ammo_to_kill[UV] = (float)590; - m->damage[ITYTD] = (float)60; - m->damage[HMP] = (float)35; - m->damage[UV] = (float)18; - m->altdamage[ITYTD] = (float)50; - m->altdamage[HMP] = (float)20; - m->altdamage[UV] = (float)10; - m->bits |= SHOOTS; - m->bits |= FLIES; + m->bits |= SLUMP_BIG; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1050; + m->ammo_to_kill[SLUMP_HMP] = (float)630; + m->ammo_to_kill[SLUMP_UV] = (float)590; + m->damage[SLUMP_ITYTD] = (float)60; + m->damage[SLUMP_HMP] = (float)35; + m->damage[SLUMP_UV] = (float)18; + m->altdamage[SLUMP_ITYTD] = (float)50; + m->altdamage[SLUMP_HMP] = (float)20; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_SHOOTS; + m->bits |= SLUMP_FLIES; m->min_level = 11; } /* Baron of Hell */ - m = find_monster(c, ID_BARON); - m->width = 50; /* Roughly */ + m = find_monster(c, SLUMP_ID_BARON); + m->width = 50; /* Roughly */ m->height = 64; - m->bits |= BIG | BOSS; /* Not placed randomly */ - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1900; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)1600; - m->ammo_to_kill[UV] = (float)1500; - m->damage[ITYTD] = (float)80; - m->damage[HMP] = (float)40; - m->damage[UV] = (float)25; - m->altdamage[ITYTD] = (float)70; - m->altdamage[HMP] = (float)25; - m->altdamage[UV] = (float)18; - m->bits |= SHOOTS; + m->bits |= SLUMP_BIG | SLUMP_BOSS; /* Not placed randomly */ + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1900; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)1600; + m->ammo_to_kill[SLUMP_UV] = (float)1500; + m->damage[SLUMP_ITYTD] = (float)80; + m->damage[SLUMP_HMP] = (float)40; + m->damage[SLUMP_UV] = (float)25; + m->altdamage[SLUMP_ITYTD] = (float)70; + m->altdamage[SLUMP_HMP] = (float)25; + m->altdamage[SLUMP_UV] = (float)18; + m->bits |= SLUMP_SHOOTS; m->min_level = 12; /* Other bosses; need to fill in data! */ - if (!(c->gamemask & (CHEX_BIT))) + if (!(c->gamemask & (SLUMP_CHEX_BIT))) { - m = find_monster(c, ID_CYBER); + m = find_monster(c, SLUMP_ID_CYBER); m->width = 84; m->height = 110; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)8000; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)6500; - m->ammo_to_kill[UV] = (float)6200; - m = find_monster(c, ID_SPIDERBOSS); - m->width = 260; - m->height = 100; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)6000; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)5000; - m->ammo_to_kill[UV] = (float)4500; - m->min_level = 17; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)8000; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)6500; + m->ammo_to_kill[SLUMP_UV] = (float)6200; + m = find_monster(c, SLUMP_ID_SPIDERBOSS); + m->width = 260; + m->height = 100; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)6000; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)5000; + m->ammo_to_kill[SLUMP_UV] = (float)4500; + m->min_level = 17; } } /* DOOM2 monsters */ - if (!(c->gamemask & (DOOM0_BIT | DOOM1_BIT | HERETIC_BIT | CHEX_BIT | HACX_BIT | HARMONY_BIT))) - { - m = find_monster(c, ID_NAZI); - m->gamemask = DOOM2_BIT; - m->width = 42; - m->ammo_to_kill[ITYTD] = (float)117; - m->ammo_to_kill[HMP] = (float)78; - m->ammo_to_kill[UV] = (float)65; - m->damage[ITYTD] = (float)40; - m->damage[HMP] = (float)14; - m->damage[UV] = (float)7; - m->altdamage[ITYTD] = (float)27; - m->altdamage[HMP] = (float)10; - m->altdamage[UV] = (float)4; - m->bits |= SHOOTS | SPECIAL; - m->min_level = 1; - m = find_monster(c, ID_COMMANDO); - m->gamemask = DOOM2_BIT; - m->width = 42; - m->ammo_provides = (float)100; - m->ammo_to_kill[ITYTD] = (float)155; - m->ammo_to_kill[HMP] = (float)106; - m->ammo_to_kill[UV] = (float)90; - m->damage[ITYTD] = (float)60; - m->damage[HMP] = (float)25; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)40; - m->altdamage[HMP] = (float)20; - m->altdamage[UV] = (float)10; - m->bits |= SHOOTS; + if (!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_HERETIC_BIT | SLUMP_CHEX_BIT | SLUMP_HACX_BIT | + SLUMP_HARMONY_BIT))) + { + m = find_monster(c, SLUMP_ID_NAZI); + m->gamemask = SLUMP_DOOM2_BIT; + m->width = 42; + m->ammo_to_kill[SLUMP_ITYTD] = (float)117; + m->ammo_to_kill[SLUMP_HMP] = (float)78; + m->ammo_to_kill[SLUMP_UV] = (float)65; + m->damage[SLUMP_ITYTD] = (float)40; + m->damage[SLUMP_HMP] = (float)14; + m->damage[SLUMP_UV] = (float)7; + m->altdamage[SLUMP_ITYTD] = (float)27; + m->altdamage[SLUMP_HMP] = (float)10; + m->altdamage[SLUMP_UV] = (float)4; + m->bits |= SLUMP_SHOOTS | SLUMP_SPECIAL; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_COMMANDO); + m->gamemask = SLUMP_DOOM2_BIT; + m->width = 42; + m->ammo_provides = (float)100; + m->ammo_to_kill[SLUMP_ITYTD] = (float)155; + m->ammo_to_kill[SLUMP_HMP] = (float)106; + m->ammo_to_kill[SLUMP_UV] = (float)90; + m->damage[SLUMP_ITYTD] = (float)60; + m->damage[SLUMP_HMP] = (float)25; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)40; + m->altdamage[SLUMP_HMP] = (float)20; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_SHOOTS; m->min_level = 5; - m = find_monster(c, ID_SKEL); - m->gamemask = DOOM2_BIT; + m = find_monster(c, SLUMP_ID_SKEL); + m->gamemask = SLUMP_DOOM2_BIT; m->width = 42; - m->bits |= BIG; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)800; - m->ammo_to_kill[HMP] = (float)500; - m->ammo_to_kill[UV] = (float)400; - m->damage[ITYTD] = (float)125; - m->damage[HMP] = (float)70; - m->damage[UV] = (float)40; - m->altdamage[ITYTD] = (float)100; - m->altdamage[HMP] = (float)40; - m->altdamage[UV] = (float)25; - m->bits |= SHOOTS; + m->bits |= SLUMP_BIG; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)800; + m->ammo_to_kill[SLUMP_HMP] = (float)500; + m->ammo_to_kill[SLUMP_UV] = (float)400; + m->damage[SLUMP_ITYTD] = (float)125; + m->damage[SLUMP_HMP] = (float)70; + m->damage[SLUMP_UV] = (float)40; + m->altdamage[SLUMP_ITYTD] = (float)100; + m->altdamage[SLUMP_HMP] = (float)40; + m->altdamage[SLUMP_UV] = (float)25; + m->bits |= SLUMP_SHOOTS; m->min_level = 7; - m = find_monster(c, ID_HELL); - m->gamemask = DOOM2_BIT; + m = find_monster(c, SLUMP_ID_HELL); + m->gamemask = SLUMP_DOOM2_BIT; m->width = 50; - m->bits |= BIG; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1400; - m->ammo_to_kill[HMP] = (float)850; - m->ammo_to_kill[UV] = (float)666; - m->damage[ITYTD] = (float)140; - m->damage[HMP] = (float)80; - m->damage[UV] = (float)50; - m->altdamage[ITYTD] = (float)120; - m->altdamage[HMP] = (float)50; - m->altdamage[UV] = (float)35; - m->bits |= SHOOTS; + m->bits |= SLUMP_BIG; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1400; + m->ammo_to_kill[SLUMP_HMP] = (float)850; + m->ammo_to_kill[SLUMP_UV] = (float)666; + m->damage[SLUMP_ITYTD] = (float)140; + m->damage[SLUMP_HMP] = (float)80; + m->damage[SLUMP_UV] = (float)50; + m->altdamage[SLUMP_ITYTD] = (float)120; + m->altdamage[SLUMP_HMP] = (float)50; + m->altdamage[SLUMP_UV] = (float)35; + m->bits |= SLUMP_SHOOTS; m->min_level = 11; /* DOOM2 bosses and underbosses; need to fill in data! */ - m = find_monster(c, ID_MANCUB); - m->gamemask = DOOM2_BIT; + m = find_monster(c, SLUMP_ID_MANCUB); + m->gamemask = SLUMP_DOOM2_BIT; m->width = 100; m->height = 64; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)100; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)50; - m->ammo_to_kill[UV] = (float)40; - m->min_level = 19; - m = find_monster(c, ID_ARCHIE); - m->gamemask = DOOM2_BIT; - m->width = 42; - m->height = 56; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1300; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)1100; - m->ammo_to_kill[UV] = (float)1000; - m->min_level = 17; - m = find_monster(c, ID_PAIN); - m->gamemask = DOOM2_BIT; - m->width = 63; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1900; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)1600; - m->ammo_to_kill[UV] = (float)1500; - m = find_monster(c, ID_ARACH); - m->gamemask = DOOM2_BIT; - m->width = 130; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)100; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)50; - m->ammo_to_kill[UV] = (float)30; - m->min_level = 23; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)100; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)50; + m->ammo_to_kill[SLUMP_UV] = (float)40; + m->min_level = 19; + m = find_monster(c, SLUMP_ID_ARCHIE); + m->gamemask = SLUMP_DOOM2_BIT; + m->width = 42; + m->height = 56; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1300; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)1100; + m->ammo_to_kill[SLUMP_UV] = (float)1000; + m->min_level = 17; + m = find_monster(c, SLUMP_ID_PAIN); + m->gamemask = SLUMP_DOOM2_BIT; + m->width = 63; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1900; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)1600; + m->ammo_to_kill[SLUMP_UV] = (float)1500; + m = find_monster(c, SLUMP_ID_ARACH); + m->gamemask = SLUMP_DOOM2_BIT; + m->width = 130; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)100; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)50; + m->ammo_to_kill[SLUMP_UV] = (float)30; + m->min_level = 23; } /* this should be the rough range of where the new monsters are: m->width = radius * 2 + 2 - m->ammo_to_kill[ITYTD] = 2.5 x health - m->ammo_to_kill[HMP] = 1.5 x health - m->ammo_to_kill[UV] = 1.3 x health - m->damage[ITYTD] = max damage value for attack - m->damage[HMP] = 1/2 max damage - m->damage[UV] = 1/4 max damage + m->ammo_to_kill[SLUMP_ITYTD] = 2.5 x health + m->ammo_to_kill[SLUMP_HMP] = 1.5 x health + m->ammo_to_kill[SLUMP_UV] = 1.3 x health + m->damage[SLUMP_ITYTD] = max damage value for attack + m->damage[SLUMP_HMP] = 1/2 max damage + m->damage[SLUMP_UV] = 1/4 max damage m->altdamage (all cases) = 2/3 of above values m->ammo_provides = ammo dropped * avg damage for weapon/ammo m->bits = appropriate per-monster values @@ -10547,519 +10561,519 @@ boolean hardwired_nonswitch_nontheme_config(config *c) */ /* Heretic monsters */ - if (c->gamemask & (HERETIC_BIT)) - { - m = find_monster(c, ID_GARGOYLE); - m->gamemask = HERETIC_BIT; - m->width = 34; - m->ammo_to_kill[ITYTD] = (float)100; - m->ammo_to_kill[HMP] = (float)60; - m->ammo_to_kill[UV] = (float)50; - m->damage[ITYTD] = (float)12; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)3; - m->altdamage[ITYTD] = (float)8; - m->altdamage[HMP] = (float)4; - m->altdamage[UV] = (float)2; - m->bits |= FLIES; - m->min_level = 10; - m = find_monster(c, ID_FIREGARGOYLE); - m->gamemask = HERETIC_BIT; - m->width = 34; - m->ammo_to_kill[ITYTD] = (float)200; - m->ammo_to_kill[HMP] = (float)120; - m->ammo_to_kill[UV] = (float)100; - m->damage[ITYTD] = (float)12; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)3; - m->altdamage[ITYTD] = (float)8; - m->altdamage[HMP] = (float)4; - m->altdamage[UV] = (float)2; - m->bits |= FLIES; - m->bits |= SHOOTS; - m->min_level = 12; - m = find_monster(c, ID_GOLEM); - m->gamemask = HERETIC_BIT; - m->width = 46; - m->ammo_to_kill[ITYTD] = (float)200; - m->ammo_to_kill[HMP] = (float)120; - m->ammo_to_kill[UV] = (float)100; - m->ammo_provides = (float)10; - m->damage[ITYTD] = (float)16; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)4; - m->altdamage[ITYTD] = (float)12; - m->altdamage[HMP] = (float)6; - m->altdamage[UV] = (float)3; - m->min_level = 10; - m = find_monster(c, ID_NITROGOLEM); - m->gamemask = HERETIC_BIT; - m->width = 46; - m->ammo_to_kill[ITYTD] = (float)250; - m->ammo_to_kill[HMP] = (float)150; - m->ammo_to_kill[UV] = (float)130; - m->damage[ITYTD] = (float)32; - m->damage[HMP] = (float)16; - m->damage[UV] = (float)8; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)10; - m->altdamage[UV] = (float)6; - m->bits |= SHOOTS; - m->min_level = 13; - m = find_monster(c, ID_OPHIDIAN); - m->gamemask = HERETIC_BIT; - m->width = 46; - m->ammo_to_kill[ITYTD] = (float)700; - m->ammo_to_kill[HMP] = (float)420; - m->ammo_to_kill[UV] = (float)360; - m->ammo_provides = (float)90; - m->damage[ITYTD] = (float)24; - m->damage[HMP] = (float)12; - m->damage[UV] = (float)6; - m->altdamage[ITYTD] = (float)16; - m->altdamage[HMP] = (float)8; - m->altdamage[UV] = (float)4; - m->bits |= SHOOTS; - m->min_level = 28; - m = find_monster(c, ID_SABRECLAW); - m->gamemask = HERETIC_BIT; - m->width = 42; - m->ammo_to_kill[ITYTD] = (float)375; - m->ammo_to_kill[HMP] = (float)225; - m->ammo_to_kill[UV] = (float)195; - m->ammo_provides = (float)14; - m->damage[ITYTD] = (float)9; - m->damage[HMP] = (float)5; - m->damage[UV] = (float)3; - m->altdamage[ITYTD] = (float)8; - m->altdamage[HMP] = (float)4; - m->altdamage[UV] = (float)2; - m->min_level = 20; - m = find_monster(c, ID_UNDEADWARRIOR); - m->gamemask = HERETIC_BIT; - m->width = 50; - m->ammo_to_kill[ITYTD] = (float)500; - m->ammo_to_kill[HMP] = (float)300; - m->ammo_to_kill[UV] = (float)275; - m->damage[ITYTD] = (float)16; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)4; - m->altdamage[ITYTD] = (float)10; - m->altdamage[HMP] = (float)6; - m->altdamage[UV] = (float)3; - m->min_level = 10; - m->bits |= SHOOTS; - m = find_monster(c, ID_DISCIPLE); - m->gamemask = HERETIC_BIT; - m->width = 34; - m->ammo_to_kill[ITYTD] = (float)450; - m->ammo_to_kill[HMP] = (float)270; - m->ammo_to_kill[UV] = (float)240; - m->ammo_provides = (float)18; - m->damage[ITYTD] = (float)24; - m->damage[HMP] = (float)12; - m->damage[UV] = (float)6; - m->altdamage[ITYTD] = (float)16; - m->altdamage[HMP] = (float)8; - m->altdamage[UV] = (float)4; - m->min_level = 13; - m->bits |= SHOOTS; - m = find_monster(c, ID_WEREDRAGON); - m->gamemask = HERETIC_BIT; - m->width = 66; - m->ammo_to_kill[ITYTD] = (float)550; - m->ammo_to_kill[HMP] = (float)330; - m->ammo_to_kill[UV] = (float)290; - m->ammo_provides = (float)45; - m->damage[ITYTD] = (float)32; - m->damage[HMP] = (float)16; - m->damage[UV] = (float)8; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)12; - m->altdamage[UV] = (float)6; - m->min_level = 19; - m->bits |= SHOOTS; - m = find_monster(c, ID_MAULOTAUR); - m->gamemask = HERETIC_BIT; - m->width = 58; - m->ammo_to_kill[ITYTD] = (float)7500; - m->ammo_to_kill[HMP] = (float)4500; - m->ammo_to_kill[UV] = (float)4000; - m->ammo_provides = (float)90; - m->damage[ITYTD] = (float)56; - m->damage[HMP] = (float)28; - m->damage[UV] = (float)14; - m->altdamage[ITYTD] = (float)38; - m->altdamage[HMP] = (float)18; - m->altdamage[UV] = (float)10; - m->min_level = 27; - m->bits |= SHOOTS; - m->bits |= BOSS; - m->bits |= BIG; - m = find_monster(c, ID_IRONLICH); - m->gamemask = HERETIC_BIT; - m->width = 82; - m->ammo_to_kill[ITYTD] = (float)1750; - m->ammo_to_kill[HMP] = (float)1050; - m->ammo_to_kill[UV] = (float)925; - m->ammo_provides = (float)18; - m->damage[ITYTD] = (float)48; - m->damage[HMP] = (float)24; - m->damage[UV] = (float)12; - m->altdamage[ITYTD] = (float)32; - m->altdamage[HMP] = (float)16; - m->altdamage[UV] = (float)8; - m->min_level = 17; - m->bits |= SHOOTS; - m->bits |= BOSS; - m->bits |= BIG; - m = find_monster(c, ID_DSPARIL); - m->gamemask = HERETIC_BIT; - m->width = 58; - m->ammo_to_kill[ITYTD] = (float)13500; - m->ammo_to_kill[HMP] = (float)8000; - m->ammo_to_kill[UV] = (float)6500; - m->damage[ITYTD] = (float)80; - m->damage[HMP] = (float)40; - m->damage[UV] = (float)20; - m->altdamage[ITYTD] = (float)60; - m->altdamage[HMP] = (float)30; - m->altdamage[UV] = (float)15; - m->min_level = 35; - m->bits |= SHOOTS; - m->bits |= BOSS; - m->bits |= BIG; + if (c->gamemask & (SLUMP_HERETIC_BIT)) + { + m = find_monster(c, SLUMP_ID_GARGOYLE); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 34; + m->ammo_to_kill[SLUMP_ITYTD] = (float)100; + m->ammo_to_kill[SLUMP_HMP] = (float)60; + m->ammo_to_kill[SLUMP_UV] = (float)50; + m->damage[SLUMP_ITYTD] = (float)12; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)3; + m->altdamage[SLUMP_ITYTD] = (float)8; + m->altdamage[SLUMP_HMP] = (float)4; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_FLIES; + m->min_level = 10; + m = find_monster(c, SLUMP_ID_FIREGARGOYLE); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 34; + m->ammo_to_kill[SLUMP_ITYTD] = (float)200; + m->ammo_to_kill[SLUMP_HMP] = (float)120; + m->ammo_to_kill[SLUMP_UV] = (float)100; + m->damage[SLUMP_ITYTD] = (float)12; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)3; + m->altdamage[SLUMP_ITYTD] = (float)8; + m->altdamage[SLUMP_HMP] = (float)4; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_FLIES; + m->bits |= SLUMP_SHOOTS; + m->min_level = 12; + m = find_monster(c, SLUMP_ID_GOLEM); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 46; + m->ammo_to_kill[SLUMP_ITYTD] = (float)200; + m->ammo_to_kill[SLUMP_HMP] = (float)120; + m->ammo_to_kill[SLUMP_UV] = (float)100; + m->ammo_provides = (float)10; + m->damage[SLUMP_ITYTD] = (float)16; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)4; + m->altdamage[SLUMP_ITYTD] = (float)12; + m->altdamage[SLUMP_HMP] = (float)6; + m->altdamage[SLUMP_UV] = (float)3; + m->min_level = 10; + m = find_monster(c, SLUMP_ID_NITROGOLEM); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 46; + m->ammo_to_kill[SLUMP_ITYTD] = (float)250; + m->ammo_to_kill[SLUMP_HMP] = (float)150; + m->ammo_to_kill[SLUMP_UV] = (float)130; + m->damage[SLUMP_ITYTD] = (float)32; + m->damage[SLUMP_HMP] = (float)16; + m->damage[SLUMP_UV] = (float)8; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)10; + m->altdamage[SLUMP_UV] = (float)6; + m->bits |= SLUMP_SHOOTS; + m->min_level = 13; + m = find_monster(c, SLUMP_ID_OPHIDIAN); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 46; + m->ammo_to_kill[SLUMP_ITYTD] = (float)700; + m->ammo_to_kill[SLUMP_HMP] = (float)420; + m->ammo_to_kill[SLUMP_UV] = (float)360; + m->ammo_provides = (float)90; + m->damage[SLUMP_ITYTD] = (float)24; + m->damage[SLUMP_HMP] = (float)12; + m->damage[SLUMP_UV] = (float)6; + m->altdamage[SLUMP_ITYTD] = (float)16; + m->altdamage[SLUMP_HMP] = (float)8; + m->altdamage[SLUMP_UV] = (float)4; + m->bits |= SLUMP_SHOOTS; + m->min_level = 28; + m = find_monster(c, SLUMP_ID_SABRECLAW); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 42; + m->ammo_to_kill[SLUMP_ITYTD] = (float)375; + m->ammo_to_kill[SLUMP_HMP] = (float)225; + m->ammo_to_kill[SLUMP_UV] = (float)195; + m->ammo_provides = (float)14; + m->damage[SLUMP_ITYTD] = (float)9; + m->damage[SLUMP_HMP] = (float)5; + m->damage[SLUMP_UV] = (float)3; + m->altdamage[SLUMP_ITYTD] = (float)8; + m->altdamage[SLUMP_HMP] = (float)4; + m->altdamage[SLUMP_UV] = (float)2; + m->min_level = 20; + m = find_monster(c, SLUMP_ID_UNDEADWARRIOR); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 50; + m->ammo_to_kill[SLUMP_ITYTD] = (float)500; + m->ammo_to_kill[SLUMP_HMP] = (float)300; + m->ammo_to_kill[SLUMP_UV] = (float)275; + m->damage[SLUMP_ITYTD] = (float)16; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)4; + m->altdamage[SLUMP_ITYTD] = (float)10; + m->altdamage[SLUMP_HMP] = (float)6; + m->altdamage[SLUMP_UV] = (float)3; + m->min_level = 10; + m->bits |= SLUMP_SHOOTS; + m = find_monster(c, SLUMP_ID_DISCIPLE); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 34; + m->ammo_to_kill[SLUMP_ITYTD] = (float)450; + m->ammo_to_kill[SLUMP_HMP] = (float)270; + m->ammo_to_kill[SLUMP_UV] = (float)240; + m->ammo_provides = (float)18; + m->damage[SLUMP_ITYTD] = (float)24; + m->damage[SLUMP_HMP] = (float)12; + m->damage[SLUMP_UV] = (float)6; + m->altdamage[SLUMP_ITYTD] = (float)16; + m->altdamage[SLUMP_HMP] = (float)8; + m->altdamage[SLUMP_UV] = (float)4; + m->min_level = 13; + m->bits |= SLUMP_SHOOTS; + m = find_monster(c, SLUMP_ID_WEREDRAGON); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 66; + m->ammo_to_kill[SLUMP_ITYTD] = (float)550; + m->ammo_to_kill[SLUMP_HMP] = (float)330; + m->ammo_to_kill[SLUMP_UV] = (float)290; + m->ammo_provides = (float)45; + m->damage[SLUMP_ITYTD] = (float)32; + m->damage[SLUMP_HMP] = (float)16; + m->damage[SLUMP_UV] = (float)8; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)12; + m->altdamage[SLUMP_UV] = (float)6; + m->min_level = 19; + m->bits |= SLUMP_SHOOTS; + m = find_monster(c, SLUMP_ID_MAULOTAUR); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 58; + m->ammo_to_kill[SLUMP_ITYTD] = (float)7500; + m->ammo_to_kill[SLUMP_HMP] = (float)4500; + m->ammo_to_kill[SLUMP_UV] = (float)4000; + m->ammo_provides = (float)90; + m->damage[SLUMP_ITYTD] = (float)56; + m->damage[SLUMP_HMP] = (float)28; + m->damage[SLUMP_UV] = (float)14; + m->altdamage[SLUMP_ITYTD] = (float)38; + m->altdamage[SLUMP_HMP] = (float)18; + m->altdamage[SLUMP_UV] = (float)10; + m->min_level = 27; + m->bits |= SLUMP_SHOOTS; + m->bits |= SLUMP_BOSS; + m->bits |= SLUMP_BIG; + m = find_monster(c, SLUMP_ID_IRONLICH); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 82; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1750; + m->ammo_to_kill[SLUMP_HMP] = (float)1050; + m->ammo_to_kill[SLUMP_UV] = (float)925; + m->ammo_provides = (float)18; + m->damage[SLUMP_ITYTD] = (float)48; + m->damage[SLUMP_HMP] = (float)24; + m->damage[SLUMP_UV] = (float)12; + m->altdamage[SLUMP_ITYTD] = (float)32; + m->altdamage[SLUMP_HMP] = (float)16; + m->altdamage[SLUMP_UV] = (float)8; + m->min_level = 17; + m->bits |= SLUMP_SHOOTS; + m->bits |= SLUMP_BOSS; + m->bits |= SLUMP_BIG; + m = find_monster(c, SLUMP_ID_DSPARIL); + m->gamemask = SLUMP_HERETIC_BIT; + m->width = 58; + m->ammo_to_kill[SLUMP_ITYTD] = (float)13500; + m->ammo_to_kill[SLUMP_HMP] = (float)8000; + m->ammo_to_kill[SLUMP_UV] = (float)6500; + m->damage[SLUMP_ITYTD] = (float)80; + m->damage[SLUMP_HMP] = (float)40; + m->damage[SLUMP_UV] = (float)20; + m->altdamage[SLUMP_ITYTD] = (float)60; + m->altdamage[SLUMP_HMP] = (float)30; + m->altdamage[SLUMP_UV] = (float)15; + m->min_level = 35; + m->bits |= SLUMP_SHOOTS; + m->bits |= SLUMP_BOSS; + m->bits |= SLUMP_BIG; } /* Hacx monsters */ - if (c->gamemask & (HACX_BIT)) - { - m = find_monster(c, ID_THUG); - m->gamemask = HACX_BIT; - m->width = 44; - m->height = 72; - m->ammo_provides = (float)100; - m->ammo_to_kill[ITYTD] = (float)160; - m->ammo_to_kill[HMP] = (float)95; - m->ammo_to_kill[UV] = (float)80; - m->damage[ITYTD] = (float)15; - m->damage[HMP] = (float)3; - m->damage[UV] = (float)1; - m->altdamage[ITYTD] = (float)10; - m->altdamage[HMP] = (float)1; - m->altdamage[UV] = (float)1; - m->bits |= SHOOTS; - m->min_level = 1; - m = find_monster(c, ID_ANDROID); - m->gamemask = HACX_BIT; - m->width = 44; - m->height = 70; - m->ammo_provides = (float)280; - m->ammo_to_kill[ITYTD] = (float)200; - m->ammo_to_kill[HMP] = (float)120; - m->ammo_to_kill[UV] = (float)100; - m->damage[ITYTD] = (float)25; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)2; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)2; - m->altdamage[UV] = (float)1; - m->bits |= SHOOTS; - m->min_level = 1; - m = find_monster(c, ID_BUZZER); - m->gamemask = HACX_BIT; - m->width = 52; - m->height = 68; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)440; - m->ammo_to_kill[HMP] = (float)265; - m->ammo_to_kill[UV] = (float)230; - m->damage[ITYTD] = (float)75; - m->damage[HMP] = (float)35; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)60; - m->altdamage[HMP] = (float)25; - m->altdamage[UV] = (float)10; - m->bits |= FLIES; - m->min_level = 1; - m = find_monster(c, ID_STEALTHBUZZER); - m->gamemask = HACX_BIT; - m->width = 52; - m->height = 68; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)440; - m->ammo_to_kill[HMP] = (float)265; - m->ammo_to_kill[UV] = (float)230; - m->damage[ITYTD] = (float)75; - m->damage[HMP] = (float)35; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)60; - m->altdamage[HMP] = (float)25; - m->altdamage[UV] = (float)10; - m->bits |= FLIES; - m->min_level = 1; - m = find_monster(c, ID_HACXPHAGE); - m->gamemask = HACX_BIT; - m->width = 52; - m->height = 96; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)375; - m->ammo_to_kill[HMP] = (float)225; - m->ammo_to_kill[UV] = (float)200; - m->damage[ITYTD] = (float)32; - m->damage[HMP] = (float)16; - m->damage[UV] = (float)8; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)10; - m->altdamage[UV] = (float)6; - m->bits |= SHOOTS; - m->min_level = 2; - m = find_monster(c, ID_ICE); - m->gamemask = HACX_BIT; - m->width = 66; - m->height = 55; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)560; - m->ammo_to_kill[HMP] = (float)340; - m->ammo_to_kill[UV] = (float)300; - m->damage[ITYTD] = (float)22; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)5; - m->altdamage[ITYTD] = (float)18; - m->altdamage[HMP] = (float)5; - m->altdamage[UV] = (float)2; - m->bits |= FLIES; - m->min_level = 5; - m = find_monster(c, ID_DMAN); - m->gamemask = HACX_BIT; - m->width = 98; - m->height = 77; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)625; - m->ammo_to_kill[HMP] = (float)375; - m->ammo_to_kill[UV] = (float)325; - m->damage[ITYTD] = (float)22; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)5; - m->altdamage[ITYTD] = (float)18; - m->altdamage[HMP] = (float)5; - m->altdamage[UV] = (float)2; - m->bits |= FLIES | BIG; - m->min_level = 5; - m = find_monster(c, ID_MAJONG7); - m->gamemask = HACX_BIT; - m->width = 64; - m->height = 56; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1500; - m->ammo_to_kill[HMP] = (float)600; - m->ammo_to_kill[UV] = (float)520; - m->min_level = 2; - m->bits |= SHOOTS; - m = find_monster(c, ID_MONSTRUCT); - m->gamemask = HACX_BIT; - m->width = 72; - m->height = 87; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1500; - m->ammo_to_kill[HMP] = (float)600; - m->ammo_to_kill[UV] = (float)520; - m->ammo_provides = (float)100; - m->damage[ITYTD] = (float)100; - m->damage[HMP] = (float)50; - m->damage[UV] = (float)25; - m->altdamage[ITYTD] = (float)80; - m->altdamage[HMP] = (float)40; - m->altdamage[UV] = (float)15; - m->min_level = 2; - m->bits |= SHOOTS | BIG; - m = find_monster(c, ID_TERMINATRIX); - m->gamemask = HACX_BIT; - m->width = 50; - m->height = 96; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)2000; - m->ammo_to_kill[HMP] = (float)1200; - m->ammo_to_kill[UV] = (float)1040; - m->damage[ITYTD] = (float)90; - m->damage[HMP] = (float)45; - m->damage[UV] = (float)20; - m->altdamage[ITYTD] = (float)75; - m->altdamage[HMP] = (float)35; - m->altdamage[UV] = (float)13; - m->min_level = 9; - m->bits |= SHOOTS | BOSS; - m = find_monster(c, ID_THORNTHING); - m->gamemask = HACX_BIT; - m->width = 130; - m->height = 96; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1500; - m->ammo_to_kill[HMP] = (float)900; - m->ammo_to_kill[UV] = (float)780; - m->damage[ITYTD] = (float)125; - m->damage[HMP] = (float)70; - m->damage[UV] = (float)40; - m->altdamage[ITYTD] = (float)100; - m->altdamage[HMP] = (float)40; - m->altdamage[UV] = (float)25; - m->min_level = 9; - m->bits |= SHOOTS | BOSS | BIG; - m = find_monster(c, ID_MECHAMANIAC); - m->gamemask = HACX_BIT; - m->width = 50; - m->height = 96; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)2000; - m->ammo_to_kill[HMP] = (float)1200; - m->ammo_to_kill[UV] = (float)1040; - m->damage[ITYTD] = (float)150; - m->damage[HMP] = (float)90; - m->damage[UV] = (float)50; - m->altdamage[ITYTD] = (float)120; - m->altdamage[HMP] = (float)80; - m->altdamage[UV] = (float)40; - m->min_level = 9; - m->bits |= SHOOTS | BOSS; - m = find_monster(c, ID_ROAMINGMINE); - m->gamemask = HACX_BIT; - m->width = 18; - m->height = 32; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)125; - m->ammo_to_kill[HMP] = (float)75; - m->ammo_to_kill[UV] = (float)65; - m->damage[ITYTD] = (float)100; - m->damage[HMP] = (float)50; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)80; - m->altdamage[HMP] = (float)40; - m->altdamage[UV] = (float)10; - m->min_level = 16; - m->bits |= FLIES; + if (c->gamemask & (SLUMP_HACX_BIT)) + { + m = find_monster(c, SLUMP_ID_THUG); + m->gamemask = SLUMP_HACX_BIT; + m->width = 44; + m->height = 72; + m->ammo_provides = (float)100; + m->ammo_to_kill[SLUMP_ITYTD] = (float)160; + m->ammo_to_kill[SLUMP_HMP] = (float)95; + m->ammo_to_kill[SLUMP_UV] = (float)80; + m->damage[SLUMP_ITYTD] = (float)15; + m->damage[SLUMP_HMP] = (float)3; + m->damage[SLUMP_UV] = (float)1; + m->altdamage[SLUMP_ITYTD] = (float)10; + m->altdamage[SLUMP_HMP] = (float)1; + m->altdamage[SLUMP_UV] = (float)1; + m->bits |= SLUMP_SHOOTS; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_ANDROID); + m->gamemask = SLUMP_HACX_BIT; + m->width = 44; + m->height = 70; + m->ammo_provides = (float)280; + m->ammo_to_kill[SLUMP_ITYTD] = (float)200; + m->ammo_to_kill[SLUMP_HMP] = (float)120; + m->ammo_to_kill[SLUMP_UV] = (float)100; + m->damage[SLUMP_ITYTD] = (float)25; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)2; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)2; + m->altdamage[SLUMP_UV] = (float)1; + m->bits |= SLUMP_SHOOTS; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_BUZZER); + m->gamemask = SLUMP_HACX_BIT; + m->width = 52; + m->height = 68; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)440; + m->ammo_to_kill[SLUMP_HMP] = (float)265; + m->ammo_to_kill[SLUMP_UV] = (float)230; + m->damage[SLUMP_ITYTD] = (float)75; + m->damage[SLUMP_HMP] = (float)35; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)60; + m->altdamage[SLUMP_HMP] = (float)25; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_FLIES; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_STEALTHBUZZER); + m->gamemask = SLUMP_HACX_BIT; + m->width = 52; + m->height = 68; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)440; + m->ammo_to_kill[SLUMP_HMP] = (float)265; + m->ammo_to_kill[SLUMP_UV] = (float)230; + m->damage[SLUMP_ITYTD] = (float)75; + m->damage[SLUMP_HMP] = (float)35; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)60; + m->altdamage[SLUMP_HMP] = (float)25; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_FLIES; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_HACXPHAGE); + m->gamemask = SLUMP_HACX_BIT; + m->width = 52; + m->height = 96; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)375; + m->ammo_to_kill[SLUMP_HMP] = (float)225; + m->ammo_to_kill[SLUMP_UV] = (float)200; + m->damage[SLUMP_ITYTD] = (float)32; + m->damage[SLUMP_HMP] = (float)16; + m->damage[SLUMP_UV] = (float)8; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)10; + m->altdamage[SLUMP_UV] = (float)6; + m->bits |= SLUMP_SHOOTS; + m->min_level = 2; + m = find_monster(c, SLUMP_ID_ICE); + m->gamemask = SLUMP_HACX_BIT; + m->width = 66; + m->height = 55; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)560; + m->ammo_to_kill[SLUMP_HMP] = (float)340; + m->ammo_to_kill[SLUMP_UV] = (float)300; + m->damage[SLUMP_ITYTD] = (float)22; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)5; + m->altdamage[SLUMP_ITYTD] = (float)18; + m->altdamage[SLUMP_HMP] = (float)5; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_FLIES; + m->min_level = 5; + m = find_monster(c, SLUMP_ID_DMAN); + m->gamemask = SLUMP_HACX_BIT; + m->width = 98; + m->height = 77; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)625; + m->ammo_to_kill[SLUMP_HMP] = (float)375; + m->ammo_to_kill[SLUMP_UV] = (float)325; + m->damage[SLUMP_ITYTD] = (float)22; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)5; + m->altdamage[SLUMP_ITYTD] = (float)18; + m->altdamage[SLUMP_HMP] = (float)5; + m->altdamage[SLUMP_UV] = (float)2; + m->bits |= SLUMP_FLIES | SLUMP_BIG; + m->min_level = 5; + m = find_monster(c, SLUMP_ID_MAJONG7); + m->gamemask = SLUMP_HACX_BIT; + m->width = 64; + m->height = 56; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1500; + m->ammo_to_kill[SLUMP_HMP] = (float)600; + m->ammo_to_kill[SLUMP_UV] = (float)520; + m->min_level = 2; + m->bits |= SLUMP_SHOOTS; + m = find_monster(c, SLUMP_ID_MONSTRUCT); + m->gamemask = SLUMP_HACX_BIT; + m->width = 72; + m->height = 87; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1500; + m->ammo_to_kill[SLUMP_HMP] = (float)600; + m->ammo_to_kill[SLUMP_UV] = (float)520; + m->ammo_provides = (float)100; + m->damage[SLUMP_ITYTD] = (float)100; + m->damage[SLUMP_HMP] = (float)50; + m->damage[SLUMP_UV] = (float)25; + m->altdamage[SLUMP_ITYTD] = (float)80; + m->altdamage[SLUMP_HMP] = (float)40; + m->altdamage[SLUMP_UV] = (float)15; + m->min_level = 2; + m->bits |= SLUMP_SHOOTS | SLUMP_BIG; + m = find_monster(c, SLUMP_ID_TERMINATRIX); + m->gamemask = SLUMP_HACX_BIT; + m->width = 50; + m->height = 96; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)2000; + m->ammo_to_kill[SLUMP_HMP] = (float)1200; + m->ammo_to_kill[SLUMP_UV] = (float)1040; + m->damage[SLUMP_ITYTD] = (float)90; + m->damage[SLUMP_HMP] = (float)45; + m->damage[SLUMP_UV] = (float)20; + m->altdamage[SLUMP_ITYTD] = (float)75; + m->altdamage[SLUMP_HMP] = (float)35; + m->altdamage[SLUMP_UV] = (float)13; + m->min_level = 9; + m->bits |= SLUMP_SHOOTS | SLUMP_BOSS; + m = find_monster(c, SLUMP_ID_THORNTHING); + m->gamemask = SLUMP_HACX_BIT; + m->width = 130; + m->height = 96; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1500; + m->ammo_to_kill[SLUMP_HMP] = (float)900; + m->ammo_to_kill[SLUMP_UV] = (float)780; + m->damage[SLUMP_ITYTD] = (float)125; + m->damage[SLUMP_HMP] = (float)70; + m->damage[SLUMP_UV] = (float)40; + m->altdamage[SLUMP_ITYTD] = (float)100; + m->altdamage[SLUMP_HMP] = (float)40; + m->altdamage[SLUMP_UV] = (float)25; + m->min_level = 9; + m->bits |= SLUMP_SHOOTS | SLUMP_BOSS | SLUMP_BIG; + m = find_monster(c, SLUMP_ID_MECHAMANIAC); + m->gamemask = SLUMP_HACX_BIT; + m->width = 50; + m->height = 96; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)2000; + m->ammo_to_kill[SLUMP_HMP] = (float)1200; + m->ammo_to_kill[SLUMP_UV] = (float)1040; + m->damage[SLUMP_ITYTD] = (float)150; + m->damage[SLUMP_HMP] = (float)90; + m->damage[SLUMP_UV] = (float)50; + m->altdamage[SLUMP_ITYTD] = (float)120; + m->altdamage[SLUMP_HMP] = (float)80; + m->altdamage[SLUMP_UV] = (float)40; + m->min_level = 9; + m->bits |= SLUMP_SHOOTS | SLUMP_BOSS; + m = find_monster(c, SLUMP_ID_ROAMINGMINE); + m->gamemask = SLUMP_HACX_BIT; + m->width = 18; + m->height = 32; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)125; + m->ammo_to_kill[SLUMP_HMP] = (float)75; + m->ammo_to_kill[SLUMP_UV] = (float)65; + m->damage[SLUMP_ITYTD] = (float)100; + m->damage[SLUMP_HMP] = (float)50; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)80; + m->altdamage[SLUMP_HMP] = (float)40; + m->altdamage[SLUMP_UV] = (float)10; + m->min_level = 16; + m->bits |= SLUMP_FLIES; } /* Harmony monsters */ - if (c->gamemask & (HARMONY_BIT)) - { - m = find_monster(c, ID_BEASTLING); - m->gamemask = HARMONY_BIT; - m->width = 62; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)385; - m->ammo_to_kill[HMP] = (float)236; - m->ammo_to_kill[UV] = (float)195; - m->damage[ITYTD] = (float)60; - m->damage[HMP] = (float)30; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)40; - m->altdamage[HMP] = (float)20; - m->altdamage[UV] = (float)10; - m->min_level = 1; - m = find_monster(c, ID_FOLLOWER); - m->gamemask = HARMONY_BIT; - m->width = 42; - m->ammo_provides = (float)280; - m->ammo_to_kill[ITYTD] = (float)80; - m->ammo_to_kill[HMP] = (float)50; - m->ammo_to_kill[UV] = (float)40; - m->damage[ITYTD] = (float)25; - m->damage[HMP] = (float)6; - m->damage[UV] = (float)2; - m->altdamage[ITYTD] = (float)20; - m->altdamage[HMP] = (float)2; - m->altdamage[UV] = (float)1; - m->bits |= SHOOTS; - m->min_level = 1; - m = find_monster(c, ID_MUTANTSOLDIER); - m->gamemask = HARMONY_BIT; - m->width = 42; - m->ammo_provides = (float)100; - m->ammo_to_kill[ITYTD] = (float)155; - m->ammo_to_kill[HMP] = (float)106; - m->ammo_to_kill[UV] = (float)90; - m->damage[ITYTD] = (float)60; - m->damage[HMP] = (float)25; - m->damage[UV] = (float)15; - m->altdamage[ITYTD] = (float)40; - m->altdamage[HMP] = (float)20; - m->altdamage[UV] = (float)10; - m->bits |= SHOOTS; + if (c->gamemask & (SLUMP_HARMONY_BIT)) + { + m = find_monster(c, SLUMP_ID_BEASTLING); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 62; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)385; + m->ammo_to_kill[SLUMP_HMP] = (float)236; + m->ammo_to_kill[SLUMP_UV] = (float)195; + m->damage[SLUMP_ITYTD] = (float)60; + m->damage[SLUMP_HMP] = (float)30; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)40; + m->altdamage[SLUMP_HMP] = (float)20; + m->altdamage[SLUMP_UV] = (float)10; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_FOLLOWER); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 42; + m->ammo_provides = (float)280; + m->ammo_to_kill[SLUMP_ITYTD] = (float)80; + m->ammo_to_kill[SLUMP_HMP] = (float)50; + m->ammo_to_kill[SLUMP_UV] = (float)40; + m->damage[SLUMP_ITYTD] = (float)25; + m->damage[SLUMP_HMP] = (float)6; + m->damage[SLUMP_UV] = (float)2; + m->altdamage[SLUMP_ITYTD] = (float)20; + m->altdamage[SLUMP_HMP] = (float)2; + m->altdamage[SLUMP_UV] = (float)1; + m->bits |= SLUMP_SHOOTS; + m->min_level = 1; + m = find_monster(c, SLUMP_ID_MUTANTSOLDIER); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 42; + m->ammo_provides = (float)100; + m->ammo_to_kill[SLUMP_ITYTD] = (float)155; + m->ammo_to_kill[SLUMP_HMP] = (float)106; + m->ammo_to_kill[SLUMP_UV] = (float)90; + m->damage[SLUMP_ITYTD] = (float)60; + m->damage[SLUMP_HMP] = (float)25; + m->damage[SLUMP_UV] = (float)15; + m->altdamage[SLUMP_ITYTD] = (float)40; + m->altdamage[SLUMP_HMP] = (float)20; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_SHOOTS; m->min_level = 5; - m = find_monster(c, ID_PHAGE); - m->gamemask = HARMONY_BIT; + m = find_monster(c, SLUMP_ID_PHAGE); + m->gamemask = SLUMP_HARMONY_BIT; m->width = 98; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)100; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)50; - m->ammo_to_kill[UV] = (float)30; - m->min_level = 23; - m = find_monster(c, ID_PREDATOR); - m->gamemask = HARMONY_BIT; - m->width = 42; - m->bits |= BIG; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)800; - m->ammo_to_kill[HMP] = (float)500; - m->ammo_to_kill[UV] = (float)400; - m->damage[ITYTD] = (float)125; - m->damage[HMP] = (float)70; - m->damage[UV] = (float)40; - m->altdamage[ITYTD] = (float)100; - m->altdamage[HMP] = (float)40; - m->altdamage[UV] = (float)25; - m->bits |= SHOOTS; - m->min_level = 7; - m = find_monster(c, ID_LANDMINE); - m->gamemask = HARMONY_BIT; - m->width = 34; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)260; - m->ammo_to_kill[HMP] = (float)165; - m->ammo_to_kill[UV] = (float)130; - m->damage[ITYTD] = (float)22; - m->damage[HMP] = (float)8; - m->damage[UV] = (float)5; - m->altdamage[ITYTD] = (float)18; - m->altdamage[HMP] = (float)5; - m->altdamage[UV] = (float)2; - m->min_level = 6; - m = find_monster(c, ID_AEROSOL); - m->gamemask = HARMONY_BIT; - m->width = 64; - m->bits |= BIG; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)1050; - m->ammo_to_kill[HMP] = (float)630; - m->ammo_to_kill[UV] = (float)590; - m->damage[ITYTD] = (float)60; - m->damage[HMP] = (float)35; - m->damage[UV] = (float)18; - m->altdamage[ITYTD] = (float)50; - m->altdamage[HMP] = (float)20; - m->altdamage[UV] = (float)10; - m->bits |= SHOOTS; - m->bits |= FLIES; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)100; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)50; + m->ammo_to_kill[SLUMP_UV] = (float)30; + m->min_level = 23; + m = find_monster(c, SLUMP_ID_PREDATOR); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 42; + m->bits |= SLUMP_BIG; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)800; + m->ammo_to_kill[SLUMP_HMP] = (float)500; + m->ammo_to_kill[SLUMP_UV] = (float)400; + m->damage[SLUMP_ITYTD] = (float)125; + m->damage[SLUMP_HMP] = (float)70; + m->damage[SLUMP_UV] = (float)40; + m->altdamage[SLUMP_ITYTD] = (float)100; + m->altdamage[SLUMP_HMP] = (float)40; + m->altdamage[SLUMP_UV] = (float)25; + m->bits |= SLUMP_SHOOTS; + m->min_level = 7; + m = find_monster(c, SLUMP_ID_LANDMINE); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 34; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)260; + m->ammo_to_kill[SLUMP_HMP] = (float)165; + m->ammo_to_kill[SLUMP_UV] = (float)130; + m->damage[SLUMP_ITYTD] = (float)22; + m->damage[SLUMP_HMP] = (float)8; + m->damage[SLUMP_UV] = (float)5; + m->altdamage[SLUMP_ITYTD] = (float)18; + m->altdamage[SLUMP_HMP] = (float)5; + m->altdamage[SLUMP_UV] = (float)2; + m->min_level = 6; + m = find_monster(c, SLUMP_ID_AEROSOL); + m->gamemask = SLUMP_HARMONY_BIT; + m->width = 64; + m->bits |= SLUMP_BIG; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)1050; + m->ammo_to_kill[SLUMP_HMP] = (float)630; + m->ammo_to_kill[SLUMP_UV] = (float)590; + m->damage[SLUMP_ITYTD] = (float)60; + m->damage[SLUMP_HMP] = (float)35; + m->damage[SLUMP_UV] = (float)18; + m->altdamage[SLUMP_ITYTD] = (float)50; + m->altdamage[SLUMP_HMP] = (float)20; + m->altdamage[SLUMP_UV] = (float)10; + m->bits |= SLUMP_SHOOTS; + m->bits |= SLUMP_FLIES; m->min_level = 11; - m = find_monster(c, ID_CENTAUR); - m->gamemask = HARMONY_BIT; + m = find_monster(c, SLUMP_ID_CENTAUR); + m->gamemask = SLUMP_HARMONY_BIT; m->width = 84; m->height = 110; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)8000; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)6500; - m->ammo_to_kill[UV] = (float)6200; - m = find_monster(c, ID_ECHIDNA); - m->width = 260; - m->height = 100; - m->bits |= BIG | BOSS; - m->ammo_provides = (float)0; - m->ammo_to_kill[ITYTD] = (float)6000; /* Numbers are all guesses; fix */ - m->ammo_to_kill[HMP] = (float)5000; - m->ammo_to_kill[UV] = (float)4500; - m->min_level = 17; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)8000; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)6500; + m->ammo_to_kill[SLUMP_UV] = (float)6200; + m = find_monster(c, SLUMP_ID_ECHIDNA); + m->width = 260; + m->height = 100; + m->bits |= SLUMP_BIG | SLUMP_BOSS; + m->ammo_provides = (float)0; + m->ammo_to_kill[SLUMP_ITYTD] = (float)6000; /* Numbers are all guesses; fix */ + m->ammo_to_kill[SLUMP_HMP] = (float)5000; + m->ammo_to_kill[SLUMP_UV] = (float)4500; + m->min_level = 17; } return SLUMP_TRUE; @@ -11076,49 +11090,49 @@ propertybits absorb_propertybit(char **r) p = *r; if ((!StringCaseCompare(p, "wall")) || (!StringCompare(p, "w"))) - return WALL; + return SLUMP_WALL; if ((!StringCaseCompare(p, "isswitch")) || (!StringCompare(p, "i"))) - return SWITCH; + return SLUMP_SWITCH; if ((!StringCaseCompare(p, "lift")) || (!StringCompare(p, "F"))) - return LIFT_TEXTURE; + return SLUMP_LIFT_TEXTURE; if ((!StringCaseCompare(p, "support")) || (!StringCompare(p, "I"))) - return SUPPORT; + return SLUMP_SUPPORT; if ((!StringCaseCompare(p, "jamb")) || (!StringCompare(p, "j"))) - return JAMB; + return SLUMP_JAMB; if ((!StringCaseCompare(p, "step")) || (!StringCompare(p, "e"))) - return STEP; + return SLUMP_STEP; if ((!StringCaseCompare(p, "grating")) || (!StringCompare(p, "g"))) - return GRATING; + return SLUMP_GRATING; if ((!StringCaseCompare(p, "plaque")) || (!StringCompare(p, "p"))) - return PLAQUE; + return SLUMP_PLAQUE; if ((!StringCaseCompare(p, "vtiles")) || (!StringCompare(p, "v"))) - return VTILES; + return SLUMP_VTILES; if ((!StringCaseCompare(p, "half_plaque")) || (!StringCompare(p, "H"))) - return HALF_PLAQUE; + return SLUMP_HALF_PLAQUE; if ((!StringCaseCompare(p, "light")) || (!StringCompare(p, "l"))) - return LIGHT; + return SLUMP_LIGHT; if ((!StringCaseCompare(p, "exitswitch")) || (!StringCompare(p, "E"))) - return EXITSWITCH; + return SLUMP_EXITSWITCH; if ((!StringCaseCompare(p, "door")) || (!StringCompare(p, "d"))) - return DOOR; + return SLUMP_DOOR; if ((!StringCaseCompare(p, "locked")) || (!StringCompare(p, "L"))) - return GATE; + return SLUMP_GATE; if ((!StringCaseCompare(p, "outside")) || (!StringCompare(p, "o"))) - return OUTDOOR; + return SLUMP_OUTDOOR; if ((!StringCaseCompare(p, "red")) || (!StringCompare(p, "r"))) - return RED; + return SLUMP_RED; if ((!StringCaseCompare(p, "blue")) || (!StringCompare(p, "b"))) - return BLUE; + return SLUMP_BLUE; if ((!StringCaseCompare(p, "yellow")) || (!StringCompare(p, "y"))) - return YELLOW; + return SLUMP_YELLOW; if ((!StringCaseCompare(p, "floor")) || (!StringCompare(p, "D"))) - return FLOOR; + return SLUMP_FLOOR; if ((!StringCaseCompare(p, "ceiling")) || (!StringCompare(p, "U"))) - return CEILING; + return SLUMP_CEILING; if ((!StringCaseCompare(p, "nukage")) || (!StringCompare(p, "n"))) - return NUKAGE; + return SLUMP_NUKAGE; if ((!StringCaseCompare(p, "gate")) || (!StringCompare(p, "G"))) - return GATE; + return SLUMP_GATE; return 0; } @@ -11134,17 +11148,17 @@ gamebits absorb_gamebit(char **r) p = *r; if ((!StringCaseCompare(p, "nodoom0")) || (!StringCompare(p, "0"))) - return DOOM0_BIT; + return SLUMP_DOOM0_BIT; if ((!StringCaseCompare(p, "nodoom1")) || (!StringCompare(p, "1"))) - return DOOM1_BIT; + return SLUMP_DOOM1_BIT; if ((!StringCaseCompare(p, "nodoom2")) || (!StringCompare(p, "2"))) - return DOOM2_BIT; + return SLUMP_DOOM2_BIT; if ((!StringCaseCompare(p, "gross")) || (!StringCompare(p, "Q"))) - return DOOMC_BIT; + return SLUMP_DOOMC_BIT; if ((!StringCaseCompare(p, "custom")) || (!StringCompare(p, "u"))) - return DOOMI_BIT; + return SLUMP_DOOMI_BIT; if ((!StringCaseCompare(p, "heretic")) || (!StringCompare(p, "R"))) - return HERETIC_BIT; // "R" for Raven, since "H" is already used + return SLUMP_HERETIC_BIT; // "R" for Raven, since "H" is already used return 0; } @@ -11583,7 +11597,7 @@ genus *random_thing0(propertybits pmask, config *c, style *s, int minh, int maxh } if (tcount == 0) { - announce(NONE, "No compatible things for theme"); /* This is OK */ + announce(SLUMP_NONE, "No compatible things for theme"); /* This is OK */ return NULL; } tcount = 1 + roll(tcount); @@ -11625,7 +11639,7 @@ flat *random_flat0(propertybits pmask, config *c, style *s) } if (fcount == 0) { - announce(NONE, "No compatible flats for theme"); /* This is OK */ + announce(SLUMP_NONE, "No compatible flats for theme"); /* This is OK */ return NULL; } fcount = 1 + roll(fcount); @@ -11644,27 +11658,27 @@ flat *random_flat0(propertybits pmask, config *c, style *s) flat *random_floor0(config *c, style *s) { - return random_flat0(FLOOR, c, s); + return random_flat0(SLUMP_FLOOR, c, s); } flat *random_gate(config *c, style *s) { - return random_flat0(GATE, c, s); + return random_flat0(SLUMP_GATE, c, s); } flat *random_ceiling0(config *c, style *s) { - return random_flat0(CEILING, c, s); + return random_flat0(SLUMP_CEILING, c, s); } flat *random_ceilinglight(config *c, style *s) { - return random_flat0(CEILING + LIGHT, c, s); + return random_flat0(SLUMP_CEILING + SLUMP_LIGHT, c, s); } flat *random_nukage1(config *c, style *s) { - return random_flat0(NUKAGE, c, s); + return random_flat0(SLUMP_NUKAGE, c, s); } flat *random_doorceiling(config *c, style *s) @@ -11715,7 +11729,7 @@ texture *random_texture0(propertybits pmask, config *c, style *s) } if (tcount == 0) { - announce(NONE, "No compatible textures for theme"); /* It's OK! */ + announce(SLUMP_NONE, "No compatible textures for theme"); /* It's OK! */ return NULL; } tcount = 1 + roll(tcount); @@ -11734,7 +11748,7 @@ texture *random_texture0(propertybits pmask, config *c, style *s) texture *random_support0(config *c, style *s) { - return random_texture0(SUPPORT, c, s); + return random_texture0(SLUMP_SUPPORT, c, s); } texture *random_wall0(config *c, style *s) @@ -11749,7 +11763,7 @@ texture *random_wall0(config *c, style *s) tcount = 0; for (answer = c->texture_anchor; answer; answer = answer->next) { - if (!(answer->props & WALL)) + if (!(answer->props & SLUMP_WALL)) continue; if (!(answer->core & tmask)) continue; @@ -11759,13 +11773,14 @@ texture *random_wall0(config *c, style *s) } if (tcount == 0) { - announce(WARNING, "No core wall textures for theme"); + announce(SLUMP_WARNING, "No core wall textures for theme"); return c->error_texture; } tcount = 1 + roll(tcount); for (answer = c->texture_anchor; answer; answer = answer->next) { - if ((answer->props & WALL) && (answer->core & tmask) && ((answer->gamemask & c->gamemask) == c->gamemask)) + if ((answer->props & SLUMP_WALL) && (answer->core & tmask) && + ((answer->gamemask & c->gamemask) == c->gamemask)) { tcount--; if (tcount == 0) @@ -11775,7 +11790,7 @@ texture *random_wall0(config *c, style *s) } else { /* Use any compatible wall texture */ - return random_texture0(WALL, c, s); + return random_texture0(SLUMP_WALL, c, s); } return NULL; @@ -11795,7 +11810,7 @@ texture *random_stepfront(config *c, style *s) if (!rollpercent(c->p_use_steps)) answer = random_kickplate(c, s); else - answer = random_texture0(STEP, c, s); + answer = random_texture0(SLUMP_STEP, c, s); if (answer == NULL) answer = random_kickplate(c, s); return answer; @@ -11809,38 +11824,38 @@ texture *switch0_for(config *c, style *s) } else { - return random_texture0(SWITCH, c, s); + return random_texture0(SLUMP_SWITCH, c, s); } } texture *random_doorjamb(config *c, style *s) { - return random_texture0(JAMB, c, s); + return random_texture0(SLUMP_JAMB, c, s); } texture *random_redface(config *c, style *s) { - return random_texture0(RED, c, s); + return random_texture0(SLUMP_RED, c, s); } texture *random_blueface(config *c, style *s) { - return random_texture0(BLUE, c, s); + return random_texture0(SLUMP_BLUE, c, s); } texture *random_yellowface(config *c, style *s) { - return random_texture0(YELLOW, c, s); + return random_texture0(SLUMP_YELLOW, c, s); } texture *random_walllight(config *c, style *s) { - return random_texture0(LIGHT, c, s); + return random_texture0(SLUMP_LIGHT, c, s); } texture *random_liftface(config *c, style *s) { - return random_texture0(LIFT_TEXTURE, c, s); + return random_texture0(SLUMP_LIFT_TEXTURE, c, s); } /* should consult the lists in the config like the others do */ @@ -11864,9 +11879,9 @@ texture *random_widedoorface_ex(config *c, style *s, boolean needhigh) tcount = 0; for (answer = c->texture_anchor; answer; answer = answer->next) { - if (!(answer->props & DOOR)) + if (!(answer->props & SLUMP_DOOR)) continue; - if (answer->props & GATE) + if (answer->props & SLUMP_GATE) continue; if ((answer->width) < 128) continue; @@ -11886,7 +11901,7 @@ texture *random_widedoorface_ex(config *c, style *s, boolean needhigh) tcount = 1 + roll(tcount); for (answer = c->texture_anchor; answer; answer = answer->next) { - if ((answer->props & DOOR) && (!(answer->props & GATE)) && (answer->width >= 128) && + if ((answer->props & SLUMP_DOOR) && (!(answer->props & SLUMP_GATE)) && (answer->width >= 128) && (!(needhigh && (answer->height < 128))) && (answer->compatible & tmask) && ((answer->gamemask & c->gamemask) == c->gamemask)) { @@ -11918,9 +11933,9 @@ texture *random_narrowdoorface_ex(config *c, style *s, boolean needhigh) tcount = 0; for (answer = c->texture_anchor; answer; answer = answer->next) { - if (!(answer->props & DOOR)) + if (!(answer->props & SLUMP_DOOR)) continue; - if (answer->props & GATE) + if (answer->props & SLUMP_GATE) continue; if ((answer->width) >= 128) continue; @@ -11940,7 +11955,7 @@ texture *random_narrowdoorface_ex(config *c, style *s, boolean needhigh) tcount = 1 + roll(tcount); for (answer = c->texture_anchor; answer; answer = answer->next) { - if ((answer->props & DOOR) && (!(answer->props & GATE)) && (answer->width < 128) && + if ((answer->props & SLUMP_DOOR) && (!(answer->props & SLUMP_GATE)) && (answer->width < 128) && (!(needhigh && (answer->height < 128))) && (answer->compatible & tmask) && ((answer->gamemask & c->gamemask) == c->gamemask)) { @@ -11986,9 +12001,9 @@ texture *random_lockdoorface(config *c, style *s) tcount = 0; for (answer = c->texture_anchor; answer; answer = answer->next) { - if (!(answer->props & DOOR)) + if (!(answer->props & SLUMP_DOOR)) continue; - if (!(answer->props & GATE)) + if (!(answer->props & SLUMP_GATE)) continue; if (!(answer->compatible & tmask)) continue; @@ -11998,13 +12013,13 @@ texture *random_lockdoorface(config *c, style *s) } if (tcount == 0) { - announce(NONE, "No locked doorfaces for theme"); /* That's OK */ + announce(SLUMP_NONE, "No locked doorfaces for theme"); /* That's OK */ return NULL; } tcount = 1 + roll(tcount); for (answer = c->texture_anchor; answer; answer = answer->next) { - if ((answer->props & DOOR) && (answer->props & GATE) && (answer->compatible & tmask) && + if ((answer->props & SLUMP_DOOR) && (answer->props & SLUMP_GATE) && (answer->compatible & tmask) && ((answer->gamemask & c->gamemask) == c->gamemask)) { tcount--; @@ -12017,12 +12032,12 @@ texture *random_lockdoorface(config *c, style *s) texture *random_grating(config *c, style *s) { - return random_texture0(GRATING, c, s); + return random_texture0(SLUMP_GRATING, c, s); } texture *random_plaque(config *c, style *s) { - return random_texture0(PLAQUE, c, s); + return random_texture0(SLUMP_PLAQUE, c, s); } /* Return the angle (east is zero, north is ninety) of a thing */ @@ -12084,7 +12099,7 @@ void frame_innersec_ex(level *l, sector *oldsector, sector *innersec, texture *t short newflags; if (innersec) - newflags = TWO_SIDED; + newflags = SLUMP_TWO_SIDED; else newflags = 0; if (!tm) @@ -12161,7 +12176,7 @@ void frame_innersec_ex(level *l, sector *oldsector, sector *innersec, texture *t } /* frame_innersec_ex() */ -/* The common axis-parallel case of frame_innersec. If the four pointers */ +/* The common axis-parallel case of SLUMP_frame_innersec. If the four pointers */ /* are given, the first and third will be y-parallel, the second and */ /* fourth x-parallel. */ void parallel_innersec_ex(level *l, sector *oldsector, sector *innersec, texture *tm, texture *tu, texture *tl, @@ -12258,19 +12273,19 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, new_thing(l, minx - 8, maxy + 8, 0, thing_id, 7, c); new_thing(l, maxx + 8, miny - 8, 0, thing_id, 7, c); new_thing(l, maxx + 8, maxy + 8, 0, thing_id, 7, c); - announce(VERBOSE, "edgelights"); + announce(SLUMP_VERBOSE, "edgelights"); } if (center_light && room_at(l, g, minx + (maxx - minx) / 2, miny + (maxy - miny) / 2, g->width, c)) { new_thing(l, minx + (maxx - minx) / 2, miny + (maxy - miny) / 2, 0, thing_id, 7, c); - announce(VERBOSE, "centerlight"); + announce(SLUMP_VERBOSE, "centerlight"); } } /* end if big enough square for lights */ { char s[200]; sprintf(s, "Ceiling effect between (%d,%d) and (%d,%d).", minx, miny, maxx, maxy); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } /* Make the sector itself */ @@ -12308,7 +12323,7 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, if (rollpercent(90)) innersec->ceiling_flat = oldsector->ceiling_flat; } - announce(VERBOSE, "Indirect lighting"); + announce(SLUMP_VERBOSE, "Indirect lighting"); } /* If no light-level decision made yet, make one */ @@ -12326,16 +12341,16 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, switch (roll(4)) { case 0: - innersec->special = RANDOM_BLINK; + innersec->special = SLUMP_RANDOM_BLINK; break; case 1: - innersec->special = SYNC_FAST_BLINK; + innersec->special = SLUMP_SYNC_FAST_BLINK; break; case 2: - innersec->special = SYNC_SLOW_BLINK; + innersec->special = SLUMP_SYNC_SLOW_BLINK; break; case 3: - innersec->special = GLOW_BLINK; + innersec->special = SLUMP_GLOW_BLINK; break; } } /* end if light effects */ @@ -12362,11 +12377,11 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, if (deltah < 0) if (force_nukage || rollpercent(30)) { - announce(VERBOSE, "Nukage"); + announce(SLUMP_VERBOSE, "Nukage"); innersec->floor_flat = ThisStyle->nukage1; - innersec->special = NUKAGE1_SPECIAL; - haa->haas[ITYTD].health -= 10; - haa->haas[HMP].health -= 5; + innersec->special = SLUMP_NUKAGE1_SPECIAL; + haa->haas[SLUMP_ITYTD].health -= 10; + haa->haas[SLUMP_HMP].health -= 5; } } else @@ -12379,22 +12394,22 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, { int xsize = ((maxx - minx) - beamsize) / 2; int ysize = ((maxy - miny) - beamsize) / 2; - parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, minx, miny, minx + xsize, - miny + ysize, c); - parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, minx, maxy - ysize, minx + xsize, - maxy, c); - parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, maxx - xsize, miny, maxx, - miny + ysize, c); - parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, maxx - xsize, maxy - ysize, maxx, - maxy, c); + SLUMP_parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, minx, miny, minx + xsize, + miny + ysize, c); + SLUMP_parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, minx, maxy - ysize, + minx + xsize, maxy, c); + SLUMP_parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, maxx - xsize, miny, maxx, + miny + ysize, c); + SLUMP_parallel_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, maxx - xsize, maxy - ysize, + maxx, maxy, c); } else if ((maxx - minx > 128) && (maxy - miny > 128) && ((maxx - minx) <= (2 * (maxy - miny))) && ((maxy - miny) <= (2 * (maxx - minx))) && rollpercent(10)) { /* A diamond! Is this safe? Not axis-parallel! */ - announce(LOG, "Diamond"); - frame_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, (minx + maxx) / 2, miny, minx, - (miny + maxy) / 2, (minx + maxx) / 2, maxy, maxx, (miny + maxy) / 2, c); + announce(SLUMP_LOG, "Diamond"); + SLUMP_frame_innersec(l, oldsector, innersec, NULL, upt, oldsector->pstyle->wall0, (minx + maxx) / 2, miny, minx, + (miny + maxy) / 2, (minx + maxx) / 2, maxy, maxx, (miny + maxy) / 2, c); } else { @@ -12428,7 +12443,7 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, ldnew = new_linedef(l, ld4new->from, ld2new->to); ldnew->left = new_sidedef(l, innersec, c); ldnew->right = new_sidedef(l, newsec, c); - ldnew->flags |= TWO_SIDED; + ldnew->flags |= SLUMP_TWO_SIDED; ldnew->right->middle_texture = c->null_texture; ldnew->left->middle_texture = c->null_texture; patch_lower(ldnew, newsec->pstyle->wall0, c); @@ -12441,10 +12456,10 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, if (rollpercent(75)) { innersec->floor_flat = c->water_flat; - announce(LOG, "Water pool"); + announce(SLUMP_LOG, "Water pool"); } if (fancied) - announce(LOG, "Bath"); + announce(SLUMP_LOG, "Bath"); } /* Sometimes more layers! How dangerous is this? */ if (rollpercent(20) && (!fancied) && /* Generalize "20" */ @@ -12468,12 +12483,13 @@ boolean ceiling_effect(level *l, sector *oldsector, style *ThisStyle, haa *haa, inner2 = clone_sector(l, innersec); inner2->special = innersec->special; inner2->floor_height += deltah; - announce(VERBOSE, "Sunk"); + announce(SLUMP_VERBOSE, "Sunk"); minx += 32; /* Generalize "32"s */ maxx -= 32; miny += 32; maxy -= 32; - parallel_innersec(l, innersec, inner2, NULL, upt, oldsector->pstyle->wall0, minx, miny, maxx, maxy, c); + SLUMP_parallel_innersec(l, innersec, inner2, NULL, upt, oldsector->pstyle->wall0, minx, miny, maxx, + maxy, c); innersec = inner2; } } @@ -12498,8 +12514,8 @@ void righthand_monster(level *l, int xa, int ya, int xb, int yb, haa *haa, confi /* Figure out where we want it */ x1 = (xa + xb) / 2; y1 = (ya + yb) / 2; - point_from(xa, ya, x1, y1, RIGHT_TURN, 1 + MONSTER_WIDTH(m) / 2, &x, &y); - if (!room_at(l, m, x, y, MONSTER_WIDTH(m), c)) + point_from(xa, ya, x1, y1, SLUMP_RIGHT_TURN, 1 + SLUMP_MONSTER_WIDTH(m) / 2, &x, &y); + if (!room_at(l, m, x, y, SLUMP_MONSTER_WIDTH(m), c)) return; /* Fill in other details */ angle = facing_right_from(xa, ya, xb, yb); /* Correct? */ @@ -12561,7 +12577,7 @@ void do_pillar(level *l, sector *oldsector, style *ThisStyle, haa *haa, config * for (t = l->thing_anchor; t; t = t->next) if ((t->x >= minx) && (t->x <= maxx) && (t->y >= miny) && (t->y <= maxy)) { - announce(VERBOSE, "Too many things for a pillar"); + announce(SLUMP_VERBOSE, "Too many things for a pillar"); return; } /* None! A miracle. Define the space. */ @@ -12582,9 +12598,9 @@ void do_pillar(level *l, sector *oldsector, style *ThisStyle, haa *haa, config * } else { - parallel_innersec(l, oldsector, NULL, t1, NULL, NULL, minx, miny, maxx, maxy, c); + SLUMP_parallel_innersec(l, oldsector, NULL, t1, NULL, NULL, minx, miny, maxx, maxy, c); } - announce(VERBOSE, "Made a pillar"); + announce(SLUMP_VERBOSE, "Made a pillar"); /* Consider putting some monsters around it */ righthand_monster(l, minx, maxy, minx, miny, haa, c); @@ -12758,7 +12774,7 @@ boolean install_construct(level *l, sector *oldsector, int minx, int miny, int m } if (tcp == NULL) { /* Impossible! */ - announce(WARNING, "Some impossible error in construct-construction."); + announce(SLUMP_WARNING, "Some impossible error in construct-construction."); return SLUMP_FALSE; } @@ -12836,17 +12852,17 @@ boolean install_construct(level *l, sector *oldsector, int minx, int miny, int m ld2->right->lower_texture = tc2->ptexture; ld3->right->lower_texture = tc3->ptexture; ld4->right->lower_texture = tc4->ptexture; - ld1->flags &= ~LOWER_UNPEGGED; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->flags &= ~LOWER_UNPEGGED; + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; } ld1->right->y_offset = rollpercent(50) ? tc1->y_offset1 : tc1->y_offset2; ld2->right->y_offset = rollpercent(50) ? tc2->y_offset1 : tc2->y_offset2; ld3->right->y_offset = rollpercent(50) ? tc3->y_offset1 : tc3->y_offset2; ld4->right->y_offset = rollpercent(50) ? tc4->y_offset1 : tc4->y_offset2; - announce(VERBOSE, "Construct"); + announce(SLUMP_VERBOSE, "Construct"); return SLUMP_TRUE; } /* end install_construct */ @@ -12956,19 +12972,19 @@ boolean do_new_pillar(level *l, sector *oldsector, sector *innersec, texture *t1 miny = miny + ((maxy - miny) - 128) / 2; maxy = miny + 128; t1 = ThisStyle->plaque; - announce(VERBOSE, "Plaque-pillar"); + announce(SLUMP_VERBOSE, "Plaque-pillar"); } if (innersec) { - announce(VERBOSE, "Inner pillar"); + announce(SLUMP_VERBOSE, "Inner pillar"); tm = NULL; } else { tm = t1; } - parallel_innersec(l, oldsector, innersec, tm, t1, t1, minx, miny, maxx, maxy, c); - announce(VERBOSE, "New pillar"); + SLUMP_parallel_innersec(l, oldsector, innersec, tm, t1, t1, minx, miny, maxx, maxy, c); + announce(SLUMP_VERBOSE, "New pillar"); } /* Consider putting some monsters around it */ if (rollpercent(50)) @@ -13064,7 +13080,7 @@ void do_new_pillars(level *l, sector *oldsector, style *ThisStyle, haa *haa, con /* Put some appropriate monster(s) and bonus(es) along the right */ /* side of the given linedef. Adjust the haa (haa adjustment */ -/* assumes that ITYTD doesn't find the bonuses, and HMP only */ +/* assumes that SLUMP_ITYTD doesn't find the bonuses, and SLUMP_HMP only */ /* finds them half the time, if is true). */ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean secret) { @@ -13075,9 +13091,9 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se int levels, farness, plen; short angle; - point_from(ldnew2->from->x, ldnew2->from->y, ldnew2->to->x, ldnew2->to->y, RIGHT_TURN, 32, &x1, + point_from(ldnew2->from->x, ldnew2->from->y, ldnew2->to->x, ldnew2->to->y, SLUMP_RIGHT_TURN, 32, &x1, &y1); /* "32" should be improved */ - plen = linelen(ldnew2); + plen = SLUMP_linelen(ldnew2); switch (roll(4)) { case 1: @@ -13093,12 +13109,12 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se farness = 32; break; } - point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, RIGHT_TURN, farness, &x, &y); + point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, SLUMP_RIGHT_TURN, farness, &x, &y); /* pick a prize; stubby */ - bonustype = ID_POTION; /* Just in case! */ + bonustype = SLUMP_ID_POTION; /* Just in case! */ if (l->heretic_level) { - bonustype = ID_WANDCRYSTAL; + bonustype = SLUMP_ID_WANDCRYSTAL; } if (rollpercent(50)) { /* Health or whatever */ @@ -13107,33 +13123,33 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se switch (roll(4)) { case 0: - bonustype = ID_QUARTZFLASK; + bonustype = SLUMP_ID_QUARTZFLASK; bonusamount = 25; break; case 1: - bonustype = ID_QUARTZFLASK; + bonustype = SLUMP_ID_QUARTZFLASK; bonusamount = 25; break; case 2: - bonustype = ID_CRYSTALVIAL; + bonustype = SLUMP_ID_CRYSTALVIAL; bonusamount = 10; break; case 3: if ((SLUMP_FALSE == l->seen_map) && rollpercent(30)) { - bonustype = ID_MAPSCROLL; + bonustype = SLUMP_ID_MAPSCROLL; bonusamount = 0; l->seen_map = SLUMP_TRUE; - announce(VERBOSE, "Area map"); + announce(SLUMP_VERBOSE, "Area map"); } else { - bonustype = ID_SHADOWSPHERE; + bonustype = SLUMP_ID_SHADOWSPHERE; bonusamount = 10; /* Also guess */ } break; default: - bonustype = ID_WANDCRYSTAL; + bonustype = SLUMP_ID_WANDCRYSTAL; bonusamount = 0; /* Impossible */ } } @@ -13142,52 +13158,52 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se switch (roll(4)) { case 0: - bonustype = ID_MEDIKIT; + bonustype = SLUMP_ID_MEDIKIT; bonusamount = 25; break; case 1: - bonustype = ID_MEDIKIT; + bonustype = SLUMP_ID_MEDIKIT; bonusamount = 25; break; case 2: - bonustype = ID_STIMPACK; + bonustype = SLUMP_ID_STIMPACK; bonusamount = 10; break; case 3: if ((SLUMP_FALSE == l->seen_suit) && (rollpercent(l->p_force_nukage))) { - bonustype = ID_SUIT; + bonustype = SLUMP_ID_SUIT; bonusamount = 10; /* Guess */ l->seen_suit = SLUMP_TRUE; } else if ((SLUMP_FALSE == l->seen_map) && rollpercent(30)) { - bonustype = ID_MAP; + bonustype = SLUMP_ID_MAP; bonusamount = 0; l->seen_map = SLUMP_TRUE; - announce(VERBOSE, "Area map"); + announce(SLUMP_VERBOSE, "Area map"); } else { - if (c->gamemask & CHEX_BIT) + if (c->gamemask & SLUMP_CHEX_BIT) { - bonustype = ID_STIMPACK; + bonustype = SLUMP_ID_STIMPACK; bonusamount = 10; } else { - bonustype = ID_INVIS; + bonustype = SLUMP_ID_INVIS; bonusamount = 10; /* Also guess */ } } break; default: - bonustype = ID_POTION; + bonustype = SLUMP_ID_POTION; bonusamount = 1; /* Impossible */ } } - /* We assume ITYTD didn't find the closet! */ - haa->haas[1].health += bonusamount / 2; /* and HMP might not have */ + /* We assume SLUMP_ITYTD didn't find the closet! */ + haa->haas[1].health += bonusamount / 2; /* and SLUMP_HMP might not have */ haa->haas[2].health += bonusamount; if (!secret) { /* Unless it's not a secret */ @@ -13201,23 +13217,23 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se { if ((haa->haas[0].can_use_cells) && (rollpercent(20))) { - bonustype = ID_HELLSTAFF; + bonustype = SLUMP_ID_HELLSTAFF; bonusamount = 1400; /* yow! */ } else if ((haa->haas[0].can_use_rockets) && (rollpercent(20))) { - bonustype = ID_INFERNOORB; + bonustype = SLUMP_ID_INFERNOORB; bonusamount = 900; } else if ((!(haa->haas[2].has_chainsaw)) && (rollpercent(20))) { - bonustype = ID_GAUNTLETS; + bonustype = SLUMP_ID_GAUNTLETS; bonusamount = 0; haa->haas[2].has_chainsaw = SLUMP_TRUE; } else if (rollpercent(2)) { - bonustype = ID_GAUNTLETS; + bonustype = SLUMP_ID_GAUNTLETS; bonusamount = 0; haa->haas[2].has_chainsaw = SLUMP_TRUE; } @@ -13225,20 +13241,20 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se switch (roll(3)) { // knickknacks case 1: - bonustype = ID_MAPSCROLL; + bonustype = SLUMP_ID_MAPSCROLL; bonusamount = 0; break; case 2: - bonustype = ID_TIMEBOMB; + bonustype = SLUMP_ID_TIMEBOMB; bonusamount = 0; break; default: - bonustype = ID_TORCH; + bonustype = SLUMP_ID_TORCH; bonusamount = 0; break; } /* end switch */ - /* We assume ITYTD didn't find the closet! */ - haa->haas[1].ammo += bonusamount / 2; /* And HMP only prolly did */ + /* We assume SLUMP_ITYTD didn't find the closet! */ + haa->haas[1].ammo += bonusamount / 2; /* And SLUMP_HMP only prolly did */ haa->haas[2].ammo += bonusamount; if (!secret) { /* Unless it's not a secret */ @@ -13246,7 +13262,7 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se haa->haas[1].ammo += bonusamount / 2; } /* Account for chainsaws; primitive */ - if (bonustype == ID_GAUNTLETS) + if (bonustype == SLUMP_ID_GAUNTLETS) { haa->haas[1].has_chainsaw = SLUMP_TRUE; /* OK? */ haa->haas[2].has_chainsaw = SLUMP_TRUE; @@ -13256,23 +13272,23 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se { if ((haa->haas[0].can_use_cells) && (rollpercent(20))) { - bonustype = ID_CELLPACK; + bonustype = SLUMP_ID_CELLPACK; bonusamount = 2000; /* yow! */ } else if ((haa->haas[0].can_use_rockets) && (rollpercent(20))) { - bonustype = ID_ROCKBOX; + bonustype = SLUMP_ID_ROCKBOX; bonusamount = 500; } else if ((!(haa->haas[2].has_chainsaw)) && (rollpercent(20))) { - bonustype = ID_CHAINSAW; + bonustype = SLUMP_ID_CHAINSAW; bonusamount = 0; haa->haas[2].has_chainsaw = SLUMP_TRUE; } else if (rollpercent(2)) { - bonustype = ID_CHAINSAW; + bonustype = SLUMP_ID_CHAINSAW; bonusamount = 0; haa->haas[2].has_chainsaw = SLUMP_TRUE; } @@ -13280,11 +13296,11 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se switch (roll(3)) { case 1: - bonustype = ID_SHELLBOX; + bonustype = SLUMP_ID_SHELLBOX; bonusamount = 1400; break; case 2: - bonustype = ID_BACKPACK; + bonustype = SLUMP_ID_BACKPACK; bonusamount = 380; if (haa->haas[1].can_use_rockets) bonusamount += 100; @@ -13294,12 +13310,12 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se haa->haas[2].has_backpack = SLUMP_TRUE; break; default: - bonustype = ID_BULBOX; + bonustype = SLUMP_ID_BULBOX; bonusamount = 500; break; } /* end switch */ - /* We assume ITYTD didn't find the closet! */ - haa->haas[1].ammo += bonusamount / 2; /* And HMP only prolly did */ + /* We assume SLUMP_ITYTD didn't find the closet! */ + haa->haas[1].ammo += bonusamount / 2; /* And SLUMP_HMP only prolly did */ haa->haas[2].ammo += bonusamount; if (!secret) { /* Unless it's not a secret */ @@ -13307,7 +13323,7 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se haa->haas[1].ammo += bonusamount / 2; } /* Account for chainsaws; primitive */ - if (bonustype == ID_CHAINSAW) + if (bonustype == SLUMP_ID_CHAINSAW) { haa->haas[1].has_chainsaw = SLUMP_TRUE; /* OK? */ haa->haas[2].has_chainsaw = SLUMP_TRUE; @@ -13319,7 +13335,7 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se if (((!secret) || c->secret_monsters) && (rollpercent(90))) { farness = 32; /* mwidth here */ - point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, RIGHT_TURN, farness, &x, &y); + point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, SLUMP_RIGHT_TURN, farness, &x, &y); for (;;) { m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 0); @@ -13337,7 +13353,7 @@ void populate_linedef(level *l, linedef *ldnew2, haa *haa, config *c, boolean se farness += 64; /* Should be mwidths stuff here */ if (farness + 32 > plen) break; - point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, RIGHT_TURN, farness, &x, &y); + point_from(ldnew2->to->x, ldnew2->to->y, x1, y1, SLUMP_RIGHT_TURN, farness, &x, &y); } /* end forever while monsters and space */ haa_unpend(haa); } /* end roll for having a monster */ @@ -13363,13 +13379,13 @@ linedef *secret_closet(level *l, linedef *ld, style *ThisStyle, int h, haa *haa, if (!empty_left_side(l, ld, 72)) return NULL; /* Room? */ - doortype = LINEDEF_NORMAL_DOOR; - if (!((DOOM0_BIT | HERETIC_BIT) & c->gamemask) && rollpercent(80)) - doortype = LINEDEF_BLAZE_DOOR; + doortype = SLUMP_LINEDEF_NORMAL_DOOR; + if (!((SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT) & c->gamemask) && rollpercent(80)) + doortype = SLUMP_LINEDEF_BLAZE_DOOR; /* Modify the outermost linedef to be doory */ ld->right->upper_texture = ld->right->middle_texture; /* Door face */ - ld->flags |= SECRET_LINEDEF; + ld->flags |= SLUMP_SECRET_LINEDEF; if (tag == -1) ld->type = doortype; /* Correct? */ @@ -13378,8 +13394,8 @@ linedef *secret_closet(level *l, linedef *ld, style *ThisStyle, int h, haa *haa, ldnew = lefthand_box_ext(l, ld, 8, ThisStyle, c, &ldedge1, &ldedge2); if (tag != -1) ldnew->right->psector->tag = tag; - ldedge1->flags |= LOWER_UNPEGGED; - ldedge2->flags |= LOWER_UNPEGGED; + ldedge1->flags |= SLUMP_LOWER_UNPEGGED; + ldedge2->flags |= SLUMP_LOWER_UNPEGGED; ldedge1->right->y_offset = ldedge2->right->y_offset = ch - ldedge1->right->psector->floor_height; /* Make the closet sector -- "64" should be variable */ ldnew2 = lefthand_box_ext(l, ldnew, 64, ThisStyle, c, &ldedge1, &ldedge2); @@ -13391,20 +13407,20 @@ linedef *secret_closet(level *l, linedef *ld, style *ThisStyle, int h, haa *haa, s = ldnew->right->psector; flip_linedef(ldnew); if (secret) - s->special = SECRET_SECTOR; + s->special = SLUMP_SECRET_SECTOR; if (inside_sr) { ldnew->type = doortype; /* reopenable */ } else { - ldnew->type = LINEDEF_NORMAL_S1_DOOR; /* Triggered doors never close */ + ldnew->type = SLUMP_LINEDEF_NORMAL_S1_DOOR; /* Triggered doors never close */ } s->ceiling_height = s->floor_height; s->light_level = ThisStyle->doorlight0; ldnew->right->upper_texture = ThisStyle->support0; - ld->flags |= BLOCK_SOUND; /* Always? */ - ldnew->flags |= BLOCK_SOUND; + ld->flags |= SLUMP_BLOCK_SOUND; /* Always? */ + ldnew->flags |= SLUMP_BLOCK_SOUND; /* and polish up the closet */ ldnew2->right->middle_texture = ThisStyle->wall0; s = ldnew2->right->psector; @@ -13414,7 +13430,7 @@ linedef *secret_closet(level *l, linedef *ld, style *ThisStyle, int h, haa *haa, if (c->clights) { s->ceiling_flat = s->pstyle->ceilinglight; - announce(VERBOSE, "ccl"); + announce(SLUMP_VERBOSE, "ccl"); make_lighted(l, s, c); } @@ -13425,10 +13441,10 @@ linedef *secret_closet(level *l, linedef *ld, style *ThisStyle, int h, haa *haa, s->floor_height -= 8; patch_lower(ldnew, ldnew->right->upper_texture, c); s->floor_flat = ThisStyle->nukage1; - s->special = NUKAGE1_SPECIAL; + s->special = SLUMP_NUKAGE1_SPECIAL; } - if (s->special == SECRET_SECTOR) + if (s->special == SLUMP_SECRET_SECTOR) l->secret_count++; if (haa) @@ -13456,18 +13472,18 @@ void trigger_box(level *l, thing *t, sector *oldsector, short tag, short type, c else { /* This shouldn't ever happen anymore, but just in case... */ - announce(WARNING, "point_sector returned NULL in trigger_box"); + announce(SLUMP_WARNING, "point_sector returned NULL in trigger_box"); } if (dist > 24) dist = 24; if (dist < 4) { - announce(LOG, "Tiny triggerbox"); + announce(SLUMP_LOG, "Tiny triggerbox"); dist = 4; } else if (dist < 24) { - announce(LOG, "Small triggerbox"); + announce(SLUMP_LOG, "Small triggerbox"); } v1 = new_vertex(l, t->x - dist, t->y - dist); @@ -13479,7 +13495,7 @@ void trigger_box(level *l, thing *t, sector *oldsector, short tag, short type, c ldnew->left = new_sidedef(l, oldsector, c); ldnew->tag = tag; ldnew->type = type; - ldnew->flags |= TWO_SIDED; + ldnew->flags |= SLUMP_TWO_SIDED; ldnew->right->middle_texture = c->null_texture; ldnew->left->middle_texture = c->null_texture; ldnew = new_linedef(l, v2, v3); @@ -13487,7 +13503,7 @@ void trigger_box(level *l, thing *t, sector *oldsector, short tag, short type, c ldnew->left = new_sidedef(l, oldsector, c); ldnew->tag = tag; ldnew->type = type; - ldnew->flags |= TWO_SIDED; + ldnew->flags |= SLUMP_TWO_SIDED; ldnew->right->middle_texture = c->null_texture; ldnew->left->middle_texture = c->null_texture; ldnew = new_linedef(l, v3, v4); @@ -13495,7 +13511,7 @@ void trigger_box(level *l, thing *t, sector *oldsector, short tag, short type, c ldnew->left = new_sidedef(l, oldsector, c); ldnew->tag = tag; ldnew->type = type; - ldnew->flags |= TWO_SIDED; + ldnew->flags |= SLUMP_TWO_SIDED; ldnew->right->middle_texture = c->null_texture; ldnew->left->middle_texture = c->null_texture; ldnew = new_linedef(l, v4, v1); @@ -13503,7 +13519,7 @@ void trigger_box(level *l, thing *t, sector *oldsector, short tag, short type, c ldnew->left = new_sidedef(l, oldsector, c); ldnew->tag = tag; ldnew->type = type; - ldnew->flags |= TWO_SIDED; + ldnew->flags |= SLUMP_TWO_SIDED; ldnew->right->middle_texture = c->null_texture; ldnew->left->middle_texture = c->null_texture; } @@ -13514,7 +13530,7 @@ link *random_patio_link(level *l, linedef *ld, style *ThisStyle, config *c) { link *answer = (link *)malloc(sizeof(*answer)); - answer->type = BASIC_LINK; + answer->type = SLUMP_BASIC_LINK; answer->bits = 0; answer->floordelta = 0; if (rollpercent(50)) @@ -13531,7 +13547,7 @@ link *random_patio_link(level *l, linedef *ld, style *ThisStyle, config *c) } else { - answer->width1 = 64 + roll(linelen(ld) - 79); + answer->width1 = 64 + roll(SLUMP_linelen(ld) - 79); } if (rollpercent(50)) { @@ -13558,15 +13574,15 @@ link *random_patio_link(level *l, linedef *ld, style *ThisStyle, config *c) answer->depth3 = (8 + 4 * roll(15)) * l->hugeness; } if (rollpercent(50)) - answer->bits |= LINK_RECESS; + answer->bits |= SLUMP_LINK_RECESS; if (rollpercent(20)) - answer->bits |= LINK_CORE; + answer->bits |= SLUMP_LINK_CORE; if (rollpercent(5)) - answer->bits |= LINK_BARS; + answer->bits |= SLUMP_LINK_BARS; if (rollpercent(20)) { /* Single door */ - answer->bits |= LINK_RECESS | LINK_ANY_DOOR; - answer->bits &= ~LINK_CORE; + answer->bits |= SLUMP_LINK_RECESS | SLUMP_LINK_ANY_DOOR; + answer->bits &= ~SLUMP_LINK_CORE; } return answer; } @@ -13596,7 +13612,7 @@ void make_extroom(level *l, sector *oldsector, haa *haa, style *ThisStyle, confi newldf = make_linkto(l, ld, ThisLink, ThisStyle, c, NULL); if (newldf == NULL) return; /* Shouldn't happen */ - depth = linelen(ld); + depth = SLUMP_linelen(ld); if ((depth <= 512) && rollpercent(25)) depth *= 2; flip_linedef(newldf); /* Just so we can use the lefthand functions */ @@ -13618,7 +13634,7 @@ void make_extroom(level *l, sector *oldsector, haa *haa, style *ThisStyle, confi ldfar->right->middle_texture = newldf->right->middle_texture = t1; if (outtex) ldfar->right->middle_texture = lde1->right->middle_texture = lde2->right->middle_texture = - random_texture0(OUTDOOR, c, NULL); + random_texture0(SLUMP_OUTDOOR, c, NULL); losec = newldf->right->psector; losec->floor_height = oldsector->floor_height; losec->floor_flat = oldsector->floor_flat; @@ -13633,20 +13649,20 @@ void make_extroom(level *l, sector *oldsector, haa *haa, style *ThisStyle, confi /* And now the little triangle thing to look good */ x = (newldf->to->x + newldf->from->x) / 2; y = (newldf->to->y + newldf->from->y) / 2; - point_from(newldf->from->x, newldf->from->y, x, y, RIGHT_TURN, 32, &x, &y); + point_from(newldf->from->x, newldf->from->y, x, y, SLUMP_RIGHT_TURN, 32, &x, &y); v = new_vertex(l, x, y); ldt = new_linedef(l, newldf->to, v); ldt->right = new_sidedef(l, hisec, c); ldt->right->middle_texture = c->null_texture; ldt->left = new_sidedef(l, losec, c); ldt->left->middle_texture = c->null_texture; - ldt->flags |= TWO_SIDED | NOT_ON_MAP; + ldt->flags |= SLUMP_TWO_SIDED | SLUMP_NOT_ON_MAP; ldt = new_linedef(l, v, newldf->from); ldt->right = new_sidedef(l, hisec, c); ldt->right->middle_texture = c->null_texture; ldt->left = new_sidedef(l, losec, c); ldt->left->middle_texture = c->null_texture; - ldt->flags |= TWO_SIDED | NOT_ON_MAP; + ldt->flags |= SLUMP_TWO_SIDED | SLUMP_NOT_ON_MAP; /* Adjust stuff */ hisec->ceiling_height = oldsector->ceiling_height + cthick; if (hisec->ceiling_height < losec->ceiling_height) @@ -13666,11 +13682,11 @@ void make_extroom(level *l, sector *oldsector, haa *haa, style *ThisStyle, confi if (ldt->right->psector == hisec) patch_upper(ldt, t1, c); if (outtex) - hisec->floor_flat = losec->floor_flat = random_flat0(OUTDOOR, c, NULL); + hisec->floor_flat = losec->floor_flat = random_flat0(SLUMP_OUTDOOR, c, NULL); /* Now populate it and stuff */ populate(l, losec, c, haa, SLUMP_FALSE); place_plants(l, 128, losec, c); /* 128? */ - announce(VERBOSE, "Patio"); + announce(SLUMP_VERBOSE, "Patio"); } } /* end make_extroom */ @@ -13690,7 +13706,7 @@ void make_extwindow(level *l, sector *oldsector, style *ThisStyle, config *c) if (ld != NULL) { t1 = ld->right->middle_texture; - ldlen = linelen(ld); + ldlen = SLUMP_linelen(ld); wlen = 32 + roll(ldlen - 31); if (wlen > ldlen) wlen = ldlen; @@ -13720,7 +13736,7 @@ void make_extwindow(level *l, sector *oldsector, style *ThisStyle, config *c) ldnew->right->psector->ceiling_height = oldsector->ceiling_height; if ((ThisStyle->window_grate) && rollpercent(50)) { - announce(VERBOSE, "Grated extwindow"); + announce(SLUMP_VERBOSE, "Grated extwindow"); ld->right->middle_texture = ThisStyle->grating; if (ldnew->right->psector->ceiling_height - ldnew->right->psector->floor_height < 128) { @@ -13735,11 +13751,11 @@ void make_extwindow(level *l, sector *oldsector, style *ThisStyle, config *c) e1->right->y_offset = e2->right->y_offset = yoff; ldnew->right->psector->floor_height = wheight - 4; ldnew->right->psector->ceiling_flat = c->sky_flat; - ldnew = lefthand_box(l, ldnew, 8, ThisStyle, c); + ldnew = SLUMP_lefthand_box(l, ldnew, 8, ThisStyle, c); ldnew->right->psector->floor_height = wheight - 16; ldnew->right->psector->ceiling_height = wheight - 8; ldnew->right->psector->ceiling_flat = c->sky_flat; - announce(VERBOSE, "Outside Window"); + announce(SLUMP_VERBOSE, "Outside Window"); } /* end if enough room */ } /* end if found a linedef */ } @@ -13805,19 +13821,19 @@ boolean grid_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, quest } if ((ThisStyle->walllight != NULL) && rollpercent(3)) { - announce(LOG, "Gridlight"); + announce(SLUMP_LOG, "Gridlight"); t = ThisStyle->walllight; oldsector->light_level = 240; /* Or so */ switch (roll(3)) { case 0: - oldsector->special = RANDOM_BLINK; + oldsector->special = SLUMP_RANDOM_BLINK; break; case 1: - oldsector->special = SYNC_FAST_BLINK; + oldsector->special = SLUMP_SYNC_FAST_BLINK; break; default: - oldsector->special = SYNC_SLOW_BLINK; + oldsector->special = SLUMP_SYNC_SLOW_BLINK; break; } } @@ -13841,35 +13857,35 @@ boolean grid_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, quest if (tx == t) tx = ThisStyle->wall0; newsec->tag = new_tag(l); - newsec->special = SECRET_SECTOR; + newsec->special = SLUMP_SECRET_SECTOR; parallel_innersec_ex(l, oldsector, newsec, NULL, ThisStyle->wall0, t, x1, y1, x1 + xwidth, y1 + ywidth, c, &ld1, &ld2, &ld3, &ld4); - ld2->flags |= SECRET_LINEDEF; - ld3->flags |= SECRET_LINEDEF; - ld4->flags |= SECRET_LINEDEF; - ld1->flags &= ~(LOWER_UNPEGGED | UPPER_UNPEGGED); /* Ought to */ - ld2->flags &= ~(LOWER_UNPEGGED | UPPER_UNPEGGED); /* re-y-align, */ - ld3->flags &= ~(LOWER_UNPEGGED | UPPER_UNPEGGED); /* also, */ - ld4->flags &= ~(LOWER_UNPEGGED | UPPER_UNPEGGED); /* eh? */ + ld2->flags |= SLUMP_SECRET_LINEDEF; + ld3->flags |= SLUMP_SECRET_LINEDEF; + ld4->flags |= SLUMP_SECRET_LINEDEF; + ld1->flags &= ~(SLUMP_LOWER_UNPEGGED | SLUMP_UPPER_UNPEGGED); /* Ought to */ + ld2->flags &= ~(SLUMP_LOWER_UNPEGGED | SLUMP_UPPER_UNPEGGED); /* re-y-align, */ + ld3->flags &= ~(SLUMP_LOWER_UNPEGGED | SLUMP_UPPER_UNPEGGED); /* also, */ + ld4->flags &= ~(SLUMP_LOWER_UNPEGGED | SLUMP_UPPER_UNPEGGED); /* eh? */ if (rollpercent(50)) { ld1->right->lower_texture = tx; - ld1->flags |= SECRET_LINEDEF; + ld1->flags |= SLUMP_SECRET_LINEDEF; } ld1->tag = newsec->tag; ld1->type = ThisStyle->slifttype; flip_linedef(ld3); ld3->tag = newsec->tag; ld3->type = ThisStyle->slifttype; - ld3->flags &= ~UPPER_UNPEGGED; - if (linelen(ld3) > 64) + ld3->flags &= ~SLUMP_UPPER_UNPEGGED; + if (SLUMP_linelen(ld3) > 64) split_linedef(l, ld3, 64, c); ld3->right->upper_texture = ThisStyle->switch0; ld3->right->x_offset = 0; ld3->right->y_offset += ThisStyle->switch0->y_bias; sx = x1 + xwidth / 2; sy = y1 + ywidth / 2; - announce(VERBOSE, "Secret grid-pillar"); + announce(SLUMP_VERBOSE, "Secret grid-pillar"); continue; } if (rollpercent(c->p_grid_gaps)) @@ -13878,10 +13894,10 @@ boolean grid_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, quest { trying_constructs = install_construct(l, oldsector, x1, y1, x1 + xwidth, y1 + ywidth, ThisStyle, c); if (trying_constructs) - announce(VERBOSE, "Grid construct"); + announce(SLUMP_VERBOSE, "Grid construct"); } if (!trying_constructs) - parallel_innersec(l, oldsector, NULL, t, NULL, NULL, x1, y1, x1 + xwidth, y1 + ywidth, c); + SLUMP_parallel_innersec(l, oldsector, NULL, t, NULL, NULL, x1, y1, x1 + xwidth, y1 + ywidth, c); /* Pretty primitive; monster-width assumptions etc. */ if (xi && rollpercent(50)) { @@ -13936,7 +13952,7 @@ boolean grid_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, quest haa_unpend(haa); } - announce(VERBOSE, "Grid room"); + announce(SLUMP_VERBOSE, "Grid room"); return SLUMP_TRUE; } @@ -13977,25 +13993,25 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f outersec->floor_flat = s->pstyle->nukage1; if (outersec->light_level < 160) outersec->light_level = 160; - outersec->special = NUKAGE1_SPECIAL; + outersec->special = SLUMP_NUKAGE1_SPECIAL; rise += 8; - parallel_innersec(l, s, outersec, NULL, s->pstyle->wall0, s->pstyle->support0, minx + leeway, miny + leeway, - maxx - leeway, maxy - leeway, c); + SLUMP_parallel_innersec(l, s, outersec, NULL, s->pstyle->wall0, s->pstyle->support0, minx + leeway, + miny + leeway, maxx - leeway, maxy - leeway, c); if (s->pgate->is_entry) { - announce(VERBOSE, "Nukage arrival"); + announce(SLUMP_VERBOSE, "Nukage arrival"); } else { - announce(VERBOSE, "Nukage gate"); + announce(SLUMP_VERBOSE, "Nukage gate"); } - ThisHaa->haas[ITYTD].health -= 10; - ThisHaa->haas[HMP].health -= 5; + ThisHaa->haas[SLUMP_ITYTD].health -= 10; + ThisHaa->haas[SLUMP_HMP].health -= 5; if (s->pgate->is_entry) { - ThisHaa->haas[ITYTD].health -= 10; - ThisHaa->haas[HMP].health -= 5; - ThisHaa->haas[UV].health -= 5; + ThisHaa->haas[SLUMP_ITYTD].health -= 10; + ThisHaa->haas[SLUMP_HMP].health -= 5; + ThisHaa->haas[SLUMP_UV].health -= 5; } } } @@ -14007,15 +14023,15 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f if ((innersec->ceiling_flat != c->sky_flat) && ThisStyle->ceilinglight) { innersec->ceiling_flat = ThisStyle->ceilinglight; - announce(VERBOSE, "gcl"); + announce(SLUMP_VERBOSE, "gcl"); } - innersec->light_level = 240; /* Should vary by style or level */ - innersec->special = GLOW_BLINK; /* Also */ + innersec->light_level = 240; /* Should vary by style or level */ + innersec->special = SLUMP_GLOW_BLINK; /* Also */ } if (s->pgate->in_tag) { innersec->tag = s->pgate->in_tag; - new_thing(l, (lowx + hix) / 2, (lowy + hiy) / 2, (short)(90 * roll(4)), ID_GATEOUT, 7, c); + new_thing(l, (lowx + hix) / 2, (lowy + hiy) / 2, (short)(90 * roll(4)), SLUMP_ID_GATEOUT, 7, c); if (s->pgate->is_entry) { s->entry_x = lowx + 32; @@ -14027,14 +14043,14 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f { switch (s->pgate->gate_lock) { - case LINEDEF_S1_OPEN_DOOR: + case SLUMP_LINEDEF_S1_OPEN_DOOR: innersec->ceiling_height = innersec->floor_height + 32; - announce(LOG, "Uplocked gate"); + announce(SLUMP_LOG, "Uplocked gate"); break; - case LINEDEF_S1_LOWER_FLOOR: + case SLUMP_LINEDEF_S1_LOWER_FLOOR: innersec->floor_height += 32; rise += 32; - announce(LOG, "Downlocked gate"); + announce(SLUMP_LOG, "Downlocked gate"); break; default: announce(SLUMP_ERROR, "Odd lock-type in install_gate"); @@ -14062,34 +14078,34 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f if (c->monsters_can_teleport) tag_mask = 0; else - tag_mask = BLOCK_MONSTERS; + tag_mask = SLUMP_BLOCK_MONSTERS; if (c->monsters_can_teleport) - announce(VERBOSE, "Possible teleporting monsters"); + announce(SLUMP_VERBOSE, "Possible teleporting monsters"); if (s->pgate->out_tag) { - ld1->type = LINEDEF_TELEPORT; + ld1->type = SLUMP_LINEDEF_TELEPORT; ld1->flags |= tag_mask; /* Always? */ ld1->tag = s->pgate->out_tag; - ld2->type = LINEDEF_TELEPORT; + ld2->type = SLUMP_LINEDEF_TELEPORT; ld2->flags |= tag_mask; /* Always? */ ld2->tag = s->pgate->out_tag; - ld3->type = LINEDEF_TELEPORT; + ld3->type = SLUMP_LINEDEF_TELEPORT; ld3->flags |= tag_mask; /* Always? */ ld3->tag = s->pgate->out_tag; - ld4->type = LINEDEF_TELEPORT; + ld4->type = SLUMP_LINEDEF_TELEPORT; ld4->flags |= tag_mask; /* Always? */ ld4->tag = s->pgate->out_tag; } else if (0 == s->pgate->in_tag) { /* Must be a level-end gate */ exit_style = SLUMP_TRUE; - ld1->type = LINEDEF_W1_END_LEVEL; + ld1->type = SLUMP_LINEDEF_W1_END_LEVEL; ld1->flags |= tag_mask; - ld2->type = LINEDEF_W1_END_LEVEL; + ld2->type = SLUMP_LINEDEF_W1_END_LEVEL; ld2->flags |= tag_mask; - ld3->type = LINEDEF_W1_END_LEVEL; + ld3->type = SLUMP_LINEDEF_W1_END_LEVEL; ld3->flags |= tag_mask; - ld4->type = LINEDEF_W1_END_LEVEL; + ld4->type = SLUMP_LINEDEF_W1_END_LEVEL; ld4->flags |= tag_mask; } /* Otherwise an in-only gate */ if (exit_style) @@ -14109,7 +14125,7 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f innersec->ceiling_flat = gateflat; } if (s->pgate->out_tag || exit_gate) - if (innersec->ceiling_flat->props & LIGHT) + if (innersec->ceiling_flat->props & SLUMP_LIGHT) if (innersec->ceiling_height - innersec->floor_height >= 96) if (!s->pgate->gate_lock) { @@ -14117,10 +14133,10 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boolean f ld1->right->upper_texture = ld2->right->upper_texture = ld3->right->upper_texture = ld4->right->upper_texture = ThisStyle->support0; } - ld1->flags &= ~LOWER_UNPEGGED; - ld2->flags &= ~LOWER_UNPEGGED; - ld3->flags &= ~LOWER_UNPEGGED; - ld4->flags &= ~LOWER_UNPEGGED; + ld1->flags &= ~SLUMP_LOWER_UNPEGGED; + ld2->flags &= ~SLUMP_LOWER_UNPEGGED; + ld3->flags &= ~SLUMP_LOWER_UNPEGGED; + ld4->flags &= ~SLUMP_LOWER_UNPEGGED; } /* end install_gate */ @@ -14150,31 +14166,31 @@ boolean install_sl_exit(level *l, sector *oldsector, haa *ThisHaa, style *ThisSt ld2 = install_switch(l, ld, SLUMP_TRUE, SLUMP_FALSE, 0, ThisStyle, c, &ld3); if (ld == ld2) { /* Didn't recess after all?? */ - announce(WARNING, "Silly switch left sitting around?"); + announce(SLUMP_WARNING, "Silly switch left sitting around?"); /* Try to fix it */ ld->right->middle_texture = ThisStyle->wall0; - ld->type = LINEDEF_NORMAL; + ld->type = SLUMP_LINEDEF_NORMAL; return SLUMP_FALSE; } tag = new_tag(l); - ld2->type = LINEDEF_S1_SEC_LEVEL; + ld2->type = SLUMP_LINEDEF_S1_SEC_LEVEL; newsec = ld2->right->psector; - newsec->special = GLOW_BLINK; + newsec->special = SLUMP_GLOW_BLINK; newsec->light_level = 255; newsec->ceiling_height = newsec->floor_height; l->sl_tag = tag; if (opens) { - ld3->type = LINEDEF_NORMAL_S1_DOOR; - announce(VERBOSE, "Openable sl exit"); + ld3->type = SLUMP_LINEDEF_NORMAL_S1_DOOR; + announce(SLUMP_VERBOSE, "Openable sl exit"); l->sl_done = SLUMP_TRUE; } else { newsec->tag = tag; - l->sl_type = LINEDEF_W1_OPEN_DOOR; /* Or S1, eh? So... */ - ld->flags |= SECRET_LINEDEF; - if (ThisQuest->goal == LEVEL_END_GOAL) + l->sl_type = SLUMP_LINEDEF_W1_OPEN_DOOR; /* Or S1, eh? So... */ + ld->flags |= SLUMP_SECRET_LINEDEF; + if (ThisQuest->goal == SLUMP_LEVEL_END_GOAL) { l->sl_open_ok = SLUMP_TRUE; } @@ -14184,7 +14200,7 @@ boolean install_sl_exit(level *l, sector *oldsector, haa *ThisHaa, style *ThisSt l->sl_open_start = ThisQuest->room; } l->sl_exit_sector = oldsector; - announce(VERBOSE, "Installed sl exit"); + announce(SLUMP_VERBOSE, "Installed sl exit"); } return SLUMP_TRUE; } @@ -14199,7 +14215,7 @@ void try_sl_triggerbox(level *l, sector *oldsector, config *c) for (t = l->thing_anchor; t; t = t->next) { - if (!(t->pgenus->bits & PICKABLE)) + if (!(t->pgenus->bits & SLUMP_PICKABLE)) continue; if (oldsector != point_sector(l, t->x, t->y, &border, &danger)) continue; @@ -14216,7 +14232,7 @@ void try_sl_triggerbox(level *l, sector *oldsector, config *c) trigger_box(l, t, oldsector, l->sl_tag, l->sl_type, c); l->sl_done = SLUMP_TRUE; l->sl_open_ok = SLUMP_FALSE; - announce(VERBOSE, "Did sl triggerbox"); + announce(SLUMP_VERBOSE, "Did sl triggerbox"); } /* if found a good thing */ } @@ -14227,7 +14243,7 @@ void enhance_room(level *l, sector *oldsector, haa *ThisHaa, style *ThisStyle, q boolean done_room = SLUMP_FALSE; boolean did_dm = SLUMP_FALSE; - if ((ThisQuest) && (ThisQuest->goal != NULL_GOAL) && (need_secret_level(c)) && (l->sl_tag == 0) && + if ((ThisQuest) && (ThisQuest->goal != SLUMP_NULL_GOAL) && (need_secret_level(c)) && (l->sl_tag == 0) && (rollpercent(20) || (ThisQuest->count + 4 > ThisQuest->minrooms))) { install_sl_exit(l, oldsector, ThisHaa, ThisStyle, ThisQuest, SLUMP_FALSE, c); @@ -14235,7 +14251,7 @@ void enhance_room(level *l, sector *oldsector, haa *ThisHaa, style *ThisStyle, q if ((first) && (oldsector->pgate)) { - announce(WARNING, "Gate and watermark do not mix!"); + announce(SLUMP_WARNING, "Gate and watermark do not mix!"); } if ((!done_room) && oldsector->middle_enhanced) @@ -14303,7 +14319,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que if (rollpercent(10)) if (oldsector->special == 0) - oldsector->special = RANDOM_BLINK; + oldsector->special = SLUMP_RANDOM_BLINK; if (first) { /* Watermark */ @@ -14359,12 +14375,12 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { t1 = ld->right->middle_texture; clen = ThisStyle->closet_width; -#ifndef WIDE_SKIES_OK +#ifndef SLUMP_WIDE_SKIES_OK if (sky_thing) if (clen > 72) clen = 72; /* Wide skyc's look lame */ #endif - ldlen = linelen(ld); + ldlen = SLUMP_linelen(ld); if (clen > ldlen) clen = ldlen; border = (ldlen - clen) / 2; @@ -14396,7 +14412,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que if (sky_thing) { int minx, miny, maxx, maxy; - announce(VERBOSE, "Sky closet"); + announce(SLUMP_VERBOSE, "Sky closet"); innersec = clone_sector(l, outersec); innersec->ceiling_height += 16; /* 8? 16? */ find_rec(l, outersec, &minx, &miny, &maxx, &maxy); @@ -14404,8 +14420,8 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que miny += 8; maxx -= 8; maxy -= 8; - parallel_innersec(l, outersec, innersec, NULL, outersec->pstyle->wall0, - outersec->pstyle->wall0, minx, miny, maxx, maxy, c); + SLUMP_parallel_innersec(l, outersec, innersec, NULL, outersec->pstyle->wall0, + outersec->pstyle->wall0, minx, miny, maxx, maxy, c); innersec->ceiling_flat = c->sky_flat; innersec->light_level = l->outside_light_level; if (outersec->light_level < l->bright_light_level) @@ -14423,39 +14439,39 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { outersec->floor_height -= 8; outersec->floor_flat = ThisStyle->nukage1; - outersec->special = NUKAGE1_SPECIAL; + outersec->special = SLUMP_NUKAGE1_SPECIAL; if (outersec->light_level < 120) outersec->light_level = 120; patch_lower(ld, ThisStyle->support0, c); - announce(VERBOSE, "Nukage ambush"); + announce(SLUMP_VERBOSE, "Nukage ambush"); } /* end nukage */ if (rollpercent(2) /* "2"? Crush! */ && (outersec->ceiling_height - outersec->floor_height <= 72) && - (l->crushercount < LEVEL_MAX_CRUSHERS)) + (l->crushercount < SLUMP_LEVEL_MAX_CRUSHERS)) { l->crushercount++; - ld->type = LINEDEF_WR_FAST_CRUSH; + ld->type = SLUMP_LINEDEF_WR_FAST_CRUSH; ld->tag = new_tag(l); ld->right->upper_texture = ThisStyle->wall0; - ld->flags &= ~UPPER_UNPEGGED; + ld->flags &= ~SLUMP_UPPER_UNPEGGED; ld->right->y_offset -= outersec->ceiling_height - oldsector->ceiling_height; - ldnew->flags |= LOWER_UNPEGGED; - ldedge1->flags |= LOWER_UNPEGGED; - ldedge2->flags |= LOWER_UNPEGGED; + ldnew->flags |= SLUMP_LOWER_UNPEGGED; + ldedge1->flags |= SLUMP_LOWER_UNPEGGED; + ldedge2->flags |= SLUMP_LOWER_UNPEGGED; ldnew->right->y_offset += outersec->ceiling_height - outersec->floor_height; ldedge1->right->y_offset += outersec->ceiling_height - outersec->floor_height; ldedge2->right->y_offset += outersec->ceiling_height - outersec->floor_height; outersec->tag = ld->tag; - outersec->ceiling_flat = random_flat0(RED, c, NULL); + outersec->ceiling_flat = random_flat0(SLUMP_RED, c, NULL); if (outersec->light_level > 120) outersec->light_level = 120; crushing = SLUMP_TRUE; - announce(VERBOSE, "Crush ambush"); + announce(SLUMP_VERBOSE, "Crush ambush"); } /* end if crushing */ if (oldsector->light_level - outersec->light_level >= 16) { linedef *ldnew2; - announce(VERBOSE, "shadow"); + announce(SLUMP_VERBOSE, "shadow"); innersec = clone_sector(l, outersec); innersec->tag = outersec->tag; innersec->pstyle = oldsector->pstyle; /* Why? */ @@ -14468,11 +14484,11 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que } else { - ldedge2 = split_linedef(l, ldedge2, linelen(ldedge2) - (16 + roll(20)), c); + ldedge2 = split_linedef(l, ldedge2, SLUMP_linelen(ldedge2) - (16 + roll(20)), c); ldedge2->right->psector = innersec; ldnew2 = new_linedef(l, ld->from, ldedge2->from); } - ldnew2->flags |= TWO_SIDED | NOT_ON_MAP; + ldnew2->flags |= SLUMP_TWO_SIDED | SLUMP_NOT_ON_MAP; ldnew2->right = new_sidedef(l, innersec, c); ldnew2->right->middle_texture = c->null_texture; ldnew2->left = new_sidedef(l, outersec, c); @@ -14482,27 +14498,27 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que else if ((outersec->pstyle->ceilinglight) && (c->clights)) { outersec->ceiling_flat = outersec->pstyle->ceilinglight; - announce(VERBOSE, "acl"); + announce(SLUMP_VERBOSE, "acl"); } } /* end general lighting effects */ /* Put something in the closet */ - point_from(ldnew->from->x, ldnew->from->y, ldnew->to->x, ldnew->to->y, RIGHT_TURN, 32, &x1, - &y1); - point_from(ldnew->to->x, ldnew->to->y, x1, y1, RIGHT_TURN, 32, &x1, &y1); + point_from(ldnew->from->x, ldnew->from->y, ldnew->to->x, ldnew->to->y, SLUMP_RIGHT_TURN, 32, + &x1, &y1); + point_from(ldnew->to->x, ldnew->to->y, x1, y1, SLUMP_RIGHT_TURN, 32, &x1, &y1); /* Eek, a monster! */ m = timely_monster(haa, c, &levels, rollpercent(l->p_biggest_monsters), 1); /* Should check for monster width here!! */ if (!m) { - new_thing(l, x1, y1, 0, ID_POTION, 7, c); /* Punt. Stub. */ + new_thing(l, x1, y1, 0, SLUMP_ID_POTION, 7, c); /* Punt. Stub. */ } else { angle = facing_right_from_ld(ldnew); new_thing(l, x1, y1, angle, m->thingid, (short)(levels | 0x08), c); /* Deaf */ if (rollpercent(50)) - if (m->bits & SHOOTS) - ld->flags |= BLOCK_MONSTERS; + if (m->bits & SLUMP_SHOOTS) + ld->flags |= SLUMP_BLOCK_MONSTERS; update_haa_for_monster(haa, m, levels, 0, c); /* zero? one? */ } /* end there was a monster */ /* Maybe some small bonus also */ @@ -14515,13 +14531,13 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(3)) { case 0: - bonustype = ID_QUARTZFLASK; + bonustype = SLUMP_ID_QUARTZFLASK; break; case 1: - bonustype = ID_CRYSTALVIAL; + bonustype = SLUMP_ID_CRYSTALVIAL; break; default: - bonustype = ID_WANDCRYSTAL; + bonustype = SLUMP_ID_WANDCRYSTAL; break; } } @@ -14530,13 +14546,13 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(3)) { case 0: - bonustype = ID_MEDIKIT; + bonustype = SLUMP_ID_MEDIKIT; break; case 1: - bonustype = ID_STIMPACK; + bonustype = SLUMP_ID_STIMPACK; break; default: - bonustype = ID_POTION; + bonustype = SLUMP_ID_POTION; break; } } @@ -14548,7 +14564,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { if ((!(haa->haas[2].has_chainsaw)) && (rollpercent(5))) { - bonustype = ID_GAUNTLETS; + bonustype = SLUMP_ID_GAUNTLETS; haa->haas[0].has_chainsaw = SLUMP_TRUE; haa->haas[1].has_chainsaw = SLUMP_TRUE; haa->haas[2].has_chainsaw = SLUMP_TRUE; @@ -14558,10 +14574,10 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(2)) { /* What about a cell? / a rocket */ case 0: - bonustype = ID_WANDCRYSTAL; + bonustype = SLUMP_ID_WANDCRYSTAL; break; default: - bonustype = ID_ETHEREALARROWS; + bonustype = SLUMP_ID_ETHEREALARROWS; break; } /* end switch */ update_haa_for_ammo(haa, 7, bonustype); @@ -14571,7 +14587,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { if ((!(haa->haas[2].has_chainsaw)) && (rollpercent(5))) { - bonustype = ID_CHAINSAW; + bonustype = SLUMP_ID_CHAINSAW; haa->haas[0].has_chainsaw = SLUMP_TRUE; haa->haas[1].has_chainsaw = SLUMP_TRUE; haa->haas[2].has_chainsaw = SLUMP_TRUE; @@ -14581,10 +14597,10 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(2)) { /* What about a cell? / a rocket */ case 0: - bonustype = ID_CLIP; + bonustype = SLUMP_ID_CLIP; break; default: - bonustype = ID_SHELLS; + bonustype = SLUMP_ID_SHELLS; break; } /* end switch */ update_haa_for_ammo(haa, 7, bonustype); @@ -14609,7 +14625,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que linedef *ldnew, *ldedge1, *ldedge2; texture *t1, *tplaque; pheight = ThisStyle->plaque->height; - if (ThisStyle->plaque->props & HALF_PLAQUE) + if (ThisStyle->plaque->props & SLUMP_HALF_PLAQUE) if (rollpercent(80)) pheight = pheight / 2; pup = ((oldsector->ceiling_height - oldsector->floor_height) - pheight) / 2; @@ -14625,30 +14641,30 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que if (ld != NULL) { t1 = ld->right->middle_texture; - ldlen = linelen(ld); + ldlen = SLUMP_linelen(ld); /* Use borderize(SLUMP_TRUE), to get possible lightboxes etc */ if (rollpercent(5)) { ThisStyle->lightboxes = SLUMP_TRUE; ThisStyle->auxheight = pup; /* "pheight" here is a nice bug! */ - announce(VERBOSE, "fancy plaque"); + announce(SLUMP_VERBOSE, "fancy plaque"); } - ld = borderize(l, ld, 128, SLUMP_TRUE, ThisStyle, LIGHT, NULL, NULL, c); + ld = borderize(l, ld, 128, SLUMP_TRUE, ThisStyle, SLUMP_LIGHT, NULL, NULL, c); ThisStyle->lightboxes = SLUMP_FALSE; /* Neaten up */ depth = 4 + roll(5) + roll(5); if (empty_left_side(l, ld, depth)) { - announce(VERBOSE, "Putting in a plaque"); + announce(SLUMP_VERBOSE, "Putting in a plaque"); ldnew = lefthand_box_ext(l, ld, depth, ThisStyle, c, &ldedge1, &ldedge2); ldnew->right->middle_texture = tplaque; if (tplaque != ThisStyle->plaque) - announce(VERBOSE, "Multiplaque"); + announce(SLUMP_VERBOSE, "Multiplaque"); ldnew->right->psector->floor_height = oldsector->floor_height + pup; ldnew->right->psector->ceiling_height = ldnew->right->psector->floor_height + pheight; /* Maybe light the recesses */ if ((ThisStyle->light_recesses) && (ThisStyle->walllight != NULL)) { - announce(VERBOSE, "Lit plaque"); + announce(SLUMP_VERBOSE, "Lit plaque"); ldedge2->right->middle_texture = ldedge1->right->middle_texture = ThisStyle->walllight; } else @@ -14668,16 +14684,16 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(4)) { case 0: - ldnew->right->psector->special = RANDOM_BLINK; + ldnew->right->psector->special = SLUMP_RANDOM_BLINK; break; case 1: - ldnew->right->psector->special = SYNC_FAST_BLINK; + ldnew->right->psector->special = SLUMP_SYNC_FAST_BLINK; break; case 2: - ldnew->right->psector->special = SYNC_SLOW_BLINK; + ldnew->right->psector->special = SLUMP_SYNC_SLOW_BLINK; break; case 3: - ldnew->right->psector->special = GLOW_BLINK; + ldnew->right->psector->special = SLUMP_GLOW_BLINK; break; } /* end switch */ } /* end if doing lights */ @@ -14690,15 +14706,15 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que if (NULL != secret_closet(l, ldnew, ThisStyle, 0, haa, c, SLUMP_TRUE, sync_tag, oldsector->ceiling_height, SLUMP_TRUE)) { - announce(VERBOSE, "Plaque closet"); + announce(SLUMP_VERBOSE, "Plaque closet"); if (sync_doors) { ldnew->tag = sync_tag; - ldnew->type = LINEDEF_SR_OC_DOOR; - if (!(c->gamemask & (DOOM0_BIT | HERETIC_BIT))) - ldnew->type = LINEDEF_SR_BLAZE_OC_DOOR; + ldnew->type = SLUMP_LINEDEF_SR_OC_DOOR; + if (!(c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT))) + ldnew->type = SLUMP_LINEDEF_SR_BLAZE_OC_DOOR; if (sync_count++) - announce(VERBOSE, "Synced doors"); + announce(SLUMP_VERBOSE, "Synced doors"); } } } /* end if secret closet */ @@ -14710,7 +14726,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que break; tplaque = random_plaque(c, ThisStyle); if ((tplaque->height != pheight) && - ((!(tplaque->props & HALF_PLAQUE)) || (tplaque->height != 2 * pheight))) + ((!(tplaque->props & SLUMP_HALF_PLAQUE)) || (tplaque->height != 2 * pheight))) { tplaque = ThisStyle->plaque; } @@ -14751,7 +14767,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que ld = NULL; /* Give up */ if (ld != NULL) { - ldlen = linelen(ld); + ldlen = SLUMP_linelen(ld); plen = ldlen - 64; if (rollpercent(50)) if (plen > 64) @@ -14767,7 +14783,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que goal_trigger = SLUMP_FALSE; if (empty_left_side(l, ld, 72)) { /* "72" is from secret_closet() */ - if (((ThisQuest->goal == KEY_GOAL) || (ThisQuest->goal == NULL_GOAL)) && (!switch_closet) && + if (((ThisQuest->goal == SLUMP_KEY_GOAL) || (ThisQuest->goal == SLUMP_NULL_GOAL)) && (!switch_closet) && (ThisQuest->auxtag == 0) && (ThisQuest->surprise == NULL)) { /* Goal-triggered, if we can */ @@ -14785,7 +14801,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que boolean danger; for (t = l->thing_anchor; t; t = t->next) { - if (!(t->pgenus->bits & PICKABLE)) + if (!(t->pgenus->bits & SLUMP_PICKABLE)) continue; /* Old bug: &border in next line was NULL */ if (oldsector != point_sector(l, t->x, t->y, &border, &danger)) @@ -14801,7 +14817,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que if (t) { tag = new_tag(l); - trigger_box(l, t, oldsector, tag, LINEDEF_WR_OPEN_DOOR, c); + trigger_box(l, t, oldsector, tag, SLUMP_LINEDEF_WR_OPEN_DOOR, c); } /* if found a good thing */ } /* if triggered closet */ pheight = 72 + roll(1 + (oldsector->ceiling_height - oldsector->floor_height) - 72); @@ -14814,15 +14830,15 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { switch_ld = install_switch(l, switch_ld, SLUMP_TRUE, SLUMP_FALSE, 0, ThisStyle, c, NULL); switch_ld->tag = switch_tag; - if ((DOOM0_BIT | HERETIC_BIT) & c->gamemask) - switch_ld->type = LINEDEF_S1_OPEN_DOOR; + if ((SLUMP_DOOM0_BIT | SLUMP_HERETIC_BIT) & c->gamemask) + switch_ld->type = SLUMP_LINEDEF_S1_OPEN_DOOR; else - switch_ld->type = LINEDEF_S1_BLAZE_O_DOOR; - announce(VERBOSE, "Switch closet"); + switch_ld->type = SLUMP_LINEDEF_S1_BLAZE_O_DOOR; + announce(SLUMP_VERBOSE, "Switch closet"); } ld->right->y_offset = (oldsector->ceiling_height - oldsector->floor_height) - 128; /* 128 should be tex-height */ - ld->flags |= SECRET_LINEDEF; + ld->flags |= SLUMP_SECRET_LINEDEF; if (tag == -1) { /* Need a subtle hint here */ boolean hinted = SLUMP_FALSE; @@ -14833,8 +14849,8 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que int x = (ld->from->x + ld->to->x) / 2; int y = (ld->from->y + ld->to->y) / 2; if ((g == NULL) || rollpercent(50)) - g = find_genus(c, ID_CANDLE); - point_from(ld->from->x, ld->from->y, x, y, RIGHT_TURN, g->width / 2, &x, &y); + g = find_genus(c, SLUMP_ID_CANDLE); + point_from(ld->from->x, ld->from->y, x, y, SLUMP_RIGHT_TURN, g->width / 2, &x, &y); if (room_at(l, g, x, y, g->width / 2, c)) { hinted = SLUMP_TRUE; @@ -14856,24 +14872,24 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { /* Subtly different texture */ ld->right->upper_texture = ld->right->upper_texture->subtle; - announce(VERBOSE, "subtle"); + announce(SLUMP_VERBOSE, "subtle"); hinted = SLUMP_TRUE; } if (!hinted) { /* Make it just show on the automap (always possible) */ - ld->flags &= ~SECRET_LINEDEF; - announce(VERBOSE, "Map hint"); + ld->flags &= ~SLUMP_SECRET_LINEDEF; + announce(SLUMP_VERBOSE, "Map hint"); hinted = SLUMP_TRUE; } } if (goal_trigger) { ThisQuest->surprise = ldc; - announce(VERBOSE, "Goal-trigger"); + announce(SLUMP_VERBOSE, "Goal-trigger"); } else if (tag != -1) - announce(VERBOSE, "Trigger"); + announce(SLUMP_VERBOSE, "Trigger"); } else if (goal_trigger) { @@ -14895,7 +14911,7 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que { /* Lightstrips on the walls */ int ll, sdepth, spec, fh, ch; - announce(VERBOSE, "Doing the lightstrip thing."); + announce(SLUMP_VERBOSE, "Doing the lightstrip thing."); sdepth = 4 + 4 * roll(2); ll = oldsector->light_level; if (ll < l->lit_light_level) @@ -14905,16 +14921,16 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que switch (roll(4)) { case 0: - spec = RANDOM_BLINK; + spec = SLUMP_RANDOM_BLINK; break; case 1: - spec = SYNC_FAST_BLINK; + spec = SLUMP_SYNC_FAST_BLINK; break; case 2: - spec = SYNC_SLOW_BLINK; + spec = SLUMP_SYNC_SLOW_BLINK; break; default: - spec = GLOW_BLINK; + spec = SLUMP_GLOW_BLINK; break; } else @@ -14935,10 +14951,10 @@ void embellish_room(level *l, sector *oldsector, haa *haa, style *ThisStyle, que else if (rollpercent(20)) { /* swell some boundaries; don't do if lightstripped! */ - /* NOTE: produces some non-square lines! Terrible bugs! */ + /* SLUMP_NOTE: produces some non-square lines! Terrible bugs! */ /* But not as bad if you populate() first! */ int sno, sdepth; - announce(VERBOSE, "Swelling the room boundaries"); + announce(SLUMP_VERBOSE, "Swelling the room boundaries"); sno = 1 + roll(2); sdepth = 4 + 4 * roll(4); for (ld = l->linedef_anchor; ld; ld = ld->next) @@ -14961,7 +14977,7 @@ link *gate_link(level *l, config *c) link *answer = (link *)malloc(sizeof(*answer)); answer->bits = 0; - answer->type = GATE_LINK; + answer->type = SLUMP_GATE_LINK; answer->next = l->link_anchor; l->link_anchor = answer; return answer; @@ -14980,7 +14996,7 @@ linedef *make_next_room(level *l, sector *oldsector, boolean radical, config *c, sector *newsector; style *ThisStyle, *NewStyle; -#ifdef DEBUG_QUEST_STACK +#ifdef SLUMP_DEBUG_QUEST_STACK { quest *q = ThisQuest; for (; q; q = q->next) @@ -15020,22 +15036,22 @@ linedef *make_next_room(level *l, sector *oldsector, boolean radical, config *c, *ldf = random_marked_linedef(l, i); unmark_linedefs(l); *ThisLink = gate_link(l, c); - announce(VERBOSE, "Gate link"); + announce(SLUMP_VERBOSE, "Gate link"); } if (!link_fitsh(*ldf, *ThisLink, c)) /* Fix if doesn't fit */ *ThisLink = random_link(l, *ldf, ThisStyle, ThisQuest, c); if (!link_fitsh(*ldf, *ThisLink, c)) - announce(WARNING, "random_link() returned too wide!!"); + announce(SLUMP_WARNING, "random_link() returned too wide!!"); newldf = make_linkto(l, *ldf, *ThisLink, NewStyle, c, newldf); if (!link_fitsv(l, *ldf, newldf, *ThisLink)) { - announce(VERBOSE, "Retrying because link didn't fit..."); + announce(SLUMP_VERBOSE, "Retrying because link didn't fit..."); continue; } newsector = generate_room_outline(l, newldf, NewStyle, try_reduction, c); if (newsector) break; - announce(VERBOSE, "Retrying because new room didn't fit..."); + announce(SLUMP_VERBOSE, "Retrying because new room didn't fit..."); } /* end until one works */ if (newsector) break; @@ -15068,13 +15084,13 @@ void place_start_things(level *l, sector *s, config *c) find_rec(l, s, &minx, &miny, &maxx, &maxy); /* Let's make sure they always have a single-barrel shotgun */ - if (c->gamemask == HERETIC_BIT) + if (c->gamemask == SLUMP_HERETIC_BIT) { - new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 90, ID_CROSSBOW, 7, c); + new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 90, SLUMP_ID_CROSSBOW, 7, c); } else { - new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 90, ID_SHOTGUN, 7, c); + new_thing(l, (minx + maxx) / 2, (miny + maxy) / 2, 90, SLUMP_ID_SHOTGUN, 7, c); } /* Now the start positions */ @@ -15082,30 +15098,30 @@ void place_start_things(level *l, sector *s, config *c) angle = 0; else angle = 90 * roll(4); - new_thing(l, minx + 32, miny + 32, angle, ID_PLAYER1, 7, c); /* 1-player start */ + new_thing(l, minx + 32, miny + 32, angle, SLUMP_ID_PLAYER1, 7, c); /* 1-player start */ /* In the first room, *lie* about where the player comes in */ s->entry_x = maxx - 32; s->entry_y = maxy - 32; if ((maxx - minx < 128) || (maxy - miny < 128)) { - announce(WARNING, "Not enough room for co-op start positions"); + announce(SLUMP_WARNING, "Not enough room for co-op start positions"); return; } if (rational_angles) angle = 0; else angle = 90 * roll(4); - new_thing(l, minx + 32, maxy - 32, angle, ID_PLAYER2, 7, c); /* 2-player start */ + new_thing(l, minx + 32, maxy - 32, angle, SLUMP_ID_PLAYER2, 7, c); /* 2-player start */ if (rational_angles) angle = 180; else angle = 90 * roll(4); - new_thing(l, maxx - 32, miny + 32, angle, ID_PLAYER3, 7, c); /* 3-player start */ + new_thing(l, maxx - 32, miny + 32, angle, SLUMP_ID_PLAYER3, 7, c); /* 3-player start */ if (rational_angles) angle = 180; else angle = 90 * roll(4); - new_thing(l, maxx - 32, maxy - 32, angle, ID_PLAYER4, 7, c); /* 4-player start */ + new_thing(l, maxx - 32, maxy - 32, angle, SLUMP_ID_PLAYER4, 7, c); /* 4-player start */ } /* Set all the fields of the given level to empty things */ @@ -15163,14 +15179,14 @@ void empty_level(level *l, config *c) if (rollpercent(5)) l->p_force_sky = 20 + roll(60); if (l->p_force_sky > 30) - announce(LOG, "Sunrooms"); + announce(SLUMP_LOG, "Sunrooms"); l->p_force_nukage = 0; if (rollpercent(8)) l->p_force_nukage = 20 + roll(60); if (c->major_nukage) l->p_force_nukage = 85; if (l->p_force_nukage > 30) - announce(LOG, "Nukage city!!"); + announce(SLUMP_LOG, "Nukage city!!"); l->p_deep_baths = 20; if (rollpercent(50)) l->p_deep_baths += l->p_force_nukage; @@ -15229,7 +15245,7 @@ void empty_level(level *l, config *c) { char s[80]; sprintf(s, "p_rational_facing %d.", l->p_rational_facing); - announce(VERBOSE, s); + announce(SLUMP_VERBOSE, s); } l->p_biggest_monsters = 0; if (rollpercent(5) && (c->big_monsters)) @@ -15237,7 +15253,7 @@ void empty_level(level *l, config *c) if (c->force_biggest) l->p_biggest_monsters = 100; if (l->p_biggest_monsters == 100) - announce(LOG, "Biggest monsters"); + announce(SLUMP_LOG, "Biggest monsters"); l->p_open_link = 15; if (rollpercent(15)) l->p_open_link = 0; @@ -15249,7 +15265,7 @@ void empty_level(level *l, config *c) if (rollpercent(5)) l->p_s1_door = 100; if (l->p_s1_door > 95) - announce(VERBOSE, "Doors stick"); + announce(SLUMP_VERBOSE, "Doors stick"); l->p_special_room = 2 + roll(5); if (rollpercent(5)) l->p_special_room = 0; @@ -15259,11 +15275,11 @@ void empty_level(level *l, config *c) l->dm_count = 0; l->dm_rho = 10; l->first_room = NULL; - if ((c->gamemask & HERETIC_BIT) || (c->gamemask & CHEX_BIT)) + if ((c->gamemask & SLUMP_HERETIC_BIT) || (c->gamemask & SLUMP_CHEX_BIT)) { l->skullkeys = SLUMP_FALSE; } - else if (c->gamemask & HACX_BIT) + else if (c->gamemask & SLUMP_HACX_BIT) { l->skullkeys = rollpercent(100); } @@ -15271,7 +15287,7 @@ void empty_level(level *l, config *c) { l->skullkeys = rollpercent(50); } - l->use_gates = rollpercent(TELEPORTS_PERCENT); + l->use_gates = rollpercent(SLUMP_TELEPORTS_PERCENT); l->raise_gates = rollpercent(60); l->no_doors = l->all_wide_links = SLUMP_FALSE; if (rollpercent(15)) @@ -15292,26 +15308,26 @@ void empty_level(level *l, config *c) break; } if (l->all_wide_links) - announce(VERBOSE, "All wide links"); + announce(SLUMP_VERBOSE, "All wide links"); if (l->no_doors) - announce(VERBOSE, "No doors"); + announce(SLUMP_VERBOSE, "No doors"); l->hugeness = 1; if (rollpercent(c->do_dm ? 30 : 8)) { l->hugeness = 2; - announce(LOG, "Extra hugeness"); + announce(SLUMP_LOG, "Extra hugeness"); } l->outside_light_level = 240; if (rollpercent(20)) { l->outside_light_level = c->minlight + 5; - announce(VERBOSE, "Night"); + announce(SLUMP_VERBOSE, "Night"); } l->bright_light_level = 220; if (rollpercent(20)) { l->bright_light_level = c->minlight + roll((221 - c->minlight) / 2); - announce(VERBOSE, "Dim"); + announce(SLUMP_VERBOSE, "Dim"); } l->lit_light_level = 220; /* Always? */ dieroll = roll(100); @@ -15343,7 +15359,7 @@ void NewLevel(level *l, haa *ThisHaa, config *c) current_level_number = c->map + (9 * c->episode) + c->mission; - if (c->gamemask & HERETIC_BIT) + if (c->gamemask & SLUMP_HERETIC_BIT) l->heretic_level = SLUMP_TRUE; else l->heretic_level = SLUMP_FALSE; @@ -15382,7 +15398,7 @@ void NewLevel(level *l, haa *ThisHaa, config *c) done_quest = 1; if (ThisQuest->next == NULL) { - announce(LOG, "Self-collision; may be fewer rooms than expected."); + announce(SLUMP_LOG, "Self-collision; may be fewer rooms than expected."); } else { @@ -15436,43 +15452,43 @@ void NewLevel(level *l, haa *ThisHaa, config *c) ThisQuest = push_quest(ThisQuest); if ((keys_used>=l->maxkeys)|| (rollpercent(15))/*|| - (ThisQuest->next->goal==NULL_GOAL)*/) + (ThisQuest->next->goal==SLUMP_NULL_GOAL)*/) { if (rollpercent(50) && l->use_gates) { - ThisQuest->goal = GATE_GOAL; + ThisQuest->goal = SLUMP_GATE_GOAL; } else { - ThisQuest->goal = NULL_GOAL; + ThisQuest->goal = SLUMP_NULL_GOAL; } } else if (rollpercent(50) && l->use_gates) { - ThisQuest->goal = GATE_GOAL; + ThisQuest->goal = SLUMP_GATE_GOAL; /* Everything else decided later */ } else if (rollpercent(60) && (0 != (newkey = new_key(l)))) { - ThisQuest->goal = KEY_GOAL; + ThisQuest->goal = SLUMP_KEY_GOAL; ThisQuest->type = newkey; } else { - ThisQuest->goal = SWITCH_GOAL; + ThisQuest->goal = SLUMP_SWITCH_GOAL; ThisQuest->tag = new_tag(l); - announce(LOG, "switch quest"); + announce(SLUMP_LOG, "switch quest"); } - radical = (ThisQuest->goal != NULL_GOAL); + radical = (ThisQuest->goal != SLUMP_NULL_GOAL); lld1 = make_next_room(l, oldsector, radical, c, &lld2, &ForkLink, ThisQuest); if (lld1) { - announce(VERBOSE, "Fork"); + announce(SLUMP_VERBOSE, "Fork"); if (forks) - announce(LOG, "Multifork"); + announce(SLUMP_LOG, "Multifork"); establish_link(l, lld2, lld1, ForkLink, ThisQuest, ThisStyle, lld1->right->psector->pstyle, ThisHaa, c); ThisQuest->room = lld1->right->psector; - if (ThisQuest->goal == NULL_GOAL) + if (ThisQuest->goal == SLUMP_NULL_GOAL) { ThisQuest->minrooms = 1 + roll(4); nullforks++; @@ -15484,9 +15500,9 @@ void NewLevel(level *l, haa *ThisHaa, config *c) ThisQuest->next->minrooms -= ThisQuest->minrooms; if (ThisQuest->next->minrooms < 1) ThisQuest->next->minrooms = 1; - if (ThisQuest->goal == KEY_GOAL) + if (ThisQuest->goal == SLUMP_KEY_GOAL) { - announce(LOG, "Key thing"); + announce(SLUMP_LOG, "Key thing"); keys_used++; } } @@ -15525,7 +15541,7 @@ void NewLevel(level *l, haa *ThisHaa, config *c) /* Hack to avoid ammo-starvation in megawads due to leftbehinds */ /* Also turn off berserk effect */ - for (i = ITYTD; i <= UV; i++) + for (i = SLUMP_ITYTD; i <= SLUMP_UV; i++) { ThisHaa->haas[i].ammo *= (float)0.75; /* awful! */ ThisHaa->haas[i].has_berserk = SLUMP_FALSE; @@ -15548,7 +15564,7 @@ void NewLevel(level *l, haa *ThisHaa, config *c) /* Warn if we failed to do a secret level */ if (need_secret_level(c) && !l->sl_done) - announce(WARNING, "Secret level(s) may be unreachable; durn!"); + announce(SLUMP_WARNING, "Secret level(s) may be unreachable; durn!"); /* Add emergency deathmatch starts, if -dm and needed, announce count */ if (c->do_dm) @@ -15564,13 +15580,13 @@ void NewLevel(level *l, haa *ThisHaa, config *c) break; } sprintf(s, "%d deathmatch starts.", l->dm_count); - announce(LOG, s); + announce(SLUMP_LOG, s); } /* and finally, always have at least one "secret", for the 100% */ if (l->secret_count == 0) if (l->first_room) - l->first_room->special = SECRET_SECTOR; + l->first_room->special = SLUMP_SECRET_SECTOR; } /****** the end of SLUMP.C ********* please come again *********/ diff --git a/source/slump.h b/source/slump.h index 2bd952bd5..5228ed1b2 100644 --- a/source/slump.h +++ b/source/slump.h @@ -40,100 +40,93 @@ bool slump_main(const std::string &filename); /* Slump 0.003.02 */ -#define SOURCE_VERSION (0) -#define SOURCE_SERIAL (003) -#define SOURCE_PATCHLEVEL (02) +#define SLUMP_SOURCE_VERSION (0) +#define SLUMP_SOURCE_SERIAL (003) +#define SLUMP_SOURCE_PATCHLEVEL (02) /* Header file for things all slump files use */ -/* Some Microsoft-specific defines which we will probably get rid of in - * a later release */ -#ifdef _MSC_VER -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif - typedef unsigned char boolean; #define SLUMP_TRUE (1 == 1) #define SLUMP_FALSE (!SLUMP_TRUE) -#define HUGE_NUMBER (1000000) +#define SLUMP_HUGE_NUMBER (1000000) -#define LEVEL_MAX_BARS (30) -#define LEVEL_MAX_CRUSHERS (2) +#define SLUMP_LEVEL_MAX_BARS (30) +#define SLUMP_LEVEL_MAX_CRUSHERS (2) -#define TLMPSIZE(rows, columns) ((rows + 9) * columns + 8) +#define SLUMP_TLMPSIZE(rows, columns) ((rows + 9) * columns + 8) typedef unsigned char byte; -#ifdef OK_TO_USE_REAL_MONSTER_WIDTH -#define MONSTER_WIDTH(m) (m->width) +#ifdef SLUMP_OK_TO_USE_REAL_MONSTER_WIDTH +#define SLUMP_MONSTER_WIDTH(m) (m->width) #else -#define MONSTER_WIDTH(m) (64) +#define SLUMP_MONSTER_WIDTH(m) (64) #endif /* Minimum room size on a level with teleports */ -#define TELEPORT_MINROOMSIZE 256 +#define SLUMP_TELEPORT_MINROOMSIZE 256 /* Percentage change that a given level will have teleports */ -#define TELEPORTS_PERCENT 30 +#define SLUMP_TELEPORTS_PERCENT 30 /* The absolute minimum allowed light in a room */ -#define ABSOLUTE_MINLIGHT 126 +#define SLUMP_ABSOLUTE_MINLIGHT 126 typedef unsigned long themebits; /* Bitarray, really */ /* So at most 32 themes in a config file */ typedef unsigned int gamebits; /* Also bitarray */ -#define DOOM0_BIT (0x01) -#define DOOM1_BIT (0x02) -#define DOOM2_BIT (0x04) +#define SLUMP_DOOM0_BIT (0x01) +#define SLUMP_DOOM1_BIT (0x02) +#define SLUMP_DOOM2_BIT (0x04) /* This is "clean" doom, with no "GROSS" items */ -#define DOOMC_BIT (0x08) +#define SLUMP_DOOMC_BIT (0x08) /* "Intrinsic"; i.e. no SLUMP-special textures */ -#define DOOMI_BIT (0x10) -#define HERETIC_BIT (0x20) -#define CHEX_BIT (0x40) -#define HACX_BIT (0x80) -#define HARMONY_BIT (0x100) -#define STRIFE_BIT (0x200) -#define REKKR_BIT (0x400) +#define SLUMP_DOOMI_BIT (0x10) +#define SLUMP_HERETIC_BIT (0x20) +#define SLUMP_CHEX_BIT (0x40) +#define SLUMP_HACX_BIT (0x80) +#define SLUMP_HARMONY_BIT (0x100) +#define SLUMP_STRIFE_BIT (0x200) +#define SLUMP_REKKR_BIT (0x400) /* and that's all */ typedef unsigned long propertybits; /* Another bitarray */ -#define FLOOR (0x01) -#define CEILING (0x02) -#define DOOR (0x04) -#define ERROR_TEXTURE (0x08) -#define WALL (0x10) -#define SUPPORT (0x20) -#define NUKAGE (0x40) -#define JAMB (0x80) -#define RED (0x100) -#define BLUE (0x200) -#define YELLOW (0x400) -#define GRATING (0x800) -#define PLAQUE (0x1000) -#define HALF_PLAQUE (0x2000) -#define LIGHT (0x4000) -#define BIG (0x8000) -#define SWITCH (0x10000) -#define OUTDOOR (0x20000) -#define GATE (0x40000) -#define EXITSWITCH (0x80000) -#define STEP (0x100000) -#define LIFT_TEXTURE (0x200000) -#define VTILES (0x400000) +#define SLUMP_FLOOR (0x01) +#define SLUMP_CEILING (0x02) +#define SLUMP_DOOR (0x04) +#define SLUMP_ERROR_TEXTURE (0x08) +#define SLUMP_WALL (0x10) +#define SLUMP_SUPPORT (0x20) +#define SLUMP_NUKAGE (0x40) +#define SLUMP_JAMB (0x80) +#define SLUMP_RED (0x100) +#define SLUMP_BLUE (0x200) +#define SLUMP_YELLOW (0x400) +#define SLUMP_GRATING (0x800) +#define SLUMP_PLAQUE (0x1000) +#define SLUMP_HALF_PLAQUE (0x2000) +#define SLUMP_LIGHT (0x4000) +#define SLUMP_BIG (0x8000) +#define SLUMP_SWITCH (0x10000) +#define SLUMP_OUTDOOR (0x20000) +#define SLUMP_GATE (0x40000) +#define SLUMP_EXITSWITCH (0x80000) +#define SLUMP_STEP (0x100000) +#define SLUMP_LIFT_TEXTURE (0x200000) +#define SLUMP_VTILES (0x400000) /* and so on and so on; 32 may well not be enough! */ /* Some thing-only bits; corresponding bits above are texture/flat-only */ -#define MONSTER (0x01) -#define AMMO (0x02) -#define HEALTH (0x04) -#define WEAPON (0x08) -#define PICKABLE (0x10) -#define SHOOTS (0x20) -#define EXPLODES (0x40) -#define FLIES (0x80) -#define BOSS (0x100) -#define SPECIAL (0x800) +#define SLUMP_MONSTER (0x01) +#define SLUMP_AMMO (0x02) +#define SLUMP_HEALTH (0x04) +#define SLUMP_WEAPON (0x08) +#define SLUMP_PICKABLE (0x10) +#define SLUMP_SHOOTS (0x20) +#define SLUMP_EXPLODES (0x40) +#define SLUMP_FLIES (0x80) +#define SLUMP_BOSS (0x100) +#define SLUMP_SPECIAL (0x800) typedef struct s_theme { @@ -190,31 +183,31 @@ typedef struct s_link } link, *plink; /* Values for link.type */ -#define BASIC_LINK 1001 -#define OPEN_LINK 1002 -#define GATE_LINK 1003 +#define SLUMP_BASIC_LINK 1001 +#define SLUMP_OPEN_LINK 1002 +#define SLUMP_GATE_LINK 1003 /* Bits for link.bits */ -#define LINK_NEAR_DOOR (0x01) -#define LINK_RECESS (0x02) -#define LINK_ALCOVE (0x04) -#define LINK_TWIN (0x08) -#define LINK_CORE (0x10) -#define LINK_LIFT (0x20) -#define LINK_STEPS (0x40) +#define SLUMP_LINK_NEAR_DOOR (0x01) +#define SLUMP_LINK_RECESS (0x02) +#define SLUMP_LINK_ALCOVE (0x04) +#define SLUMP_LINK_TWIN (0x08) +#define SLUMP_LINK_CORE (0x10) +#define SLUMP_LINK_LIFT (0x20) +#define SLUMP_LINK_STEPS (0x40) /* LINK_WINDOW is used only if LINK_TWIN */ -#define LINK_WINDOW (0x80) -#define LINK_MAX_CEILING (0x100) -#define LINK_TRIGGERED (0x200) -#define LINK_LAMPS (0x400) -#define LINK_BARS (0x800) -#define LINK_LEFT (0x1000) -#define LINK_LOCK_CORE (0x2000) -#define LINK_FAR_TWINS (0x4000) -#define LINK_DECROOM (0x8000) -#define LINK_FAR_DOOR (0x10000) - -#define LINK_ANY_DOOR (LINK_NEAR_DOOR | LINK_FAR_DOOR) +#define SLUMP_LINK_WINDOW (0x80) +#define SLUMP_LINK_MAX_CEILING (0x100) +#define SLUMP_LINK_TRIGGERED (0x200) +#define SLUMP_LINK_LAMPS (0x400) +#define SLUMP_LINK_BARS (0x800) +#define SLUMP_LINK_LEFT (0x1000) +#define SLUMP_LINK_LOCK_CORE (0x2000) +#define SLUMP_LINK_FAR_TWINS (0x4000) +#define SLUMP_LINK_DECROOM (0x8000) +#define SLUMP_LINK_FAR_DOOR (0x10000) + +#define SLUMP_LINK_ANY_DOOR (SLUMP_LINK_NEAR_DOOR | SLUMP_LINK_FAR_DOOR) /* The kinds of things that there are */ @@ -224,69 +217,69 @@ typedef struct s_genus themebits compatible; propertybits bits; short thingid; -#define ID_PLAYER1 (0x0001) -#define ID_PLAYER2 (0x0002) -#define ID_PLAYER3 (0x0003) -#define ID_PLAYER4 (0x0004) -#define ID_DM (0x000b) -#define ID_GATEOUT (0x000e) +#define SLUMP_ID_PLAYER1 (0x0001) +#define SLUMP_ID_PLAYER2 (0x0002) +#define SLUMP_ID_PLAYER3 (0x0003) +#define SLUMP_ID_PLAYER4 (0x0004) +#define SLUMP_ID_DM (0x000b) +#define SLUMP_ID_GATEOUT (0x000e) /* The monsters */ -#define ID_TROOPER (0x0bbc) -#define ID_SERGEANT (0x0009) -#define ID_IMP (0x0bb9) -#define ID_PINK (0x0bba) -#define ID_SPECTRE (0x003a) -#define ID_COMMANDO (0x041) -#define ID_NAZI (0x054) -#define ID_SKULL (0xbbe) -#define ID_HEAD (0xbbd) -#define ID_SKEL (0x042) -#define ID_ARACH (0x044) -#define ID_MANCUB (0x0043) -#define ID_HELL (0x045) -#define ID_BARON (0x0bbb) -#define ID_PAIN (0x047) -#define ID_ARCHIE (0x0040) -#define ID_CYBER (0x10) -#define ID_SPIDERBOSS (0x07) -#define ID_BRAIN (0x58) +#define SLUMP_ID_TROOPER (0x0bbc) +#define SLUMP_ID_SERGEANT (0x0009) +#define SLUMP_ID_IMP (0x0bb9) +#define SLUMP_ID_PINK (0x0bba) +#define SLUMP_ID_SPECTRE (0x003a) +#define SLUMP_ID_COMMANDO (0x041) +#define SLUMP_ID_NAZI (0x054) +#define SLUMP_ID_SKULL (0xbbe) +#define SLUMP_ID_HEAD (0xbbd) +#define SLUMP_ID_SKEL (0x042) +#define SLUMP_ID_ARACH (0x044) +#define SLUMP_ID_MANCUB (0x0043) +#define SLUMP_ID_HELL (0x045) +#define SLUMP_ID_BARON (0x0bbb) +#define SLUMP_ID_PAIN (0x047) +#define SLUMP_ID_ARCHIE (0x0040) +#define SLUMP_ID_CYBER (0x10) +#define SLUMP_ID_SPIDERBOSS (0x07) +#define SLUMP_ID_BRAIN (0x58) /* The Heretic monsters (No ghosts - Dasho) */ -#define ID_GARGOYLE (0x42) -#define ID_FIREGARGOYLE (0x05) -#define ID_GOLEM (0x44) -#define ID_NITROGOLEM (0x2D) -#define ID_OPHIDIAN (0x5C) -#define ID_SABRECLAW (0x5A) -#define ID_UNDEADWARRIOR (0x40) -#define ID_DISCIPLE (0x0F) -#define ID_WEREDRAGON (0x46) -#define ID_MAULOTAUR (0x09) -#define ID_IRONLICH (0x06) -#define ID_DSPARIL (0x07) +#define SLUMP_ID_GARGOYLE (0x42) +#define SLUMP_ID_FIREGARGOYLE (0x05) +#define SLUMP_ID_GOLEM (0x44) +#define SLUMP_ID_NITROGOLEM (0x2D) +#define SLUMP_ID_OPHIDIAN (0x5C) +#define SLUMP_ID_SABRECLAW (0x5A) +#define SLUMP_ID_UNDEADWARRIOR (0x40) +#define SLUMP_ID_DISCIPLE (0x0F) +#define SLUMP_ID_WEREDRAGON (0x46) +#define SLUMP_ID_MAULOTAUR (0x09) +#define SLUMP_ID_IRONLICH (0x06) +#define SLUMP_ID_DSPARIL (0x07) /* The Hacx Monsters*/ -#define ID_THUG (0x0bbc) -#define ID_ANDROID (0x0009) -#define ID_BUZZER (0x0bba) -#define ID_STEALTHBUZZER (0x003a) -#define ID_HACXPHAGE (0x0043) -#define ID_ICE (0x0bb9) -#define ID_DMAN (0xbbe) -#define ID_MAJONG7 (0x047) -#define ID_MONSTRUCT (0x041) -#define ID_TERMINATRIX (0x0bbb) -#define ID_THORNTHING (0x044) -#define ID_MECHAMANIAC (0x045) -#define ID_ROAMINGMINE (0x054) +#define SLUMP_ID_THUG (0x0bbc) +#define SLUMP_ID_ANDROID (0x0009) +#define SLUMP_ID_BUZZER (0x0bba) +#define SLUMP_ID_STEALTHBUZZER (0x003a) +#define SLUMP_ID_HACXPHAGE (0x0043) +#define SLUMP_ID_ICE (0x0bb9) +#define SLUMP_ID_DMAN (0xbbe) +#define SLUMP_ID_MAJONG7 (0x047) +#define SLUMP_ID_MONSTRUCT (0x041) +#define SLUMP_ID_TERMINATRIX (0x0bbb) +#define SLUMP_ID_THORNTHING (0x044) +#define SLUMP_ID_MECHAMANIAC (0x045) +#define SLUMP_ID_ROAMINGMINE (0x054) /* The Harmony Monsters */ -#define ID_BEASTLING (0x0bba) -#define ID_FOLLOWER (0x9) -#define ID_MUTANTSOLDIER (0x41) -#define ID_PHAGE (0x44) -#define ID_PREDATOR (0x42) -#define ID_LANDMINE (0xbbe) -#define ID_AEROSOL (0xbbd) -#define ID_CENTAUR (0x10) -#define ID_ECHIDNA (0x7) +#define SLUMP_ID_BEASTLING (0x0bba) +#define SLUMP_ID_FOLLOWER (0x9) +#define SLUMP_ID_MUTANTSOLDIER (0x41) +#define SLUMP_ID_PHAGE (0x44) +#define SLUMP_ID_PREDATOR (0x42) +#define SLUMP_ID_LANDMINE (0xbbe) +#define SLUMP_ID_AEROSOL (0xbbd) +#define SLUMP_ID_CENTAUR (0x10) +#define SLUMP_ID_ECHIDNA (0x7) short width; short height; int min_level; /* Minimum level to put monster in */ @@ -299,118 +292,118 @@ typedef struct s_genus } genus, *pgenus; // Doom weapons/ammo -#define ID_SHOTGUN (0x7d1) -#define ID_SSGUN (0x052) -#define ID_CHAINGUN (0x7d2) -#define ID_CHAINSAW (0x7d5) -#define ID_PLASMA (0x7d4) -#define ID_BFG (0x7d6) -#define ID_CLIP (0x7d7) -#define ID_SHELLS (0x7d8) -#define ID_BULBOX (0x800) -#define ID_SHELLBOX (0x801) -#define ID_CELL (0x7ff) -#define ID_CELLPACK (0x11) -#define ID_BACKPACK (0x08) -#define ID_LAUNCHER (0x7d3) -#define ID_ROCKET (0x7da) -#define ID_ROCKBOX (0x7fe) +#define SLUMP_ID_SHOTGUN (0x7d1) +#define SLUMP_ID_SSGUN (0x052) +#define SLUMP_ID_CHAINGUN (0x7d2) +#define SLUMP_ID_CHAINSAW (0x7d5) +#define SLUMP_ID_PLASMA (0x7d4) +#define SLUMP_ID_BFG (0x7d6) +#define SLUMP_ID_CLIP (0x7d7) +#define SLUMP_ID_SHELLS (0x7d8) +#define SLUMP_ID_BULBOX (0x800) +#define SLUMP_ID_SHELLBOX (0x801) +#define SLUMP_ID_CELL (0x7ff) +#define SLUMP_ID_CELLPACK (0x11) +#define SLUMP_ID_BACKPACK (0x08) +#define SLUMP_ID_LAUNCHER (0x7d3) +#define SLUMP_ID_ROCKET (0x7da) +#define SLUMP_ID_ROCKBOX (0x7fe) // Heretic weapons/ammo -#define ID_GAUNTLETS (0x7D5) -#define ID_CROSSBOW (0x7D1) -#define ID_DRAGONCLAW (0x035) -#define ID_PHOENIXROD (0x7D3) -#define ID_HELLSTAFF (0x7D4) -#define ID_FIREMACE (0x7D2) -#define ID_WANDCRYSTAL (0xA) -#define ID_CRYSTALGEODE (0xC) -#define ID_ETHEREALARROWS (0x12) -#define ID_ETHEREALQUIVER (0x13) -#define ID_CLAWORB (0x36) -#define ID_ENERGYORB (0x37) -#define ID_LESSERRUNES (0x14) -#define ID_GREATERRUNES (0x15) -#define ID_FLAMEORB (0x16) -#define ID_INFERNOORB (0x17) -#define ID_MACESPHERES (0xD) -#define ID_MACESPHEREPILE (0x10) +#define SLUMP_ID_GAUNTLETS (0x7D5) +#define SLUMP_ID_CROSSBOW (0x7D1) +#define SLUMP_ID_DRAGONCLAW (0x035) +#define SLUMP_ID_PHOENIXROD (0x7D3) +#define SLUMP_ID_HELLSTAFF (0x7D4) +#define SLUMP_ID_FIREMACE (0x7D2) +#define SLUMP_ID_WANDCRYSTAL (0xA) +#define SLUMP_ID_CRYSTALGEODE (0xC) +#define SLUMP_ID_ETHEREALARROWS (0x12) +#define SLUMP_ID_ETHEREALQUIVER (0x13) +#define SLUMP_ID_CLAWORB (0x36) +#define SLUMP_ID_ENERGYORB (0x37) +#define SLUMP_ID_LESSERRUNES (0x14) +#define SLUMP_ID_GREATERRUNES (0x15) +#define SLUMP_ID_FLAMEORB (0x16) +#define SLUMP_ID_INFERNOORB (0x17) +#define SLUMP_ID_MACESPHERES (0xD) +#define SLUMP_ID_MACESPHEREPILE (0x10) // Doom health/powerups -#define ID_STIMPACK (0x7DB) -#define ID_MEDIKIT (0x7dc) -#define ID_POTION (0x7de) -#define ID_SOUL (0x7dd) -#define ID_BERSERK (0x7e7) -#define ID_INVIS (0x7e8) -#define ID_SUIT (0x7e9) -#define ID_MAP (0x7ea) +#define SLUMP_ID_STIMPACK (0x7DB) +#define SLUMP_ID_MEDIKIT (0x7dc) +#define SLUMP_ID_POTION (0x7de) +#define SLUMP_ID_SOUL (0x7dd) +#define SLUMP_ID_BERSERK (0x7e7) +#define SLUMP_ID_INVIS (0x7e8) +#define SLUMP_ID_SUIT (0x7e9) +#define SLUMP_ID_MAP (0x7ea) // Heretic health/powerups -#define ID_CRYSTALVIAL (0x51) -#define ID_QUARTZFLASK (0x52) -#define ID_MYSTICURN (0x20) -#define ID_MAPSCROLL (0x23) -#define ID_CHAOSDEVICE (0x24) -#define ID_MORPHOVUM (0x1E) -#define ID_RINGOFINVINCIBILITY (0x54) -#define ID_SHADOWSPHERE (0x4B) -#define ID_TIMEBOMB (0x22) -#define ID_TOMEOFPOWER (0x56) -#define ID_TORCH (0x21) +#define SLUMP_ID_CRYSTALVIAL (0x51) +#define SLUMP_ID_QUARTZFLASK (0x52) +#define SLUMP_ID_MYSTICURN (0x20) +#define SLUMP_ID_MAPSCROLL (0x23) +#define SLUMP_ID_CHAOSDEVICE (0x24) +#define SLUMP_ID_MORPHOVUM (0x1E) +#define SLUMP_ID_RINGOFINVINCIBILITY (0x54) +#define SLUMP_ID_SHADOWSPHERE (0x4B) +#define SLUMP_ID_TIMEBOMB (0x22) +#define SLUMP_ID_TOMEOFPOWER (0x56) +#define SLUMP_ID_TORCH (0x21) // Doom armor -#define ID_HELMET (0x7df) -#define ID_BLUESUIT (0x7e3) -#define ID_GREENSUIT (0x7e2) +#define SLUMP_ID_HELMET (0x7df) +#define SLUMP_ID_BLUESUIT (0x7e3) +#define SLUMP_ID_GREENSUIT (0x7e2) // Heretic armor -#define ID_SILVERSHIELD (0x55) -#define ID_ENCHANTEDSHIELD (0x1F) +#define SLUMP_ID_SILVERSHIELD (0x55) +#define SLUMP_ID_ENCHANTEDSHIELD (0x1F) // Doom keys -#define ID_BLUEKEY (0x028) -#define ID_REDKEY (0x026) -#define ID_YELLOWKEY (0x027) -#define ID_BLUECARD (0x0005) -#define ID_REDCARD (0x00d) -#define ID_YELLOWCARD (0x006) +#define SLUMP_ID_BLUEKEY (0x028) +#define SLUMP_ID_REDKEY (0x026) +#define SLUMP_ID_YELLOWKEY (0x027) +#define SLUMP_ID_BLUECARD (0x0005) +#define SLUMP_ID_REDCARD (0x00d) +#define SLUMP_ID_YELLOWCARD (0x006) // Heretic keys -#define ID_HERETICBLUEKEY (0x4F) -#define ID_HERETICYELLOWKEY (0x50) -#define ID_HERETICGREENKEY (0x49) +#define SLUMP_ID_HERETICBLUEKEY (0x4F) +#define SLUMP_ID_HERETICYELLOWKEY (0x50) +#define SLUMP_ID_HERETICGREENKEY (0x49) // Doom decor -#define ID_LAMP (0x07ec) -#define ID_ELEC (0x030) -#define ID_TLAMP2 (0x055) -#define ID_LAMP2 (0x056) -#define ID_TALLBLUE (0x002c) -#define ID_SHORTBLUE (0x037) -#define ID_TALLGREEN (0x02d) -#define ID_SHORTGREEN (0x038) -#define ID_TALLRED (0x02e) -#define ID_SHORTRED (0x039) -#define ID_CANDLE (0x022) -#define ID_CBRA (0x023) -#define ID_BARREL (0x07f3) -#define ID_FBARREL (0x0046) -#define ID_SMIT (0x002f) -#define ID_TREE1 (0x002b) -#define ID_TREE2 (0x0036) +#define SLUMP_ID_LAMP (0x07ec) +#define SLUMP_ID_ELEC (0x030) +#define SLUMP_ID_TLAMP2 (0x055) +#define SLUMP_ID_LAMP2 (0x056) +#define SLUMP_ID_TALLBLUE (0x002c) +#define SLUMP_ID_SHORTBLUE (0x037) +#define SLUMP_ID_TALLGREEN (0x02d) +#define SLUMP_ID_SHORTGREEN (0x038) +#define SLUMP_ID_TALLRED (0x02e) +#define SLUMP_ID_SHORTRED (0x039) +#define SLUMP_ID_CANDLE (0x022) +#define SLUMP_ID_CBRA (0x023) +#define SLUMP_ID_BARREL (0x07f3) +#define SLUMP_ID_FBARREL (0x0046) +#define SLUMP_ID_SMIT (0x002f) +#define SLUMP_ID_TREE1 (0x002b) +#define SLUMP_ID_TREE2 (0x0036) // Heretic decor -#define ID_POD (0x7F3) -#define ID_SERPENTTORCH (0x1B) -#define ID_FIREBRAZIER (0x4C) -#define ID_SMSTALAGMITE (0x25) -#define ID_LGSTALAGMITE (0x26) +#define SLUMP_ID_POD (0x7F3) +#define SLUMP_ID_SERPENTTORCH (0x1B) +#define SLUMP_ID_FIREBRAZIER (0x4C) +#define SLUMP_ID_SMSTALAGMITE (0x25) +#define SLUMP_ID_LGSTALAGMITE (0x26) // Hacx decor -#define ID_CEILINGLAMP (0x02c) -#define ID_TALLCEILINGLAMP (0x02e) -#define ID_FLOORLAMP (0x039) +#define SLUMP_ID_CEILINGLAMP (0x02c) +#define SLUMP_ID_TALLCEILINGLAMP (0x02e) +#define SLUMP_ID_FLOORLAMP (0x039) /* The style is the dynamic architectural knowledge and stuff. */ /* It changes throughout the run. */ @@ -469,14 +462,14 @@ typedef struct s_style boolean slitwindows; /* part of link? */ boolean window_grate; /* part of link? */ int window_decor; /* part of link? */ -#define WINDOW_NORMAL (5001) -#define WINDOW_JAMBS (5002) -#define WINDOW_SUPPORT (5003) -#define WINDOW_LIGHT (5004) +#define SLUMP_WINDOW_NORMAL (5001) +#define SLUMP_WINDOW_JAMBS (5002) +#define SLUMP_WINDOW_SUPPORT (5003) +#define SLUMP_WINDOW_LIGHT (5004) int lightbox_lighting; -#define LIGHTBOX_NORMAL (6001) -#define LIGHTBOX_LIGHTED (6002) -#define LIGHTBOX_DARK (6003) +#define SLUMP_LIGHTBOX_NORMAL (6001) +#define SLUMP_LIGHTBOX_LIGHTED (6002) +#define SLUMP_LIGHTBOX_DARK (6003) boolean light_recesses; boolean light_steps; boolean light_edges; @@ -598,66 +591,66 @@ struct s_linedef }; /* linedef and plinedef defined above; gcc chokes if we do it again! */ /* Linedef flags */ -#define IMPASSIBLE (0x01) -#define BLOCK_MONSTERS (0x02) -#define TWO_SIDED (0x04) -#define UPPER_UNPEGGED (0x08) -#define LOWER_UNPEGGED (0x10) -#define SECRET_LINEDEF (0x20) -#define BLOCK_SOUND (0x40) -#define NOT_ON_MAP (0x80) -#define ALREADY_ON_MAP (0x100) +#define SLUMP_IMPASSIBLE (0x01) +#define SLUMP_BLOCK_MONSTERS (0x02) +#define SLUMP_TWO_SIDED (0x04) +#define SLUMP_UPPER_UNPEGGED (0x08) +#define SLUMP_LOWER_UNPEGGED (0x10) +#define SLUMP_SECRET_LINEDEF (0x20) +#define SLUMP_BLOCK_SOUND (0x40) +#define SLUMP_NOT_ON_MAP (0x80) +#define SLUMP_ALREADY_ON_MAP (0x100) /* Linedef types */ -#define LINEDEF_NORMAL (0) -#define LINEDEF_NORMAL_DOOR (1) -#define LINEDEF_NORMAL_S1_DOOR (31) -#define LINEDEF_BLUE_S1_DOOR (32) -#define LINEDEF_RED_S1_DOOR (33) -#define LINEDEF_YELLOW_S1_DOOR (34) -#define LINEDEF_S1_OPEN_DOOR (103) -#define LINEDEF_S1_RAISE_STAIRS (7) -#define LINEDEF_S1_LOWER_FLOOR (23) -#define LINEDEF_SCROLL (48) -#define LINEDEF_TELEPORT (97) -#define LINEDEF_WR_OPEN_DOOR (86) -#define LINEDEF_W1_OPEN_DOOR (2) -#define LINEDEF_GR_OPEN_DOOR (46) -#define LINEDEF_SR_OC_DOOR (63) -#define LINEDEF_WR_OC_DOOR (90) -#define LINEDEF_S1_END_LEVEL (11) -#define LINEDEF_W1_END_LEVEL (52) -#define LINEDEF_S1_SEC_LEVEL (51) -#define LINEDEF_WR_FAST_CRUSH (77) -#define LINEDEF_WR_LOWER_LIFT (88) -#define LINEDEF_SR_LOWER_LIFT (62) -#define LINEDEF_S1_RAISE_AND_CLEAN_FLOOR (20) -#define LINEDEF_S1_RAISE_FLOOR (18) +#define SLUMP_LINEDEF_NORMAL (0) +#define SLUMP_LINEDEF_NORMAL_DOOR (1) +#define SLUMP_LINEDEF_NORMAL_S1_DOOR (31) +#define SLUMP_LINEDEF_BLUE_S1_DOOR (32) +#define SLUMP_LINEDEF_RED_S1_DOOR (33) +#define SLUMP_LINEDEF_YELLOW_S1_DOOR (34) +#define SLUMP_LINEDEF_S1_OPEN_DOOR (103) +#define SLUMP_LINEDEF_S1_RAISE_STAIRS (7) +#define SLUMP_LINEDEF_S1_LOWER_FLOOR (23) +#define SLUMP_LINEDEF_SCROLL (48) +#define SLUMP_LINEDEF_TELEPORT (97) +#define SLUMP_LINEDEF_WR_OPEN_DOOR (86) +#define SLUMP_LINEDEF_W1_OPEN_DOOR (2) +#define SLUMP_LINEDEF_GR_OPEN_DOOR (46) +#define SLUMP_LINEDEF_SR_OC_DOOR (63) +#define SLUMP_LINEDEF_WR_OC_DOOR (90) +#define SLUMP_LINEDEF_S1_END_LEVEL (11) +#define SLUMP_LINEDEF_W1_END_LEVEL (52) +#define SLUMP_LINEDEF_S1_SEC_LEVEL (51) +#define SLUMP_LINEDEF_WR_FAST_CRUSH (77) +#define SLUMP_LINEDEF_WR_LOWER_LIFT (88) +#define SLUMP_LINEDEF_SR_LOWER_LIFT (62) +#define SLUMP_LINEDEF_S1_RAISE_AND_CLEAN_FLOOR (20) +#define SLUMP_LINEDEF_S1_RAISE_FLOOR (18) // These aren't in Heretic -#define LINEDEF_WR_TURBO_LIFT (120) -#define LINEDEF_SR_TURBO_LIFT (123) -#define LINEDEF_S1_OPEN_DOOR_BLUE (133) -#define LINEDEF_S1_OPEN_DOOR_RED (135) -#define LINEDEF_S1_OPEN_DOOR_YELLOW (137) -#define LINEDEF_BLAZE_DOOR (117) -#define LINEDEF_BLAZE_S1_DOOR (118) -#define LINEDEF_S1_BLAZE_O_DOOR (112) -#define LINEDEF_SR_BLAZE_OC_DOOR (114) -#define LINEDEF_W1_SEC_LEVEL (124) -#define LINEDEF_W1_RAISE_FLOOR (119) +#define SLUMP_LINEDEF_WR_TURBO_LIFT (120) +#define SLUMP_LINEDEF_SR_TURBO_LIFT (123) +#define SLUMP_LINEDEF_S1_OPEN_DOOR_BLUE (133) +#define SLUMP_LINEDEF_S1_OPEN_DOOR_RED (135) +#define SLUMP_LINEDEF_S1_OPEN_DOOR_YELLOW (137) +#define SLUMP_LINEDEF_BLAZE_DOOR (117) +#define SLUMP_LINEDEF_BLAZE_S1_DOOR (118) +#define SLUMP_LINEDEF_S1_BLAZE_O_DOOR (112) +#define SLUMP_LINEDEF_SR_BLAZE_OC_DOOR (114) +#define SLUMP_LINEDEF_W1_SEC_LEVEL (124) +#define SLUMP_LINEDEF_W1_RAISE_FLOOR (119) /* and so on and so on */ /* sector specials */ -#define RANDOM_BLINK (1) -#define SYNC_FAST_BLINK (0x0c) -#define SYNC_SLOW_BLINK (0x0d) -#define GLOW_BLINK (0x08) -#define SECRET_SECTOR (0x09) -#define NUKAGE1_SPECIAL (5) -#define DEATH_SECTOR (0x0b) // This is a no-op for Heretic -#define HERETIC_LAVA (0x10) // Use this instead +#define SLUMP_RANDOM_BLINK (1) +#define SLUMP_SYNC_FAST_BLINK (0x0c) +#define SLUMP_SYNC_SLOW_BLINK (0x0d) +#define SLUMP_GLOW_BLINK (0x08) +#define SLUMP_SECRET_SECTOR (0x09) +#define SLUMP_NUKAGE1_SPECIAL (5) +#define SLUMP_DEATH_SECTOR (0x0b) // This is a no-op for Heretic +#define SLUMP_HERETIC_LAVA (0x10) // Use this instead /* Stuff related to an open PWAD we're generating */ @@ -733,9 +726,9 @@ typedef struct s_one_haa typedef struct s_haa { one_haa haas[3]; -#define ITYTD (0) -#define HMP (1) -#define UV (2) +#define SLUMP_ITYTD (0) +#define SLUMP_HMP (1) +#define SLUMP_UV (2) } haa, *phaa; typedef struct s_quest @@ -755,12 +748,12 @@ typedef struct s_quest } quest, *pquest; /* Values for quest.goal */ -#define LEVEL_END_GOAL 101 -#define KEY_GOAL 102 -#define SWITCH_GOAL 103 -#define NULL_GOAL 104 -#define ARENA_GOAL 105 -#define GATE_GOAL 106 +#define SLUMP_LEVEL_END_GOAL 101 +#define SLUMP_KEY_GOAL 102 +#define SLUMP_SWITCH_GOAL 103 +#define SLUMP_NULL_GOAL 104 +#define SLUMP_ARENA_GOAL 105 +#define SLUMP_GATE_GOAL 106 /* Teleport gates */ struct s_gate @@ -777,11 +770,11 @@ struct s_gate typedef struct s_arena { propertybits props; -#define ARENA_ROOF (0x01) -#define ARENA_PORCH (0x02) -#define ARENA_LAMPS (0x04) -#define ARENA_ARRIVAL_HOLE (0x08) -#define ARENA_NUKAGE (0x10) +#define SLUMP_ARENA_ROOF (0x01) +#define SLUMP_ARENA_PORCH (0x02) +#define SLUMP_ARENA_LAMPS (0x04) +#define SLUMP_ARENA_ARRIVAL_HOLE (0x08) +#define SLUMP_ARENA_NUKAGE (0x10) genus *boss; int boss_count; genus *weapon; @@ -984,7 +977,7 @@ void maybe_push_quest(level *l, sector *s, quest *ThisQuest, config *c); linedef *make_parallel(level *l, linedef *ld, int depth, linedef *old); linedef *lefthand_box_ext(level *l, linedef *ldf1, int depth, style *ThisStyle, config *c, linedef **nld1, linedef **nld2); -#define lefthand_box(l, ldf1, depth, ThisStyle, c) (lefthand_box_ext(l, ldf1, depth, ThisStyle, c, NULL, NULL)) +#define SLUMP_lefthand_box(l, ldf1, depth, ThisStyle, c) (lefthand_box_ext(l, ldf1, depth, ThisStyle, c, NULL, NULL)) int facing_along(int x1, int y1, int x2, int y2); int facing_right_from(int x1, int y1, int x2, int y2); int facing_right_from_ld(linedef *ld); @@ -1022,7 +1015,7 @@ void patch_lower(linedef *ld, texture *t, config *c); linedef *flip_linedef(linedef *ld); sector *make_box_ext(level *l, linedef *ldf1, linedef *ldf2, style *ThisStyle, config *c, linedef **nld1, linedef **nld2); -#define make_box(l, ld1, ld2, st, c) (make_box_ext(l, ld1, ld2, st, c, NULL, NULL)) +#define SLUMP_make_box(l, ld1, ld2, st, c) (make_box_ext(l, ld1, ld2, st, c, NULL, NULL)) thing *place_object(level *l, sector *s, config *c, short thingid, int width, int angle, int ax, int ay, int bits); thing *place_object_in_region(level *l, int minx, int miny, int maxx, int maxy, config *c, short thingid, int width, int angle, int ax, int ay, int bits); @@ -1046,12 +1039,12 @@ void install_gate(level *l, sector *s, style *ThisStyle, haa *ThisHaa, boole void frame_innersec_ex(level *l, sector *oldsector, sector *innersec, texture *tm, texture *tu, texture *tl, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, config *c, linedef **l1, linedef **l2, linedef **l3, linedef **l4); -#define frame_innersec(l, s, i, tm, tu, tl, x1, y1, x2, y2, x3, y3, x4, y4, c) \ +#define SLUMP_frame_innersec(l, s, i, tm, tu, tl, x1, y1, x2, y2, x3, y3, x4, y4, c) \ frame_innersec_ex(l, s, i, tm, tu, tl, x1, y1, x2, y2, x3, y3, x4, y4, c, NULL, NULL, NULL, NULL) void parallel_innersec_ex(level *l, sector *oldsector, sector *innersec, texture *tm, texture *tu, texture *tl, int minx, int miny, int maxx, int maxy, config *c, linedef **l1, linedef **l2, linedef **l3, linedef **l4); -#define parallel_innersec(l, o, i, tm, tu, tl, ix, iy, ax, ay, c) \ +#define SLUMP_parallel_innersec(l, o, i, tm, tu, tl, ix, iy, ax, ay, c) \ parallel_innersec_ex(l, o, i, tm, tu, tl, ix, iy, ax, ay, c, NULL, NULL, NULL, NULL) boolean install_construct(level *l, sector *oldsector, int minx, int miny, int maxx, int maxy, style *ThisStyle, config *c); @@ -1068,19 +1061,19 @@ void secretize_config(config *c); boolean install_sl_exit(level *l, sector *oldsector, haa *ThisHaa, style *ThisStyle, quest *ThisQuest, boolean opens, config *c); -#define NONE -1 -#define VERBOSE 0 -#define LOG 1 -#define NOTE 2 -#define WARNING 3 +#define SLUMP_NONE -1 +#define SLUMP_VERBOSE 0 +#define SLUMP_LOG 1 +#define SLUMP_NOTE 2 +#define SLUMP_WARNING 3 #define SLUMP_ERROR 4 void announce(int announcetype, const char *s); -#define RIGHT_TURN (90) -#define LEFT_TURN (270) +#define SLUMP_RIGHT_TURN (90) +#define SLUMP_LEFT_TURN (270) void point_from(int x1, int y1, int x2, int y2, int angle, int len, int *x3, int *y3); unsigned short psi_sqrt(int v); -#define linelen(x) (unsigned short)(psi_sqrt(lengthsquared(x))) +#define SLUMP_linelen(x) (unsigned short)(psi_sqrt(lengthsquared(x))) boolean no_monsters_stuck_on(level *l, linedef *ld1); flat *random_ceiling0(config *c, style *s); diff --git a/source/slump_dump.cc b/source/slump_dump.cc index 97f9ddb59..914f5f733 100644 --- a/source/slump_dump.cc +++ b/source/slump_dump.cc @@ -42,7 +42,7 @@ extern int current_level_number; extern int global_verbosity; /* Oooh, a global variable! */ extern boolean ok_to_roll; /* Stop breaking -seed... */ -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG unsigned int swap_32(unsigned int in) { return ((in >> 24) & 0xff) | /* hi byte (byte 1) becomes low uint8_t */ @@ -61,7 +61,7 @@ short swap_16(short in) { return ((in >> 8) & 0xff) | ((in & 0xff) << 8); } -#endif /* ENDIAN_BIG */ +#endif /* SLUMP_ENDIAN_BIG */ /* Open a file ready to dump multiple levels into */ dumphandle OpenDump(config *c) @@ -110,10 +110,10 @@ void CloseDump(dumphandle dh) { directory_entry.offset = ie->offset; directory_entry.length = ie->length; -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG directory_entry.offset = swap_32(directory_entry.offset); directory_entry.length = swap_32(directory_entry.length); -#endif /* ENDIAN_BIG */ +#endif /* SLUMP_ENDIAN_BIG */ memset(directory_entry.lumpname, 0, 8); memcpy(directory_entry.lumpname, ie->name, strlen(ie->name)); fwrite(&directory_entry, sizeof(directory_entry), 1, dh->f); @@ -121,17 +121,17 @@ void CloseDump(dumphandle dh) /* Go back and patch up the header */ fseek(dh->f, 4, SEEK_SET); -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG dh->lmpcount = swap_32(dh->lmpcount); dh->offset_to_index = swap_32(dh->offset_to_index); -#endif /* ENDIAN_BIG */ +#endif /* SLUMP_ENDIAN_BIG */ fwrite(&(dh->lmpcount), sizeof(unsigned int), 1, dh->f); fwrite(&(dh->offset_to_index), sizeof(unsigned int), 1, dh->f); -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG /* Swap back in case we use the numbers later */ dh->lmpcount = swap_32(dh->lmpcount); dh->offset_to_index = swap_32(dh->offset_to_index); -#endif /* ENDIAN_BIG */ +#endif /* SLUMP_ENDIAN_BIG */ /* and that's all! */ fclose(dh->f); @@ -173,7 +173,7 @@ void record_music(dumphandle dh, musheader *mh, uint8_t *buf, const char *s, con RegisterLmp(dh, s, lsize); /* It'll be a royal pain to endian swap the header, so we just don't * have custom music on big-endian machines */ -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG // Need to try to get this working - Dasho fwrite(mh, sizeof(musheader), 1, dh->f); // Write fixed header fwrite(buf, mh->patches * sizeof(short) + mh->muslength, 1, dh->f); @@ -185,7 +185,7 @@ void make_slinfo(dumphandle dh, config *c) { static byte slinfo[100]; - sprintf((char *)slinfo, "SLUMP (%d.%03d.%02d)", SOURCE_VERSION, SOURCE_SERIAL, SOURCE_PATCHLEVEL); + sprintf((char *)slinfo, "SLUMP (%d.%03d.%02d)", SLUMP_SOURCE_VERSION, SLUMP_SOURCE_SERIAL, SLUMP_SOURCE_PATCHLEVEL); RegisterLmp(dh, "SLINFO", strlen((char *)slinfo) + 1); fwrite(slinfo, strlen((char *)slinfo) + 1, 1, dh->f); @@ -210,11 +210,12 @@ void validate_teleports(linedef *pLinedef, sector *pSector) } for (; pLinedef != NULL; pLinedef = pLinedef->next) { - if (pLinedef->type == LINEDEF_TELEPORT && pLinedef->tag > 0 && pLinedef->tag < 1024 && tags[pLinedef->tag] == 0) + if (pLinedef->type == SLUMP_LINEDEF_TELEPORT && pLinedef->tag > 0 && pLinedef->tag < 1024 && + tags[pLinedef->tag] == 0) { printf("Warning: teleport with invalid tag; " "making end of level!\n"); - pLinedef->type = LINEDEF_W1_END_LEVEL; + pLinedef->type = SLUMP_LINEDEF_W1_END_LEVEL; } } } @@ -355,7 +356,7 @@ void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int rawthing.angle = pThing->angle; rawthing.type = pThing->pgenus->thingid; rawthing.options = pThing->options; -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG rawthing.x = swap_16(rawthing.x); rawthing.y = swap_16(rawthing.y); rawthing.angle = swap_16(rawthing.angle); @@ -393,7 +394,7 @@ void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int { rawlinedef.left = (pLinedef->left)->number; } -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG rawlinedef.from = swap_16(rawlinedef.from); rawlinedef.to = swap_16(rawlinedef.to); rawlinedef.flags = swap_16(rawlinedef.flags); @@ -421,7 +422,7 @@ void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int strlen(pSidedef->middle_texture->realname)); pSidedef->middle_texture->used = SLUMP_TRUE; rawsidedef.sector = (pSidedef->psector)->number; -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG rawsidedef.x_offset = swap_16(rawsidedef.x_offset); rawsidedef.y_offset = swap_16(rawsidedef.y_offset); rawsidedef.sector = swap_16(rawsidedef.sector); @@ -434,7 +435,7 @@ void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int { rawvertex.x = pVertex->x; rawvertex.y = pVertex->y; -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG rawvertex.x = swap_16(rawvertex.x); rawvertex.y = swap_16(rawvertex.y); #endif @@ -453,14 +454,14 @@ void DumpLevel(dumphandle dh, config *c, level *l, int episode, int mission, int memset(rawsector.ceiling_flat, 0, 8); memcpy(rawsector.ceiling_flat, pSector->ceiling_flat->name, strlen(pSector->ceiling_flat->name)); pSector->ceiling_flat->used = SLUMP_TRUE; - if (pSector->light_level < ABSOLUTE_MINLIGHT) + if (pSector->light_level < SLUMP_ABSOLUTE_MINLIGHT) { /* Rooms can be too dark */ - pSector->light_level = ABSOLUTE_MINLIGHT; + pSector->light_level = SLUMP_ABSOLUTE_MINLIGHT; } rawsector.light_level = pSector->light_level; rawsector.special = pSector->special; rawsector.tag = pSector->tag; -#ifdef ENDIAN_BIG +#ifdef SLUMP_ENDIAN_BIG rawsector.floor_height = swap_16(rawsector.floor_height); rawsector.ceiling_height = swap_16(rawsector.ceiling_height); rawsector.light_level = swap_16(rawsector.light_level); @@ -500,7 +501,7 @@ void dump_texture_lmp(dumphandle dh, texture_lmp *tl) tbuf = buf; /* Write in the count */ -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(int *)tbuf = texturecount; tbuf += sizeof(int); #else @@ -512,7 +513,7 @@ void dump_texture_lmp(dumphandle dh, texture_lmp *tl) isize = 4 + 4 * texturecount; for (ct = tl->custom_texture_anchor; ct; ct = ct->next) { -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(int *)tbuf = isize; tbuf += sizeof(int); #else @@ -539,7 +540,7 @@ void dump_texture_lmp(dumphandle dh, texture_lmp *tl) tbuf += sizeof(short); *(short *)tbuf = 0; tbuf += sizeof(short); -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)tbuf = ct->xsize; tbuf += sizeof(short); *(short *)tbuf = ct->ysize; @@ -556,7 +557,7 @@ void dump_texture_lmp(dumphandle dh, texture_lmp *tl) tbuf += sizeof(short); for (patchcount = 0, p = ct->patch_anchor; p; p = p->next) patchcount++; -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)tbuf = patchcount; tbuf += sizeof(short); #else @@ -565,7 +566,7 @@ void dump_texture_lmp(dumphandle dh, texture_lmp *tl) #endif for (p = ct->patch_anchor; p; p = p->next) { -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)tbuf = p->x; tbuf += sizeof(short); *(short *)tbuf = p->y; @@ -628,7 +629,7 @@ void record_custom_textures(dumphandle dh, config *c) custom_texture *ct; /* Return if TEXTURE2 not available */ - if (c->gamemask & (DOOM0_BIT | DOOM1_BIT | DOOMI_BIT | HERETIC_BIT)) + if (c->gamemask & (SLUMP_DOOM0_BIT | SLUMP_DOOM1_BIT | SLUMP_DOOMI_BIT | SLUMP_HERETIC_BIT)) return; tl = new_texture_lmp("TEXTURE2"); @@ -679,8 +680,8 @@ void record_custom_textures(dumphandle dh, config *c) free_texture_lmp(tl); } /* end record_custom_textures */ -byte fbuf[64 * 64 + 4]; /* For use in making custom flats and patches; 64x64 */ -byte pbuf[TLMPSIZE(0x80, 0x40)]; /* Also */ +byte fbuf[64 * 64 + 4]; /* For use in making custom flats and patches; 64x64 */ +byte pbuf[SLUMP_TLMPSIZE(0x80, 0x40)]; /* Also */ /* Record any custom flats that we might want to show off by using. */ /* This is *much* simpler than textures! */ @@ -695,7 +696,7 @@ void record_custom_flats(dumphandle dh, config *c, boolean even_unused) if (!started) RegisterLmp(dh, "FF_START", 0); started = SLUMP_TRUE; - announce(VERBOSE, "SLGRASS1"); + announce(SLUMP_VERBOSE, "SLGRASS1"); basic_background2(fbuf, 0x7c, 4); x = roll(64); @@ -745,7 +746,7 @@ void record_custom_flats(dumphandle dh, config *c, boolean even_unused) if (!started) RegisterLmp(dh, "FF_START", 0); started = SLUMP_TRUE; - announce(VERBOSE, "SLSPARKS"); + announce(SLUMP_VERBOSE, "SLSPARKS"); memset(fbuf, 0, 4096); for (i = 512; i; i--) fbuf[roll(64) + 64 * roll(64)] = 0xb0 + roll(16); @@ -759,7 +760,7 @@ void record_custom_flats(dumphandle dh, config *c, boolean even_unused) if (!started) RegisterLmp(dh, "FF_START", 0); started = SLUMP_TRUE; - announce(VERBOSE, "SLGATE1"); + announce(SLUMP_VERBOSE, "SLGATE1"); basic_background2(fbuf, 0x9c, 4); @@ -790,7 +791,7 @@ void record_custom_flats(dumphandle dh, config *c, boolean even_unused) if (!started) RegisterLmp(dh, "FF_START", 0); started = SLUMP_TRUE; - announce(VERBOSE, "SLLITE1"); + announce(SLUMP_VERBOSE, "SLLITE1"); basic_background2(fbuf, 0x94, 4); @@ -830,7 +831,7 @@ void record_custom_flats(dumphandle dh, config *c, boolean even_unused) if (!started) RegisterLmp(dh, "FF_START", 0); started = SLUMP_TRUE; - announce(VERBOSE, "SLFLAT01"); + announce(SLUMP_VERBOSE, "SLFLAT01"); basic_background2(fbuf, 0x6b, 5); for (i = 0; i < 4096; i++) @@ -875,12 +876,12 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) rows = 0x80; columns = 0x40; - lsize = TLMPSIZE(rows, columns); + lsize = SLUMP_TLMPSIZE(rows, columns); if (lsize > sizeof(pbuf)) announce(SLUMP_ERROR, "Buffer overflow in r_c_t()"); p = pbuf; /* The picture header */ -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)p = columns; p += sizeof(short); /* Width */ *(short *)p = rows; @@ -904,7 +905,7 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) { int z; z = 8 + 4 * (columns) + i * (rows + 5); -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(int *)p = z; p += sizeof(int); #else @@ -952,12 +953,12 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) rows = 0x80; columns = 0x40; - lsize = TLMPSIZE(rows, columns); + lsize = SLUMP_TLMPSIZE(rows, columns); if (lsize > sizeof(pbuf)) announce(SLUMP_ERROR, "Buffer overflow in r_c_t()"); p = pbuf; /* The picture header */ -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)p = columns; p += sizeof(short); /* Width */ *(short *)p = rows; @@ -981,7 +982,7 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) { int z; z = 8 + 4 * (columns) + i * (rows + 5); -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(int *)p = z; p += sizeof(int); #else @@ -1038,12 +1039,12 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) /* Then the actual patch */ rows = 0x80; columns = 0x40; - lsize = TLMPSIZE(rows, columns); + lsize = SLUMP_TLMPSIZE(rows, columns); if (lsize > sizeof(pbuf)) announce(SLUMP_ERROR, "Buffer overflow in r_c_t()"); p = pbuf; /* The picture header */ -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(short *)p = columns; p += sizeof(short); /* Width */ *(short *)p = rows; @@ -1067,7 +1068,7 @@ void record_custom_patches(dumphandle dh, config *c, boolean even_unused) { int z; z = 8 + 4 * (columns) + i * (rows + 5); -#ifndef ENDIAN_BIG +#ifndef SLUMP_ENDIAN_BIG *(int *)p = z; p += sizeof(int); #else @@ -1117,13 +1118,13 @@ void make_music(dumphandle dh, config *c) uint8_t *musbuf; /* Definitely a stub! */ - if (c->gamemask & DOOM1_BIT) + if (c->gamemask & SLUMP_DOOM1_BIT) { musbuf = one_piece(&mh); record_music(dh, &mh, musbuf, "D_INTROA", c); free(musbuf); } - if (c->gamemask & DOOM2_BIT) + if (c->gamemask & SLUMP_DOOM2_BIT) { musbuf = one_piece(&mh); record_music(dh, &mh, musbuf, "D_DM2TTL", c); diff --git a/source/slump_main.cc b/source/slump_main.cc index 2ef210197..fa85db4f3 100644 --- a/source/slump_main.cc +++ b/source/slump_main.cc @@ -52,7 +52,7 @@ void machioize(config *c, float amount) int a; for (m = c->genus_anchor; m; m = m->next) { - if (!(m->bits & MONSTER)) + if (!(m->bits & SLUMP_MONSTER)) continue; for (a = 0; a <= 2; a++) { @@ -77,7 +77,7 @@ bool slump_main(const std::string &filename) printf("SLUMP version %d.%03d.%02d -- by Sam Trenholme, http://www.samiam.org\n" "based on SLIGE by Dave Chess, dmchess@aol.com\n\n", - SOURCE_VERSION, SOURCE_SERIAL, SOURCE_PATCHLEVEL); + SLUMP_SOURCE_VERSION, SLUMP_SOURCE_SERIAL, SLUMP_SOURCE_PATCHLEVEL); ThisConfig = get_config(filename); if (ThisConfig == NULL) @@ -142,7 +142,7 @@ bool slump_main(const std::string &filename) } FreeLevel(&ThisLevel); } - if (!(ThisConfig->gamemask & (DOOMI_BIT | HERETIC_BIT))) + if (!(ThisConfig->gamemask & (SLUMP_DOOMI_BIT | SLUMP_HERETIC_BIT))) { record_custom_textures(dh, ThisConfig); record_custom_flats(dh, ThisConfig, SLUMP_FALSE); diff --git a/source/sys_assert.h b/source/sys_assert.h index 67670549b..fd3717772 100644 --- a/source/sys_assert.h +++ b/source/sys_assert.h @@ -23,7 +23,7 @@ // -------- the macros -------- -#ifdef NDEBUG +#ifdef SYS_NDEBUG #define SYS_ASSERT(cond) ((void)0) #elif defined(__GNUC__) @@ -37,7 +37,7 @@ #endif // NDEBUG -#ifdef NDEBUG +#ifdef SYS_NDEBUG #define SYS_ASSERT_MSG(cond, arglist) ((void)0) #else #define SYS_ASSERT_MSG(cond, arglist) ((cond) ? (void)0 : AssertFail arglist) diff --git a/source/sys_debug.cc b/source/sys_debug.cc index 9c860b554..c6be1560b 100644 --- a/source/sys_debug.cc +++ b/source/sys_debug.cc @@ -27,12 +27,12 @@ #include "main.h" #include "sys_assert.h" -#define DEBUG_BUF_LEN 20000 +static constexpr uint16_t DEBUG_BUF_LEN = 20000; -FILE *log_file = nullptr; -FILE *ref_file = nullptr; -std::string log_filename; -std::string ref_filename; +static FILE *log_file = nullptr; +static FILE *ref_file = nullptr; +std::string log_filename; +std::string ref_filename; bool debugging = false; bool terminal = false; @@ -241,7 +241,7 @@ void ProgStatus(const char *message, ...) // I hope nobody is printing strings longer than 4096 chars... SYS_ASSERT(message_buf[4095] == 0); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY if (main_win) { main_win->build_box->SetStatus(message_buf); @@ -300,12 +300,12 @@ void ProgStatus(const char *message, ...) if (terminal) printf("ERROR: %s", message_buf); -#ifndef CONSOLE_ONLY +#ifndef OBSIDIAN_CONSOLE_ONLY DLG_ShowError("%s", message_buf); #endif Main::Shutdown(true); -#if defined _WIN32 && !defined CONSOLE_ONLY +#if defined _WIN32 && !defined OBSIDIAN_CONSOLE_ONLY if (batch_mode) { printf("\nClose window when finished..."); diff --git a/source/sys_macro.h b/source/sys_macro.h index 8ea9256b0..f335958bb 100644 --- a/source/sys_macro.h +++ b/source/sys_macro.h @@ -24,30 +24,31 @@ #include #include -constexpr const char *BLANKOUT = " " - " " - " "; +constexpr const char *BLANKOUT = + " " + " " + " "; // basic constants -#define OBSIDIAN_MSG_BUF_LEN 2000 -#define OBSIDIAN_DIST_EPSILON (1.0 / 1024.0) -#define OBSIDIAN_ANG_EPSILON (1.0 / 1024.0) -#define OBSIDIAN_PI 3.14159265358979323846 +constexpr uint16_t OBSIDIAN_MSG_BUF_LEN = 2000; +constexpr double OBSIDIAN_POLY_EPSILON = (1.0 / 128.0); +constexpr double OBSIDIAN_DIST_EPSILON = (1.0 / 1024.0); +constexpr double OBSIDIAN_ANG_EPSILON = (1.0 / 1024.0); +constexpr double OBSIDIAN_PI = 3.14159265358979323846; // basic math #define OBSIDIAN_MAX(a, b) ((a > b) ? a : b) #define OBSIDIAN_MIN(a, b) ((a < b) ? a : b) #define OBSIDIAN_ABS(a) ((a < 0) ? -a : a) #define OBSIDIAN_CLAMP(low, x, high) ((x < low) ? low : ((x > high) ? high : x)) -// formerly I_ROUND macros -inline int RoundToInteger(float x) -{ - return (int)roundf(x); -} -inline int RoundToInteger(double x) -{ - return (int)round(x); -} +#define OBSIDIAN_I_ROUND(x) ((int)(((x) < 0.0f) ? ((x) - 0.5f) : ((x) + 0.5f))) + +// colors +#define OBSIDIAN_MAKE_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | (a)) +#define OBSIDIAN_RGB_RED(col) ((col >> 24) & 255) +#define OBSIDIAN_RGB_GREEN(col) ((col >> 16) & 255) +#define OBSIDIAN_RGB_BLUE(col) ((col >> 8) & 255) +#define OBSIDIAN_RGB_ALPHA(col) ((col) & 255) //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source/tx_forge.cc b/source/tx_forge.cc index e037c02f3..3d93ab508 100644 --- a/source/tx_forge.cc +++ b/source/tx_forge.cc @@ -40,14 +40,14 @@ #include "sys_macro.h" #include "sys_xoshiro.h" -/* Definitions used to address real and imaginary parts in a two-dimensional +/* Definitions used to address FORGE_REAL and imaginary parts in a two-dimensional array of complex numbers as stored by fourn(). */ static float *mesh_a; static int meshsize; -#define Real(x, y) mesh_a[1 + (((x) * meshsize) + (y)) * 2] -#define Imag(x, y) mesh_a[2 + (((x) * meshsize) + (y)) * 2] +#define FORGE_REAL(x, y) mesh_a[1 + (((x) * meshsize) + (y)) * 2] +#define FORGE_IMAG(x, y) mesh_a[2 + (((x) * meshsize) + (y)) * 2] static void create_mesh(int width) { @@ -99,7 +99,7 @@ static void fourn(float data[], int nn[], int ndim, int isign) float tempi, tempr; double theta, wi, wpi, wpr, wr, wtemp; -#define FN_SWAP(a, b) \ +#define FORGE_FN_SWAP(a, b) \ tempr = (a); \ (a) = (b); \ (b) = tempr @@ -127,8 +127,8 @@ static void fourn(float data[], int nn[], int ndim, int isign) for (i3 = i1; i3 <= ip3; i3 += ip2) { i3rev = i2rev + i3 - i2; - FN_SWAP(data[i3], data[i3rev]); - FN_SWAP(data[i3 + 1], data[i3rev + 1]); + FORGE_FN_SWAP(data[i3], data[i3rev]); + FORGE_FN_SWAP(data[i3 + 1], data[i3rev + 1]); } } } @@ -174,12 +174,12 @@ static void fourn(float data[], int nn[], int ndim, int isign) nprev *= n; } } -#undef FN_SWAP +#undef FORGE_FN_SWAP /* INITGAUSS -- Initialize random number generators. As given in Peitgen & Saupe, page 77. */ -#define NRAND 4 /* Gauss() sample count */ +static constexpr uint8_t NRAND = 4; /* Gauss() sample count */ static double gauss_add, gauss_mul; /* Gaussian random parameters */ @@ -240,16 +240,16 @@ static void spectral_synth(int n, double h) int i0 = (i == 0) ? 0 : n - i; int j0 = (j == 0) ? 0 : n - j; - Real(i, j) = rcos; - Imag(i, j) = rsin; - Real(i0, j0) = rcos; - Imag(i0, j0) = -rsin; + FORGE_REAL(i, j) = rcos; + FORGE_IMAG(i, j) = rsin; + FORGE_REAL(i0, j0) = rcos; + FORGE_IMAG(i0, j0) = -rsin; } } - Imag(n / 2, 0) = 0; - Imag(0, n / 2) = 0; - Imag(n / 2, n / 2) = 0; + FORGE_IMAG(n / 2, 0) = 0; + FORGE_IMAG(0, n / 2) = 0; + FORGE_IMAG(n / 2, n / 2) = 0; for (i = 1; i <= n / 2 - 1; i++) { @@ -261,10 +261,10 @@ static void spectral_synth(int n, double h) double rcos = rad * cos(phase); double rsin = rad * sin(phase); - Real(i, n - j) = rcos; - Imag(i, n - j) = rsin; - Real(n - i, j) = rcos; - Imag(n - i, j) = -rsin; + FORGE_REAL(i, n - j) = rcos; + FORGE_IMAG(i, n - j) = rsin; + FORGE_REAL(n - i, j) = rcos; + FORGE_IMAG(n - i, j) = -rsin; } } @@ -288,7 +288,7 @@ static void copy_and_scale(float *buf) { for (j = 0; j < meshsize; j++) { - double r = Real(i, j); + double r = FORGE_REAL(i, j); rmin = OBSIDIAN_MIN(rmin, r); rmax = OBSIDIAN_MAX(rmax, r); @@ -308,7 +308,7 @@ static void copy_and_scale(float *buf) { for (j = 0; j < meshsize; j++) { - *buf++ = (Real(i, j) - rmin) / range; + *buf++ = (FORGE_REAL(i, j) - rmin) / range; } } } diff --git a/source/ui_boxes.cc b/source/ui_boxes.cc index 705986e00..e4aeb50cf 100644 --- a/source/ui_boxes.cc +++ b/source/ui_boxes.cc @@ -454,7 +454,7 @@ void cplastic_down_box(int x, int y, int w, int h, Fl_Color c) // CUSTOM SHADOW BOX // --------------------------------------------------------------------------------------- -#define BW 3 +static constexpr uint8_t BW = 3; void cshadow_frame(int x, int y, int w, int h, Fl_Color c) { diff --git a/source/ui_build.cc b/source/ui_build.cc index 264ab2ed0..a37ab9b5b 100644 --- a/source/ui_build.cc +++ b/source/ui_build.cc @@ -34,12 +34,12 @@ UI_Build::UI_Build(int X, int Y, int W, int H, const char *label) : Fl_Group(X, status_label = "0"; - int pad = kf_w(12); + int pad = KromulentWidth(12); int mini_w = W * .80; int mini_h = mini_w; - int cy = Y + kf_h(6); + int cy = Y + KromulentHeight(6); /* --- Status Area --- */ @@ -67,16 +67,16 @@ UI_Build::UI_Build(int X, int Y, int W, int H, const char *label) : Fl_Group(X, alt_disp->labelsize(header_font_size); alt_disp->labelfont(font_style); - cy += mini_map->h() + kf_h(4); + cy += mini_map->h() + KromulentHeight(4); - status = new Fl_Box(FL_FLAT_BOX, X + pad, cy, W - pad * 2, kf_h(26), _("Ready to go!")); + status = new Fl_Box(FL_FLAT_BOX, X + pad, cy, W - pad * 2, KromulentHeight(26), _("Ready to go!")); status->box(FL_NO_BOX); status->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT); status->labelfont(font_style); - cy += status->h() + kf_h(4); + cy += status->h() + KromulentHeight(4); - progress = new Fl_Progress(X + pad, cy, W - pad * 2, kf_h(26)); + progress = new Fl_Progress(X + pad, cy, W - pad * 2, KromulentHeight(26)); progress->align(FL_ALIGN_INSIDE); progress->box(FL_FLAT_BOX); progress->color(GAP_COLOR, GAP_COLOR); @@ -241,7 +241,7 @@ void UI_Build::Prog_AtLevel(int index, int total) level_index = index; level_total = total; - Prog_Step(N_("Plan")); + Prog_Step(_("Plan")); } void UI_Build::Prog_Step(const char *step_name) diff --git a/source/ui_game.cc b/source/ui_game.cc index 4cefb079a..9f281ab15 100644 --- a/source/ui_game.cc +++ b/source/ui_game.cc @@ -24,8 +24,6 @@ #include "m_trans.h" #include "main.h" -#define ABORT_COLOR fl_color_cube(3, 1, 1) - // // Constructor // @@ -34,24 +32,25 @@ UI_Game::UI_Game(int X, int Y, int W, int H) : Fl_Group(X, Y, W, H) box(box_style); int button_w = W * 0.35; - int button_h = kf_h(30); - int button_x = X + kf_w(25); + int button_h = KromulentHeight(30); + int button_x = X + KromulentWidth(25); - int y_step = kf_h(30); + int y_step = KromulentHeight(30); int cx = X + W * 0.29; - int cy = Y + kf_h(4); + int cy = Y + KromulentHeight(4); - heading = new Fl_Box(FL_NO_BOX, X + kf_w(8), cy, W - kf_w(12), kf_h(24), _("Game Settings")); + heading = new Fl_Box(FL_NO_BOX, X + KromulentWidth(8), cy, W - KromulentWidth(12), KromulentHeight(24), + _("Game Settings")); heading->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); heading->labeltype(FL_NORMAL_LABEL); heading->labelfont(font_style | FL_BOLD); heading->labelsize(header_font_size); - cy = Y + kf_h(32); + cy = Y + KromulentHeight(32); int cw = W * 0.50; - int ch = kf_h(22); + int ch = KromulentHeight(22); engine = new UI_RChoiceMenu(cx, cy, cw, ch, ""); engine->copy_label(_("Engine: ")); @@ -390,7 +389,7 @@ void UI_Game::SetAbortButton(bool abort) if (abort) { quit->label(_("Cancel")); - quit->labelcolor(ABORT_COLOR); + quit->labelcolor(fl_color_cube(3, 1, 1)); quit->labelfont(font_style | FL_BOLD); quit->callback(stop_callback, this); diff --git a/source/ui_module.cc b/source/ui_module.cc index f26c22627..54f50ce32 100644 --- a/source/ui_module.cc +++ b/source/ui_module.cc @@ -32,8 +32,8 @@ #include "sys_macro.h" #include "sys_xoshiro.h" -UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const std::string &label, const std::string &tip, int red, int green, - int blue, bool suboptions) +UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const std::string &label, + const std::string &tip, int red, int green, int blue, bool suboptions) : Fl_Group(X, Y, W, H), choice_map(), cur_opt_y(0) { box(box_style); @@ -45,7 +45,8 @@ UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const st color(fl_rgb_color(red, green, blue)); } - mod_button = new UI_CustomCheckBox(X + kf_w(6), Y + kf_h(5), W - kf_w(12), kf_h(24)); + mod_button = new UI_CustomCheckBox(X + KromulentWidth(6), Y + KromulentHeight(5), W - KromulentWidth(12), + KromulentHeight(24)); mod_button->box(FL_NO_BOX); if (suboptions) { @@ -63,7 +64,8 @@ UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const st if (!Is_UI()) { - heading = new Fl_Box(FL_NO_BOX, X + kf_w(tx), Y + kf_h(4), W - kf_w(tx + 4), kf_h(24), ""); + heading = new Fl_Box(FL_NO_BOX, X + KromulentWidth(tx), Y + KromulentHeight(4), W - KromulentWidth(tx + 4), + KromulentHeight(24), ""); heading->copy_label(label.c_str()); heading->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); heading->labelfont(font_style | FL_BOLD); @@ -78,7 +80,7 @@ UI_Module::UI_Module(int X, int Y, int W, int H, const std::string &id, const st } } - cur_opt_y += Is_UI() ? kf_h(8) : kf_h(32); + cur_opt_y += Is_UI() ? KromulentHeight(8) : KromulentHeight(32); end(); @@ -100,12 +102,12 @@ void UI_Module::AddHeader(const std::string &opt, const std::string &label, int { int nw = this->parent()->w(); - int nx = x() + kf_w(6); - int ny = y() + cur_opt_y - kf_h(15); + int nx = x() + KromulentWidth(6); + int ny = y() + cur_opt_y - KromulentHeight(15); - UI_RHeader *rhead = new UI_RHeader(nx, ny + kf_h(15), nw * .95, kf_h(24)); + UI_RHeader *rhead = new UI_RHeader(nx, ny + KromulentHeight(15), nw * .95, KromulentHeight(24)); - rhead->mod_label = new Fl_Box(rhead->x(), rhead->y(), rhead->w() * .95, kf_h(24), ""); + rhead->mod_label = new Fl_Box(rhead->x(), rhead->y(), rhead->w() * .95, KromulentHeight(24), ""); rhead->mod_label->copy_label(label.c_str()); rhead->mod_label->align((FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP)); rhead->mod_label->labelfont(font_style + 1); @@ -118,7 +120,7 @@ void UI_Module::AddHeader(const std::string &opt, const std::string &label, int add(rhead); - cur_opt_y += (gap ? kf_h(36) : kf_h(26)); + cur_opt_y += (gap ? KromulentHeight(36) : KromulentHeight(26)); resize(x(), y(), w(), CalcHeight()); redraw(); @@ -130,12 +132,12 @@ void UI_Module::AddUrl(const std::string &opt, const std::string &label, const s { int nw = this->parent()->w(); - int nx = x() + kf_w(6); - int ny = y() + cur_opt_y - kf_h(15); + int nx = x() + KromulentWidth(6); + int ny = y() + cur_opt_y - KromulentHeight(15); - UI_RLink *rurl = new UI_RLink(nx, ny + kf_h(15), nw * .95, kf_h(24)); + UI_RLink *rurl = new UI_RLink(nx, ny + KromulentHeight(15), nw * .95, KromulentHeight(24)); - rurl->mod_link = new UI_ModHyperLink(rurl->x(), rurl->y(), rurl->w() * .95, kf_h(24), "", url.c_str()); + rurl->mod_link = new UI_ModHyperLink(rurl->x(), rurl->y(), rurl->w() * .95, KromulentHeight(24), "", url.c_str()); rurl->mod_link->copy_label(label.c_str()); rurl->mod_link->align((FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP)); rurl->mod_link->labelfont(font_style + 1); @@ -148,7 +150,7 @@ void UI_Module::AddUrl(const std::string &opt, const std::string &label, const s add(rurl); - cur_opt_y += (gap ? kf_h(36) : kf_h(26)); + cur_opt_y += (gap ? KromulentHeight(36) : KromulentHeight(26)); resize(x(), y(), w(), CalcHeight()); redraw(); @@ -156,38 +158,39 @@ void UI_Module::AddUrl(const std::string &opt, const std::string &label, const s choice_map_url[opt] = rurl; } -void UI_Module::AddOption(const std::string &opt, const std::string &label, const std::string &tip, std::string &longtip, int gap, - const std::string &randomize_group, const std::string &default_value) +void UI_Module::AddOption(const std::string &opt, const std::string &label, const std::string &tip, + std::string &longtip, int gap, const std::string &randomize_group, + const std::string &default_value) { int nw = this->parent()->w(); - // int nh = kf_h(30); + // int nh = KromulentHeight(30); - int nx = x() + kf_w(6); - int ny = y() + cur_opt_y - kf_h(15); + int nx = x() + KromulentWidth(6); + int ny = y() + cur_opt_y - KromulentHeight(15); if (longtip.empty()) { longtip = tip; } - UI_RChoice *rch = new UI_RChoice(nx, ny + kf_h(15), nw * .95, kf_h(24)); + UI_RChoice *rch = new UI_RChoice(nx, ny + KromulentHeight(15), nw * .95, KromulentHeight(24)); - rch->mod_label = new Fl_Box(rch->x(), rch->y(), rch->w() * .40, kf_h(24), ""); + rch->mod_label = new Fl_Box(rch->x(), rch->y(), rch->w() * .40, KromulentHeight(24), ""); rch->mod_label->copy_label(StringFormat("%s: ", label.c_str()).c_str()); rch->mod_label->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); rch->mod_label->labelfont(font_style); rch->mod_label->copy_tooltip(tip.c_str()); - rch->mod_menu = new UI_RChoiceMenu(rch->x() + (rch->w() * .40), rch->y(), rch->w() * .50, kf_h(24)); + rch->mod_menu = new UI_RChoiceMenu(rch->x() + (rch->w() * .40), rch->y(), rch->w() * .50, KromulentHeight(24)); rch->mod_menu->textcolor(FONT2_COLOR); rch->mod_menu->selection_color(SELECTION); - rch->mod_reset = new UI_ResetOption(rch->x() + (rch->w() * .90), rch->y(), rch->w() * .075, kf_h(24)); + rch->mod_reset = new UI_ResetOption(rch->x() + (rch->w() * .90), rch->y(), rch->w() * .075, KromulentHeight(24)); rch->mod_reset->box(FL_NO_BOX); rch->mod_reset->labelcolor(FONT_COLOR); rch->mod_reset->visible_focus(0); - rch->mod_help = new UI_HelpLink(rch->x() + (rch->w() * .95), rch->y(), rch->w() * .075, kf_h(24)); + rch->mod_help = new UI_HelpLink(rch->x() + (rch->w() * .95), rch->y(), rch->w() * .075, KromulentHeight(24)); rch->mod_help->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER); rch->mod_help->labelfont(font_style); rch->mod_help->labelcolor(FONT_COLOR); @@ -213,7 +216,7 @@ void UI_Module::AddOption(const std::string &opt, const std::string &label, cons add(rch); - cur_opt_y += (gap ? kf_h(36) : kf_h(26)); + cur_opt_y += (gap ? KromulentHeight(36) : KromulentHeight(26)); resize(x(), y(), w(), CalcHeight()); redraw(); @@ -221,15 +224,16 @@ void UI_Module::AddOption(const std::string &opt, const std::string &label, cons choice_map[opt] = rch; } -void UI_Module::AddSliderOption(const std::string &opt, std::string &label, const std::string &tip, std::string &longtip, int gap, - double min, double max, double inc, const std::string &units, const std::string &presets, - const std::string &nan, const std::string &randomize_group, const std::string &default_value) +void UI_Module::AddSliderOption(const std::string &opt, std::string &label, const std::string &tip, + std::string &longtip, int gap, double min, double max, double inc, + const std::string &units, const std::string &presets, const std::string &nan, + const std::string &randomize_group, const std::string &default_value) { int nw = this->parent()->w(); - // int nh = kf_h(30); + // int nh = KromulentHeight(30); - int nx = x() + kf_w(6); - int ny = y() + cur_opt_y - kf_h(15); + int nx = x() + KromulentWidth(6); + int ny = y() + cur_opt_y - KromulentHeight(15); if (longtip.empty()) { @@ -238,7 +242,7 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons label = StringFormat("%s: ", label.c_str()); - UI_RSlide *rsl = new UI_RSlide(nx, ny + kf_h(15), nw * .95, kf_h(24)); + UI_RSlide *rsl = new UI_RSlide(nx, ny + KromulentHeight(15), nw * .95, KromulentHeight(24)); // Populate the nan_options vector std::string::size_type oldpos = 0; @@ -257,13 +261,14 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons } } - rsl->mod_label = new Fl_Box(rsl->x(), rsl->y(), rsl->w() * .40, kf_h(24), ""); + rsl->mod_label = new Fl_Box(rsl->x(), rsl->y(), rsl->w() * .40, KromulentHeight(24), ""); rsl->mod_label->copy_label(label.c_str()); rsl->mod_label->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); rsl->mod_label->labelfont(font_style); rsl->mod_label->copy_tooltip(tip.c_str()); - rsl->prev_button = new UI_CustomArrowButton(rsl->x() + (rsl->w() * .40), rsl->y(), rsl->w() * .05, kf_h(24)); + rsl->prev_button = + new UI_CustomArrowButton(rsl->x() + (rsl->w() * .40), rsl->y(), rsl->w() * .05, KromulentHeight(24)); rsl->prev_button->copy_label("@<"); rsl->prev_button->visible_focus(0); rsl->prev_button->box(button_style); @@ -274,7 +279,7 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons rsl->prev_button->callback(callback_SliderPrevious, NULL); rsl->mod_slider = new UI_CustomSlider(rsl->x() + (rsl->w() * .45), rsl->y(), - rsl->w() * (rsl->nan_choices.size() > 0 ? .30 : .35), kf_h(24)); + rsl->w() * (rsl->nan_choices.size() > 0 ? .30 : .35), KromulentHeight(24)); rsl->mod_slider->box(button_style); rsl->mod_slider->visible_focus(0); rsl->mod_slider->color(BUTTON_COLOR); @@ -285,13 +290,13 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons rsl->mod_slider->callback(callback_PresetCheck, NULL); rsl->unit_label = new Fl_Box(rsl->x() + (rsl->w() * .45), rsl->y(), - rsl->w() * (rsl->nan_choices.size() > 0 ? .30 : .35), kf_h(24), ""); + rsl->w() * (rsl->nan_choices.size() > 0 ? .30 : .35), KromulentHeight(24), ""); rsl->unit_label->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); rsl->unit_label->labelfont(font_style); rsl->unit_label->labelcolor(FONT2_COLOR); rsl->next_button = new UI_CustomArrowButton(rsl->x() + rsl->w() * (rsl->nan_choices.size() > 0 ? .75 : .80), - rsl->y(), rsl->w() * .05, kf_h(24)); + rsl->y(), rsl->w() * .05, KromulentHeight(24)); rsl->next_button->copy_label("@>"); rsl->next_button->box(button_style); rsl->next_button->color(BUTTON_COLOR); @@ -303,7 +308,8 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons if (rsl->nan_choices.size() > 0) { - rsl->nan_options = new UI_CustomMenuButton(rsl->x() + (rsl->w() * .80), rsl->y(), rsl->w() * .075, kf_h(24)); + rsl->nan_options = + new UI_CustomMenuButton(rsl->x() + (rsl->w() * .80), rsl->y(), rsl->w() * .075, KromulentHeight(24)); rsl->nan_options->box(FL_FLAT_BOX); rsl->nan_options->color(this->color()); rsl->nan_options->selection_color(SELECTION); @@ -315,18 +321,18 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons rsl->nan_options->callback(callback_NanOptions, NULL); } - rsl->mod_entry = new UI_ManualEntry(rsl->x() + (rsl->w() * .85), rsl->y(), rsl->w() * .075, kf_h(24)); + rsl->mod_entry = new UI_ManualEntry(rsl->x() + (rsl->w() * .85), rsl->y(), rsl->w() * .075, KromulentHeight(24)); rsl->mod_entry->box(FL_NO_BOX); rsl->mod_entry->labelcolor(FONT_COLOR); rsl->mod_entry->visible_focus(0); rsl->mod_entry->callback(callback_ManualEntry, NULL); - rsl->mod_reset = new UI_ResetOption(rsl->x() + (rsl->w() * .90), rsl->y(), rsl->w() * .075, kf_h(24)); + rsl->mod_reset = new UI_ResetOption(rsl->x() + (rsl->w() * .90), rsl->y(), rsl->w() * .075, KromulentHeight(24)); rsl->mod_reset->box(FL_NO_BOX); rsl->mod_reset->labelcolor(FONT_COLOR); rsl->mod_reset->visible_focus(0); - rsl->mod_help = new UI_HelpLink(rsl->x() + (rsl->w() * .95), rsl->y(), rsl->w() * .075, kf_h(24)); + rsl->mod_help = new UI_HelpLink(rsl->x() + (rsl->w() * .95), rsl->y(), rsl->w() * .075, KromulentHeight(24)); rsl->mod_help->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER); rsl->mod_help->labelfont(font_style); rsl->mod_help->labelcolor(FONT_COLOR); @@ -400,7 +406,7 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons add(rsl); - cur_opt_y += (gap ? kf_h(36) : kf_h(26)); + cur_opt_y += (gap ? KromulentHeight(36) : KromulentHeight(26)); resize(x(), y(), w(), CalcHeight()); redraw(); @@ -408,37 +414,39 @@ void UI_Module::AddSliderOption(const std::string &opt, std::string &label, cons choice_map_slider[opt] = rsl; } -void UI_Module::AddButtonOption(const std::string &opt, const std::string &label, const std::string &tip, std::string &longtip, int gap, - const std::string &randomize_group, const std::string &default_value) +void UI_Module::AddButtonOption(const std::string &opt, const std::string &label, const std::string &tip, + std::string &longtip, int gap, const std::string &randomize_group, + const std::string &default_value) { int nw = this->parent()->w(); - // int nh = kf_h(30); + // int nh = KromulentHeight(30); - int nx = x() + kf_w(6); - int ny = y() + cur_opt_y - kf_h(15); + int nx = x() + KromulentWidth(6); + int ny = y() + cur_opt_y - KromulentHeight(15); if (longtip.empty()) { longtip = tip; } - UI_RButton *rbt = new UI_RButton(nx, ny + kf_h(15), nw * .95, kf_h(24)); + UI_RButton *rbt = new UI_RButton(nx, ny + KromulentHeight(15), nw * .95, KromulentHeight(24)); - rbt->mod_label = new Fl_Box(rbt->x(), rbt->y(), rbt->w() * .40, kf_h(24), ""); + rbt->mod_label = new Fl_Box(rbt->x(), rbt->y(), rbt->w() * .40, KromulentHeight(24), ""); rbt->mod_label->copy_label(StringFormat("%s: ", label.c_str()).c_str()); rbt->mod_label->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); rbt->mod_label->labelfont(font_style); rbt->mod_label->copy_tooltip(tip.c_str()); - rbt->mod_check = new UI_CustomCheckBox(rbt->x() + (rbt->w() * .40), rbt->y(), rbt->w() * .10, kf_h(24), ""); + rbt->mod_check = + new UI_CustomCheckBox(rbt->x() + (rbt->w() * .40), rbt->y(), rbt->w() * .10, KromulentHeight(24), ""); rbt->mod_check->selection_color(SELECTION); - rbt->mod_reset = new UI_ResetOption(rbt->x() + (rbt->w() * .90), rbt->y(), rbt->w() * .075, kf_h(24)); + rbt->mod_reset = new UI_ResetOption(rbt->x() + (rbt->w() * .90), rbt->y(), rbt->w() * .075, KromulentHeight(24)); rbt->mod_reset->box(FL_NO_BOX); rbt->mod_reset->labelcolor(FONT_COLOR); rbt->mod_reset->visible_focus(0); - rbt->mod_help = new UI_HelpLink(rbt->x() + (rbt->w() * .95), rbt->y(), rbt->w() * .075, kf_h(24)); + rbt->mod_help = new UI_HelpLink(rbt->x() + (rbt->w() * .95), rbt->y(), rbt->w() * .075, KromulentHeight(24)); rbt->mod_help->align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER); rbt->mod_help->labelfont(font_style); rbt->mod_help->labelcolor(FONT_COLOR); @@ -463,7 +471,7 @@ void UI_Module::AddButtonOption(const std::string &opt, const std::string &label add(rbt); - cur_opt_y += (gap ? kf_h(36) : kf_h(26)); + cur_opt_y += (gap ? KromulentHeight(36) : KromulentHeight(26)); resize(x(), y(), w(), CalcHeight()); redraw(); @@ -475,11 +483,11 @@ int UI_Module::CalcHeight() const { if (mod_button->value()) { - return cur_opt_y + kf_h(6); + return cur_opt_y + KromulentHeight(6); } else { - return kf_h(34); + return KromulentHeight(34); } } @@ -594,8 +602,8 @@ void UI_Module::randomize_Values(std::vector selected_randomize_gro M->nan_options->value(0); M->nan_options->do_callback(); } - M->mod_slider->value(M->mod_slider->round( - xoshiro_Between(M->mod_slider->minimum(), M->mod_slider->maximum()))); + M->mod_slider->value( + M->mod_slider->round(xoshiro_Between(M->mod_slider->minimum(), M->mod_slider->maximum()))); M->mod_slider->do_callback(); break; } @@ -1118,10 +1126,10 @@ typedef struct UI_CustomMods *parent; } mod_enable_callback_data_t; -void UI_CustomMods::AddModule(const std::string &id, const std::string &label, const std::string &tip, int red, int green, int blue, - bool suboptions) +void UI_CustomMods::AddModule(const std::string &id, const std::string &label, const std::string &tip, int red, + int green, int blue, bool suboptions) { - UI_Module *M = new UI_Module(mx, my, mw - 4, kf_h(34), id, label, tip, red, green, blue, suboptions); + UI_Module *M = new UI_Module(mx, my, mw - 4, KromulentHeight(34), id, label, tip, red, green, blue, suboptions); mod_enable_callback_data_t *cb_data = new mod_enable_callback_data_t; cb_data->mod = M; @@ -1153,7 +1161,8 @@ bool UI_CustomMods::AddHeader(const std::string &module, const std::string &opti return true; } -bool UI_CustomMods::AddUrl(const std::string &module, const std::string &option, const std::string &label, const std::string &url, int gap) +bool UI_CustomMods::AddUrl(const std::string &module, const std::string &option, const std::string &label, + const std::string &url, int gap) { UI_Module *M = FindID(module); @@ -1169,8 +1178,9 @@ bool UI_CustomMods::AddUrl(const std::string &module, const std::string &option, return true; } -bool UI_CustomMods::AddOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, - std::string &longtip, int gap, const std::string &randomize_group, const std::string &default_value) +bool UI_CustomMods::AddOption(const std::string &module, const std::string &option, const std::string &label, + const std::string &tip, std::string &longtip, int gap, const std::string &randomize_group, + const std::string &default_value) { UI_Module *M = FindID(module); @@ -1186,9 +1196,10 @@ bool UI_CustomMods::AddOption(const std::string &module, const std::string &opti return true; } -bool UI_CustomMods::AddSliderOption(const std::string &module, const std::string &option, std::string &label, const std::string &tip, - std::string &longtip, int gap, double min, double max, double inc, const std::string &units, - const std::string &presets, const std::string &nan, const std::string &randomize_group, +bool UI_CustomMods::AddSliderOption(const std::string &module, const std::string &option, std::string &label, + const std::string &tip, std::string &longtip, int gap, double min, double max, + double inc, const std::string &units, const std::string &presets, + const std::string &nan, const std::string &randomize_group, const std::string &default_value) { UI_Module *M = FindID(module); @@ -1206,9 +1217,9 @@ bool UI_CustomMods::AddSliderOption(const std::string &module, const std::string return true; } -bool UI_CustomMods::AddButtonOption(const std::string &module, const std::string &option, const std::string &label, const std::string &tip, - std::string &longtip, int gap, const std::string &randomize_group, - const std::string &default_value) +bool UI_CustomMods::AddButtonOption(const std::string &module, const std::string &option, const std::string &label, + const std::string &tip, std::string &longtip, int gap, + const std::string &randomize_group, const std::string &default_value) { UI_Module *M = FindID(module); @@ -1224,7 +1235,8 @@ bool UI_CustomMods::AddButtonOption(const std::string &module, const std::string return true; } -bool UI_CustomMods::AddOptionChoice(const std::string &module, const std::string &option, const std::string &id, const std::string &label) +bool UI_CustomMods::AddOptionChoice(const std::string &module, const std::string &option, const std::string &id, + const std::string &label) { UI_Module *M = FindID(module); @@ -1849,25 +1861,25 @@ UI_CustomTabs::UI_CustomTabs(int X, int Y, int W, int H) : Fl_Tabs(X, Y, W, H) visible_focus(0); - arch_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Architecture")); + arch_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Architecture")); arch_mods->color(BUTTON_COLOR, BUTTON_COLOR); arch_mods->end(); - combat_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Combat")); + combat_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Combat")); combat_mods->color(BUTTON_COLOR, BUTTON_COLOR); combat_mods->end(); - pickup_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Pickups")); + pickup_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Pickups")); pickup_mods->color(BUTTON_COLOR, BUTTON_COLOR); pickup_mods->end(); - other_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Other")); + other_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Other")); other_mods->color(BUTTON_COLOR, BUTTON_COLOR); other_mods->end(); - debug_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Debug")); + debug_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Debug")); debug_mods->color(BUTTON_COLOR, BUTTON_COLOR); debug_mods->end(); - experimental_mods = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Experimental")); + experimental_mods = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Experimental")); experimental_mods->color(BUTTON_COLOR, BUTTON_COLOR); experimental_mods->end(); - links = new UI_CustomMods(X, Y + kf_h(22), W, H - kf_h(22), _("Links")); + links = new UI_CustomMods(X, Y + KromulentHeight(22), W, H - KromulentHeight(22), _("Links")); links->color(BUTTON_COLOR, BUTTON_COLOR); links->end(); diff --git a/source/ui_window.cc b/source/ui_window.cc index ce1ed863e..2d7cd4736 100644 --- a/source/ui_window.cc +++ b/source/ui_window.cc @@ -29,8 +29,8 @@ #error "Require FLTK version 1.3.0 or later" #endif -#define BASE_WINDOW_W 816 -#define BASE_WINDOW_H 512 +static constexpr uint16_t BASE_WINDOW_W = 816; +static constexpr uint16_t BASE_WINDOW_H = 512; UI_MainWin *main_win; @@ -78,13 +78,13 @@ UI_MainWin::UI_MainWin(int W, int H, const char *title) : Fl_Double_Window(W, H, color(GAP_COLOR, SELECTION); - int LEFT_W = kf_w(232); - int MOD_W = (W - LEFT_W) / 2 - kf_h(4); + int LEFT_W = KromulentWidth(232); + int MOD_W = (W - LEFT_W) / 2 - KromulentHeight(4); - int TOP_H = kf_h(240); - int BOT_H = H - TOP_H - kf_h(4); + int TOP_H = KromulentHeight(240); + int BOT_H = H - TOP_H - KromulentHeight(4); - menu_bar = new Fl_Menu_Bar(0, 0, W, kf_h(20)); + menu_bar = new Fl_Menu_Bar(0, 0, W, KromulentHeight(20)); menu_bar->box(box_style); menu_bar->textfont(font_style); menu_bar->textsize(font_scaling * .90); @@ -101,14 +101,14 @@ UI_MainWin::UI_MainWin(int W, int H, const char *title) : Fl_Double_Window(W, H, menu_bar->selection_color(SELECTION); menu_bar->align(FL_ALIGN_INSIDE | FL_ALIGN_CLIP | FL_ALIGN_LEFT); - sizing_group = new Fl_Group(0, kf_h(22), W, H - kf_h(20)); + sizing_group = new Fl_Group(0, KromulentHeight(22), W, H - KromulentHeight(20)); sizing_group->box(FL_NO_BOX); - game_box = new UI_Game(0, kf_h(22), LEFT_W, TOP_H - kf_h(22)); + game_box = new UI_Game(0, KromulentHeight(22), LEFT_W, TOP_H - KromulentHeight(22)); - build_box = new UI_Build(0, TOP_H + kf_h(4), LEFT_W, BOT_H); + build_box = new UI_Build(0, TOP_H + KromulentHeight(4), LEFT_W, BOT_H); - mod_tabs = new UI_CustomTabs(LEFT_W + kf_h(4), kf_h(22), MOD_W * 2, H - kf_h(22)); + mod_tabs = new UI_CustomTabs(LEFT_W + KromulentHeight(4), KromulentHeight(22), MOD_W * 2, H - KromulentHeight(22)); clippy = new UI_Clippy(); @@ -130,8 +130,8 @@ UI_MainWin::~UI_MainWin() void UI_MainWin::CalcWindowSize(int *W, int *H) { - *W = kf_w(BASE_WINDOW_W); - *H = kf_h(BASE_WINDOW_H); + *W = KromulentWidth(BASE_WINDOW_W); + *H = KromulentHeight(BASE_WINDOW_H); // tweak for "Tiny" setting if (KF < 0) diff --git a/source/ui_window.h b/source/ui_window.h index 694753526..ba37f498a 100644 --- a/source/ui_window.h +++ b/source/ui_window.h @@ -31,8 +31,15 @@ // support for scaling up the GUI extern int KF; // Kromulent Factor : -1 .. 3 -#define kf_w(w) ((w) + KF * (w) / (KF >= 0 ? 4 : 8)) -#define kf_h(h) ((h) + KF * (h) / (KF >= 0 ? 5 : 10)) +inline int KromulentWidth(int w) +{ + return ((w) + KF * (w) / (KF >= 0 ? 4 : 8)); +} + +inline int KromulentHeight(int h) +{ + return ((h) + KF * (h) / (KF >= 0 ? 5 : 10)); +} extern int small_font_size; extern int header_font_size;