IModelDrawer::~IModelDrawer() { eventHandler.RemoveClient(this); for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { delete opaqueModelRenderers[modelType]; delete cloakedModelRenderers[modelType]; } opaqueModelRenderers.clear(); cloakedModelRenderers.clear(); LOG_L(L_DEBUG, "[%s]", __FUNCTION__); }
bool CKeyBindings::SetFakeMetaKey(const std::string& keystr) { CKeySet ks; if (StringToLower(keystr) == "none") { fakeMetaKey = -1; return true; } if (!ks.Parse(keystr)) { LOG_L(L_WARNING, "SetFakeMetaKey: could not parse key: %s", keystr.c_str()); return false; } fakeMetaKey = ks.Key(); return true; }
void CModelDrawerGLSL::PushDrawState(int modelType) { LOG_L(L_DEBUG, "[%s] modelType=%d, gameDrawMode=%d", __FUNCTION__, modelType, game->gameDrawMode); // shadowHandler may have been deleted, so // update the program if in the shadow pass if (game->gameDrawMode == CGame::gameShadowDraw) { shaders[modelType][game->gameDrawMode] = shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MODEL); } shaders[modelType][game->gameDrawMode]->Enable(); }
void CQuitBox::MouseRelease(int x,int y,int button) { float mx=MouseX(x); float my=MouseY(y); scrolling = false; scrollGrab = 0.0f; if(InBox(mx,my,box+resignBox) || (InBox(mx,my,box+saveBox) && !teamHandler->Team(gu->myTeam)->isDead) || (InBox(mx,my,box+giveAwayBox) && !teamHandler->Team(shareTeam)->isDead && !teamHandler->Team(gu->myTeam)->isDead)) { // give away all units (and resources) if(InBox(mx,my,box+giveAwayBox) && !playerHandler->Player(gu->myPlayerNum)->spectator) { net->Send(CBaseNetProtocol::Get().SendGiveAwayEverything(gu->myPlayerNum, shareTeam, playerHandler->Player(gu->myPlayerNum)->team)); } // resign, so self-d all units if (InBox(mx,my,box+resignBox) && !playerHandler->Player(gu->myPlayerNum)->spectator) { net->Send(CBaseNetProtocol::Get().SendResign(gu->myPlayerNum)); } // save current game state if (InBox(mx,my,box+saveBox)) { if (FileSystem::CreateDirectory("Saves")) { std::string timeStr = CTimeUtil::GetCurrentTimeStr(); std::string saveFileName(timeStr + "_" + modInfo.filename + "_" + gameSetup->mapName); saveFileName = "Saves/" + saveFileName + ".ssf"; if (!FileSystem::FileExists(saveFileName)) { LOG("Saving game to %s", saveFileName.c_str()); ILoadSaveHandler* ls = ILoadSaveHandler::Create(); ls->mapName = gameSetup->mapName; ls->modName = modInfo.filename; ls->SaveGame(saveFileName); delete ls; } else { LOG_L(L_ERROR, "File %s already exists, game NOT saved!", saveFileName.c_str()); } } } } else if (InBox(mx, my, box + quitBox)) { LOG("User exited"); gu->globalQuit = true; } // if we're still in the game, remove the resign box if(InBox(mx,my,box+resignBox) || InBox(mx,my,box+saveBox) || InBox(mx,my,box+giveAwayBox) || InBox(mx,my,box+cancelBox) || InBox(mx,my,box+quitBox)){ delete this; return; } moveBox=false; }
CSound::~CSound() { soundThreadQuit = true; configHandler->RemoveObserver(this); LOG_L(L_INFO, "[%s][1] soundThread=%p", __FUNCTION__, soundThread); if (soundThread != NULL) { soundThread->join(); delete soundThread; soundThread = NULL; } LOG_L(L_INFO, "[%s][2]", __FUNCTION__); for (soundVecT::iterator it = sounds.begin(); it != sounds.end(); ++it) delete *it; sounds.clear(); SoundBuffer::Deinitialise(); LOG_L(L_INFO, "[%s][3]", __FUNCTION__); }
void Gui::Draw() { for (ElList::iterator it = toBeAdded.begin(); it != toBeAdded.end(); ++it) { bool duplicate = false; for (ElList::iterator elIt = elements.begin(); elIt != elements.end(); ++elIt) { if (it->element == elIt->element) { LOG_L(L_DEBUG, "Gui::AddElement: skipping duplicated object"); duplicate = true; break; } } if (!duplicate) { if (it->asBackground) elements.push_back(*it); else elements.push_front(*it); } } toBeAdded.clear(); for (ElList::iterator it = toBeRemoved.begin(); it != toBeRemoved.end(); ++it) { for (ElList::iterator elIt = elements.begin(); elIt != elements.end(); ++elIt) { if (it->element == elIt->element) { delete (elIt->element); elements.erase(elIt); break; } } } toBeRemoved.clear(); glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, 1, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); for (ElList::reverse_iterator it = elements.rbegin(); it != elements.rend(); ++it) { (*it).element->Draw(); } }
//A thread wants to continue running at a later time, and adds itself to the scheduler void CCobEngine::AddThread(CCobThread *thread) { switch (thread->state) { case CCobThread::Run: wantToRun.push_front(thread); break; case CCobThread::Sleep: sleeping.push(thread); break; default: LOG_L(L_ERROR, "thread added to scheduler with unknown state (%d)", thread->state); break; } }
/** * * This entry point is tailored for the Watchdog module. * Since the thread to be traced may be running, it requires a ThreadControls object in order to suspend/resume the thread. * @brief RemoteStacktrace */ void SuspendedStacktrace(Threading::ThreadControls* ctls, const std::string& threadName) { #if !(DEDICATED || UNIT_TEST) Watchdog::ClearTimer(); #endif assert(ctls != nullptr); assert(ctls->handle != 0); assert(threadName.size() > 0); LOG_L(L_WARNING, "Suspended-thread Stacktrace (%s) for Spring %s:", threadName.c_str(), (SpringVersion::GetFull()).c_str()); LOG_L(L_DEBUG, "SuspendedStacktrace[1]"); StackTrace stacktrace; // Get untranslated stacktrace symbols { // process and analyse the raw stack trace void* iparray[MAX_STACKTRACE_DEPTH]; ctls->Suspend(); const int numLines = thread_unwind(&ctls->ucontext, iparray, stacktrace); ctls->Resume(); LOG_L(L_DEBUG, "SuspendedStacktrace[2]"); if(numLines > MAX_STACKTRACE_DEPTH) { LOG_L(L_ERROR, "thread_unwind returned more lines than we allotted space for!"); } char** lines = backtrace_symbols(iparray, numLines); // give them meaningfull names ExtractSymbols(lines, stacktrace); } if (stacktrace.empty()) { LOG_L(L_WARNING, " Unable to create suspended stacktrace"); return; } LOG_L(L_DEBUG, "SuspendedStacktrace[3]"); // Translate symbols into code line numbers TranslateStackTrace(NULL, stacktrace, LOG_LEVEL_WARNING); LOG_L(L_DEBUG, "SuspendedStacktrace[4]"); // Print out the translated StackTrace LogStacktrace(LOG_LEVEL_WARNING, stacktrace); }
void CSound::PrintDebugInfo() { boost::recursive_mutex::scoped_lock lck(soundMutex); LOG_L(L_DEBUG, "OpenAL Sound System:"); LOG_L(L_DEBUG, "# SoundSources: %i", (int)sources.size()); LOG_L(L_DEBUG, "# SoundBuffers: %i", (int)SoundBuffer::Count()); LOG_L(L_DEBUG, "# reserved for buffers: %i kB", (int)(SoundBuffer::AllocedSize() / 1024)); LOG_L(L_DEBUG, "# PlayRequests for empty sound: %i", numEmptyPlayRequests); LOG_L(L_DEBUG, "# Samples disrupted: %i", numAbortedPlays); LOG_L(L_DEBUG, "# SoundItems: %i", (int)sounds.size()); }
static bool TestCregClasses2() { PreCregTest("CREG: Test2 (Class' Sizes)"); int fineClasses = 0; int brokenClasses = 0; const std::vector<creg::Class*>& cregClasses = creg::System::GetClasses(); for (std::vector<creg::Class*>::const_iterator it = cregClasses.begin(); it != cregClasses.end(); ++it) { const creg::Class* c = *it; const std::string& className = c->name; const size_t classSize = c->size; size_t cregSize = 1; // c++ class is min. 1byte large (part of sizeof definition) const creg::Class* c_base = c; while (c_base){ const std::vector<creg::Class::Member*>& classMembers = c_base->members; for (std::vector<creg::Class::Member*>::const_iterator jt = classMembers.begin(); jt != classMembers.end(); ++jt) { const size_t memberOffset = (*jt)->offset; const size_t typeSize = (*jt)->type->GetSize(); cregSize = std::max(cregSize, memberOffset + typeSize); } c_base = c_base->base; } // alignment padding const float alignment = c->alignment; cregSize = std::ceil(cregSize / alignment) * alignment; //FIXME too simple, gcc's appending rules are ways more complicated if (cregSize != classSize) { brokenClasses++; LOG_L(L_WARNING, " Missing member(s) in class %s, real size %u, creg size %u", className.c_str(), classSize, cregSize); /*for (std::vector<creg::Class::Member*>::const_iterator jt = classMembers.begin(); jt != classMembers.end(); ++jt) { const std::string memberName = (*jt)->name; const size_t memberOffset = (*jt)->offset; const std::string typeName = (*jt)->type->GetName(); const size_t typeSize = (*jt)->type->GetSize(); LOG_L(L_WARNING, " member %20s, type %12s, offset %3u, size %u", memberName.c_str(), typeName.c_str(), memberOffset, typeSize); }*/ } else { //LOG( "CREG: Class %s fine, size %u", className.c_str(), classSize); fineClasses++; } } return PostCregTest(fineClasses, brokenClasses, 15); }
CWeapon* CWeaponLoader::LoadWeapon(CUnit* owner, const UnitDefWeapon* defWeapon) { CWeapon* weapon = NULL; const WeaponDef* weaponDef = defWeapon->def; const std::string& weaponType = weaponDef->type; if (weaponType == "Cannon") { weapon = new CCannon(owner, weaponDef); } else if (weaponType == "Rifle") { weapon = new CRifle(owner, weaponDef); } else if (weaponType == "Melee") { weapon = new CMeleeWeapon(owner, weaponDef); } else if (weaponType == "Shield") { weapon = new CPlasmaRepulser(owner, weaponDef); } else if (weaponType == "Flame") { weapon = new CFlameThrower(owner, weaponDef); } else if (weaponType == "MissileLauncher") { weapon = new CMissileLauncher(owner, weaponDef); } else if (weaponType == "AircraftBomb") { weapon = new CBombDropper(owner, weaponDef, false); } else if (weaponType == "TorpedoLauncher") { if (owner->unitDef->canfly && !weaponDef->submissile) { weapon = new CBombDropper(owner, weaponDef, true); } else { weapon = new CTorpedoLauncher(owner, weaponDef); } } else if (weaponType == "LaserCannon") { weapon = new CLaserCannon(owner, weaponDef); } else if (weaponType == "BeamLaser") { weapon = new CBeamLaser(owner, weaponDef); } else if (weaponType == "LightningCannon") { weapon = new CLightningCannon(owner, weaponDef); } else if (weaponType == "EmgCannon") { weapon = new CEmgCannon(owner, weaponDef); } else if (weaponType == "DGun") { // NOTE: no special connection to UnitDef::canManualFire // (any type of weapon may be slaved to the button which // controls manual firing) or the CMD_MANUALFIRE command weapon = new CDGunWeapon(owner, weaponDef); } else if (weaponType == "StarburstLauncher") { weapon = new CStarburstLauncher(owner, weaponDef); } else { weapon = new CNoWeapon(owner, weaponDef); LOG_L(L_ERROR, "weapon-type %s unknown or NOWEAPON", weaponType.c_str()); } return weapon; }
void CGameSetup::LoadAllyTeams(const TdfParser& file) { // i = allyteam index in game (no gaps), a = allyteam index in script int i = 0; for (int a = 0; a < MAX_TEAMS; ++a) { char section[50]; sprintf(section,"GAME\\ALLYTEAM%i",a); string s(section); if (!file.SectionExist(s)) continue; AllyTeam data; std::map<std::string, std::string> setup = file.GetAllValues(s); for (std::map<std::string, std::string>::const_iterator it = setup.begin(); it != setup.end(); ++it) data.SetValue(it->first, it->second); allyStartingData.push_back(data); allyteamRemap[a] = i; ++i; } { const size_t numAllyTeams = allyStartingData.size(); for (size_t a = 0; a < numAllyTeams; ++a) { allyStartingData[a].allies.resize(numAllyTeams, false); allyStartingData[a].allies[a] = true; // each team is allied with itself std::ostringstream section; section << "GAME\\ALLYTEAM" << a << "\\"; const size_t numAllies = atoi(file.SGetValueDef("0", section.str() + "NumAllies").c_str()); for (size_t b = 0; b < numAllies; ++b) { std::ostringstream key; key << "GAME\\ALLYTEAM" << a << "\\Ally" << b; const int other = atoi(file.SGetValueDef("0",key.str()).c_str()); allyStartingData[a].allies[allyteamRemap[other]] = true; } } } unsigned allyCount = 0; if (file.GetValue(allyCount, "GAME\\NumAllyTeams") && (allyStartingData.size() != allyCount)) { LOG_L(L_WARNING, "Incorrect number of ally teams in GameSetup script"); } }
int CSkirmishAILibrary::HandleEvent(int skirmishAIId, int topic, const void* data) const { int ret = sSAI.handleEvent(skirmishAIId, topic, data); if (ret != 0) { // event handling failed! const int teamId = skirmishAIHandler.GetSkirmishAI(skirmishAIId)->team; LOG_L(L_WARNING, "AI for team %i (ID: %i) failed handling event with topic %i, error: %i", teamId, skirmishAIId, topic, ret ); } return ret; }
CSkirmishAILibrary::CSkirmishAILibrary(const SSkirmishAILibrary& ai, const SkirmishAIKey& key) : sSAI(ai), key(key) { if (sSAI.handleEvent == NULL) { LOG_L(L_ERROR, "Fetched AI library %s-%s has no handleEvent function" "available. It is therefore illegal and will not be used." "This usually indicates a problem in the used AI Interface" "library (%s-%s).", key.GetShortName().c_str(), key.GetVersion().c_str(), key.GetInterface().GetShortName().c_str(), key.GetInterface().GetVersion().c_str()); } }
IModelDrawer::IModelDrawer(const std::string& name, int order, bool synced): CEventClient(name, order, synced) { eventHandler.AddClient(this); opaqueModelRenderers.resize(MODELTYPE_OTHER, NULL); cloakedModelRenderers.resize(MODELTYPE_OTHER, NULL); for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { opaqueModelRenderers[modelType] = IWorldObjectModelRenderer::GetInstance(modelType); cloakedModelRenderers[modelType] = IWorldObjectModelRenderer::GetInstance(modelType); } LOG_L(L_DEBUG, "[%s] this=%p, name=%s, order=%d, synced=%d", __FUNCTION__, this, name.c_str(), order, synced); }
void ClearTimer(const std::string &name, bool disable) { if (hangDetectorThread == NULL) return; //! Watchdog isn't running std::map<std::string, unsigned int>::iterator i = threadNameToNum.find(name); unsigned int num; WatchDogThreadInfo* th_info; if (i == threadNameToNum.end() || (num = i->second) >= WDT_LAST || !(th_info = registeredThreads[num])->numreg) { LOG_L(L_ERROR, "[Watchdog::ClearTimer] Invalid thread name"); return; } th_info->timer = disable ? spring_notime : spring_gettime(); }
void CGroupHandler::RemoveGroup(CGroup* group) { GML_RECMUTEX_LOCK(grpsel); // RemoveGroup if (group->id < FIRST_SPECIAL_GROUP) { LOG_L(L_WARNING, "Trying to remove hot-key group %i", group->id); return; } if (selectedUnits.selectedGroup == group->id) { selectedUnits.ClearSelected(); } groups[group->id] = NULL; freeGroups.push_back(group->id); delete group; }
bool COSCStatsSender::Update(int frameNum) { if (IsEnabled() && IsTimeToSend(frameNum)) { try { // Try to send team stats first, as they are more important, // more interesting. return SendTeamStats() && SendPlayerStats(); } catch (const boost::system::system_error& ex) { LOG_L(L_ERROR, "Failed sending OSC Stats init: %s", ex.what()); return false; } } else { return false; } }
bool COSCStatsSender::SendInit() { if (IsEnabled()) { try { return SendInitialInfo() && SendTeamStatsTitles() && SendPlayerStatsTitles(); } catch (const boost::system::system_error& ex) { LOG_L(L_ERROR, "Failed sending OSC Stats init: %s", ex.what()); return false; } } else { return false; } }
static bool info_parseInfoItem(const LuaTable& root, int index, InfoItem& inf, std::set<string>& infoSet) { const LuaTable& infsTbl = root.SubTable(index); if (!infsTbl.IsValid()) { LOG_L(L_WARNING, "parseInfoItem: subtable %d invalid", index); return false; } // common info properties inf.key = infsTbl.GetString("key", ""); if (inf.key.empty() || (inf.key.find_first_of(InfoItem_badKeyChars) != string::npos)) { LOG_L(L_WARNING, "parseInfoItem: empty key or key contains bad characters"); return false; } std::string lowerKey = StringToLower(inf.key); if (infoSet.find(inf.key) != infoSet.end()) { LOG_L(L_WARNING, "parseInfoItem: key toLowerCase(%s) exists already", inf.key.c_str()); return false; } // TODO add support for info value types other then string inf.valueType = INFO_VALUE_TYPE_STRING; inf.valueTypeString = infsTbl.GetString("value", ""); if (inf.valueTypeString.empty()) { LOG_L(L_WARNING, "parseInfoItem: %s: empty value", inf.key.c_str()); return false; } inf.desc = infsTbl.GetString("desc", ""); infoSet.insert(lowerKey); return true; }
static char* fgets_addr2line(char* line, int maxLength, FILE* cmdOut) { char* res = fgets(line, maxLength, cmdOut); if (res) { int sz = strnlen(line, maxLength); if (line[sz-1] == '\n') { line[sz-1] = 0;// exclude the line-ending } } else { line[0] = 0; } LOG_L(L_DEBUG, "addr2line: %s", line); return res; }
void IModelDrawer::RenderUnitCreated(const CUnit* u, int cloaked) { LOG_L(L_DEBUG, "[%s] id=%d", __FUNCTION__, u->id); #if (MODEL_DRAWER_DEBUG_RENDERING) if (u->model) { if (cloaked) { // units can start life cloaked cloakedModelRenderers[MDL_TYPE(u)]->AddUnit(u); } else { opaqueModelRenderers[MDL_TYPE(u)]->AddUnit(u); } } #endif }
void DataDirLocater::AddDir(const std::string& dir) { if (!dir.empty()) { // to make use of ensure-slash-at-end, // we create a DataDir here already const DataDir newDataDir(dir); bool alreadyAdded = false; std::vector<DataDir>::const_iterator ddi; for (ddi = dataDirs.begin(); ddi != dataDirs.end(); ++ddi) { if (newDataDir.path == ddi->path) { alreadyAdded = true; break; } } if (!alreadyAdded) { dataDirs.push_back(newDataDir); LOG_L(L_DEBUG, "Adding %s to directories", newDataDir.path.c_str()); } else { LOG_L(L_DEBUG, "Skipping already added directory %s", newDataDir.path.c_str()); } } }
void SetAffinityHelper(const char *threadName, boost::uint32_t affinity) { const boost::uint32_t cpuMask = Threading::SetAffinity(affinity); if (cpuMask == ~0) { LOG("[Threading] %s thread CPU affinity not set", threadName); } else if (cpuMask != affinity) { LOG("[Threading] %s thread CPU affinity mask set: %d (config is %d)", threadName, cpuMask, affinity); } else if (cpuMask == 0) { LOG_L(L_ERROR, "[Threading] %s thread CPU affinity mask failed: %d", threadName, affinity); } else { LOG("[Threading] %s thread CPU affinity mask set: %d", threadName, cpuMask); } }
static inline void SetSingleHoverAirMoveTypeValue(lua_State* L, int keyIdx, int valIdx, CHoverAirMoveType* moveType) { const string key = lua_tostring(L, keyIdx); bool assigned = true; if (lua_isnumber(L, valIdx)) { assigned = SetHoverAirMoveTypeValue(moveType, key, lua_tofloat(L, valIdx)); } else if (lua_isboolean(L, valIdx)) { assigned = SetHoverAirMoveTypeValue(moveType, key, lua_toboolean(L, valIdx)); } if (!assigned) { LOG_L(L_WARNING, "Can not assign key \"%s\" to GunshipMoveType", key.c_str()); } }
bool CFarTextureHandler::CheckResizeAtlas() { const unsigned int maxSprites = ((texSizeX / iconSizeX) * (texSizeY / iconSizeY) / numOrientations) - 1; if (usedFarTextures + 1 <= maxSprites) return true; const int oldTexSizeY = texSizeY; if (globalRendering->supportNPOTs) { texSizeY += std::max(iconSizeY, 4 * numOrientations * iconSizeX * iconSizeY / texSizeX); // make space for minimum 4 additional icons } else { texSizeY <<= 1; } if (texSizeY > globalRendering->maxTextureSize) { LOG_L(L_DEBUG, "Out of farTextures"); texSizeY = oldTexSizeY; return false; } unsigned char* oldPixels = new unsigned char[texSizeX*texSizeY*4]; glBindTexture(GL_TEXTURE_2D, farTextureID); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, oldPixels); //TODO use the FBO? memset(oldPixels + texSizeX*oldTexSizeY*4, 0, texSizeX*(texSizeY - oldTexSizeY)*4); GLuint newFarTextureID; glGenTextures(1, &newFarTextureID); glBindTexture(GL_TEXTURE_2D, newFarTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texSizeX, texSizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, oldPixels); delete[] oldPixels; fbo.Bind(); fbo.DetachAll(); glDeleteTextures(1, &farTextureID); farTextureID = newFarTextureID; fbo.AttachTexture(farTextureID); fbo.CheckStatus("FARTEXTURE"); fbo.Unbind(); return true; }
void CollisionVolume::Init(const float3& scales, const float3& offsets, int vType, int tType, int pAxis) { // assign these here, since we can be // called from outside the constructor primaryAxis = std::max(pAxis, 0) % COLVOL_NUM_AXES; volumeType = std::max(vType, 0) % COLVOL_NUM_SHAPES; testType = std::max(tType, 0) % COLVOL_NUM_HITTESTS; // allow defining a custom volume without using it for coldet disabled = (scales.x < 0.0f || scales.y < 0.0f || scales.z < 0.0f); axisOffsets = offsets; // make sure none of the scales are ever negative // or zero; if the resulting vector is <1, 1, 1>, // then the unit / feature loaders will override // the (clone) scales with the model's radius const float3 adjScales(std::max(1.0f, scales.x), std::max(1.0f, scales.y), std::max(1.0f, scales.z)); if (volumeType == COLVOL_TYPE_ELLIPSOID) { // if all axes are equal in scale, volume is a sphere (a special-case ellipsoid) if ((math::fabsf(adjScales.x - adjScales.y) < EPS) && (math::fabsf(adjScales.y - adjScales.z) < EPS)) { LOG_L(L_DEBUG, "auto-converting spherical COLVOL_TYPE_ELLIPSOID to COLVOL_TYPE_SPHERE"); volumeType = COLVOL_TYPE_SPHERE; } } // secondaryAxes[0] = (primaryAxis + 1) % COLVOL_NUM_AXES; // secondaryAxes[1] = (primaryAxis + 2) % COLVOL_NUM_AXES; switch (primaryAxis) { case COLVOL_AXIS_X: { secondaryAxes[0] = COLVOL_AXIS_Y; secondaryAxes[1] = COLVOL_AXIS_Z; } break; case COLVOL_AXIS_Y: { secondaryAxes[0] = COLVOL_AXIS_X; secondaryAxes[1] = COLVOL_AXIS_Z; } break; case COLVOL_AXIS_Z: { secondaryAxes[0] = COLVOL_AXIS_X; secondaryAxes[1] = COLVOL_AXIS_Y; } break; } SetAxisScales(adjScales.x,adjScales.y,adjScales.z); }
/* scopes process */ PROCESS_THREAD(scopes_process, ev, data) { PROCESS_BEGIN(); LOG_L("scopes process started\n"); /* create and start an event timer */ static struct etimer scopes_timer; etimer_set(&scopes_timer, SCOPES_TIMER_DURATION * CLOCK_SECOND); do { /* wait till the timer expires and then reset it immediately */ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&scopes_timer)); etimer_reset(&scopes_timer); struct scope *s; /* check memberships of dynamic scopes */ // LOG_L("checking dynamic scope memberships\n"); for (s = list_head(scopes); s != NULL; s = s->next) { /* only check scopes not created by the local node */ if (HAS_FLAG(s, SCOPES_FLAG_DYNAMIC) && !HAS_STATUS(s, SCOPES_STATUS_CREATOR)) { /* check membership */ int should_be_member = membership->check(s->specs, s->spec_len); /* decide action */ if (should_be_member && !HAS_STATUS(s, SCOPES_STATUS_MEMBER)) { /* join scope */ join_scope(s); } else if (!should_be_member && HAS_STATUS(s, SCOPES_STATUS_MEMBER)) { /* leave scope */ leave_scope(s); } } } // /* print scopes information */ // LOG_L("known scopes:\n"); // LOG_L("-------------\n"); // for (s = list_head(scopes); s != NULL; s = s->next) { // print_scope(s); // } // LOG_L("-------------\n"); }while(1); PROCESS_END(); }
bool CKeyBindings::UnBindKeyset(const string& keystr) { CKeySet ks; if (!ParseKeySet(keystr, ks)) { LOG_L(L_WARNING, "UnBindKeyset: could not parse key: %s", keystr.c_str()); return false; } bool success = false; KeyMap::iterator it = bindings.find(ks); if (it != bindings.end()) { bindings.erase(it); success = true; } return success; }
/** * Consumes (and frees) the lines produced by backtrace_symbols and puts these into the StackTrace fields */ static void ExtractSymbols(char** lines, StackTrace& stacktrace) { int l=0; auto fit = stacktrace.begin(); while (fit != stacktrace.end()) { LOG_L(L_DEBUG, "backtrace_symbols: %s", lines[l]); if (strncmp(lines[l], "[(nil)]", 20) != 0) { fit->symbol = lines[l]; fit++; } else { fit = stacktrace.erase(fit); } l++; } free(lines); }