-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdata_main.lua
86 lines (79 loc) · 3.3 KB
/
data_main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
local ffi = require('my_ffi')
require('top_manager')
require('player')
require('tools.task_sch')
require('top_db')
------------------------------------------------------------------------------------------------------------------------------------------
local sizeof = ffi.sizeof
local new = ffi.new
local C = ffi.C
local cast = ffi.cast
local copy = ffi.copy
local processor_ = {}
------------------------------------------------------------------------------------------------------------------------------------------
processor_[C.kGetOtherPlayerOverviewInfo] = function(uid, msg)
local target_id = cast('const GetOtherPlayerOverviewInfo&', msg).uid
if uid==target_id then return end
local res = new('OtherPlayerOverviewInfo', player.GetOverviewInfo(target_id))
return res
end
------------------------------------------------------------------------------------------------------------------------------------------
processor_[C.kGetOtherPlayerBuildings] = function(uid, msg)
local get = cast('const GetOtherPlayerBuildings&', msg)
if uid==get.uid then return end
local res = new('OtherPlayerBuildings')
local count,data,len = player.GetOtherPlayerBuildings(get.uid, get.type)
if count then
res.count = count
copy(res.data, data, len)
end
return res, 2+len
end
------------------------------------------------------------------------------------------------------------------------------------------
processor_[C.kGetOtherPlayerTownInfo] = function(uid, msg)
local get = cast('const GetOtherPlayerTownInfo&', msg)
if uid==get.uid then return end
return player.GetOtherPlayerTownInfo(get.uid)
end
------------------------------------------------------------------------------------------------------------------------------------------
function ProcessMsgFromGate(h, msg, len)
local head = cast('MqHead&', h)
local uid = head.aid
local f = processor_[head.type]
if f then
local res,res_len = f(uid, msg)
if res then
head.type = res.kType
C.Send2Gate(head, res, res_len or sizeof(res))
end
end
end
------------------------------------------------------------------------------------------------------------------------------------------
--初始化排名数据库表
top_manager.GetTop(processor_)
top_manager.UpdateRankDataTable()
top_manager.InitTop()--第一次获取
top_manager.SelectWoshipListTable()--初始化玩家膜拜的内存
local function ReSetPlayerWorship()
--从新数据库排序
top_manager.UpdateRankDataTableExceptSilver()
--重置每天的膜拜数据
top_manager.DayWorshipReset()
--初始化
top_manager.InitTopExceptSilver()
end
CreateTaskSch_Day("23:00",ReSetPlayerWorship)
------------------------------------------------------------------------------------------------------------------------------------------
local function ReSetWeekSilver()
--更新银币排序
top_manager.UpdateRankDataTableSilver()
--初始化
top_manager.InitSilverTop()
--清除所有的膜拜
top_db.ResetWorship()
end
CreateTaskSch_Week("7 00:00",ReSetWeekSilver)
------------------------------------------------------------------------------------------------------------------------------------------
function RunOnce()
end
------------------------------------------------------------------------------------------------------------------------------------------