timers.h

来自「This programm is proxy server for ragnar」· C头文件 代码 · 共 71 行

H
71
字号
#ifndef __TIMERS_H
#define __TIMERS_H

#pragma once

#pragma warning(disable:4786)  // anti-STL
#include <set>

#include "win_and_sock.h"
#include "data.h" // ParsePoint

// timer tags
enum {
    TTAG_ALL = 0,
    TTAG_WALK,
    TTAG_LOOT
};

// timer ids
enum {
    TID_NULL = 0,
    TID_WALK,
    TID_LOOT_HERE,
    TID_LOOT_ALL
};

typedef DWORD (*TimerFuncT)(ParsePoint * pp, DWORD timestamp);

class stl_class_timer
{
public:
    DWORD tick;
    TimerFuncT timer_func;
    DWORD tag;
    DWORD id;
    ParserFuncT timer_death;
    

	// constructor
	stl_class_timer(DWORD ttick=0, 
                    TimerFuncT tfunc=NULL, 
                    DWORD ttag=TTAG_ALL, DWORD tid=0,
                    ParserFuncT tdeath=NULL)
	{
		tick = ttick;
		timer_func = tfunc;
        tag = ttag;
        id = tid;
        timer_death = tdeath;
	}
};

bool operator<(stl_class_timer first, stl_class_timer second);

typedef std::set <stl_class_timer> TimersSetT;

//////////////////////

TimersSetT::iterator register_timer(DWORD tick, TimerFuncT parse_func, 
                                    DWORD tag, DWORD id,
                                    ParserFuncT tdeath=NULL
                                    );

int call_timers(ParsePoint * pp);

// DO NOT KILL timers in the `timer_func`!!! Do `return 0` instead.
void kill_timer(DWORD id);
void kill_all_timers(void);
void kill_timers_byTag(DWORD tag);

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?