Skip to content

Commit

Permalink
Mc171-1 NOTIFY otherghostnameの受信コードと起動中ゴースト「」の存在
Browse files Browse the repository at this point in the history
  • Loading branch information
ponapalt committed Dec 31, 2024
1 parent 16a0197 commit 769dd18
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 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,7,1
FILEVERSION 1,171,1,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, 7, 1\0"
VALUE "FileVersion", "1, 171, 1, 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-7";
const char* gSatoriVersion = "phase Mc171-1";
const char* gShioriVersion = "3.0";
const char* gSaoriVersion = "1.0";

Expand Down
1 change: 1 addition & 0 deletions satoriya/satori/satori.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class Satori : public Evalcator, public SakuraDLLHost
bool updateGhostsInfo(); // FMOから情報取得
#endif
std::vector<strmap> ghosts_info; // FMOの内容そのまま。0は自分自身、1~は順番どおり。
std::set<string> otherghostname; // NOTIFY otherghostnameから拾ったsakura名
strmap* find_ghost_info(string name); // ghosts_infoを検索、特定のゴーストの情報を得る

string mCommunicateFor; // 話しかけ対象ゴースト。→で設定されresponseにToをつける
Expand Down
20 changes: 20 additions & 0 deletions satoriya/satori/satori_CreateResponce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
////////////////////////////////////////

void CreateStringSet(const strvec& vec, std::set<string>& strset);
void CreateStringSetFromFirstElement(const strvec& vec, std::set<string>& strset);

int Satori::CreateResponse(strmap& oResponse)
{
Expand Down Expand Up @@ -64,6 +65,10 @@ int Satori::CreateResponse(strmap& oResponse)
else if (mRequestID == "installedheadlinename"){
CreateStringSet(mReferences, installed_headline_name);
}
else if (mRequestID == "otherghostname"){
//インストール済み情報
CreateStringSetFromFirstElement(mReferences, otherghostname);
}
else if (mRequestID == "OnNotifyFontInfo"){
CreateStringSet(mReferences, installed_font_name);
}
Expand Down Expand Up @@ -195,4 +200,19 @@ void CreateStringSet(const strvec& vec, std::set<string>& strset)
for (int i = 0; i < vec.size(); i++){
strset.insert(vec.at(i));
}
}

void CreateStringSetFromFirstElement(const strvec& vec, std::set<string>& strset)
{
strset.clear();

strvec byte1splitter;
string vecelem;

for (int i = 0; i < vec.size(); i++){
vecelem = vec.at(i);
byte1splitter.clear();
split(vecelem,"\1",byte1splitter);
strset.insert(byte1splitter[0]);
}
}
11 changes: 7 additions & 4 deletions satoriya/satori/satori_Kakko.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,10 @@ bool Satori::CallReal(const string& iName, string& oResult, bool for_calc, bool
#endif

else if ( iName == "隣で起動しているゴースト" ) {
updateGhostsInfo(); // ゴースト情報を更新
oResult = ( ghosts_info.size()>=2 ) ? (ghosts_info[1])["name"] : "";
oResult = ( otherghostname.size()>=1 ) ? *otherghostname.begin() : "";
}
else if ( iName == "起動しているゴースト数" ) {
updateGhostsInfo(); // ゴースト情報を更新
oResult = int2zen(ghosts_info.size());
oResult = int2zen(otherghostname.size());
}
else if ( compare_head(iName, "isempty") && iName.size()>=8 ) {
const char* p = iName.c_str()+7;
Expand Down Expand Up @@ -1153,6 +1151,11 @@ bool Satori::CallReal(const string& iName, string& oResult, bool for_calc, bool
oResult = ul2zen(FindProcessName(str.c_str(),true));
}

else if (compare_head(iName, "起動中ゴースト「") && compare_tail(iName, "」の存在")){
string str(iName, 16, iName.length() - 16 - 8);
oResult = otherghostname.count(str) ? "1" : "0";
}

else if ( compare_tail(iName, "の存在") ) {
updateGhostsInfo(); // ゴースト情報を更新
std::vector<strmap>::iterator i=ghosts_info.begin();
Expand Down
1 change: 1 addition & 0 deletions satoriya/satori/satori_load_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void Satori::InitMembers() {
dic_load_prefix = "dic";

ghosts_info.clear();
otherghostname.clear();
mCommunicateFor="";
mCommunicateLog.clear();

Expand Down
14 changes: 7 additions & 7 deletions satoriya/satori/satori_sentence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ int Satori::SentenceToSakuraScriptInternal(const strvec &vec,string &result,stri

if ( it==vec.begin() && strncmp(p, "", 2)==0 ) {
p+=2;
updateGhostsInfo(); // ゴースト情報を更新
//updateGhostsInfo(); // ゴースト情報を更新 -> いらない

if ( ghosts_info.size()>=2 ) { // そもそも自分以外にゴーストはいるのか。
if ( otherghostname.size()>=2 ) { // そもそも自分以外にゴーストはいるのか。
string temp = p;
std::vector<strmap>::iterator i=ghosts_info.begin(); ++i; // 自分は飛ばす
for ( ; i!=ghosts_info.end() ; ++i ) {
string name = (*i)["name"];
std::set<string>::iterator i=otherghostname.begin(); ++i; // 自分は飛ばす
for ( ; i!=otherghostname.end() ; ++i ) {
string name = *i;
GetSender().sender() << "ghost: " << name <<std::endl;
if ( compare_head(temp, name) ) {// 相手を特定
mCommunicateFor = name;
Expand All @@ -264,11 +264,11 @@ int Satori::SentenceToSakuraScriptInternal(const strvec &vec,string &result,stri
}


if ( i==ghosts_info.end() ) { // 特定しなかった場合
if ( i==otherghostname.end() ) { // 特定しなかった場合
// ランダム
//int n = random(ghosts_info.size()-1))+1;
//assert( n>=1 && n < ghosts_info.size());
mCommunicateFor = (ghosts_info[1])["name"];
mCommunicateFor = *otherghostname.begin();

// あかん、隣で起動している~~にならん
}
Expand Down

0 comments on commit 769dd18

Please sign in to comment.