void TimeLogger::pop(QString label){ TimeInformation* timeinfo = timerinfos.top(); for(unsigned int i = 0; i < timeinfo->messages.size(); ++i){ timeinfo->messages[i]->percent = timeinfo->messages[i]->time*1.0/timeinfo->totaltime*100; } long time = timerinfos.top()->totaltime; if(label == "") markIt("Time to finish this level: ", time); else markIt(label, time); timerinfos.pop(); if(timerinfos.size()) timerinfos.top()->timer += time; }
bool Monster::findPath( Pos sour ) { this->parent = Pos(sour.x + 1, sour.y); Pos** record; record = new Pos *[mMapHeight]; for(int i = 0; i < mMapHeight; ++i) { record[i] = new Pos[mMapWidth]; } stack<CellNode> st = stack<CellNode>(); CellNode node; node.self = sour; st.push(node); //判断从起点到终点之间是否有通路 CellNode temp; while(true) { if(!st.empty()) { temp = st.top(); st.pop(); } else { return false; } if(isFinal(temp.self)) { if(isValid(temp.self)) { markIt(temp.self); record[temp.self.y][temp.self.x] = temp.pare; parent = temp.pare; } break; } else { if(isValid(temp.self)) { markIt(temp.self); record[temp.self.y][temp.self.x] = temp.pare; parent = temp.pare; pushPos(temp.self, st); } } } //// 如果有通路则寻找合适的路径 Pos parent = finalPos; bool success = false; while(isValid(parent) && !success) { stepTo(parent); path.push_back(getStep()); markIt(parent); parent = record[parent.y][parent.x]; if(parent.x==sour.x && parent.y==sour.y) { success = true; } } path.push_back(fromPos); std::reverse(path.begin(),path.end()); return true; }
void markRegion(off_t a, off_t b) { int i; for (i = MAX(a - base, 0); i <= MIN(b - base, nbBytes - 1); i++) markIt(i); }