int picolCondition(picolInterp *i, char* str) { if(str) { char buf[MAXSTR], buf2[MAXSTR]; int rc; rc = picolSubst(i,str); if(rc != PICOL_OK) return rc; //mysnprintf(buf, MAXSTR, "Condi: (%s) ->(%s)\n",str,i->result); //dbg_send_str3(buf, 1); mystrncpy(buf2,i->result, MAXSTR); /* ------- try whether the format suits [expr]... */ mystrncpy(buf,"llength ", MAXSTR); LAPPEND(buf,i->result); //dbg_send_str3(buf, 1); rc = picolEval(i,buf); if(rc != PICOL_OK) return rc; #if 0 if(EQ(i->result,"3")) { FOREACH(buf,cp,buf2) argv[a++] = mystrdup(buf); if(picolGetCmd(i,argv[1])) { /* defined operator in center */ mystrncpy(buf,argv[1], MAXSTR); /* translate to Polish :) */ LAPPEND(buf,argv[0]); /* e.g. {1 > 2} -> {> 1 2} */ LAPPEND(buf,argv[2]); rc = picolEval(i, buf); return rc; } } /* .. otherwise, check for inequality to zero */ #endif if(*str == '!') {mystrncpy(buf, "== 0 ", MAXSTR); str++;} /* allow !$x */ else mystrncpy(buf, "!= 0 ", MAXSTR); mystrncat(buf, str, MAXSTR); return picolEval(i, buf); // todo: compare without eval } else return picolErr(i, "NULL condition"); }
Behaviour::Behaviour(std::string filename) { std::fstream f(filename); f >> name; LINFO("Name: "); LAPPEND(name); while(f.good()) { std::string evalType; f >> evalType; std::pair<int,int> valuePair; if(evalType == "enemy_cover") { valuePair.first = ENEMY_COVER; } else if(evalType == "enemy_value") { valuePair.first = ENEMY_VALUE; } else if(evalType == "friend_cover") { valuePair.first = FRIEND_COVER; } else if(evalType == "own_value") { valuePair.first = OWN_VALUE; } else if(evalType == "destination_distance") { valuePair.first = DESTINATION_DISTANCE; } f >> valuePair.second; values.push_back(valuePair); } }