Mercurial > otakunoraifu
diff system/system_config.cc @ 53:ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
* ParseMoji moved to TextStream
* Some cleaning (0 -> NULL when needed, removal of useless returns, ...)
author | thib |
---|---|
date | Sun, 19 Apr 2009 11:44:05 +0000 |
parents | 15a18fbe6f21 |
children | d7cde171a1de |
line wrap: on
line diff
--- a/system/system_config.cc +++ b/system/system_config.cc @@ -70,6 +70,7 @@ public: else return a.hash < b.hash; } }; + HashStr::HashStr(const char* s ) { if (s == NULL || s[0] == '\0') { str = NULL; @@ -676,6 +677,25 @@ void AyuSysConfig::Dump(FILE* f) const { ** AyuSysConfig のコンストラクタ: ** 全ての config 項目を初期化する */ + +AyuSysConfig * AyuSysConfig::_singleton = NULL; + +AyuSysConfig* AyuSysConfig::GetInstance(void) +{ + if (_singleton == NULL) + _singleton = new AyuSysConfig; + return _singleton; +} + +void AyuSysConfig::Quit(void) +{ + if (_singleton != NULL) { + delete _singleton; + _singleton = NULL; + } +} + + AyuSysConfig::AyuSysConfig(void) { int i; @@ -889,11 +909,13 @@ static inline int SplitVar(const char* s bool AyuSysConfig::LoadInitFile(void) { + FileSearcher* file_searcher = FileSearcher::GetInstance(); + char buf[1024]; int i; char* tokens[MAXTOKEN]; int token_deal; int buf_ptr; int numbers[MAXVARS]; - ARCINFO* info = file_searcher.Find(FILESEARCH::ROOT, "gameexe.ini"); + ARCINFO* info = file_searcher->Find(FileSearcher::ROOT, "gameexe.ini"); if (info == NULL) return false; int size = info->Size(); unsigned char* buf_orig = (unsigned char*)info->Read(); @@ -1000,24 +1022,24 @@ bool AyuSysConfig::LoadInitFile(void) } else if (strncmp(tokens[0],"#DIRC.",6) == 0) { if (token_deal != 3) goto parse_error; /* ファイル形式の指定 */ - FILESEARCH::FILETYPE type; + FileSearcher::FILETYPE type; char* name = tokens[0]+6; - if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; - else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; - else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; - else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; - else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; - else if (strcmp(name, "KOE") == 0) type = FILESEARCH::KOE; - else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; + if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN; + else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM; + else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD; + else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR; + else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV; + else if (strcmp(name, "KOE") == 0) type = FileSearcher::KOE; + else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN; else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */ if (tokens[2][0] == 'N') { /* directory */ - file_searcher.SetFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); + file_searcher->SetFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]); dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* アーカイブ */ - file_searcher.SetFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); + file_searcher->SetFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2); dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); } else goto parse_error; goto parse_end; @@ -1025,27 +1047,27 @@ bool AyuSysConfig::LoadInitFile(void) if (strncmp(tokens[0],"#ADRC.",6) == 0) { if (token_deal != 3) goto parse_error; /* ファイル形式の指定 */ - FILESEARCH::FILETYPE type; + FileSearcher::FILETYPE type; char* name = tokens[0]+6; - if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; - else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; - else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; - else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; - else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; - else if (strcmp(name, "KOE") == 0) type = FILESEARCH::KOE; - else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; + if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN; + else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM; + else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD; + else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR; + else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV; + else if (strcmp(name, "KOE") == 0) type = FileSearcher::KOE; + else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN; else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */ if (tokens[2][0] == 'N') { /* directory */ - file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); + file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]); dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* アーカイブ */ - file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); + file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2); dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); } else if (tokens[2][0] == 'R' && tokens[2][1] == ':') { /* それ散るアーカイブ */ - file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); + file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2); dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); } else goto parse_error; goto parse_end; @@ -1053,24 +1075,24 @@ bool AyuSysConfig::LoadInitFile(void) if (strncmp(tokens[0],"#FOLDNAME.",10) == 0) { if (token_deal != 3) goto parse_error; /* ファイル形式の指定 */ - FILESEARCH::FILETYPE type; + FileSearcher::FILETYPE type; char* name = tokens[0]+10; - if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; - else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; - else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; - else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; - else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; - else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; - else if (strcmp(name, "BGM") == 0) type = FILESEARCH::BGM; - else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; + if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT; + else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN; + else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM; + else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD; + else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR; + else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV; + else if (strcmp(name, "BGM") == 0) type = FileSearcher::BGM; + else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN; else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */ if (tokens[2][0] == '0') { /* directory */ - file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); + file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]); dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); } else if (tokens[2][0] == '1' && tokens[2][1] == ':') { /* アーカイブ */ - file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_SCN2k, tokens[2]+2); + file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_SCN2k, tokens[2]+2); dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); } else goto parse_error; goto parse_end;