1 Star 0 Fork 0

liuxuezhan/mylib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
LC_GM.go 40.68 KB
一键复制 编辑 原始数据 按行查看 历史
liuxuezhan 提交于 2020-12-19 16:15 . 'ok'
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
package logic
import (
"encoding/json"
"math/rand"
"strings"
"time"
csv "gitee.com/liuxuezhan/mylib/GameServer/CSV"
"gitee.com/liuxuezhan/mylib/GameServer/GameDB"
"gitee.com/liuxuezhan/mylib/GameServer/JsonConfig"
"gitee.com/liuxuezhan/mylib/GameServer/cache"
"gitee.com/liuxuezhan/mylib/GameServer/observer"
"gitee.com/liuxuezhan/mylib/GameServer/oss"
proto "gitee.com/liuxuezhan/mylib/Protocol"
"gitee.com/liuxuezhan/mylib/Utils/wlog"
"gitee.com/liuxuezhan/mylib/common"
"gitee.com/liuxuezhan/mylib/wtime"
"github.com/kataras/go-errors"
"gopkg.in/mgo.v2/bson"
)
var (
GMCommandHandlerMap map[string]func(string) (error, string)
)
func getBuildingID(buildings []*proto.ST_Building_PB, buildingType uint32) []uint32 {
ret := make([]uint32, 0)
for _, v := range buildings {
if v.GetBuildingtype() == buildingType {
ret = append(ret, v.GetBuildingID())
}
}
return ret
}
func SetBuildingLevel(userData *cache.Info, buildinglevel uint32) {
buildingAsset := userData.GetBuildings()
for _, v := range csv.Mgr.CSV_BuildingConfig.GetIDList() {
bConfig := csv.Mgr.CSV_BuildingConfig.GetEntryPtr(v)
if bConfig.TagType == 4 || bConfig.IsDisuse == 1 {
continue
}
maxCount := int(bConfig.MaxCount)
maxlevel := uint32(bConfig.MaxLevel)
if buildinglevel < maxlevel {
maxlevel = buildinglevel
}
buildingIDList := getBuildingID(buildingAsset, uint32(v))
for _, v := range buildingIDList {
userData.SetBuildingLevel(v, maxlevel)
if bConfig.Type == int64(proto.BuildingType_BT_BASE_STATION) {
userData.SetMainCityLevel(maxlevel)
wdata := cache.Instance_GlobalAssetWorldData.GetWorldData(userData.GetWorldDataId())
if wdata != nil {
dataEntry := wdata.GetWorldDataEntry()
dataEntry.Z = proto.SetInt32(int32(maxlevel))
wdata.SetWorldDataEntry(dataEntry)
}
//>>>主城升级事件
observer.ObserverSingleton.AsyncNotify(observer.MainCityLevelUpgradeEvent, []interface{}{userData})
}
}
needAdd := maxCount - len(buildingIDList)
for i := 0; i < needAdd; i++ {
width := uint32(bConfig.Width)
height := uint32(bConfig.Height)
find := false
var x, y uint32
for {
x = uint32(common.GetRandomNum(150))
y = uint32(common.GetRandomNum(150))
tileid := common.ConvertMainCityCoordinateToId(x, y)
if cache.SafeCheckTileCanUse(userData, x, y, width, height) && userData.CheckBuildingIndex(tileid, width, height) {
find = true
break
}
}
if find {
tileid := common.ConvertMainCityCoordinateToId(x, y)
bID := userData.AllocBuildingID()
userData.AddBuildingWithLevel(tileid, bID, uint32(v), maxlevel)
//userData.UpdateBuildingIndex(tileid, width, height, bID)
if bConfig.Type == int64(proto.BuildingType_BT_BASE_STATION) {
wdata := cache.Instance_GlobalAssetWorldData.GetWorldData(userData.GetWorldDataId())
if wdata != nil {
dataEntry := wdata.GetWorldDataEntry()
dataEntry.Z = proto.SetInt32(int32(maxlevel))
wdata.SetWorldDataEntry(dataEntry)
}
//>>>主城升级事件
observer.ObserverSingleton.AsyncNotify(observer.MainCityLevelUpgradeEvent, []interface{}{userData})
}
if bConfig.Type == int64(proto.BuildingType_BT_EQUIP_FACTORY) {
processFactoryLevelUp(userData)
}
}
}
}
}
func ResetBuildingPos(userData *cache.Info) {
buildingAsset := userData.GetBuildings()
for _, v := range buildingAsset {
bConfig := csv.Mgr.CSV_BuildingConfig.GetEntryPtr(int64(v.GetBuildingtype()))
if bConfig.TagType == 4 {
continue
}
width := uint32(bConfig.Width)
height := uint32(bConfig.Height)
find := false
var x, y uint32
for {
x = uint32(common.GetRandomNum(150))
y = uint32(common.GetRandomNum(150))
tileid := common.ConvertMainCityCoordinateToId(x, y)
if cache.SafeCheckTileCanUse(userData, x, y, width, height) && userData.CheckBuildingIndex(tileid, width, height) {
find = true
break
}
}
if find {
userData.UpdateBuildingLocation(v.GetBuildingID(), x, y)
}
}
}
func DropTest(userData *cache.Info, dropid int32) bool {
itemList := csv.GetDropItem(dropid)
wlog.Info(itemList)
for _, v := range itemList {
AddItem(userData, v.GetItemId(), v.GetItemNum(), oss.AddCashSrcTypeGM)
}
return true
}
/**
@brief GM发送邮件
*/
func SendGMMail(userData *cache.Info) {
title := "此处应该是title"
content := "此处应该是content"
details := "内容还是省略吧"
if 0 == rand.Int()%2 {
for i := 0; i < 10; i++ {
userData.AddTextMailAsset(uint32(proto.MailType_MT_SYSTEM), 0, userData.GetUid(), 0, int32(proto.MailSourceType_MST_GM), title, content, "", details, "", -1)
}
} else {
title := "还是给点奖励吧"
itemIdList := csv.Mgr.CSV_ItemList.GetIDList()
rewardList := &proto.ST_MailRewardList_PB{}
for i := 0; i < int(rand.Int31n(5)); i++ {
randomIndex := rand.Int31n(int32(len(itemIdList)))
entry := csv.Mgr.CSV_ItemList.GetEntryPtr(itemIdList[randomIndex])
rewardList.Reward = append(rewardList.Reward, &proto.ST_Vector4Int_PB{
X: proto.SetInt32(2),
Y: proto.SetInt32(int32(entry.ID)),
Z: proto.SetInt32(1),
W: proto.SetInt32(int32(rand.Int31n(10) + 1)),
})
}
rewardStr := string(proto.Marshal(rewardList))
for i := 0; i < 10; i++ {
userData.AddTextMailAsset(uint32(proto.MailType_MT_SYSTEM), 0, userData.GetUid(), 0, int32(proto.MailSourceType_MST_GM), title, content, rewardStr, details, "", -1)
}
}
}
func ExeGMCommand(command, params string) (error, string) {
if handler, ok := GMCommandHandlerMap[command]; ok {
wlog.Info("ExeGMCommand ", command)
return handler(params)
}
return errors.New("query type error"), ""
}
func registerGMCommandHandler() {
GMCommandHandlerMap = map[string]func(string) (error, string){
"10": handleQueryAccountInfo,
"11": handleQueryCharBasicInfo,
"14": handleQueryItemPack,
"18": handleQueryHero,
"19": handleQueryBuilding,
"110": handleQueryUnit,
"111": handleQueryTech,
"15": handleQueryTalent,
"37": handleQueryPower,
"38": handleQueryPayHistory30,
"39": handleQueryStatistics,
"40": handleQueryForbiddenInfo,
"410": handleQueryResource,
"41": handleForbiddenChatAll,
"42": handleOpenChatAll,
"43": handleForbidLogin,
"44": handleOpenLogin,
"45": handleKickOut,
"46": handleForbidChatWorld,
"47": handleOpenChatWorld,
"48": handleForbidChatLeague,
"49": handleOpenChatLeague,
"411": handleModifyResource,
"71": handleQueryServerStatus,
"412": handleModifySpecialItem,
"21": handleAndEveryoneMail,
"22": handleRemoveEveryoneMail,
"10000": handleKickOutAll,
"60": handleGiftPackOperator,
"63": handleOfferGiftOperator,
"51": handleArchonNoticeOperator,
"52": handleQueryArchonNotice,
"50": handleSendGlobalMessage,
"80": handleBoonActivityOper,
"82": handleQueryBoonActivity,
"84": handleLuckyStarOperator,
"85": handleWorldSituationSet,
"87": handleAddTBActivity,
"88": handleCloseTBActivity,
"90": handleAddStrongestCommander,
"91": handleCloseStrongestCommander,
}
}
func handleWorldSituationSet(num string) (error, string) {
err, ret := WorldSituationSet(common.StringToUint64(num))
ret = common.Base64Encode(string(ret))
if err == "" {
return nil, ret
} else {
return errors.New(err), ret
}
}
func handleQueryCharBasicInfo(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
basicInfo := &proto.ST_GM_CharBasic_PB{
Uid: proto.SetUint64(userData.GetUid()),
Name: proto.SetString(userData.GetUserName()),
VipLevel: proto.SetUint32(userData.GetVipLevel()),
LeagueID: proto.SetUint64(userData.GetLeagueID()),
Resource: userData.GetCashAsset(),
Power: proto.SetUint64(userData.GetPower()),
LeagueName: proto.SetString(userData.GetLeagueName()),
CreateTime: proto.SetUint64(userData.GetCreateTime()),
CommanderLevel: proto.SetUint32(userData.GetLevel()),
BaseLevel: proto.SetUint32(userData.GetMainCityLevel()),
Language: proto.SetUint32(userData.GetLanguage()),
Channel: proto.SetUint32(0),
LeagueLevel: proto.SetInt32(cache.Instance_GlobalAssetLeague.GetMemberLevel(userData.GetLeagueID(), userData.GetUid())),
KillNum: proto.SetUint64(userData.GetKillUnitNum()),
Location: proto.SetInt32(userData.GetLocation()),
Sid: proto.SetUint64(uint64(JsonConfig.GlobalConfig.Basic.ServerID)),
TotalPay: proto.SetUint32(userData.GetTotalPay()),
CurLabel: proto.SetUint64(userData.GetCurLabel()),
IP: proto.SetString(userData.GetIP()),
}
if cache.Sessionkey.IsRealOnline(uid) {
basicInfo.OnlineStatus = proto.SetUint32(1)
}
if userData.GetForbidLogin() > wtime.GetNow() {
basicInfo.ForbiddenTime = proto.SetUint64(userData.GetForbidLogin())
basicInfo.ForbiddenStatus = proto.SetUint32(1)
}
b := proto.Marshal(basicInfo)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryAccountInfo(params string) (error, string) {
cname := params
if len(cname) <= 0 {
return errors.New("cname error"), ""
}
err, accounts := GameDB.Characteristic.FindUsersByName(cname, bson.M{"_id": 1, "user_name": 1}, 50)
if err != nil {
return errors.New("query err"), ""
}
accountInfos := &proto.ST_AccountInfos_PB{}
for _, v := range accounts {
info := &proto.ST_AccountInfo_PB{
Uid: proto.SetUint32(uint32(v.UserId)),
Name: proto.SetString(v.UserName),
}
accountInfos.Infos = append(accountInfos.Infos, info)
}
b := proto.Marshal(accountInfos)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryItemPack(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
asset := userData.GetItemPackAsset()
b := proto.Marshal(asset)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryPayHistory30(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
asset := userData.GetHistory30()
b := proto.Marshal(asset)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryHero(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
heros := userData.GetAllHero()
b := proto.Marshal(heros)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryBuilding(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
buildingAsset := &proto.ST_GM_Buildings_PB{}
for _, v := range userData.GetBuildings() {
building := &proto.ST_GM_Building_PB{
BuildingID: proto.SetUint32(v.GetBuildingID()),
X: proto.SetUint32(v.GetX()),
Y: proto.SetUint32(v.GetY()),
Buildingtype: proto.SetUint32(v.GetBuildingtype()),
Buildinglevel: proto.SetUint32(v.GetBuildinglevel()),
}
userData.SafeForeachLocalAction(true, func(action *proto.ST_LocalActionEntry_PB) bool {
if action.GetBuildingID() == v.GetBuildingID() &&
(action.GetActiontype() == uint32(proto.ActionType_AT_BUILD_LEVELUP) || action.GetActiontype() == uint32(proto.ActionType_AT_BUILD_EMPTY)) {
building.Status = proto.SetUint32(1)
return false
}
return true
})
buildingAsset.Buildings = append(buildingAsset.Buildings, building)
}
b := proto.Marshal(buildingAsset)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryUnit(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
unitAsset := userData.GetUnitAsset()
if unitAsset == nil || unitAsset.Units == nil {
unitAsset = &proto.ST_UnitAsset_PB{
Units: make([]*proto.ST_Unit_PB, 0),
}
}
for _, v := range userData.GetGlobalActionIDs() {
action := cache.Instance_GlobalAssetGlobalAction.GetGlobalActionAsset(v)
if nil != action && (action.Actiondata.GetActiontype() > uint32(proto.ActionType_AT_WORLDMAP_BEGIN) &&
action.Actiondata.GetActiontype() < uint32(proto.ActionType_AT_WORLDMAP_END)) && action.Actiondata.GetHit() == 0 {
if action.Actiondata.GetUnits() != nil {
unitAsset.Units = common.CombineUnitMap(unitAsset.Units, action.Actiondata.GetUnits().Units)
}
}
}
b := proto.Marshal(unitAsset)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryTech(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
b := proto.Marshal(userData.GetResearchAsset())
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryTalent(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
b := proto.Marshal(userData.GetTalentAsset())
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryPower(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
totalPower := uint64(0)
powerPB := &proto.ST_GM_Power_PB{}
powerPB.BuildingPower = proto.SetUint64(userData.CalcBuildingPower())
powerPB.HeroPower = proto.SetUint64(userData.CalcAllHeroPower())
powerPB.TechPower = proto.SetUint64(userData.CalcResearchPower())
powerPB.TelentPower = proto.SetUint64(userData.CalcTelentPower())
powerPB.UnitPower = proto.SetUint64(userData.CalcUnitPower())
powerPB.LorderPower = proto.SetUint64(userData.CalcLordPower())
totalPower = powerPB.GetBuildingPower() + powerPB.GetHeroPower() + powerPB.GetTechPower() + powerPB.GetTelentPower() +
powerPB.GetUnitPower() + powerPB.GetLorderPower()
powerPB.TotalPower = proto.SetUint64(totalPower)
b := proto.Marshal(powerPB)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryStatistics(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
b := proto.Marshal(userData.CopyStatisticsAsset())
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryForbiddenInfo(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
forbidden := &proto.ST_GM_Forbidden_PB{}
forbidden.ForbiddenChat = userData.GetForbidChatInfo()
startTime, dur, msg := userData.GetForbidLoginInfo()
forbidden.ForbiddenLoginStart = proto.SetUint64(startTime)
forbidden.ForbiddenLoginDur = proto.SetUint64(dur)
forbidden.ForbiddenLoginMsg = proto.SetString(msg)
b := proto.Marshal(forbidden)
result := common.Base64Encode(string(b))
return nil, result
}
func handleQueryResource(params string) (error, string) {
uid := common.StringToUint64(params)
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
resourceInfo := &proto.ST_GM_Resource_PB{
Uid: proto.SetUint64(uid),
Name: proto.SetString(userData.GetUserName()),
RegionID: proto.SetUint32(0),
CreateTime: proto.SetUint64(userData.GetCreateTime()),
Resource: userData.GetCashAsset(),
}
b := proto.Marshal(resourceInfo)
result := common.Base64Encode(string(b))
return nil, result
}
func handleForbiddenChatAll(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
now := wtime.GetNow()
endTime := common.StringToUint64(p[1])
msg := p[2]
if endTime < now {
return errors.New("param time error"), ""
}
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_ALL_CHAT), endTime-now, msg)
if userData.GetLeagueID() != 0 {
ForbidLeagueChat(userData.GetLeagueID(), userData.GetUid(), endTime-now)
}
return nil, ""
}
func handleOpenChatAll(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
msg := p[2]
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_ALL_CHAT), 0, msg)
if userData.GetLeagueID() != 0 {
ForbidLeagueChat(userData.GetLeagueID(), userData.GetUid(), 1)
}
return nil, ""
}
func handleForbidLogin(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
now := wtime.GetNow()
endTime := common.StringToUint64(p[1])
msg := p[2]
if endTime < now {
return errors.New("param time error"), ""
}
userData.SetForbidLogin(endTime-now, msg)
cache.Sessionkey.Delete(uid)
return nil, ""
}
func handleOpenLogin(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
msg := p[2]
userData.SetForbidLogin(0, msg)
return nil, ""
}
func handleKickOut(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
cache.Sessionkey.Delete(uid)
return nil, ""
}
func handleKickOutAll(params string) (error, string) {
cache.Sessionkey.DeleteAll()
return nil, ""
}
func handleForbidChatWorld(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
now := wtime.GetNow()
endTime := common.StringToUint64(p[1])
msg := p[2]
if endTime < now {
return errors.New("param time error"), ""
}
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_WORLD_CHAT), endTime-now, msg)
return nil, ""
}
func handleOpenChatWorld(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
msg := p[2]
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_WORLD_CHAT), 0, msg)
return nil, ""
}
func handleForbidChatLeague(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
now := wtime.GetNow()
endTime := common.StringToUint64(p[1])
msg := p[2]
if endTime < now {
return errors.New("param time error"), ""
}
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_LEAGUE_CHAT), endTime-now, msg)
if userData.GetLeagueID() != 0 {
ForbidLeagueChat(userData.GetLeagueID(), userData.GetUid(), endTime-now)
}
return nil, ""
}
func handleOpenChatLeague(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 3 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
msg := p[2]
userData.SetForbidChat(uint32(proto.ForbiddenChatType_FCT_LEAGUE_CHAT), 0, msg)
if userData.GetLeagueID() != 0 {
ForbidLeagueChat(userData.GetLeagueID(), userData.GetUid(), 1)
}
return nil, ""
}
func handleQueryServerStatus(params string) (error, string) {
serverStatus := &proto.ST_GM_ServerStatus_PB{
ServerID: proto.SetUint32(JsonConfig.GlobalConfig.Basic.ServerID),
ServerName: proto.SetString(JsonConfig.GlobalConfig.Basic.ServerName),
OnlineCount: proto.SetUint32(cache.Sessionkey.Count()),
MaxLimit: proto.SetUint32(0),
GameVersion: proto.SetString(""),
ServerStatus: proto.SetUint32(0),
}
b := proto.Marshal(serverStatus)
result := common.Base64Encode(string(b))
return nil, result
}
func handleModifyResource(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 5 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
if common.StringToInt32(p[4]) < 0 {
return errors.New("number error"), ""
}
itemType := p[1]
if itemType == "410" {
cashType := common.StringToUint32(p[2])
if cashType != uint32(proto.CashType_CASH_TYPE_1) &&
cashType != uint32(proto.CashType_CASH_TYPE_2) &&
cashType != uint32(proto.CashType_CASH_TYPE_3) &&
cashType != uint32(proto.CashType_CASH_TYPE_4) &&
cashType != uint32(proto.CashType_CASH_TYPE_5) &&
cashType != uint32(proto.CashType_CASH_TYPE_100) &&
cashType != uint32(proto.CashType_CASH_TYPE_EXPEDITION) {
return errors.New("item id err"), ""
}
status := p[3]
number := common.StringToUint64(p[4])
if status == "1" || status == "3" {
userData.AddCash(cashType, number, oss.AddCashSrcTypeGM)
} else if status == "2" {
if !userData.ReduceCash(cashType, number, oss.ReduceCashSrcTypeGM) {
return errors.New("number error"), ""
}
} else {
return errors.New("status err"), ""
}
} else if itemType == "14" {
itemID := common.StringToInt64(p[2])
if !csv.Mgr.CSV_ItemList.ContainsID(itemID) {
return errors.New("item id err"), ""
}
status := p[3]
number := common.StringToUint32(p[4])
if status == "1" || status == "3" {
AddItem(userData, uint32(itemID), number, oss.AddCashSrcTypeGM)
} else if status == "2" {
if !userData.CheckItem(uint32(itemID), number) {
return errors.New("number error"), ""
}
userData.ReduceItem(uint32(itemID), number, oss.ReduceCashSrcTypeGM)
} else {
return errors.New("status err"), ""
}
} else {
return errors.New("item type err"), ""
}
return nil, ""
}
func handleModifySpecialItem(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 4 {
return errors.New("param count error"), ""
}
uid := common.StringToUint64(p[0])
userData := cache.GetCharinfo(uid)
if nil == userData {
return errors.New("uid error"), ""
}
itemType := p[1]
switch itemType {
case "18":
itemStr := p[2]
type Hero struct {
Name string
Id string
Level string
Quality string
}
hero := &Hero{}
err := json.Unmarshal([]byte(itemStr), hero)
if err != nil {
return err, ""
}
id := common.StringToUint32(hero.Id)
star := common.StringToUint32(hero.Quality)
level := common.StringToUint32(hero.Level)
userData.InitHeroByParm(id, level, star)
case "19":
{
type Building struct {
Name string `json:"name"`
Location string `json:"location"`
Id string `json:"id"`
Index string `json:"index"`
Level string `json:"level"`
Status string `json:"status"`
}
itemStr := p[2]
building := &Building{}
err := json.Unmarshal([]byte(itemStr), building)
if err != nil {
return err, ""
}
buidingId := common.StringToUint32(building.Index)
buildingAsset := userData.GetBuildingAssetByBuildingId(buidingId)
if nil == buildingAsset {
return errors.New("building id err"), ""
}
del := p[3]
if del == "0" {
userData.DeleteBuildingAsset(buidingId)
return nil, ""
}
buildingType := common.StringToUint32(building.Id)
if buildingAsset.GetBuildingtype() != buildingType {
return errors.New("building id err"), ""
}
level := common.StringToUint32(building.Level)
if level != buildingAsset.GetBuildinglevel() {
buildingConf := csv.GetDoubleKeyBuildingLevel(buildingType, level)
if nil == buildingConf {
return errors.New("building level err"), ""
}
conf := csv.Mgr.CSV_BuildingConfig.GetEntryPtr(int64(buildingType))
if nil == conf {
return errors.New("buildng type err"), ""
}
userData.SetBuildingLevel(buidingId, level)
if conf.Type == int64(proto.BuildingType_BT_BASE_STATION) {
wdata := cache.Instance_GlobalAssetWorldData.GetWorldData(userData.GetWorldDataId())
if wdata != nil {
dataEntry := wdata.GetWorldDataEntry()
dataEntry.Z = proto.SetInt32(int32(level))
wdata.SetWorldDataEntry(dataEntry)
}
//>>>主城升级事件
observer.ObserverSingleton.AsyncNotify(observer.MainCityLevelUpgradeEvent, []interface{}{userData})
}
}
}
default:
return errors.New("item type err"), ""
}
return nil, ""
}
func handleAndEveryoneMail(params string) (error, string) {
everyoneMail := &proto.ST_EveryOneMail{}
err := proto.Unmarshal([]byte(params), everyoneMail)
if err != nil {
return err, ""
}
cache.EveryoneMail.AddEveryoneMailAsset(everyoneMail.GetReward(), everyoneMail.Content)
return nil, ""
}
func handleRemoveEveryoneMail(params string) (error, string) {
cache.EveryoneMail.RemoveEveryoneMailAsset(params)
return nil, ""
}
/**
@brief 实时更新OSS变化礼包
*/
func syncOssGiftInfo(giftPackConfig *proto.ST_GiftPackConfig) {
v := giftPackConfig
packEntry := csv.Mgr.CSV_GiftPackList.GetEntryPtr(int64(v.GetGiftId()))
if packEntry == nil {
return
}
entry := csv.Mgr.CSV_GiftList.GetEntryPtr(int64(packEntry.StartGiftID))
if nil == entry {
return
}
// 此处只处理在线玩家的礼包删除
if v.GetOpType() != 3 {
return
}
wlog.Info("delete gift pack begin---------------------------------")
// 如果是当前正在开启的礼包则修改玩家资产
now := wtime.GetNow()
if now >= v.GetRunTime() && now <= v.GetCloseTime() {
cache.ForeachUser(func(userData *cache.Info) bool {
if !userData.IsRealOnline() {
return true
}
giftAsset := userData.GetGiftAsset()
_, giftIndex := userData.CheckGiftIndex(entry)
if giftIndex != -1 {
giftData := giftAsset.AssetData.GiftList[giftIndex]
giftAsset.Lock()
// 删除直接设置endtime 为 0
giftData.EndTimeStamp = proto.SetUint64(0)
giftData.IsOssControl = proto.SetBool(false)
giftData.OnSale = proto.SetBool(false)
giftAsset.Unlock()
giftAsset.Dirty()
userData.DirtyAll()
wlog.Info(userData.GetUid(), giftData)
}
return true
})
}
wlog.Info("delete gift pack---------------------------------")
}
func handleGiftPackOperator(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 1 {
return errors.New("param count error"), ""
}
giftPackConfig := &proto.ST_GiftPackConfig{}
err := proto.Unmarshal([]byte(params), giftPackConfig)
if nil != err {
wlog.Error(err.Error())
return errors.New("giftpack proto unmarshal error"), ""
}
//
respon := &proto.ST_CS2GS_GetGiftPackConfigs_Response{
Result: proto.SetInt32(1),
Configs: []*proto.ST_GiftPackConfig{giftPackConfig},
}
err, result := csv.UpdateOssGiftInfo(false, respon)
if err != nil {
return err, result
}
go syncOssGiftInfo(giftPackConfig)
return nil, ""
}
func handleOfferGiftOperator(params string) (error, string) {
p := strings.Split(params, " ")
if len(p) < 1 {
return errors.New("param count error"), ""
}
giftPackConfig := &proto.ST_OfferGiftPack{}
err := proto.Unmarshal([]byte(params), giftPackConfig)
if nil != err {
wlog.Error(err.Error())
return errors.New("giftpack proto unmarshal error"), ""
}
if nil == csv.OfferGiftMap {
csv.OfferGiftMap = &csv.SafeOssGiftPackMap{}
}
csv.UpdateOfferGiftUser = &csv.SafeUpdateOssGiftCharMap{}
//缓存中如果存在相同index,则先删除后再重新添加
ossIndex := int64(giftPackConfig.GetId())
if tmp, ok := csv.OfferGiftMap.DataMap.Load(ossIndex); ok {
if old, ok := tmp.(*proto.ST_OfferGiftPack); ok {
if giftPackConfig.GetOp() == 2 {
old.Op = proto.SetInt32(2)
giftPackConfig = old
}
csv.OfferGiftMap.DataMap.Delete(ossIndex)
}
}
if giftPackConfig.GetOp() != 2 {
csv.OfferGiftMap.DataMap.Store(ossIndex, giftPackConfig)
}
if giftPackConfig.GetCond() == uint32(proto.EveryoneMailConditionType_EMCT_VipLevel) {
cache.ForeachUser(func(userData *cache.Info) bool {
if giftPackConfig.GetOp() == 4 && userData.GetVipLevel() >= common.StringToUint32(giftPackConfig.GetCondvalue1()) &&
userData.GetVipLevel() <= common.StringToUint32(giftPackConfig.GetCondvalue2()) {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
if giftPackConfig.GetOp() == 2 {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
return true
})
} else if giftPackConfig.GetCond() == uint32(proto.EveryoneMailConditionType_EMCT_MainCityLevel) {
cache.ForeachUser(func(userData *cache.Info) bool {
if giftPackConfig.GetOp() == 4 && userData.GetMainCityLevel() >= common.StringToUint32(giftPackConfig.GetCondvalue1()) &&
userData.GetMainCityLevel() <= common.StringToUint32(giftPackConfig.GetCondvalue2()) {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
if giftPackConfig.GetOp() == 2 {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
return true
})
} else if giftPackConfig.GetCond() == uint32(proto.EveryoneMailConditionType_EMCT_Uid) {
for _, uid := range strings.Split(giftPackConfig.GetCondvalue1(), ",") {
userData := cache.GetCharinfo(common.StringToUint64(uid))
if userData != nil {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
}
} else if giftPackConfig.GetCond() == uint32(proto.EveryoneMailConditionType_EMCT_RegionId) {
cache.ForeachUser(func(userData *cache.Info) bool {
if giftPackConfig.GetOp() == 4 {
is := false
for _, MaxLabel := range strings.Split(giftPackConfig.GetCondvalue1(), ",") {
if userData.GetMaxLabel() == common.StringToUint64(MaxLabel) {
is = true
break
}
}
if !is {
return true
}
is = false
for _, CurLabel := range strings.Split(giftPackConfig.GetCondvalue2(), ",") {
if userData.GetCurLabel() == common.StringToUint64(CurLabel) {
is = true
break
}
}
if is {
if giftPackConfig.GetCondvalue3() == "0" || userData.GetCurLabelNum() == common.StringToUint64(giftPackConfig.GetCondvalue3()) {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
}
}
if giftPackConfig.GetOp() == 2 {
userData.UpdateOfferGiftInfo(giftPackConfig)
}
return true
})
}
return nil, ""
}
func handleLuckyStarOperator(params string) (error, string) {
luckyStar := &proto.ST_LuckyStar_PB{}
err := proto.Unmarshal([]byte(params), luckyStar)
if err != nil {
wlog.Error(err.Error())
return errors.New("lucky star proto unmarshal error"), ""
}
cache.Instance_GlobalAssetLuckyStar.Update(luckyStar)
return nil, ""
}
func handleAddStrongestCommander(params string) (error, string) {
info := &proto.ST_StrongestCommander_Entry{}
err := proto.Unmarshal([]byte(params), info)
if err != nil {
wlog.Error(err.Error())
return errors.New("ST_StrongestCommander_Entry proto unmarshal error"), ""
}
InitStrongestCommander(info)
return nil, ""
}
func handleCloseStrongestCommander(params string) (error, string) {
info := &proto.ST_StrongestCommander_Entry{}
err := proto.Unmarshal([]byte(params), info)
if err != nil {
wlog.Error(err.Error())
return errors.New("ST_StrongestCommander_Entry proto unmarshal error"), ""
}
InitStrongestCommander(info)
return nil, ""
}
func handleAddTBActivity(params string) (error, string) {
info := &proto.ST_TransferBattle_Group_Entry{}
err := proto.Unmarshal([]byte(params), info)
if err != nil {
wlog.Error(err.Error())
return errors.New("ST_TransferBattle_Group_Entry proto unmarshal error"), ""
}
InitTransferBattle(info)
return nil, ""
}
func handleCloseTBActivity(params string) (error, string) {
info := &proto.ST_TransferBattle_Group_Entry{}
err := proto.Unmarshal([]byte(params), info)
if err != nil {
wlog.Error(err.Error())
return errors.New("ST_TransferBattle_Group_Entry proto unmarshal error"), ""
}
InitTransferBattle(info)
return nil, ""
}
func handleArchonNoticeOperator(params string) (error, string) {
request := &proto.ST_ModifyArchonNotice_Request{}
err := proto.Unmarshal([]byte(params), request)
if err != nil {
return errors.New(err.Error()), ""
}
ret := true
cache.Instance_GlobalMiracleWarAsset.WithMiracleWarAsset(false, 7305001, func(asset *proto.ST_MiracleWar_PB) bool {
if asset.GetNotice() == nil {
ret = false
return false
}
switch request.GetOperType() {
case 1:
asset.Notice.Notice = proto.SetString(request.GetContent())
case 2, 3:
asset.Notice = nil
}
return true
})
if ret {
return nil, ""
}
return errors.New("archon notice is nil"), ""
}
func handleQueryArchonNotice(params string) (error, string) {
archonInfo := &proto.ST_GM_ArchonNoticeInfo{}
cache.Instance_GlobalMiracleWarAsset.WithMiracleWarAsset(true, 7305001, func(asset *proto.ST_MiracleWar_PB) bool {
if asset.GetNotice() != nil {
notice := asset.GetNotice()
archonInfo.Uid = proto.SetUint64(notice.GetUid())
if userData := cache.GetCharinfo(notice.GetUid()); nil != userData {
archonInfo.UserName = proto.SetString(userData.GetUserName())
}
archonInfo.Content = proto.SetString(notice.GetNotice())
archonInfo.SendTime = proto.SetUint64(notice.GetTime())
}
return false
})
return nil, common.Base64Encode(string(proto.Marshal(archonInfo)))
}
func handleSendGlobalMessage(params string) (error, string) {
request := &proto.ST_GlobalMessage_PB{}
err := proto.Unmarshal([]byte(params), request)
if err != nil {
return errors.New(err.Error()), ""
}
cache.Instance_GlobalAssetChat.AddGlobalMessage(request)
return nil, ""
}
func handleBoonActivityOper(params string) (error, string) {
request := &proto.ST_GM_BoonActivityOper{}
err := proto.Unmarshal([]byte(params), request)
if err != nil {
return errors.New(err.Error()), ""
}
// todo 修改福利活动奖励配置
ret := cache.SetBoonRewardConfig(request)
if ret != "" {
return errors.New(ret), ""
} else {
return nil, ""
}
}
func handleQueryBoonActivity(param string) (error, string) {
boonActivities := &proto.ST_GM_BoonActivities{}
// todo 查询福利奖励配置
for _, id := range csv.Mgr.CSV_BoonCenter.GetIDList() {
if conf := csv.Mgr.CSV_BoonCenter.GetEntryPtr(id); conf != nil {
// 调查询接口
if activity := cache.GetBoonDetailsGM(id); activity.GetDuration() != 0 {
boonActivities.Activities = append(boonActivities.Activities, activity)
}
}
}
return nil, common.Base64Encode(string(proto.Marshal(boonActivities)))
}
func ProduceResource(uid uint64) {
userData := cache.GetCharinfo(uid)
if nil == userData {
return
}
var buildingIds []uint32
for _, building := range userData.GetBuildings() {
buildingConfig := csv.Mgr.CSV_BuildingConfig.GetEntryPtr(int64(building.GetBuildingtype()))
if nil == buildingConfig || "2" != strings.TrimSpace(buildingConfig.FuncType) {
continue
}
buildingLevelUpConfig := csv.GetDoubleKeyBuildingLevel(building.GetBuildingtype(), building.GetBuildinglevel())
if nil == buildingLevelUpConfig {
continue
}
fnMap := common.ParseParameterStringToMap(buildingLevelUpConfig.Function)
v1, ok1 := fnMap["producetype"]
v2, ok2 := fnMap["capability"]
if !ok1 || !ok2 {
continue
}
pro := common.ParseStringToVector4(v1)[0]
cap := common.StringToUint64(v2)
resource := common.NewCashAsset()
switch pro.GetY() {
case int32(proto.CashType_CASH_TYPE_1):
resource.Cash1 = proto.SetUint64(cap)
case int32(proto.CashType_CASH_TYPE_2):
resource.Cash2 = proto.SetUint64(cap)
case int32(proto.CashType_CASH_TYPE_3):
resource.Cash3 = proto.SetUint64(cap)
case int32(proto.CashType_CASH_TYPE_4):
resource.Cash4 = proto.SetUint64(cap)
case int32(proto.CashType_CASH_TYPE_5):
resource.Cash5 = proto.SetUint64(cap)
case int32(proto.CashType_CASH_TYPE_EXPEDITION):
resource.CashExpedition = proto.SetUint64(cap)
}
userData.WithBuildingAsset(false, func(asset *cache.Asset_Building) {
if asset.AddResource(building.GetBuildingID(), resource) {
buildingIds = append(buildingIds, building.GetBuildingID())
userData.DirtyAll()
}
})
}
userData.WithLocalAction(false, func(asset *cache.Asset_LocalAction) {
for _, action := range asset.AssetData.ActionList {
if uint32(proto.ActionType_AT_PRODUCTION_RESOURCE) != action.GetActiontype() {
continue
}
for _, buildingId := range buildingIds {
if buildingId == action.GetBuildingID() {
action.Starttime = proto.SetUint64(0)
userData.AddSyncAsset(proto.SyncType_SetLocalActionStartTime, &proto.ST_LocalActionEntry_PB{
Actionid: action.Actionid,
Starttime: action.Starttime,
})
asset.ServerDirty()
userData.DirtyAll()
break
}
}
}
})
}
func AddAllHero(uid uint64) {
userData := cache.GetCharinfo(uid)
if nil == userData {
return
}
for _, v := range csv.Mgr.CSV_HeroList.GetIDList() {
heroEntry := csv.Mgr.CSV_HeroList.GetEntryPtr(int64(v))
if heroEntry.HeroMainType == int64(1) {
userData.InitHeroByParm(uint32(v), 1, 1)
}
}
}
func ResearchMax(uid uint64) {
userData := cache.GetCharinfo(uid)
if nil == userData {
return
}
asset := userData.GetResearchAsset()
if nil != asset {
for _, item := range asset.EntryList {
csvConfig := csv.Mgr.CSV_TechnologyLevelUp.GetEntryPtr(int64(item.GetRID()))
if csvConfig == nil {
continue
}
rType := uint32(csvConfig.FuncType)
researchTypeID := userData.GetResearchIDByType(rType)
researchConfig := csv.Mgr.CSV_TechnologyLevelUp.GetEntryPtr(int64(researchTypeID))
if researchConfig != nil {
cache.ReduceAttribute(userData, researchConfig.Function, uint32(proto.AttributeSource_Research)) //ok
}
}
userData.ResetResearch()
}
tMap := make(map[uint32]uint32)
for _, id := range csv.Mgr.CSV_TechnologyLevelUp.GetIDList() {
entry := csv.Mgr.CSV_TechnologyLevelUp.GetEntryPtr(id)
if v, ok := tMap[uint32(entry.FuncType)]; !ok || v < uint32(entry.ID) {
tMap[uint32(entry.FuncType)] = uint32(entry.ID)
}
}
for k, v := range tMap {
userData.AddResearchAsset(k, v)
config := csv.Mgr.CSV_TechnologyLevelUp.GetEntryPtr(int64(v))
cache.SetAttribute(userData, config.Function, uint32(proto.AttributeSource_Research)) //ok
}
}
func GMSetMiracleWarStage(sn, stage int32) {
cid := 7305001
if sn > 0 {
cid = 7304000 + int(sn)
}
timeNow := wtime.GetNow()
cache.Instance_GlobalMiracleWarAsset.WithMiracleWarAsset(false, cid, func(asset *proto.ST_MiracleWar_PB) bool {
if stage == int32(proto.MiracleWarStage_MWS_UnOpenStage) {
asset.Number = proto.SetInt32(0)
cache.Instance_GlobalMiracleWarAsset.UnsafeStartStage(cid, int32(proto.MiracleWarStage_MWS_UnOpenStage), timeNow, timeNow+uint64(csv.GetGameConfigValueUint32("First_Miracle")),
timeNow, timeNow)
asset.HistoryArchons = make([]*proto.ST_HistoryArchon_PB, 0)
} else if stage == int32(proto.MiracleWarStage_MWS_PrepareStage) {
stageEndTime := timeNow + uint64(csv.GetGameConfigValueUint32("Ready_Miracle"))
subStageEndTime := stageEndTime - prepareStageTimes[0]
cache.Instance_GlobalMiracleWarAsset.UnsafeStartStage(cid, int32(proto.MiracleWarStage_MWS_PrepareStage),
timeNow, stageEndTime, timeNow, subStageEndTime)
} else if stage == int32(proto.MiracleWarStage_MWS_FightStage) {
cache.Instance_GlobalMiracleWarAsset.UnsafeStartStage(cid, int32(proto.MiracleWarStage_MWS_FightStage),
timeNow, timeNow, timeNow, timeNow)
resetBigMiracle(cid, false)
if cid == 7305001 {
initFightStage(asset)
}
} else if stage == int32(proto.MiracleWarStage_MWS_ProtectStage) {
occupyInfo := asset.GetOccupyInfo()
if occupyInfo != nil {
stageEndTime := timeNow + uint64(csv.GetGameConfigValueUint32("Follow_Miracle"))
subStageEndTime := stageEndTime - prepareStageTimes[0]
cache.Instance_GlobalMiracleWarAsset.UnsafeStartStage(cid, int32(proto.MiracleWarStage_MWS_ProtectStage),
timeNow, stageEndTime, timeNow, subStageEndTime)
asset.OwnerLeagueID = proto.SetUint64(occupyInfo.GetLid())
asset.Number = proto.SetInt32(asset.GetNumber() + 1)
resetBigMiracle(cid, false)
setBigMiracleOwner(cid, 0, occupyInfo.GetLid())
}
} else if stage == int32(proto.MiracleWarStage_MWS_WaitStage) {
cache.Instance_GlobalMiracleWarAsset.UnsafeStartStage(cid, int32(proto.MiracleWarStage_MWS_WaitStage), timeNow, timeNow,
timeNow, timeNow)
}
return true
})
go func() {
cache.ForeachUser(func(tmpInfo *cache.Info) bool {
if tmpInfo.IsRealOnline() {
processMiracleWarUserInfo(tmpInfo, cid)
}
time.Sleep(time.Duration(1 * time.Millisecond))
return true
})
}()
}
func GMCloseBlackMarket(uid uint64) {
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liuxuezhan/mylib.git
git@gitee.com:liuxuezhan/mylib.git
liuxuezhan
mylib
mylib
v1.1.1

搜索帮助