本文整理汇总了C++中Time_Value类的典型用法代码示例。如果您正苦于以下问题:C++ Time_Value类的具体用法?C++ Time_Value怎么用?C++ Time_Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Time_Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:9,代码来源:Oper_Activity_Manager.cpp
示例2: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:11,代码来源:Vip.cpp
示例3: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:11,代码来源:Answer_Manager.cpp
示例4: 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;
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:13,代码来源:Logic_Arenaer.cpp
示例5: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:14,代码来源:Date_Time.cpp
示例6: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:14,代码来源:Game_Manager.cpp
示例7: sync_info_logic
int Map_Team::sync_info_logic(void) {
MSG_20100304 inner_msg;
Block_Buffer buf;
Time_Value now;
now = Time_Value::gettimeofday();
buf.make_message(inner_msg.msg_id);
buf.write_int64(team_id_);
buf.write_int16(fail_times_);
buf.write_int16(match_fail_);
now.serialize(buf);
buf.finish_message();
this->info_all_online_player(inner_msg.msg_id, &buf);
return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:14,代码来源:Map_Team.cpp
示例8: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:15,代码来源:Game_Manager.cpp
示例9: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:15,代码来源:Logic_Arenaer.cpp
示例10: 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();
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:29,代码来源:Answer_Scene.cpp
示例11: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:18,代码来源:Answer_Scene.cpp
示例12: rand_role_name
std::string Logic_Public::get_name(int gender) {
String_Set &set = (gender == 1) ? male_name_set : female_name_set;
int size = set.size();
if (size < 200) {
rand_role_name();
}
size = set.size();
if (size <= 0) {
Time_Value now = Time_Value::gettimeofday();
int num = now.sec() % 1000000;
std::ostringstream ost;
ost << num;
return ost.str();
}
size = (size > 10000) ? 10000 : size;
int rand = random() % size;
String_Set::iterator it = set.begin();
std::advance(it, rand);
return *it;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:21,代码来源:Logic_Public.cpp
示例13: 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);
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:29,代码来源:Vip.cpp
示例14: 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);
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:32,代码来源:Vip.cpp
示例15: 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;
}
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:52,代码来源:Answer_Scene.cpp
示例16: deserialize
int Expedition_Global_Manager_Data::deserialize(Block_Buffer &r) {
uint16_t len = 0;
int64_t uuid = 0;
Time_Value tv = Time_Value::zero;
r.read_uint16(len);
for (uint16_t i = 0; i < len; ++i) {
r.read_int64(uuid);
tv.deserialize(r);
opened_uuid_opentime_map_.insert(std::make_pair(uuid, tv));
}
int inter = 0;
r.read_uint16(len);
for (uint16_t i = 0; i < len; ++i) {
r.read_int64(uuid);
r.read_int32(inter);
uuid_inter_map_.insert(std::make_pair(uuid, inter));
}
r.read_uint16(len);
for (uint16_t i = 0; i < len; ++i) {
r.read_int32(inter);
tv.deserialize(r);
opentime_.insert(std::make_pair(inter, tv));
}
mmuid_.deserialize(r);
// uint32_t inter_u = 0;
// Expedition_Manager_Data emd;
// r.read_uint16(len);
// for (uint16_t i = 0; i < len; ++i) {
// emd.reset();
// r.read_uint32(inter_u);
// emd.deserialize(r);
// inter_manager_data_map_.insert(std::make_pair(inter_u, emd));
// }
return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:39,代码来源:Expedition_Scene_Struct.cpp
示例17: 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;
}
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:16,代码来源:Honor_Arena_Manager.cpp
示例18: 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;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:16,代码来源:Operating.cpp
示例19: save_access_count
void Logic_Public::save_access_count(const Time_Value &now) {
if(now.sec() - access_count_record_time.sec() > Time_Value::ONE_MINUTE_IN_SECS) {
if(access_count.size() == 0) {
access_count_record_time = now;
}
Block_Buffer buf;
buf.make_message(MONGO_SACE_ACCESS_DATA_COUNT);
buf.write_uint8(access_count.size());
for(UInt_UInt_Map::iterator ait = access_count.begin(); ait != access_count.end(); ++ait) {
buf.write_uint32(ait->first);
buf.write_uint32(ait->second);
}
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
access_count.clear();
}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:17,代码来源:Logic_Public.cpp
示例20: offline_firend_add
int Operating::offline_firend_add(role_id_t role_id, role_id_t other_role_id, Time_Value time) {
if (!role_id) {
MSG_USER("error role id");
return -1;
}
Block_Buffer buf;
buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
int type = OPERATING_OFFLINE_FIREND_ADD;
buf.write_int32(type);
buf.write_int64(role_id);
buf.write_int64(other_role_id);
buf.write_int64(time.sec());
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:18,代码来源:Operating.cpp
注:本文中的Time_Value类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论