本文整理汇总了C++中NLOG函数的典型用法代码示例。如果您正苦于以下问题:C++ NLOG函数的具体用法?C++ NLOG怎么用?C++ NLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NLOG函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NLOG
bool CEconomy::BuildMetalStorage(bool extreme){
NLOG("CEconomy::BuildMetalStorage");
float x = (float)atof(G->Get_mod_tdf()->SGetValueDef("0.8","ECONOMY\\RULES\\metalstorage").c_str());
x = max(x,0.01f);
if(G->cb->GetMetal() >G->cb->GetMetalStorage () * x){
int randnum = G->mrand()%4;
randnum = max(1,randnum);
if(G->cb->GetCurrentFrame()%randnum == 0){
return true;
}else{
return false;
}
}else{
return false;
}
// for now I've used a half fudged rule I took from JCAI
// erm, take the amount of metal currently being used, then see how long it would take to drain away to zero if there was no metal income and if it's smaller than a threshold then say yes, else say no
}
示例2: NLOG
float3 CMap::Pos2BuildPos(float3 pos, const UnitDef* ud){
NLOG("CMap::Pos2BuildPos");
if(ud->xsize&2)
pos.x=floor((pos.x)/(SQUARE_SIZE*2))*SQUARE_SIZE*2+8;
else
pos.x=floor((pos.x+8)/(SQUARE_SIZE*2))*SQUARE_SIZE*2;
if(ud->ysize&2)
pos.z=floor((pos.z)/(SQUARE_SIZE*2))*SQUARE_SIZE*2+8;
else
pos.z=floor((pos.z+8)/(SQUARE_SIZE*2))*SQUARE_SIZE*2;
pos.y=GetBuildHeight(pos,ud);
if(ud->floater && pos.y<0)
pos.y = -ud->waterline;
return pos;
}
示例3: NLOG
bool CActions::DGun(int uid,int enemy){
NLOG("CActions::DGun");
TCommand TCS(tc,"cmd_attack chaser::update every 4 secs");
tc.ID(CMD_DGUN);
tc.Push(enemy);
tc.c.timeOut = 3 SECONDS+(G->cb->GetCurrentFrame()%300) + G->cb->GetCurrentFrame(); // dont let this command get in the way of the commanders taskqueue with a never ending vendetta that can never be fulfilled
tc.created = G->cb->GetCurrentFrame();
tc.unit = uid;
if(G->OrderRouter->GiveOrder(tc,true)==false){
return false; // GiveOrder returned an error
}else{
G->Ch->dgunning.insert(uid);
// Command successful, This unit is now dgunning, so add it to this container so that next time it
// dguns we can prevent it from doing so because it's already dgunning
return true;
}
}
示例4: NLOG
void COrderRouter::CleanUpOrders(){
NLOG("COrderRouter::CleanUpOrders()");
if(CommandCache.empty() == false){
int hg = CommandCache.size();
if( hg >20){
for(int j = 2; j <(hg/2) ; j++){
if(CommandCache.empty() == false){
for(vector<TCommand>::iterator i = CommandCache.begin(); i != CommandCache.end();++i){
if(i->clear == true){
CommandCache.erase(i);
break;
}
}
}
}
}
}
}
示例5: NLOG
string CUBuild::GetESTORE(){
NLOG("CUBuild::GetESTORE");
list<string> possibles;
const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
if(di == 0) return string("");
int randnum = 0;
for(vector<CommandDescription>::const_iterator is = di->begin(); is != di->end();++is){
if(is->id<0){
// retrieve the unit type information
CUnitTypeData* p =G->UnitDefLoader->GetUnitTypeDataByName(is->name);
const UnitDef* pd = p->GetUnitDef();
if(pd->energyStorage >100){
if(G->Pl->feasable(pd->name,uid)==false) continue;
if(pd->floater == true){
if((G->info->spacemod == true)||(water == true)){
possibles.push_back(pd->name);
randnum++;
}
} else{
possibles.push_back(pd->name);
randnum++;
}
}
}
}
if(possibles.empty() == false){
randnum = G->mrand()%randnum;
int j = 0;
for(list<string>::iterator k = possibles.begin(); k != possibles.end(); ++k){
if(j == randnum){
return *k;
}else{
j++;
}
}
return possibles.front();
}
return string("");
}
示例6: NLOG
string CUBuild::GetMISSILE_UNIT(){
NLOG("CUBuild::GetMISSILE_UNIT");
const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
if(di == 0) return string("");
list<string> possibles;
float best_score = 0;
string best = "";
for(vector<CommandDescription>::const_iterator is = di->begin(); is != di->end();++is){
if(is->id<0){
const UnitDef* pd = G->GetUnitDef(is->name);
if(pd == 0) continue;
if(pd->metalCost+pd->energyCost > (G->cb->GetEnergyStorage()+G->cb->GetMetalStorage())*atof(G->Get_mod_tdf()->SGetValueDef("2.1", "AI\\cheap_multiplier").c_str())) continue;
bool good = true;
if(pd->canfly ==false) good = false;
if(pd->weapons.empty() == true) good = false;
if(pd->builder == true) good = false;
if(pd->transportCapacity > 0) good = false;
bool found = false;
for(vector<UnitDef::UnitDefWeapon>::const_iterator i = pd->weapons.begin(); i != pd->weapons.end(); ++i){
if(i->def->interceptor > 0){
continue;
}
if(i->def->vlaunch == true){
found = true;
break;
}
}
if(found == false) good = false;
if(good == true){
srand(uint(time(NULL) + G->Cached->randadd));
G->Cached->randadd++;
float temp = G->GetEfficiency(pd->name);
temp = temp - rand()%(int)(temp/3);
if(temp > best_score){
best_score = temp;
best = pd->name;
}
}
}
}
return best;
}
示例7: init_logging
/*
* Initialize the logging
*/
void
init_logging(
char const *name,
int log_version
)
{
const char *cp;
/*
* Logging. This may actually work on the gizmo board. Find a name
* to log with by using the basename
*/
cp = strrchr(name, '/');
if (cp == 0)
cp = name;
else
cp++;
#if !defined(VMS)
# ifndef LOG_DAEMON
openlog(cp, LOG_PID);
# else /* LOG_DAEMON */
# ifndef LOG_NTP
# define LOG_NTP LOG_DAEMON
# endif
openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP);
# ifdef DEBUG
if (debug)
setlogmask(LOG_UPTO(LOG_DEBUG));
else
# endif /* DEBUG */
setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
# endif /* LOG_DAEMON */
#endif /* !VMS */
if (log_version)
NLOG(NLOG_SYSINFO) /* 'if' clause for syslog */
msyslog(LOG_NOTICE, "%s", Version);
}
示例8: NLOG
void Scouter::UnitDestroyed(int unit){
NLOG("Scouter::UnitDestroyed");
if(cp.empty() == false){
for(map< int, list<float3> >::iterator q = cp.begin(); q != cp.end();++q){
if(q->first == unit){
cp.erase(q);
break;
}
}
}
const UnitDef* ud = G->cb->GetUnitDef(unit);
if(ud == 0) return;
float3 dpos = G->cb->GetUnitPos(unit);
if((ud->extractsMetal >0)&&(cp.empty() == false)){
for(map<int, list<float3> >::iterator i = cp.begin(); i != cp.end(); ++i){
i->second.push_back(dpos);
}
mexes.push_back(dpos);
}
}
示例9: refclock_report
/*
* refclock_report - note the occurance of an event
*
* This routine presently just remembers the report and logs it, but
* does nothing heroic for the trap handler. It tries to be a good
* citizen and bothers the system log only if things change.
*/
void
refclock_report(
struct peer *peer,
int code
)
{
struct refclockproc *pp;
if (!(pp = peer->procptr))
return;
if (code == CEVNT_BADREPLY)
pp->badformat++;
if (code == CEVNT_BADTIME)
pp->baddata++;
if (code == CEVNT_TIMEOUT)
pp->noreply++;
if (pp->currentstatus != code) {
pp->currentstatus = code;
pp->lastevent = code;
if (code == CEVNT_FAULT)
msyslog(LOG_ERR,
"clock %s event '%s' (0x%02x)",
refnumtoa(peer->srcadr.sin_addr.s_addr),
ceventstr(code), code);
else {
NLOG(NLOG_CLOCKEVENT)
msyslog(LOG_INFO,
"clock %s event '%s' (0x%02x)",
refnumtoa(peer->srcadr.sin_addr.s_addr),
ceventstr(code), code);
}
}
#ifdef DEBUG
if (debug)
printf("clock %s event '%s' (0x%02x)\n",
refnumtoa(peer->srcadr.sin_addr.s_addr),
ceventstr(code), code);
#endif
}
示例10: NLOG
bool CEconomy::BuildMex(bool extreme){
NLOG("CEconomy::BuildMex");
if(extreme){
float x = (float)atof(G->Get_mod_tdf()->SGetValueDef("0.4","ECONOMY\\RULES\\EXTREME\\mex").c_str());
// if below 20% metal stored then yah we need mexes!!
if(G->cb->GetMetal() < G->cb->GetMetalStorage()*x){
return true;
}else{
if(G->cb->GetMetal() < 400.0f){
return true;
}
if(G->Pl->GetMetalIncome() < G->cb->GetMetalUsage()*(1-x)){
return true;
}
return false;
}
}else{
float x = (float)atof(G->Get_mod_tdf()->SGetValueDef("0.5","ECONOMY\\RULES\\mex").c_str());
// if below 50% metal stored then yah we need mexes!!
if(G->cb->GetMetal() < G->cb->GetMetalStorage()*x){
return true;
}else{
if(G->cb->GetMetal() < 500.0f){
return true;
}
if(G->Pl->GetMetalIncome() < G->cb->GetMetalUsage()*(1-x)){
return true;
}
return false;
}
}
return false;
}