int main(object me, string arg) { int nowtime = time(); mapping quest; if(!(quest = me->query("quest"))) return notify_fail("你现在没有任何任务!\n"); write("你现在的任务是" + quest["quest_type"] + "『" + quest["quest"] + "』。\n" ); nowtime = (int) me->query("task_time") - time(); if( nowtime > 0 ) time_period(nowtime, me); else write("但是你已经没有足够的时间来完成它了。\n"); return 1; }
inline std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, time_period& tp) { gregorian::date d(not_a_date_time); time_duration td(0,0,0); ptime beg(d, td); ptime end(beg); std::basic_string<charT> s; // get first date string and remove leading '[' is >> s; { std::basic_stringstream<charT> ss; ss << s.substr(s.find('[')+1); ss >> d; } // get first time_duration & second date string, remove the '/' // and split into 2 strings is >> s; { std::basic_stringstream<charT> ss; ss << s.substr(0, s.find('/')); ss >> td; } beg = ptime(d, td); { std::basic_stringstream<charT> ss; ss << s.substr(s.find('/')+1); ss >> d; } // get last time_duration and remove the trailing ']' is >> s; { std::basic_stringstream<charT> ss; ss << s.substr(0, s.find(']')); ss >> td; } end = ptime(d, td); tp = time_period(beg,end); return is; }
void GRaportManager::UpdateTime(GClock & clock) { if(!time_period(clock)) return; if(flush_period(clock)) { if(raport_file) { fflush(raport_file); #ifdef LINUX struct stat buf; int ret= stat( file_name, &buf ); #else struct __stat64 buf; int ret= _stat64( file_name, &buf ); #endif if(ret==-1){fclose(raport_file);raport_file=NULL;wait_for_data=true;} } overflow_lines=0; } UpdateName(clock); }
int main(object me, string arg) { int i, j, tim, sum=0; i = LOGIN_D->get_dienpc(); j = LOGIN_D->get_madlock(); tim = F_DISASTER->query_hj_startT(); tim = time() - tim; sum += F_DISASTER->query_children("/d/haojie/npc/pker9.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker8.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker7.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker6.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker5.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker4.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker3.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker2.c"); sum += F_DISASTER->query_children("/d/haojie/npc/pker1.c"); write(" 被杀NPC人数:"+i+"\n"); write("系统封锁状态:"+j+"\n"); write("封锁持续时间:"+time_period(tim)+"\n"); write("当前杀手数量:"+sum+"\n"); return 1; }
int main(object ob, string arg) { int nowtime = time(); object me; if(!arg || !wizardp(ob)) { me = this_player(); if(!me->query("delivery")) { if((me->query("next_delivery_time")) > time()) { return notify_fail(HIW"─у╥к╣¤" + QUESTS_D->wait_period(me->query("next_delivery_time") - time()) + "╓о║є▓┼┐╔╝╠╨°╦═╗ибг\n"NOR); }else return notify_fail("─у╧╓╘┌├╗╙╨╚╬║╬╦═╗и╚╬╬ёгб\n"); } if(mapp(me->query("delivery"))) { mapping delivery; delivery = me->query("delivery"); write(WHT"─у╧╓╘┌╡─╚╬╬ё╩╟╠ц" + delivery["sender"] + "╦═╗и╕°╫б╘┌" +delivery["area"]+"╡─"+delivery["receiver"]->name()+"бг\n"NOR); } else { return notify_fail("─у╧╓╘┌├╗╙╨╚╬║╬╦═╗и╚╬╬ёгб\n"); } nowtime = (int)time() - me->query("delivery_time"); if(nowtime < 600) { time_period(nowtime, me); } else { return notify_fail("─у╥╤╛н├╗╙╨╫у╣╗╡─╩▒╝ф└┤═ъ│╔╦№┴╦бг\n"); if (nowtime < 1200) { return notify_fail(HIW"─у╥к╣¤" + QUESTS_D->wait_period(1200-nowtime) + "╓о║є▓┼┐╔╝╠╨°╦═╗ибг\n"NOR); } } } else { if(!(ob = present(arg, environment(ob))) && !(ob = find_player(arg))) { return notify_fail("─у╥к▓ь┐┤╦н╡─╦═╗и╚╬╬ёг┐\n"); } if(!ob->query("delivery")) { if((ob->query("next_delivery_time")) > time()) { return notify_fail(HIW+ob->name()+"╥к╣¤" + QUESTS_D->wait_period(me->query("next_delivery_time") - time()) + "╓о║є▓┼┐╔╝╠╨°╦═╗ибг\n"NOR); }else return notify_fail(ob->name()+"╧╓╘┌├╗╙╨╚╬║╬╦═╗и╚╬╬ёгб\n"); } if(mapp(ob->query("delivery"))) { mapping delivery; delivery = ob->query("delivery"); write(WHT""+ob->name()+"╧╓╘┌╡─╚╬╬ё╩╟╠ц" + delivery["sender"] + "╦═╗и╕°╫б╘┌" +delivery["area"]+"╡─"+ delivery["receiver"]->name()+"бг\n"NOR); }else { return notify_fail(ob->name()+"╧╓╘┌├╗╙╨╚╬║╬╦═╗и╚╬╬ёгб\n"); } nowtime = (int)time() - ob->query("delivery_time"); if(nowtime < 600) { time_period(nowtime, ob); } else { return notify_fail(ob->name()+"╥╤╛н├╗╙╨╫у╣╗╡─╩▒╝ф└┤═ъ│╔╦№┴╦бг\n"); if (nowtime < 1200) { return notify_fail(HIW+ob->name()+"╥к╣¤" + QUESTS_D->wait_period(1200-nowtime) + "╓о║є▓┼┐╔╝╠╨°╦═╗ибг\n"NOR); } } } return 1; }
//--------------------------------------------------------- int main(int argc, char* argv[]) { //deadline_timer is not copyable; { boost::asio::io_service io_service; boost::asio::deadline_timer deadline_timer(io_service); boost::posix_time::ptime starting_time=boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration time_duration=boost::posix_time::seconds(5); boost::posix_time::time_period time_period(starting_time, time_duration); std::string str; deadline_timer.expires_from_now(time_duration); deadline_timer.async_wait(boost::bind(handle_timer, boost::asio::placeholders::error)); io_service.run_one(); str=boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::local_time()-starting_time); std::cout<<str<<std::endl; } { boost::asio::io_service io_service; boost::asio::deadline_timer deadline_timer(io_service); _starting_time=boost::posix_time::microsec_clock::local_time(); _time_duration=boost::posix_time::seconds(5); deadline_timer.expires_from_now(_time_duration); deadline_timer.async_wait(boost::bind(handle_timer, boost::asio::placeholders::error)); io_service.run_one(); boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::local_time()-_starting_time); } { boost::asio::io_service io_service; boost::asio::deadline_timer deadline_timer(io_service); deadline_timer.expires_from_now(boost::posix_time::seconds(1)); deadline_timer.async_wait(boost::bind(handle_timer, boost::ref(deadline_timer), boost::asio::placeholders::error)); io_service.run(); } { boost::asio::io_service io_service; boost::asio::deadline_timer deadline_timer(io_service); deadline_timer.expires_at( boost::posix_time::microsec_clock::universal_time() +boost::posix_time::seconds(1)); } { boost::asio::io_service io_service; boost::asio::deadline_timer deadline_timer(io_service); //expires_from_now(duration)==expires_at(boost::posix_time::microsec_clock::universal_time()+duration) deadline_timer.expires_from_now(boost::posix_time::seconds(1)); std::cout<<"sleeping..."<<std::endl; boost::this_thread::sleep(boost::posix_time::seconds(2)); std::cout<<"woke up!"<<std::endl; std::cout<<"running timer"<<std::endl; //will expire immediatly deadline_timer.async_wait(boost::bind(pass, &deadline_timer, boost::asio::placeholders::error)); io_service.run(); } return 0; }
int main(object me, string arg) { int nowtime = time(); string quest_list = ""; string msg; object who = this_player(); if ( stringp(arg) ) { who = find_player( arg ); if ( !objectp(who) || !me->visible(who)) return notify_fail( "你想查看谁的任务?\n" ); if ( who->query("id") != me->query("id") && !wizardp(me) ) return notify_fail( "只有巫师才能查看别人的任务!\n" ); } msg = quest_msg( who, "wei" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"]+"『"+quest["quest"]+"』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "shan" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"] + "『" + quest["quest"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "helian" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"] + "『" + quest["quest"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "book" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += "查找在『" + quest["dest"] + "』一带的" + quest["book"] + "。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "betrayer" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += "铲除在『" + quest["dest"] + "』一带活动的『" + quest["name"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "thief" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( who, "kill" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += "杀了在『" + quest["place"] + "』一带出现的『" + quest["name"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } if ( quest_list != "" ) { write( "\n你目前的部分任务:\n\n" ); write( HIC"≡"HIY"──────────────────────────────"HIC"≡\n\n"NOR ); write( quest_list ); write( HIC"≡"HIY"──────────────────────────────"HIC"≡\n\n"NOR ); } else write( HIW"\n你现在没有任何任务!\n\n"NOR ); return 1; }
int main(object me, string arg) { int nowtime = time(); string quest_list = ""; string msg; msg = quest_msg( "wei" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"] + "『" + quest["quest"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( "shan" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"] + "『" + quest["quest"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( "helian" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += quest["quest_type"] + "『" + quest["quest"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( "book" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += "查找在『" + quest["dest"] + "』一带的" + quest["book"] + "。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( "betrayer" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; quest_list += "铲除在『" + quest["dest"] + "』一带活动的『" + quest["name"] + "』。\n "; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } msg = quest_msg( "thief" ); quest_list += msg; if ( msg != "" && !quest["finished"] && !quest["lock"] ) { quest_list += HIC; nowtime = quest["time"] - time(); quest_list += time_period( nowtime ); quest_list += "\n\n"NOR; } if ( quest_list != "" ) { write( "\n你目前的部分任务:\n\n" ); write( HIC"≡"HIY"──────────────────────────────"HIC"≡\n\n"NOR ); write( quest_list ); write( HIC"≡"HIY"──────────────────────────────"HIC"≡\n\n"NOR ); } else write( HIW"\n你现在没有任何任务!\n\n"NOR ); return 1; }