本文整理汇总了C++中Time_Value::sec方法的典型用法代码示例。如果您正苦于以下问题:C++ Time_Value::sec方法的具体用法?C++ Time_Value::sec怎么用?C++ Time_Value::sec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time_Value
的用法示例。
在下文中一共展示了Time_Value::sec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: item_is_open
bool Oper_Activity_Manager::item_is_open(const uint32_t act_id) {
Time_Value now = Time_Value::gettimeofday();
if(act_start.sec() <= now.sec() && now.sec() < act_end.sec()) {
if(start_time[act_id].sec() <= now.sec() && now.sec() < end_time[act_id].sec()) {
return true;
}
}
return false;
}
示例2: is_open
int Answer_Manager::is_open(Logic_Player *player) {
if((uint32_t)player->level() < level_limit) {
return ERROR_LEVEL_LIMIT;
}
Time_Value now = Time_Value::gettimeofday();
if(now.sec() >= bef_start_time.sec() && now.sec() < end_time.sec() && !is_close) {
MSG_DEBUG("req enter answer scene on logic role_id:%ld, endtime:%ld, thistime:%ld", player->role_id(), end_time.sec(), now.sec());
return 0;
}
return ERROR_ANSWER_ACTIVE_NOT_OPEN;
}
示例3: check_make_question
void Answer_Scene::check_make_question(const Time_Value &now) {
//检测当前题目是否完成状态
if(q.status != QUESTION_STATUS_OK && q.id != 0) {
return;
}
//检测当前时间处于第几题
int sl_sec = now.sec() - start_time.sec();
if(sl_sec < 0) {
return;
}
uint32_t ones_sec = get_ones_time_sec();
uint16_t this_qno = sl_sec/ones_sec + 1;
//检测当前是否正处于哪一题
if(this_qno <= answer_info.question_id_list.size()) {
return;
}
//随机生成题目
uint32_t qid = rand_make_question();
if(qid == 0) {
return;
}
//更新题目信息
if(make_active_question(qid)){
return;
}
answer_info.cur_qno = this_qno;
answer_info.question_id_list.insert(qid);
send_to_logic_save_data();
}
示例4: tick
int Answer_Scene::tick(const Time_Value &now){
if(now.sec() >= start_time.sec()
&& now.sec() < (start_time.sec() + get_ones_time_sec() * CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_QUESTION_NUM))) {
//检测生成题目
check_make_question(now);
//检测当前题目所处于时间的应该触发状态
update_question_status(now);
}
if(end_time.sec() && now.sec() >= end_time.sec()) {
send_to_logic_get_rank_reward();
kick_all_palyer();
this->set_scene_status(Move_Scene::SCENE_RECOVER_STATUS);
}
return 0;
}
示例5: get_vip_days
uint32_t Vip::get_vip_days(void) {
//求出VIP剩余天数
Time_Value now = Time_Value::gettimeofday();
int32_t sec = player_self()->base_detail().vip_over_time.sec() - now.sec();
if(sec <= 0) {
return 0;
}
//uint8_t mod = sec % (3600*24);
uint32_t days = sec/(3600*24);// + ((mod == 0)?0:1);
return days;
}
示例6: lost_grow
void Vip::lost_grow(const Time_Value &start_time, const Time_Value &end_time) {
if(start_time == Time_Value::zero) { //出现0时间的情况只会出现在未开通过VIP
return;
}
const Grow_Get_Config *conf = CONFIG_CACHE_VIP->get_grow_get_config(player_self()->base_detail().vip);
if(!conf) {
return;
}
if(end_time.sec() > start_time.sec()) {
long int slip_sec = end_time.sec() - start_time.sec(); //时间间隔的秒数
uint32_t slip_days = slip_sec/(3600*24); //间隔天数
tm tm_end,tm_start; //求开始和结束的TM
{
time_t t_end = end_time.sec();
localtime_r(&t_end, &tm_end);
time_t t_start = start_time.sec();
localtime_r(&t_start, &tm_start);
}
if(tm_end.tm_hour >= 6 && tm_start.tm_hour < 6) { //如果开始在六点前,结束在6点后; 加一天
++slip_days;
}
int32_t lost_to_val = vip_detail_->grow_val - conf->lost_val * slip_days;
if(lost_to_val >= 0) {
vip_detail_->grow_val = lost_to_val;
} else {
vip_detail_->grow_val = 0;
}
vip_detail_->last_settle_grow = end_time;
vip_detail_->detail_change();
send_vip_info_client(VIP_ACTIVE_GROW_CHANGE);
}
}
示例7: get_grow
void Vip::get_grow(const Time_Value &start_time, const Time_Value &end_time) {
if(start_time == Time_Value::zero) { //出现0时间的情况只会出现在未开通过VIP
return;
}
MSG_DEBUG("get grow on six role_id:%ld, start:%ld, end:%ld", player_self()->role_id(), start_time.sec(), end_time.sec());
const Grow_Get_Config *conf = CONFIG_CACHE_VIP->get_grow_get_config(player_self()->base_detail().vip);
if(!conf) {
return;
}
if(end_time.sec() > start_time.sec()) {
long int slip_sec = end_time.sec() - start_time.sec(); //时间间隔的秒数
uint32_t slip_days = slip_sec/(3600*24); //间隔天数
tm tm_end,tm_start; //求开始和结束的TM
{
time_t t_end = end_time.sec();
localtime_r(&t_end, &tm_end);
time_t t_start = start_time.sec();
localtime_r(&t_start, &tm_start);
}
if(tm_end.tm_hour >= 6 && tm_start.tm_hour < 6) { //如果开始在六点前,结束在6点后; 加一天
++slip_days;
}
vip_detail_->grow_val += conf->get_val * slip_days; //补全所缺天数成长值
vip_detail_->last_settle_grow = end_time;
vip_detail_->detail_change();
MSG_DEBUG("get grow on six role_id:%ld, slip_days:%d, oldval:%d, newval:%d", player_self()->role_id(), slip_days, conf->get_val, vip_detail_->grow_val);
send_vip_info_client(VIP_ACTIVE_GROW_CHANGE);
}
}
示例8: update_question_status
void Answer_Scene::update_question_status(const Time_Value &now) {
int this_start_sec = get_ones_time_sec() * (answer_info.cur_qno-1);
if(this_start_sec < 0) {
return;
}
uint32_t this_start_time = start_time.sec() + this_start_sec;
int slep_sec = now.sec() - this_start_time;//当前题目开始时间与当前时间间隔的秒数
if(slep_sec < 0) {
return;
}
//计算当前时间该题目应该处于神马状态
uint32_t read_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_READ_TIME);
uint32_t answer_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_ANSWER_TIME);
uint32_t ann_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_ANN_TIME);
if((uint32_t)slep_sec <= read_sec) {
//阅题
if(q.status == QUESTION_STATUS_READ) {
return;
} else {
q.status = QUESTION_STATUS_READ;
q.over_time = this_start_time + read_sec;
send_client_question_info();
}
} else if((uint32_t)slep_sec <= (answer_sec+read_sec)) {
//答题
if(q.status == QUESTION_STATUS_ANSWER) {
return;
} else {
q.status = QUESTION_STATUS_ANSWER;
q.over_time = this_start_time + read_sec + answer_sec;
send_client_question_info();
}
} else if((uint32_t)slep_sec <= (ann_sec+answer_sec+read_sec)) {
//公布
if(q.status == QUESTION_STATUS_ANN) {
return;
} else {
q.status = QUESTION_STATUS_ANN;
q.over_time = this_start_time + read_sec + answer_sec + ann_sec;
//计算动态答案
make_active_question_on_fulfil(q.id);
send_client_question_info();
fulfil_active_question();
}
} else {
if(q.status == QUESTION_STATUS_OK) {
return;
} else {
q.status = QUESTION_STATUS_OK;
}
}
}
示例9: get_arena_match_remain_time
void Logic_Arenaer::get_arena_match_remain_time(bool& match, int& remain_time){
if(arenaer_detail_->match_time != Time_Value::zero){
match = true;
Time_Value now = Time_Value::gettimeofday();
remain_time = arenaer_detail_->match_time.sec() - now.sec();
if(remain_time < 0){
remain_time = 0;
}
}else{
match = false;
remain_time = 0;
}
}
示例10: update
void Date_Time::update(const Time_Value &timevalue) {
time_t time = timevalue.sec();
struct tm tm_time;
::localtime_r(&time, &tm_time);
this->day_ = tm_time.tm_mday;
this->month_ = tm_time.tm_mon + 1; // localtime's months are 0-11
this->year_ = tm_time.tm_year + 1900; // localtime reports years since 1900
this->hour_ = tm_time.tm_hour;
this->minute_ = tm_time.tm_min;
this->second_ = tm_time.tm_sec;
this->microsec_ = timevalue.usec();
this->wday_ = tm_time.tm_wday;
this->isdst_ = tm_time.tm_isdst;
}
示例11: check_forbid_account_list
bool Game_Manager::check_forbid_account_list(std::string &account) {
//return forbid_account_list_.count(account);
String_Time_Map::iterator find_it = forbid_account_list_.find(account);
if (find_it != forbid_account_list_.end()) {
Time_Value now = Time_Value::gettimeofday();//获取当前时间
if(find_it->second.sec()<now.sec()){
forbid_account_list_.erase(find_it);
return false;
}else{
return true;
}
}
return false;
}
示例12: get_arena_cd
int Logic_Arenaer::get_arena_cd(void){
if(arenaer_detail_){
if(arenaer_detail_->cd == Time_Value::zero){
return 0;
}else{
Time_Value now = Time_Value::gettimeofday();
int remain_time = arenaer_detail_->cd.sec() - now.sec();
if(remain_time < 0){
remain_time = 0;
}
return remain_time;
}
}
return 0;
}
示例13: check_forbid_role_id_list
bool Game_Manager::check_forbid_role_id_list(role_id_t role_id) {
//return forbid_role_id_list_.count(role_id);
Role_Id_Time_Map::iterator find_it = forbid_role_id_list_.find(role_id);
if (find_it != forbid_role_id_list_.end()) {
Time_Value now = Time_Value::gettimeofday();//获取当前时间
if(find_it->second.sec()<now.sec()){
forbid_role_id_list_.erase(find_it);
return false;
}else{
return true;
}
}
return false;
}
示例14: offline_invite_player
int Operating::offline_invite_player(role_id_t role_id, const Time_Value &time) {
if (!role_id) {
MSG_USER("error role id");
return -1;
}
Block_Buffer buf;
buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
uint32_t op_type = OPERATING_OFFLINE_INVITE_PLAYER;
buf.write_uint32(op_type);
buf.write_int64(role_id);
buf.write_int64(time.sec());
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
return 0;
}
示例15: check_fight_teams
void Honor_Arena_Manager::check_fight_teams(const Time_Value& now){
int now_sec = now.sec();
std::vector<Honor_Arena_Match_Team>::iterator it;
for(it = fight_teams_.begin(); it != fight_teams_.end();){
if(now_sec > it->fight_time){
if(start_fight(it->role_id_1, it->role_id_2) == 0){
}else{
}
it = fight_teams_.erase(it);
}else{
++it;
}
}
}