本文整理汇总了C++中DIFF_TICK函数的典型用法代码示例。如果您正苦于以下问题:C++ DIFF_TICK函数的具体用法?C++ DIFF_TICK怎么用?C++ DIFF_TICK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DIFF_TICK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channel_send
/**
* Sends a message to a channel.
*
* @param chan The destination channel.
* @param sd The source character.
* @param msg The message to send.
*
* If no source character is specified, it'll send an anonymous message.
*/
void channel_send(struct channel_data *chan, struct map_session_data *sd, const char *msg)
{
char message[150];
nullpo_retv(chan);
nullpo_retv(msg);
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
&& !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
safesnprintf(message, 150, "[ #%s ] %s : %s", chan->name, sd->status.name, msg);
clif->channel_msg(chan,sd,message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(sd->status.name,msg);
if (chan->msg_delay != 0)
sd->hchsysch_tick = timer->gettick();
} else {
safesnprintf(message, 150, "[ #%s ] %s", chan->name, msg);
clif->channel_msg2(chan, message);
if (chan->type == HCS_TYPE_IRC)
ircbot->relay(NULL, msg);
}
}
示例2: pet_attackskill
/*==========================================
* Pet Attack Skill [Skotlex]
*------------------------------------------*/
int pet_attackskill(struct pet_data *pd, int target_id)
{
struct block_list *bl;
int inf;
if (!battle_config.pet_status_support || !pd->a_skill ||
(battle_config.pet_equip_required && !pd->pet.equip))
return 0;
if (DIFF_TICK(pd->ud.canact_tick, gettick()) > 0)
return 0;
if (rand()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000))
{ //Skotlex: Use pet's skill
bl=map_id2bl(target_id);
if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) ||
!check_distance_bl(&pd->bl, bl, pd->db->range3))
return 0;
inf = skill_get_inf(pd->a_skill->id);
if (inf & INF_GROUND_SKILL)
unit_skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv);
else //Offensive self skill? Could be stuff like GX.
unit_skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv);
return 1; //Skill invoked.
}
return 0;
}
示例3: push_timer_heap
/*======================================
* CORE : Timer Heap
*--------------------------------------
*/
static void push_timer_heap(int index)
{
int i,h;
if(timer_heap==NULL || timer_heap[0]+1>=timer_heap_max){
int first = timer_heap==NULL;
timer_heap_max += 256;
timer_heap = realloc(timer_heap,sizeof(int)*timer_heap_max);
if(timer_heap==NULL){
printf("out of memory : push_timer_heap\n");
exit(1);
}
if(first)
timer_heap[0]=0;
}
timer_heap[0]++;
for(h=timer_heap[0]-1,i=(h-1)/2;
h>0 && DIFF_TICK(timer_data[index].tick , timer_data[timer_heap[i+1]].tick)<0;
i=(h-1)/2) {
timer_heap[h+1]=timer_heap[i+1],h=i;
}
timer_heap[h+1]=index;
}
示例4: chrif_save_scdata
int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the player and sends it to the char-server for saving. [Skotlex]
#ifdef ENABLE_SC_SAVING
int i, count=0;
unsigned int tick;
struct status_change_data data;
struct status_change *sc = &sd->sc;
const struct TimerData *timer;
chrif_check(-1);
tick = gettick();
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(char_fd,0) = 0x2b1c;
WFIFOL(char_fd,4) = sd->status.account_id;
WFIFOL(char_fd,8) = sd->status.char_id;
for (i = 0; i < SC_MAX; i++) {
if (!sc->data[i])
continue;
if (sc->data[i]->timer != INVALID_TIMER) {
timer = get_timer(sc->data[i]->timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
} else
data.tick = -1; //Infinite duration
data.type = i;
data.val1 = sc->data[i]->val1;
data.val2 = sc->data[i]->val2;
data.val3 = sc->data[i]->val3;
data.val4 = sc->data[i]->val4;
memcpy(WFIFOP(char_fd,14 +count*sizeof(struct status_change_data)),
&data, sizeof(struct status_change_data));
count++;
}
if (count == 0)
return 0; //Nothing to save.
WFIFOW(char_fd,12) = count;
WFIFOW(char_fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
WFIFOSET(char_fd,WFIFOW(char_fd,2));
#endif
return 0;
}
示例5: mercenary_get_lifetime
/**
* Get current Mercenary lifetime
* @param md The Mercenary
* @return The Lifetime
**/
int mercenary_get_lifetime(struct mercenary_data *md) {
const struct TimerData * td;
if( md == NULL || md->contract_timer == INVALID_TIMER )
return 0;
td = get_timer(md->contract_timer);
return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
}
示例6: elemental_get_lifetime
int elemental_get_lifetime(struct elemental_data *ed) {
const struct TimerData * td;
if( ed == NULL || ed->summon_timer == INVALID_TIMER )
return 0;
td = get_timer(ed->summon_timer);
return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
}
示例7: bg_send_xy_timer_sub
int bg_send_xy_timer_sub(DBKey key, void *data, va_list ap)
{
struct battleground_data *bg = (struct battleground_data *)data;
struct map_session_data *sd;
char output[128];
int i, m;
nullpo_ret(bg);
m = map_mapindex2mapid(bg->mapindex);
bg->reveal_flag = !bg->reveal_flag; // Switch
for( i = 0; i < MAX_BG_MEMBERS; i++ )
{
if( (sd = bg->members[i].sd) == NULL )
continue;
if( battle_config.bg_idle_autokick && DIFF_TICK(last_tick, sd->idletime) >= battle_config.bg_idle_autokick && bg->g )
{
sprintf(output, "- AFK [%s] Kicked -", sd->status.name);
clif_broadcast2(&sd->bl, output, (int)strlen(output)+1, bg->color, 0x190, 20, 0, 0, BG);
bg_team_leave(sd,3);
clif_displaymessage(sd->fd, "You have been kicked from Battleground because of your AFK status.");
pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3);
continue;
}
if( sd->bl.x != bg->members[i].x || sd->bl.y != bg->members[i].y )
{ // xy update
bg->members[i].x = sd->bl.x;
bg->members[i].y = sd->bl.y;
clif_bg_xy(sd);
}
if( bg->reveal_pos && bg->reveal_flag && sd->bl.m == m ) // Reveal each 4 seconds
map_foreachinmap(bg_reveal_pos,m,BL_PC,sd,1,bg->color);
if( battle_config.bg_idle_announce && !sd->state.bg_afk && DIFF_TICK(last_tick, sd->idletime) >= battle_config.bg_idle_announce && bg->g )
{ // Idle announces
sd->state.bg_afk = 1;
sprintf(output, "%s : %s seens to be away. AFK Warning - Can be kicked out with @reportafk", bg->g->name, sd->status.name);
clif_bg_message(bg, bg->bg_id, bg->g->name, output, strlen(output) + 1);
}
}
return 0;
}
示例8: check_ttl_wisdata_sub
// Existence check of WISP data
int check_ttl_wisdata_sub(void *key, void *data, va_list ap) {
unsigned long tick;
struct WisData *wd = (struct WisData *)data;
tick = va_arg(ap, unsigned long);
if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
wis_dellist[wis_delnum++] = wd->id;
return 0;
}
示例9: check_ttl_wisdata_sub
/**
* Existence check of WISP data
* @see DBApply
*/
int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
{
int64 tick;
struct WisData *wd = DB->data2ptr(data);
tick = va_arg(ap, int64);
if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
wis_dellist[wis_delnum++] = wd->id;
return 0;
}
示例10: auth_db_cleanup_sub
int auth_db_cleanup_sub(DBKey key,void *data,va_list ap)
{
struct auth_node *node=(struct auth_node*)data;
if(DIFF_TICK(gettick(),node->node_created)>30000) {
ShowNotice("Character (aid: %d) not authed within 30 seconds of character select!\n", node->account_id);
if (node->char_dat)
aFree(node->char_dat);
db_remove(auth_db, key);
return 1;
}
return 0;
}
示例11: check_ttl_wislist
// Wisリストの生存チェック
int check_ttl_wislist()
{
unsigned long tick=gettick();
struct WisList* p=wis_list, **prev=&wis_list;
for( ; p; prev=&p->next,p=p->next ){
if( DIFF_TICK(tick,p->tick)>WISLIST_TTL ){
*prev=p->next;
free(p);
p=*prev;
}
}
return 0;
}
示例12: bg_block_skill_status
void bg_block_skill_status(struct battleground_data *bg, int skillnum)
{
const struct TimerData * td;
char output[128];
int seconds, idx;
idx = battle_config.guild_skills_separed_delay ? skillnum - GD_SKILLBASE : 0;
if( bg == NULL || bg->g == NULL || idx < 0 || idx >= MAX_GUILDSKILL || bg->skill_block_timer[idx] == INVALID_TIMER )
return;
if( (td = get_timer(bg->skill_block_timer[idx])) == NULL )
return;
seconds = DIFF_TICK(td->tick,gettick())/1000;
sprintf(output, "%s : Cannot use team skill %s. %d seconds remaining...", bg->g->name, skill_get_desc(skillnum), seconds);
clif_bg_message(bg, bg->bg_id, bg->g->name, output, strlen(output) + 1);
}
示例13: mail_send
/**
* Attempt to send mail
* @param sd Sender
* @param dest_name Destination name
* @param title Mail title
* @param body_msg Mail message
* @param body_len Message's length
*/
void mail_send(struct map_session_data *sd, const char *dest_name, const char *title, const char *body_msg, int body_len) {
struct mail_message msg;
nullpo_retv(sd);
if( sd->state.trading )
return;
if( DIFF_TICK(sd->cansendmail_tick, gettick()) > 0 ) {
clif_displaymessage(sd->fd,msg_txt(sd,675)); //"Cannot send mails too fast!!."
clif_Mail_send(sd->fd, true); // fail
return;
}
if( body_len > MAIL_BODY_LENGTH )
body_len = MAIL_BODY_LENGTH;
if( !mail_setattachment(sd, &msg) ) { // Invalid Append condition
clif_Mail_send(sd->fd, true); // fail
mail_removeitem(sd,0);
mail_removezeny(sd,0);
return;
}
msg.id = 0; // id will be assigned by charserver
msg.send_id = sd->status.char_id;
msg.dest_id = 0; // will attempt to resolve name
safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH);
safestrncpy(msg.dest_name, (char*)dest_name, NAME_LENGTH);
safestrncpy(msg.title, (char*)title, MAIL_TITLE_LENGTH);
if (msg.title[0] == '\0') {
return; // Message has no length and somehow client verification was skipped.
}
if (body_len)
safestrncpy(msg.body, (char*)body_msg, body_len + 1);
else
memset(msg.body, 0x00, MAIL_BODY_LENGTH);
msg.timestamp = time(NULL);
if( !intif_Mail_send(sd->status.account_id, &msg) )
mail_deliveryfail(sd, &msg);
sd->cansendmail_tick = gettick() + battle_config.mail_delay; // Flood Protection
}
示例14: channel_send
/**
* Format message from player to send to the channel
* - Also truncate extra characters if message is too long
* @param channel: Channel data
* @param sd: Player data
* @param msg: Message to send
* @return
* 0: Success
* -1: Invalid player, channel, or message
* -2: Delay message from last message
*/
int channel_send(struct Channel *channel, struct map_session_data *sd, const char *msg) {
int idx = 0;
if(!channel || !sd || !msg || (idx = channel_pc_haschan(sd, channel)) < 0)
return -1;
if(!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && DIFF_TICK(sd->channel_tick[idx] + channel->msg_delay, gettick()) > 0) {
clif_messagecolor(&sd->bl,color_table[COLOR_RED],msg_txt(sd,1455),false,SELF); //You're talking too fast!
return -2;
}
else {
char output[CHAT_SIZE_MAX];
unsigned long color = channel->color;
if((channel->opt&CHAN_OPT_COLOR_OVERRIDE) && sd->fontcolor && sd->fontcolor < channel_config.colors_count && channel_config.colors[sd->fontcolor])
color = channel_config.colors[sd->fontcolor];
safesnprintf(output, CHAT_SIZE_MAX, "%s %s : %s", channel->alias, sd->status.name, msg);
clif_channel_msg(channel,output,color);
sd->channel_tick[idx] = gettick();
}
return 0;
}
示例15: auth_db_cleanup_sub
/**
* This can still happen (client times out while waiting for char to confirm auth data)
* @see DBApply
*/
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
if(DIFF_TICK(gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
//Re-save attempt (->sd should never be null here).
node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
chrif_save(node->sd, 1);
break;
default:
//Clear data. any connected players should have timed out by now.
ShowInfo("auth_db: Node (state %s) timed out for %d:%d\n", states[node->state], node->account_id, node->char_id);
chrif_char_offline_nsd(node->account_id, node->char_id);
chrif_auth_delete(node->account_id, node->char_id, node->state);
break;
}
return 1;
}
return 0;
}