Comments (14)
1、common中的字段定义的是加载到LUA table表的字段
2、check_rolename_exists这个写改名逻辑的时候用到
3、实际的游戏业务逻辑,可能不需要roleinit这一个消息,一般玩家第一次创建角色的时候就初始化了。
entUserCustom只是在lua table中维护了一个所有玩家的名字table。你要更新user表的其它数据,用entUser
from metoo.
4、如果做了改名操作,你就需要操作entUserCustom这个实体
from metoo.
1、第一个问题config.fields应该改为config.columns
from metoo.
我理解common
表是方便逻辑上全局唯一性查询,所以跟key是分不开的。
但是CommonEntity
中的方法却和UserMultiEntity
和UserSingleEntity
一样以self.pk
来操作,比如
local id = row[self.pk]
if not self.recordset[id] then return end -- 记录不存在,返回
事实上我看了dbmgr
中的方法get_common
,lua map是以key索引的,打印也证实了这点
for _, v in pairs(keys) do
if v ~= tbname..":"..schema[tbname]["pk"] then
local row = do_redis({ "hgetall", v })
row = make_pairs_table(row)
row = convert_record(tbname, row)
local key = make_rediskey(row, config.key)
data[key] = row
end
end
所以才有我上面提到的common表更新的疑问
from metoo.
另外userdc.lua
中的check_role_exists
方法来判断用户是否存在,只是判断了在线用户吧?
userdc
在logout
后不是unload
了吗? recordset里lua map里应该只是在线用户的数据了,我是这么理解的。
楼主这个项目为什么很少维护呢? 我是skynet
菜鸟,从您这学到了很多,正在以metoo
为模板做游戏服务器呢,遇到了不少问题希望能和您多交流。
from metoo.
CommonEntity的语义,我定的不够清晰,CommonEntity的update操作应该不同步到数据库,只是改写lua table,CommonEntity应该大部分情况下存的是一些只读的数据。EntUser EntUserCustom这个比较特殊,改名操作 应该是更新了EntUserCustom的lua table ,但不更新到数据库,更新到数据库操作应该由EntUser这个实体完成。如有必要,可以考虑提供一个CustomEntity做这种特殊操作
from metoo.
check_role_exists 确实的有问题,应该用EntUserCustom去做检查,这样,EntUserCustom这个实体加载的时候还应该加载个uid
from metoo.
metoo是我在上个公司花两周时间做的,然后用在了项目中,可能还不完善,后来就离职了,所以就没怎么更新了。
from metoo.
CommonEntity可能还是需要Add Update这些操作的,我觉得针对这个EntUserCustom最好定义一个CustomEntity实体类会比较好
from metoo.
“EntUserCustom
这个实体加载的时候还应该加载个uid
”,但是uid
和key
都是唯一性key,岂不是需要两个common table
?貌似现在的结构不支持两个相同mysql实体表名的common 元素。
楼主现在不用skynet
了吗?能不能留个邮件以后向你请教。
from metoo.
我认真看了一下代码,check_role_exists是没有问题的,它可以判断离线玩家,因为entUser:getValue获取数据的时候,发现如果是离线的,会从mysql加载到redis再到lua table,所以EntUserCustom也不需要uid,只需要name即可。
from metoo.
也就是说对用户来说,这些实体操作是透明的,你不用担心到底是在线玩家数据,还是离线玩家数据
from metoo.
谢谢
还想请教一个问题,比如竞技场的排名奖励,类似这种系统发放物品,怎么对在线玩家和离线玩家进行分别处理?
离线的直接调用skynet.call("dbsync", "lua", "sync", sql)
往数据库写?
from metoo.
是的,离线写条sql就好了, 玩家在线的时候自然会去加载这个数据的
from metoo.
Related Issues (12)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metoo.