const RadarValues &Trail::GetRadarValues() const { if( m_bRadarValuesCached ) { return m_CachedRadarValues; } if( IsSecret() ) { // Don't calculate RadarValues for a non-fixed Course. They values are // worthless because they'll change every time this Trail is // regenerated. m_CachedRadarValues = RadarValues(); return m_CachedRadarValues; } else { RadarValues rv; rv.Zero(); FOREACH_CONST( TrailEntry, m_vEntries, e ) { const Steps *pSteps = e->pSteps; ASSERT( pSteps != NULL ); // Hack: don't calculate for autogen entries if( !pSteps->IsAutogen() && e->ContainsTransformOrTurn() ) { NoteData nd; pSteps->GetNoteData( nd ); RadarValues rv_orig; GAMESTATE->SetProcessedTimingData(const_cast<TimingData *>(pSteps->GetTimingData())); NoteDataUtil::CalculateRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv_orig ); PlayerOptions po; po.FromString( e->Modifiers ); if( po.ContainsTransformOrTurn() ) { NoteDataUtil::TransformNoteData(nd, *(pSteps->GetTimingData()), po, pSteps->m_StepsType); } NoteDataUtil::TransformNoteData(nd, *(pSteps->GetTimingData()), e->Attacks, pSteps->m_StepsType, e->pSong); RadarValues transformed_rv; NoteDataUtil::CalculateRadarValues( nd, e->pSong->m_fMusicLengthSeconds, transformed_rv ); GAMESTATE->SetProcessedTimingData(NULL); rv += transformed_rv; } else { rv += pSteps->GetRadarValues( PLAYER_1 ); } } /* Hack: SetRadarValues is non-const (a const setter doesn't * make sense), but it only modifies a mutable value. Just * cast away const. */ const_cast<Trail*>(this)->SetRadarValues( rv ); return m_CachedRadarValues; } }
const RadarValues &Trail::GetRadarValues() const { if( m_bRadarValuesCached ) { return m_CachedRadarValues; } else if( IsSecret() ) { // Don't calculate RadarValues for a non-fixed Course. The values are // worthless because they'll change every time this Trail is // regenerated. m_CachedRadarValues = RadarValues(); return m_CachedRadarValues; } else { RadarValues rv; rv.Zero(); FOREACH_CONST( TrailEntry, m_vEntries, e ) { const Steps *pSteps = e->pSteps; ASSERT( pSteps ); /* Hack: don't calculate for autogen entries; it makes writing Catalog.xml * take way too long. (Tournamix 4 Sample.crs takes me ~10s.) */ if( !pSteps->IsAutogen() && e->ContainsTransformOrTurn() ) { NoteData nd; pSteps->GetNoteData( nd ); RadarValues rv_orig; NoteDataUtil::CalculateRadarValues( nd, e->pSong->MusicLengthSeconds(), rv_orig ); PlayerOptions po; po.FromString( e->Modifiers ); if( po.ContainsTransformOrTurn() ) NoteDataUtil::TransformNoteData( nd, po, pSteps->m_StepsType ); NoteDataUtil::TransformNoteData( nd, e->Attacks, pSteps->m_StepsType, e->pSong ); RadarValues transformed_rv; NoteDataUtil::CalculateRadarValues( nd, e->pSong->MusicLengthSeconds(), transformed_rv ); rv += transformed_rv; } else { rv += pSteps->GetRadarValues(); } } /* Hack: SetRadarValues is non-const (a const setter doesn't * make sense), but it only modifies a mutable value. Just * cast away const. */ const_cast<Trail*>(this)->SetRadarValues( rv ); return m_CachedRadarValues; } }
void handlewhoischannels(int hooknum, void *arg) { channel **chans; char buffer[1024]; unsigned int bufpos; sstring *name; unsigned long *num; int i; char **args = (char **)arg; nick *sender = (nick *)args[0]; /* sender nick */ nick *target = (nick *)args[1]; /* target nick */ char *sourcenum = args[2]; /* source numeric */ /* do not show channels for +k service clients or IRC Operators * do not show channels for +n users * unless they whois themselves */ if ((IsService(target) || IsHideChan(target)) && sender != target) return; chans = (channel **)(target->channels->content); buffer[0] = '\0'; bufpos=0; /* Not handling delayed joins. */ for(i=target->channels->cursi-1;i>=0;i--) { /* Secret / Private channels: only show if the sender is on the channel as well */ if(IsSecret(chans[i]) || IsPrivate(chans[i])) { if (!getnumerichandlefromchanhash(chans[i]->users, sender->numeric)) continue; } name = chans[i]->index->name; if (bufpos + name->length > 508) { /* why 508? - need room for -@#channame\0 + 1 slack */ irc_send("%s", buffer); buffer[0] = '\0'; bufpos=0; } /* * 319 RPL_WHOISCHANNELS "source 319 target nick :channels" * "irc.netsplit.net 319 foobar barfoo :@#chan1 +#chan2 #chan3" * "irc.netsplit.net 319 foobar barfoo :-@#chan1 -+#chan2 -#chan3" */ if(buffer[0] == '\0') bufpos=snprintf(buffer, sizeof(buffer), "%s 319 %s %s :", getmynumeric(), sourcenum, target->nick); num = getnumerichandlefromchanhash(chans[i]->users, target->numeric); /* Adding these flags might make the string "unsafe" (without terminating \0). */ /* sprintf'ing the channel name afterwards is guaranteed to fix it though */ if (IsDeaf(target)) buffer[bufpos++]='-'; if (*num & CUMODE_OP) buffer[bufpos++]='@'; else if (*num & CUMODE_VOICE) buffer[bufpos++]='+'; bufpos += sprintf(buffer+bufpos, "%s ",name->content); } if (buffer[0] != '\0') irc_send("%s", buffer); }