Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
f52d970ea6
|
@ -703,6 +703,20 @@ public class RedisUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//操作sortset score<<32+time
|
||||||
|
public void zsetAddOneOffsetByTime(String key, String uid, int score){
|
||||||
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
|
try {
|
||||||
|
long s= (long)score<<40;
|
||||||
|
long sort = s+(0xFFFFFFFFFFL-(int)(System.currentTimeMillis()/1000));
|
||||||
|
redisTemplate.opsForZSet().add(key, uid, sort);
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
TimeUtils.sleep(FAILED_SLEEP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void zsetRemoveOne(String key, String value){
|
public void zsetRemoveOne(String key, String value){
|
||||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -772,6 +786,7 @@ public class RedisUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getZSetreverseRank(String type,String key, String value){
|
public Long getZSetreverseRank(String type,String key, String value){
|
||||||
String rkey = getKey(type,key);
|
String rkey = getKey(type,key);
|
||||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
|
|
|
@ -2257,7 +2257,7 @@ public class MapLogic {
|
||||||
|
|
||||||
//排行榜
|
//排行榜
|
||||||
String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false);
|
String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false);
|
||||||
RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(user.getId()), checkFightId+1);
|
RedisUtil.getInstence().zsetAddOneOffsetByTime(rankKey, String.valueOf(user.getId()), checkFightId);
|
||||||
|
|
||||||
//归还水滴
|
//归还水滴
|
||||||
Map<Integer,Integer> itemMap = new HashMap<>(1);
|
Map<Integer,Integer> itemMap = new HashMap<>(1);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class GetMonsterAttackRankHandler extends BaseHandler<PlayerInfoProto.Get
|
||||||
|
|
||||||
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
|
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
|
||||||
String value = item.getValue();
|
String value = item.getValue();
|
||||||
int score = item.getScore().intValue();
|
int score = (int)(item.getScore().longValue()>>40);
|
||||||
int uid = Integer.parseInt(value);
|
int uid = Integer.parseInt(value);
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class GetMonsterAttackRankHandler extends BaseHandler<PlayerInfoProto.Get
|
||||||
}
|
}
|
||||||
|
|
||||||
int uid = iSession.getUid();
|
int uid = iSession.getUid();
|
||||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.MONSTER_ATTACK_RANK, "", Integer.toString(uid)).intValue();
|
int score = (int)(RedisUtil.getInstence().getZSetScore(RedisKey.MONSTER_ATTACK_RANK, "", Integer.toString(uid)).longValue()>>40);
|
||||||
int myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.MONSTER_ATTACK_RANK, "", Integer.toString(uid)).intValue();
|
int myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.MONSTER_ATTACK_RANK, "", Integer.toString(uid)).intValue();
|
||||||
if(myRank>300){
|
if(myRank>300){
|
||||||
score=-1;
|
score=-1;
|
||||||
|
|
Loading…
Reference in New Issue