Skip to content

Commit

Permalink
Mc170-3
Browse files Browse the repository at this point in the history
- SakuraScriptのタグ認識処理を厳密化
  • Loading branch information
ponapalt committed Oct 19, 2024
1 parent 41df02d commit fc8658c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
4 changes: 2 additions & 2 deletions satoriya/satori/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,170,2,1
FILEVERSION 1,170,3,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -47,7 +47,7 @@ BEGIN
VALUE "Comments", " \0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "satori\0"
VALUE "FileVersion", "1, 170, 2, 1\0"
VALUE "FileVersion", "1, 170, 3, 1\0"
VALUE "InternalName", "satori\0"
VALUE "LegalCopyright", " \0"
VALUE "LegalTrademarks", "\0"
Expand Down
2 changes: 1 addition & 1 deletion satoriya/satori/satori.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const char* gSatoriName = "Satori";
const char* gSatoriNameW = "里々";
const char* gSatoriCraftman = "Yagi Kushigahama/The Maintenance Shop";
const char* gSatoriCraftmanW = "櫛ヶ浜やぎ/整備班";
const char* gSatoriVersion = "phase Mc170-2";
const char* gSatoriVersion = "phase Mc170-3";
const char* gShioriVersion = "3.0";
const char* gSaoriVersion = "1.0";

Expand Down
58 changes: 54 additions & 4 deletions satoriya/satori/satori_sentence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,20 +479,23 @@ int Satori::SentenceToSakuraScriptInternal(const strvec &vec,string &result,stri
character_wait_clear(2);
result += (speaker ? "\\1" : "\\0");
}
else if ( c=="\\" || c=="%" ) { // さくらスクリプトの解釈、というか解釈のスキップ。
else if ( c=="\\" ) { // さくらスクリプトの解釈、というか解釈のスキップ。

if (*p=='\\'||*p=='%') { // エスケープされた\, %
if ( *p=='\\' ) { // エスケープ
result += c + *p++;
continue;
}

const char* start=p;
string cmd="",opt="";

while (!_ismbblead(*p) && (isalpha(*p)||isdigit(*p)||*p=='!'||*p=='-'||*p=='*'||*p=='&'||*p=='?'||*p=='_'||*p=='+'))
//複数個のアンダースコアと、1個の文字
while (!_ismbblead(*p) && *p=='_')
++p;
if (!_ismbblead(*p) && (isalpha(*p)||isdigit(*p)||*p=='!'||*p=='-'||*p=='*'||*p=='&'||*p=='?'||*p=='+'))
++p;
cmd.assign(start, p-start);

if ( cmd == "_?" || cmd == "_!" ) { //エスケープ処理 この間に自動タグ挿入はしない
const char* e1 = strstr(p,"\\_?");
if ( ! e1 ) { e1 = strstr(p,"\\_!"); }
Expand Down Expand Up @@ -578,6 +581,53 @@ int Satori::SentenceToSakuraScriptInternal(const strvec &vec,string &result,stri
}


//result += string(start, p-start);
}
else if ( c=="%" ) { // さくらスクリプトの解釈、というか解釈のスキップ。

if ( *p=='%' || *p=='*' ) { // エスケープされた%か、%*
result += c + *p++;
continue;
}

string cmd="";

static const char* tag_pattern[] = {
"month","day","hour","minute","second","username","selfname","selfname2","keroname","screenwidth","screenheight",
"exh","et","wronghour","ms","mz","mc","mh","mt","me","mp","m?","dms","lastghostname","lastobjectname","property"
};
static unsigned int tag_pattern_count = sizeof(tag_pattern)/sizeof(tag_pattern[0]);

for ( unsigned int tg = 0 ; tg < tag_pattern_count ; ++tg ) {
int len = strlen(tag_pattern[tg]);

if ( strncmp(p,tag_pattern[tg],len) == 0 ) {
cmd = tag_pattern[tg];
p += len;
}
}

string opt="";

if ( (cmd=="property") && (*p=='[') ) {
const char* opt_start = ++p;
while (*p!=']') {
if (p[0]=='\\' && p[1]==']') // エスケープされた]
++p;
p += _ismbblead(*p) ? 2 : 1;
}
opt.assign(opt_start, p++ -opt_start);
opt=UnKakko(opt.c_str());
}

if ( opt!="" ) {
//GetSender().sender() << "ss_cmd: " << c << "," << cmd << "," << opt << std::endl;
result += c + cmd + "[" + opt + "]";
} else {
//GetSender().sender() << "ss_cmd: " << c << "," << cmd << std::endl;
result += c + cmd;
}

//result += string(start, p-start);
}
else { // 通常の一文字
Expand Down

0 comments on commit fc8658c

Please sign in to comment.