diff options
author | Aki <please@ignore.pl> | 2024-03-19 22:56:52 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-03-19 22:56:52 +0100 |
commit | f5b8091ee91b8323b8e2b1044ba8be676f2bfaf4 (patch) | |
tree | bbcfc73dd8db75579127686f9cd07e9c45d374d0 /StarsEx | |
parent | 2066e4911948d11cac5a234d2f7773dc5f06ba96 (diff) | |
download | starshatter-f5b8091ee91b8323b8e2b1044ba8be676f2bfaf4.zip starshatter-f5b8091ee91b8323b8e2b1044ba8be676f2bfaf4.tar.gz starshatter-f5b8091ee91b8323b8e2b1044ba8be676f2bfaf4.tar.bz2 |
Definition Parser now consumes from the new Reader
Next steps are to move ParseUtils functionality to DefinitinoEx, sort
things into the namespaces in this library, and then prepare it to
handle overloading like nlohmann_json does. On the other side, it's
time for starshatter::data.
Diffstat (limited to 'StarsEx')
-rw-r--r-- | StarsEx/AudioConfig.cpp | 5 | ||||
-rw-r--r-- | StarsEx/Campaign.cpp | 8 | ||||
-rw-r--r-- | StarsEx/CampaignSaveGame.cpp | 2 | ||||
-rw-r--r-- | StarsEx/CombatGroup.cpp | 4 | ||||
-rw-r--r-- | StarsEx/CombatZone.cpp | 2 | ||||
-rw-r--r-- | StarsEx/Explosion.cpp | 2 | ||||
-rw-r--r-- | StarsEx/Font.cpp | 2 | ||||
-rw-r--r-- | StarsEx/FormDef.cpp | 2 | ||||
-rw-r--r-- | StarsEx/Galaxy.cpp | 2 | ||||
-rw-r--r-- | StarsEx/Mission.cpp | 2 | ||||
-rw-r--r-- | StarsEx/MissionTemplate.cpp | 2 | ||||
-rw-r--r-- | StarsEx/ModConfig.cpp | 2 | ||||
-rw-r--r-- | StarsEx/ModInfo.cpp | 2 | ||||
-rw-r--r-- | StarsEx/MsnEventDlg.cpp | 4 | ||||
-rw-r--r-- | StarsEx/NetClientConfig.cpp | 2 | ||||
-rw-r--r-- | StarsEx/NetLobby.cpp | 3 | ||||
-rw-r--r-- | StarsEx/NetServerConfig.cpp | 4 | ||||
-rw-r--r-- | StarsEx/ParseUtil.h | 11 | ||||
-rw-r--r-- | StarsEx/Player.cpp | 4 | ||||
-rw-r--r-- | StarsEx/Ship.cpp | 1 | ||||
-rw-r--r-- | StarsEx/ShipDesign.cpp | 8 | ||||
-rw-r--r-- | StarsEx/StarSystem.cpp | 2 | ||||
-rw-r--r-- | StarsEx/Starshatter.cpp | 2 | ||||
-rw-r--r-- | StarsEx/SystemDesign.cpp | 2 | ||||
-rw-r--r-- | StarsEx/WeaponDesign.cpp | 2 |
25 files changed, 41 insertions, 41 deletions
diff --git a/StarsEx/AudioConfig.cpp b/StarsEx/AudioConfig.cpp index c8939a1..6f8ceb8 100644 --- a/StarsEx/AudioConfig.cpp +++ b/StarsEx/AudioConfig.cpp @@ -14,6 +14,7 @@ #include "AudioConfig.h" #include <algorithm> +#include <cstddef> #include "DataLoader.h" #include "ParseUtil.h" @@ -243,7 +244,7 @@ AudioConfig::Load() // read the config file: BYTE* block = 0; - int blocklen = 0; + std::size_t blocklen = 0; const char* filename = "audio.cfg"; FILE* f; @@ -264,7 +265,7 @@ AudioConfig::Load() if (blocklen == 0) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/Campaign.cpp b/StarsEx/Campaign.cpp index 63c9e3b..70846f0 100644 --- a/StarsEx/Campaign.cpp +++ b/StarsEx/Campaign.cpp @@ -432,7 +432,7 @@ Campaign::LoadCampaign(DataLoader* loader, bool full) loader->UseFileSystem(true); loader->LoadBuffer(filename, block, true); loader->UseFileSystem(Starshatter::UseFileSystem()); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); @@ -970,7 +970,7 @@ Campaign::LoadMissionList(DataLoader* loader) loader->UseFileSystem(true); loader->LoadBuffer(filename, block, true); loader->UseFileSystem(Starshatter::UseFileSystem()); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); @@ -1112,7 +1112,7 @@ Campaign::LoadCustomMissions(DataLoader* loader) int type = 0; int msn_id = 0; - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); if (!term) { @@ -1225,7 +1225,7 @@ Campaign::LoadTemplateList(DataLoader* loader) loader->UseFileSystem(true); loader->LoadBuffer(filename, block, true); loader->UseFileSystem(Starshatter::UseFileSystem()); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/CampaignSaveGame.cpp b/StarsEx/CampaignSaveGame.cpp index cc64dbf..b959f01 100644 --- a/StarsEx/CampaignSaveGame.cpp +++ b/StarsEx/CampaignSaveGame.cpp @@ -167,7 +167,7 @@ CampaignSaveGame::Load(const char* filename) Sleep(10); - Parser parser(new BlockReader((const char*) block)); + Parser parser(reinterpret_cast<const char*>(block)); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/CombatGroup.cpp b/StarsEx/CombatGroup.cpp index 57afd7b..6963a36 100644 --- a/StarsEx/CombatGroup.cpp +++ b/StarsEx/CombatGroup.cpp @@ -969,7 +969,7 @@ CombatGroup::LoadOrderOfBattle(const char* filename, int team, Combatant* combat BYTE* block; loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); if (!term) { @@ -1213,7 +1213,7 @@ CombatGroup::MergeOrderOfBattle(BYTE* block, const char* filename, int team, Com { CombatGroup* force = 0; - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/CombatZone.cpp b/StarsEx/CombatZone.cpp index cd2ad1b..4b0655c 100644 --- a/StarsEx/CombatZone.cpp +++ b/StarsEx/CombatZone.cpp @@ -145,7 +145,7 @@ CombatZone::Load(const char* filename) BYTE* block = 0; loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/Explosion.cpp b/StarsEx/Explosion.cpp index 1f613e7..925343d 100644 --- a/StarsEx/Explosion.cpp +++ b/StarsEx/Explosion.cpp @@ -203,7 +203,7 @@ Explosion::Initialize() loader->SetDataPath("Explosions/"); int blocklen = loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/Font.cpp b/StarsEx/Font.cpp index 9dca717..92e4723 100644 --- a/StarsEx/Font.cpp +++ b/StarsEx/Font.cpp @@ -159,7 +159,7 @@ Font::LoadDef(char* defname, char* imgname) if (!block || blocklen < 4) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/FormDef.cpp b/StarsEx/FormDef.cpp index 7a521ff..53f8218 100644 --- a/StarsEx/FormDef.cpp +++ b/StarsEx/FormDef.cpp @@ -580,7 +580,7 @@ FormDef::Load(const char* fname) if (!block || blocklen < 4) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/Galaxy.cpp b/StarsEx/Galaxy.cpp index 3d4e02d..5759738 100644 --- a/StarsEx/Galaxy.cpp +++ b/StarsEx/Galaxy.cpp @@ -98,7 +98,7 @@ Galaxy::Load(const char* filename) DataLoader* loader = DataLoader::GetLoader(); loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/Mission.cpp b/StarsEx/Mission.cpp index cb3ef86..2350a8d 100644 --- a/StarsEx/Mission.cpp +++ b/StarsEx/Mission.cpp @@ -267,7 +267,7 @@ Mission::Load(const char* fname, const char* pname) bool Mission::ParseMission(const char* block) { - Parser parser(new BlockReader(block)); + Parser parser(starshatter::foundation::Reader{block}); Term* term = parser.ParseTerm(); char err[256]; diff --git a/StarsEx/MissionTemplate.cpp b/StarsEx/MissionTemplate.cpp index 55bec50..3e527a4 100644 --- a/StarsEx/MissionTemplate.cpp +++ b/StarsEx/MissionTemplate.cpp @@ -303,7 +303,7 @@ MissionTemplate::Load(const char* fname, const char* pname) loader->SetDataPath(0); loader->UseFileSystem(old_fs); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/ModConfig.cpp b/StarsEx/ModConfig.cpp index ad7e852..674e0b1 100644 --- a/StarsEx/ModConfig.cpp +++ b/StarsEx/ModConfig.cpp @@ -102,7 +102,7 @@ ModConfig::Load() if (blocklen == 0) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/ModInfo.cpp b/StarsEx/ModInfo.cpp index 7f025b7..f48b46d 100644 --- a/StarsEx/ModInfo.cpp +++ b/StarsEx/ModInfo.cpp @@ -106,7 +106,7 @@ bool ModInfo::ParseModInfo(const char* block) { bool ok = false; - Parser parser(new BlockReader(block)); + Parser parser(starshatter::foundation::Reader{block}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/MsnEventDlg.cpp b/StarsEx/MsnEventDlg.cpp index 268c70c..5940d2c 100644 --- a/StarsEx/MsnEventDlg.cpp +++ b/StarsEx/MsnEventDlg.cpp @@ -309,7 +309,7 @@ MsnEventDlg::OnAccept(AWEvent* e) event->event_nparams = 1; } else if (*buf == '(') { - Parser parser(new BlockReader(buf)); + Parser parser(starshatter::foundation::Reader{buf}); Term* term = parser.ParseTerm(); if (term && term->isArray()) { @@ -360,7 +360,7 @@ MsnEventDlg::OnAccept(AWEvent* e) } else if (*buf == '(') { - Parser parser(new BlockReader(buf)); + Parser parser(starshatter::foundation::Reader{buf}); Term* term = parser.ParseTerm(); if (term && term->isArray()) { diff --git a/StarsEx/NetClientConfig.cpp b/StarsEx/NetClientConfig.cpp index 97cd11c..c90eff9 100644 --- a/StarsEx/NetClientConfig.cpp +++ b/StarsEx/NetClientConfig.cpp @@ -164,7 +164,7 @@ NetClientConfig::Load() servers.destroy(); - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/NetLobby.cpp b/StarsEx/NetLobby.cpp index 8222c75..10047d1 100644 --- a/StarsEx/NetLobby.cpp +++ b/StarsEx/NetLobby.cpp @@ -360,8 +360,7 @@ NetLobby::ParseMsg(Text msg, List<NetLobbyParam>& params) { params.destroy(); - BlockReader reader(msg.data(), msg.length()); - Scanner lexer(&reader); + Scanner lexer(starshatter::foundation::Reader{msg.data(), msg.length()}); Token name = lexer.Get(); diff --git a/StarsEx/NetServerConfig.cpp b/StarsEx/NetServerConfig.cpp index 831c4da..47197f6 100644 --- a/StarsEx/NetServerConfig.cpp +++ b/StarsEx/NetServerConfig.cpp @@ -109,7 +109,7 @@ NetServerConfig::Load() return; } - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { @@ -359,7 +359,7 @@ NetServerConfig::LoadBanList() return; } - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/ParseUtil.h b/StarsEx/ParseUtil.h index 947b4c7..554393c 100644 --- a/StarsEx/ParseUtil.h +++ b/StarsEx/ParseUtil.h @@ -15,15 +15,16 @@ #define ParseUtil_h #include <vector> + +#include <Parser_ss.h> +#include <starshatter/foundation/reader.h> +#include <Text.h> +#include <Token.h> + #include "Types.h" #include "Geometry.h" #include "Color.h" -#include "Text.h" -#include "Parser_ss.h" -#include "Reader.h" -#include "Token.h" - // +--------------------------------------------------------------------+ bool GetDefBool(bool& dst, TermDef* def, const char* file); diff --git a/StarsEx/Player.cpp b/StarsEx/Player.cpp index a5e31b0..4be2cff 100644 --- a/StarsEx/Player.cpp +++ b/StarsEx/Player.cpp @@ -962,7 +962,7 @@ Player::Load() if (blocklen == 0) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { @@ -1340,7 +1340,7 @@ Player::LoadAwardTables() loader->SetDataPath("Awards/"); loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/Ship.cpp b/StarsEx/Ship.cpp index aebb1f0..251f92a 100644 --- a/StarsEx/Ship.cpp +++ b/StarsEx/Ship.cpp @@ -85,7 +85,6 @@ #include "Panic.h" #include "Parser_ss.h" -#include "Reader.h" // +----------------------------------------------------------------------+ diff --git a/StarsEx/ShipDesign.cpp b/StarsEx/ShipDesign.cpp index 9b4be4c..3fb11f3 100644 --- a/StarsEx/ShipDesign.cpp +++ b/StarsEx/ShipDesign.cpp @@ -264,7 +264,7 @@ bolt_hit_sound_resource(0), beam_hit_sound_resource(0), lod_levels(0) return; } - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { @@ -527,7 +527,7 @@ void AddModCatalogEntry(const char* design_name, const char* design_path) return; } - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { @@ -665,7 +665,7 @@ ShipDesign::LoadCatalog(const char* path, const char* fname, bool mod) BYTE* block; int blocklen = loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { @@ -771,7 +771,7 @@ ShipDesign::LoadSkins(const char* path, int source) continue; } - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); ShipDesign* design = 0; diff --git a/StarsEx/StarSystem.cpp b/StarsEx/StarSystem.cpp index b6037b5..b8340f6 100644 --- a/StarsEx/StarSystem.cpp +++ b/StarsEx/StarSystem.cpp @@ -137,7 +137,7 @@ StarSystem::Load() return; } - Parser parser(new BlockReader((const char*) block)); + Parser parser(starshatter::foundation::Reader{reinterpret_cast<const char*>(block)}); Term* term = parser.ParseTerm(); diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp index 3decdae..adb519a 100644 --- a/StarsEx/Starshatter.cpp +++ b/StarsEx/Starshatter.cpp @@ -2292,7 +2292,7 @@ Starshatter::LoadVideoConfig(const char* filename) if (blocklen == 0) return; - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/SystemDesign.cpp b/StarsEx/SystemDesign.cpp index 4c64f57..a0f877d 100644 --- a/StarsEx/SystemDesign.cpp +++ b/StarsEx/SystemDesign.cpp @@ -48,7 +48,7 @@ SystemDesign::Initialize(const char* filename) BYTE* block; int blocklen = loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { diff --git a/StarsEx/WeaponDesign.cpp b/StarsEx/WeaponDesign.cpp index 3dd826d..ff26ec1 100644 --- a/StarsEx/WeaponDesign.cpp +++ b/StarsEx/WeaponDesign.cpp @@ -186,7 +186,7 @@ WeaponDesign::LoadDesign(const char* path, const char* filename, bool mod) BYTE* block; int blocklen = loader->LoadBuffer(filename, block, true); - Parser parser(new BlockReader((const char*) block, blocklen)); + Parser parser({reinterpret_cast<const char*>(block), blocklen}); Term* term = parser.ParseTerm(); if (!term) { |