diff --git a/Campofinale.Protocol/CsMsgId.cs b/Campofinale.Protocol/CsMsgId.cs index fbb7d7e..49acb28 100644 --- a/Campofinale.Protocol/CsMsgId.cs +++ b/Campofinale.Protocol/CsMsgId.cs @@ -1,329 +1,323 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Protocol +namespace Campofinale.Protocol { -public enum CsMsgId : int -{ - CsMessageBegin = 0, - CsLogin = 1, - CsCreateRole = 2, - CsLogout = 3, - CsGmCommand = 4, - CsPing = 5, - CsFlushSync = 6, - CsSetName = 7, - CsSetGender = 8, - CsCheckName = 9, - CsCheckSensitive = 10, - CsAchieveBegin = 20, - CsAchieveComplete = 21, - CsAchieveTakeReward = 22, - CsAchieveEnd = 29, - CsCharBagBegin = 30, - CsCharBagTeamBegin = 31, - CsCharBagSetTeam = 32, - CsCharBagSetCurrTeamIndex = 33, - CsCharBagSetTeamName = 34, - CsCharBagSetTeamLeader = 35, - CsCharBagTeamChangeFinish = 36, - CsCharBagTeamEnd = 37, - CsCharBagEnd = 39, - CsCharBegin = 40, - CsCharLevelUp = 41, - CsCharSetNormalSkill = 43, - CsCharSkillLevelUp = 45, - CsCharSetTeamSkill = 46, - CsCharPotentialUnlock = 47, - CsCharEnd = 49, - CsEquipBegin = 50, - CsEquipPuton = 51, - CsEquipPutoff = 52, - CsEquipMedicineModify = 53, - CsEquipRecycle = 54, - CsEquipEnhance = 55, - CsEquipProduce = 57, - CsEquipEnd = 59, - CsSceneBegin = 80, - CsEnterScene = 81, - CsMoveObjectMove = 82, - CsSceneSetLastRecordCampid = 83, - CsSceneInteractiveEventTrigger = 84, - CsSceneSetVar = 85, - CsSceneRest = 86, - CsSceneLoadFinish = 88, - CsSceneSetSafeZone = 95, - CsSceneQueryEntityExist = 96, - CsSceneQueryInteractiveProperty = 97, - CsSceneSetTrackPoint = 99, - CsSceneInteractTree = 100, - CsSceneStaticMapMarkUpdate = 101, - CsSceneTeleport = 103, - CsSceneMoveStateSet = 104, - CsSceneSubmitItem = 105, - CsSceneSubmitEther = 106, - CsSceneSetLevelScriptActive = 107, - CsSceneLevelScriptEventTrigger = 109, - CsSceneCommitLevelScriptCacheStep = 110, - CsSceneRepatriate = 115, - CsSceneInteractSpInteractive = 116, - CsSceneSetLastSafeZone = 117, - CsSceneSetBattle = 118, - CsSceneRevival = 119, - CsSceneSetLevelScriptStart = 120, - CsSceneMonsterSpawnerBeginWave = 121, - CsSceneSpawnSummon = 122, - CsSceneLeavePlane = 123, - CsSceneGradeModify = 124, - CsSceneUpdateScriptTaskProgress = 125, - CsSceneTeleportFinish = 126, - CsSceneSetStorySafeZone = 127, - CsSceneSubmitRecycle = 128, - CsSceneEnd = 199, - CsFactoryBegin = 200, - CsFactorySttUnlockNode = 201, - CsFactorySttUnlockLayer = 202, - CsFactoryManuallyWorkExec = 211, - CsFactoryProductManualUnlock = 212, - CsFactoryQuickbarSetOne = 215, - CsFactoryQuickbarMoveOne = 216, - CsFactorySoilReclaim = 217, - CsFactorySoilWater = 218, - CsFactorySoilCancel = 219, - CsFactorySoilHarvest = 220, - CsFactorySoilFarmlandLevelUp = 221, - CsFactoryHubWorkshopMake = 222, - CsFactoryHubTransportRouteSet = 223, - CsFactoryHubTransportRouteReset = 224, - CsFactoryHubTransportRouteRestart = 225, - CsFactoryHsFb = 232, - CsFactoryStatisticSetBookmarkItemIds = 234, - CsFactoryStatisticRequire = 235, - CsFactoryPinSet = 236, - CsFactoryOp = 251, - CsFactoryObserverOp = 268, - CsFactoryEnd = 269, - CsWeaponBegin = 270, - CsWeaponPuton = 271, - CsWeaponBreakthrough = 273, - CsWeaponAddExp = 274, - CsWeaponAttachGem = 275, - CsWeaponDetachGem = 276, - CsWeaponRefineUpgrade = 277, - CsWeaponEnd = 279, - CsWikiBegin = 290, - CsUnlockWiki = 291, - CsMarkWikiRead = 292, - CsWikiEnd = 299, - CsMissionBegin = 310, - CsFailMission = 311, - CsTrackMission = 313, - CsStopTrackingMission = 314, - CsUpdateQuestObjective = 315, - CsAcceptMission = 316, - CsRollBlocMission = 317, - CsMissionEventTrigger = 318, - CsMissionClientTriggerDone = 319, - CsSetNewMissionTagDone = 320, - CsMissionEnd = 329, - CsGuideBegin = 330, - CsCompleteGuideGroupKeyStep = 331, - CsCompleteGuideGroup = 332, - CsGuideEnd = 339, - CsDialogBegin = 340, - CsFinishDialog = 341, - CsDialogEnd = 349, - CsBlocBegin = 350, - CsBlocTakeLevelReward = 351, - CsBlocShopBuy = 352, - CsBlocEnd = 360, - CsDungeonBegin = 370, - CsEnterDungeon = 371, - CsRestartDungeon = 372, - CsLeaveDungeon = 373, - CsDungeonRecoverAp = 375, - CsDungeonTouchEntrance = 377, - CsDungeonEnd = 378, - CsEnterTrainDungeon = 379, - CsGameMechanicsBegin = 380, - CsGameMechanicsReqActive = 381, - CsGameMechanicsReqReward = 382, - CsGameMechanicsNtfInstPrepareFinish = 383, - CsGameMechanicsEnd = 399, - CsMailBegin = 400, - CsGetMail = 401, - CsReadMail = 402, - CsDeleteMail = 403, - CsDeleteAllMail = 404, - CsGetMailAttachment = 405, - CsGetAllMailAttachment = 406, - CsMarkStarMail = 407, - CsMailEnd = 419, - CsRedDotBegin = 430, - CsRemoveItemNewTags = 431, - CsRedDotReadFormula = 432, - CsRedDotReadCharDoc = 433, - CsRedDotReadCharVoice = 434, - CsRedDotReadEquipFormula = 435, - CsRedDotEnd = 440, - CsPrtsBegin = 441, - CsPrtsMarkRead = 442, - CsPrtsMarkTerminalRead = 443, - CsPrtsRichContentRead = 444, - CsPrtsFinishInvestigate = 445, - CsPrtsEnd = 449, - CsBitsetBegin = 480, - CsBitsetAdd = 481, - CsBitsetRemove = 482, - CsBitsetRemoveAll = 483, - CsBitsetEnd = 499, - CsMergeMsg = 500, - CsPayBegin = 510, - CsCreateOrder = 511, - CsPayEnd = 529, - CsFriendBegin = 530, - CsFriendRequestSubmit = 531, - CsFriendRequestReject = 532, - CsFriendRequestAccept = 533, - CsFriendDelete = 534, - CsFriendSearchName = 535, - CsFriendRequestListSync = 536, - CsFriendListSync = 537, - CsFriendEnd = 570, - CsWalletBegin = 600, - CsMoneyChange = 601, - CsWalletEnd = 630, - CsGameVarBegin = 631, - CsUpdateClientGameVar = 632, - CsGameVarEnd = 640, - CsMiniGameBegin = 641, - CsCompleteMiniGame = 642, - CsMiniGameEnd = 650, - CsRpgDungeonBegin = 651, - CsRpgDungeonBuy = 652, - CsRpgDungeonSell = 653, - CsRpgDungeonEquipPuton = 654, - CsRpgDungeonEquipPutoff = 655, - CsRpgDungeonPickLvAbility = 656, - CsRpgDungeonTimeStop = 657, - CsRpgDungeonAbilityChange = 658, - CsRpgDungeonEnd = 700, - CsGemBegin = 801, - CsGemRecast = 802, - CsGemEnd = 820, - CsSnsBegin = 701, - CsSnsGetList = 702, - CsSnsMomentOption = 703, - CsSnsChatDialogOption = 704, - CsSnsMomentRead = 705, - CsSnsFinishDialog = 706, - CsSnsReadDialog = 707, - CsSnsEnd = 730, - CsSpaceshipBegin = 751, - CsSpaceshipBuildRoom = 752, - CsSpaceshipLevelUpRoom = 753, - CsSpaceshipStationChar = 754, - CsSpaceshipStationCharChangeWorkState = 755, - CsSpaceshipPresentGiftToChar = 756, - CsSpaceshipRecvGiftFromChar = 757, - CsSpaceshipManufacturingBegin = 771, - CsSpaceshipManufacturingStationStart = 772, - CsSpaceshipManufacturingStationCollect = 775, - CsSpaceshipManufacturingStationCancel = 776, - CsSpaceshipManufacturingStationChangeOrder = 777, - CsSpaceshipManufacturingEnd = 785, - CsSpaceshipGrowCabinBegin = 786, - CsSpaceshipGrowCabinBreed = 787, - CsSpaceshipGrowCabinSow = 788, - CsSpaceshipGrowCabinHarvest = 789, - CsSpaceshipGrowCabinCancel = 790, - CsSpaceshipGrowCabinClearPreviewRecipe = 791, - CsSpaceshipGrowCabinEnd = 799, - CsSpaceshipEnd = 800, - CsTdBegin = 821, - CsTdGetTdList = 822, - CsTdStart = 823, - CsTdLeave = 825, - CsTdBuyBuilding = 826, - CsTdPickDropItem = 827, - CsTdDropExpired = 828, - CsTdEnd = 899, - CsBuffBegin = 900, - CsBattleOp = 901, - CsDevClearBattleInfo = 902, - CsBuffEnd = 950, - CsSkillBegin = 960, - CsCastSkill = 961, - CsCastSkillEnd = 962, - CsCastSkillEffect = 963, - CsSkillEnd = 999, - CsItemBagBegin = 1000, - CsItemBagTidyInBag = 1001, - CsItemBagMoveInBag = 1002, - CsItemBagSplitInBag = 1003, - CsItemBagFactoryDepotToBag = 1004, - CsItemBagBagToFactoryDepot = 1005, - CsItemBagFactoryDepotToBagGrid = 1006, - CsItemBagUseItem = 1007, - CsItemBagSetQuickBar = 1008, - CsItemBagSetQuickBarPos = 1009, - CsItemBagSetItemLock = 1010, - CsItemBagAbandonInBag = 1011, - CsItemBagDestroyInDepot = 1012, - CsItemBagDestroyInFactoryDepot = 1013, - CsItemBagDumpBottleInBag = 1014, - CsItemBagDumpBottleInFactoryDepot = 1015, - CsItemBagTakeoutLostAndFound = 1031, - CsItemBagUseItemCase = 1032, - CsItemBagChgSpaceshipChapter = 1033, - CsItemBagEnd = 1049, - CsSettlementBegin = 1050, - CsSettlementSelectRequire = 1051, - CsSettlementSetOfficer = 1052, - CsSettlementSetSubmitMode = 1053, - CsSettlementSubmitRequire = 1054, - CsSettlementEnd = 1099, - CsShopBegin = 1100, - CsShopBuy = 1111, - CsShopSwapMoney = 1112, - CsShopEnd = 1149, - CsAdventureBegin = 1150, - CsAdventureTakeRewardAll = 1151, - CsAdventureEnd = 1179, - CsAdventureBookBegin = 1250, - CsTakeAllAdventureTaskReward = 1251, - CsTakeAdventureTaskReward = 1252, - CsTakeAdventureBookStageReward = 1253, - CsAdventureBookEnd = 1299, - CsTalentBegin = 1300, - CsCharUnlockTalentNode = 1301, - CsTalentEnd = 1329, - CsRacingDungeonBegin = 1330, - CsRacingDungeonBattlePassReceiveReward = 1332, - CsRacingDungeonGetBattlePass = 1333, - CsRacingDungeonGetAchievement = 1334, - CsRacingDungeonAchievementReceiveReward = 1335, - CsRacingDungeonLeave = 1336, - CsRacingDungeonUpdateBattleInfo = 1337, - CsRacingDungeonEnd = 1400, - CsTrialCharacterBegin = 1401, - CsUseTrialCharacterEquipMedicine = 1402, - CsTrialCharacterEnd = 1403, - CsGachaBegin = 1431, - CsGachaSinglePullReq = 1432, - CsGachaTenPullReq = 1433, - CsGachaEnd = 1450, - CsGameTimeFreezeBegin = 1451, - CsGameTimeFreezeStartReq = 1452, - CsGameTimeFreezeEndReq = 1453, - CsGameTimeFreezeEnd = 1460, - CsActivityBegin = 1461, - CsDailyCheckin = 1471, - CsActivityEnd = 1510, - CsMessageEnd = 4095, + public enum CsMsgId : int + { + CsMessageBegin = 0, + CsLogin = 1, + CsCreateRole = 2, + CsLogout = 3, + CsGmCommand = 4, + CsPing = 5, + CsFlushSync = 6, + CsSetName = 7, + CsSetGender = 8, + CsCheckName = 9, + CsCheckSensitive = 10, + CsAchieveBegin = 20, + CsAchieveComplete = 21, + CsAchieveTakeReward = 22, + CsAchieveEnd = 29, + CsCharBagBegin = 30, + CsCharBagTeamBegin = 31, + CsCharBagSetTeam = 32, + CsCharBagSetCurrTeamIndex = 33, + CsCharBagSetTeamName = 34, + CsCharBagSetTeamLeader = 35, + CsCharBagTeamChangeFinish = 36, + CsCharBagTeamEnd = 37, + CsCharBagEnd = 39, + CsCharBegin = 40, + CsCharLevelUp = 41, + CsCharSetNormalSkill = 43, + CsCharSkillLevelUp = 45, + CsCharSetTeamSkill = 46, + CsCharPotentialUnlock = 47, + CsCharEnd = 49, + CsEquipBegin = 50, + CsEquipPuton = 51, + CsEquipPutoff = 52, + CsEquipMedicineModify = 53, + CsEquipRecycle = 54, + CsEquipEnhance = 55, + CsEquipProduce = 57, + CsEquipEnd = 59, + CsSceneBegin = 80, + CsEnterScene = 81, + CsMoveObjectMove = 82, + CsSceneSetLastRecordCampid = 83, + CsSceneInteractiveEventTrigger = 84, + CsSceneSetVar = 85, + CsSceneRest = 86, + CsSceneLoadFinish = 88, + CsSceneSetSafeZone = 95, + CsSceneQueryEntityExist = 96, + CsSceneQueryInteractiveProperty = 97, + CsSceneSetTrackPoint = 99, + CsSceneInteractTree = 100, + CsSceneStaticMapMarkUpdate = 101, + CsSceneTeleport = 103, + CsSceneMoveStateSet = 104, + CsSceneSubmitItem = 105, + CsSceneSubmitEther = 106, + CsSceneSetLevelScriptActive = 107, + CsSceneLevelScriptEventTrigger = 109, + CsSceneCommitLevelScriptCacheStep = 110, + CsSceneRepatriate = 115, + CsSceneInteractSpInteractive = 116, + CsSceneSetLastSafeZone = 117, + CsSceneSetBattle = 118, + CsSceneRevival = 119, + CsSceneSetLevelScriptStart = 120, + CsSceneMonsterSpawnerBeginWave = 121, + CsSceneSpawnSummon = 122, + CsSceneLeavePlane = 123, + CsSceneGradeModify = 124, + CsSceneUpdateScriptTaskProgress = 125, + CsSceneTeleportFinish = 126, + CsSceneSetStorySafeZone = 127, + CsSceneSubmitRecycle = 128, + CsSceneEnd = 199, + CsFactoryBegin = 200, + CsFactorySttUnlockNode = 201, + CsFactorySttUnlockLayer = 202, + CsFactoryManuallyWorkExec = 211, + CsFactoryProductManualUnlock = 212, + CsFactoryQuickbarSetOne = 215, + CsFactoryQuickbarMoveOne = 216, + CsFactorySoilReclaim = 217, + CsFactorySoilWater = 218, + CsFactorySoilCancel = 219, + CsFactorySoilHarvest = 220, + CsFactorySoilFarmlandLevelUp = 221, + CsFactoryHubWorkshopMake = 222, + CsFactoryHubTransportRouteSet = 223, + CsFactoryHubTransportRouteReset = 224, + CsFactoryHubTransportRouteRestart = 225, + CsFactoryHsFb = 232, + CsFactoryStatisticSetBookmarkItemIds = 234, + CsFactoryStatisticRequire = 235, + CsFactoryPinSet = 236, + CsFactoryOp = 251, + CsFactoryObserverOp = 268, + CsFactoryEnd = 269, + CsWeaponBegin = 270, + CsWeaponPuton = 271, + CsWeaponBreakthrough = 273, + CsWeaponAddExp = 274, + CsWeaponAttachGem = 275, + CsWeaponDetachGem = 276, + CsWeaponRefineUpgrade = 277, + CsWeaponEnd = 279, + CsWikiBegin = 290, + CsUnlockWiki = 291, + CsMarkWikiRead = 292, + CsWikiEnd = 299, + CsMissionBegin = 310, + CsFailMission = 311, + CsTrackMission = 313, + CsStopTrackingMission = 314, + CsUpdateQuestObjective = 315, + CsAcceptMission = 316, + CsRollBlocMission = 317, + CsMissionEventTrigger = 318, + CsMissionClientTriggerDone = 319, + CsSetNewMissionTagDone = 320, + CsMissionEnd = 329, + CsGuideBegin = 330, + CsCompleteGuideGroupKeyStep = 331, + CsCompleteGuideGroup = 332, + CsGuideEnd = 339, + CsDialogBegin = 340, + CsFinishDialog = 341, + CsDialogEnd = 349, + CsBlocBegin = 350, + CsBlocTakeLevelReward = 351, + CsBlocShopBuy = 352, + CsBlocEnd = 360, + CsDungeonBegin = 370, + CsEnterDungeon = 371, + CsRestartDungeon = 372, + CsLeaveDungeon = 373, + CsDungeonRecoverAp = 375, + CsDungeonTouchEntrance = 377, + CsDungeonEnd = 378, + CsEnterTrainDungeon = 379, + CsGameMechanicsBegin = 380, + CsGameMechanicsReqActive = 381, + CsGameMechanicsReqReward = 382, + CsGameMechanicsNtfInstPrepareFinish = 383, + CsGameMechanicsEnd = 399, + CsMailBegin = 400, + CsGetMail = 401, + CsReadMail = 402, + CsDeleteMail = 403, + CsDeleteAllMail = 404, + CsGetMailAttachment = 405, + CsGetAllMailAttachment = 406, + CsMarkStarMail = 407, + CsMailEnd = 419, + CsRedDotBegin = 430, + CsRemoveItemNewTags = 431, + CsRedDotReadFormula = 432, + CsRedDotReadCharDoc = 433, + CsRedDotReadCharVoice = 434, + CsRedDotReadEquipFormula = 435, + CsRedDotEnd = 440, + CsPrtsBegin = 441, + CsPrtsMarkRead = 442, + CsPrtsMarkTerminalRead = 443, + CsPrtsRichContentRead = 444, + CsPrtsFinishInvestigate = 445, + CsPrtsEnd = 449, + CsBitsetBegin = 480, + CsBitsetAdd = 481, + CsBitsetRemove = 482, + CsBitsetRemoveAll = 483, + CsBitsetEnd = 499, + CsMergeMsg = 500, + CsPayBegin = 510, + CsCreateOrder = 511, + CsPayEnd = 529, + CsFriendBegin = 530, + CsFriendRequestSubmit = 531, + CsFriendRequestReject = 532, + CsFriendRequestAccept = 533, + CsFriendDelete = 534, + CsFriendSearchName = 535, + CsFriendRequestListSync = 536, + CsFriendListSync = 537, + CsFriendEnd = 570, + CsWalletBegin = 600, + CsMoneyChange = 601, + CsWalletEnd = 630, + CsGameVarBegin = 631, + CsUpdateClientGameVar = 632, + CsGameVarEnd = 640, + CsMiniGameBegin = 641, + CsCompleteMiniGame = 642, + CsMiniGameEnd = 650, + CsRpgDungeonBegin = 651, + CsRpgDungeonBuy = 652, + CsRpgDungeonSell = 653, + CsRpgDungeonEquipPuton = 654, + CsRpgDungeonEquipPutoff = 655, + CsRpgDungeonPickLvAbility = 656, + CsRpgDungeonTimeStop = 657, + CsRpgDungeonAbilityChange = 658, + CsRpgDungeonEnd = 700, + CsGemBegin = 801, + CsGemRecast = 802, + CsGemEnd = 820, + CsSnsBegin = 701, + CsSnsGetList = 702, + CsSnsMomentOption = 703, + CsSnsChatDialogOption = 704, + CsSnsMomentRead = 705, + CsSnsFinishDialog = 706, + CsSnsReadDialog = 707, + CsSnsEnd = 730, + CsSpaceshipBegin = 751, + CsSpaceshipBuildRoom = 752, + CsSpaceshipLevelUpRoom = 753, + CsSpaceshipStationChar = 754, + CsSpaceshipStationCharChangeWorkState = 755, + CsSpaceshipPresentGiftToChar = 756, + CsSpaceshipRecvGiftFromChar = 757, + CsSpaceshipManufacturingBegin = 771, + CsSpaceshipManufacturingStationStart = 772, + CsSpaceshipManufacturingStationCollect = 775, + CsSpaceshipManufacturingStationCancel = 776, + CsSpaceshipManufacturingStationChangeOrder = 777, + CsSpaceshipManufacturingEnd = 785, + CsSpaceshipGrowCabinBegin = 786, + CsSpaceshipGrowCabinBreed = 787, + CsSpaceshipGrowCabinSow = 788, + CsSpaceshipGrowCabinHarvest = 789, + CsSpaceshipGrowCabinCancel = 790, + CsSpaceshipGrowCabinClearPreviewRecipe = 791, + CsSpaceshipGrowCabinEnd = 799, + CsSpaceshipEnd = 800, + CsTdBegin = 821, + CsTdGetTdList = 822, + CsTdStart = 823, + CsTdLeave = 825, + CsTdBuyBuilding = 826, + CsTdPickDropItem = 827, + CsTdDropExpired = 828, + CsTdEnd = 899, + CsBuffBegin = 900, + CsBattleOp = 901, + CsDevClearBattleInfo = 902, + CsBuffEnd = 950, + CsSkillBegin = 960, + CsCastSkill = 961, + CsCastSkillEnd = 962, + CsCastSkillEffect = 963, + CsSkillEnd = 999, + CsItemBagBegin = 1000, + CsItemBagTidyInBag = 1001, + CsItemBagMoveInBag = 1002, + CsItemBagSplitInBag = 1003, + CsItemBagFactoryDepotToBag = 1004, + CsItemBagBagToFactoryDepot = 1005, + CsItemBagFactoryDepotToBagGrid = 1006, + CsItemBagUseItem = 1007, + CsItemBagSetQuickBar = 1008, + CsItemBagSetQuickBarPos = 1009, + CsItemBagSetItemLock = 1010, + CsItemBagAbandonInBag = 1011, + CsItemBagDestroyInDepot = 1012, + CsItemBagDestroyInFactoryDepot = 1013, + CsItemBagDumpBottleInBag = 1014, + CsItemBagDumpBottleInFactoryDepot = 1015, + CsItemBagTakeoutLostAndFound = 1031, + CsItemBagUseItemCase = 1032, + CsItemBagChgSpaceshipChapter = 1033, + CsItemBagEnd = 1049, + CsSettlementBegin = 1050, + CsSettlementSelectRequire = 1051, + CsSettlementSetOfficer = 1052, + CsSettlementSetSubmitMode = 1053, + CsSettlementSubmitRequire = 1054, + CsSettlementEnd = 1099, + CsShopBegin = 1100, + CsShopBuy = 1111, + CsShopSwapMoney = 1112, + CsShopEnd = 1149, + CsAdventureBegin = 1150, + CsAdventureTakeRewardAll = 1151, + CsAdventureEnd = 1179, + CsAdventureBookBegin = 1250, + CsTakeAllAdventureTaskReward = 1251, + CsTakeAdventureTaskReward = 1252, + CsTakeAdventureBookStageReward = 1253, + CsAdventureBookEnd = 1299, + CsTalentBegin = 1300, + CsCharUnlockTalentNode = 1301, + CsTalentEnd = 1329, + CsRacingDungeonBegin = 1330, + CsRacingDungeonBattlePassReceiveReward = 1332, + CsRacingDungeonGetBattlePass = 1333, + CsRacingDungeonGetAchievement = 1334, + CsRacingDungeonAchievementReceiveReward = 1335, + CsRacingDungeonLeave = 1336, + CsRacingDungeonUpdateBattleInfo = 1337, + CsRacingDungeonEnd = 1400, + CsTrialCharacterBegin = 1401, + CsUseTrialCharacterEquipMedicine = 1402, + CsTrialCharacterEnd = 1403, + CsGachaBegin = 1431, + CsGachaSinglePullReq = 1432, + CsGachaTenPullReq = 1433, + CsGachaEnd = 1450, + CsGameTimeFreezeBegin = 1451, + CsGameTimeFreezeStartReq = 1452, + CsGameTimeFreezeEndReq = 1453, + CsGameTimeFreezeEnd = 1460, + CsActivityBegin = 1461, + CsDailyCheckin = 1471, + CsActivityEnd = 1510, + CsMessageEnd = 4095, -} + } } diff --git a/Campofinale.Protocol/ScMsgId.cs b/Campofinale.Protocol/ScMsgId.cs index 33ff68a..a33246c 100644 --- a/Campofinale.Protocol/ScMsgId.cs +++ b/Campofinale.Protocol/ScMsgId.cs @@ -1,401 +1,395 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Protocol +namespace Campofinale.Protocol { -public enum ScMsgId : int -{ - ScMessageBegin = 0, - ScLogin = 1, - ScSyncBaseData = 2, - ScNtfErrorCode = 3, - ScGmCommand = 4, - ScPing = 5, - ScReconnectIncr = 6, - ScReconnectFull = 7, - ScFlushSync = 8, - ScNtfCode = 9, - ScSetName = 10, - ScSetGender = 11, - ScCheckName = 12, - ScCheckSensitive = 13, - ScSyncFullDataEnd = 14,// - ScAchieveComplete = 15, - ScSyncAllRoleScene = 20,// - ScObjectEnterView = 21, - ScObjectLeaveView = 22, - ScMoveObjectMove = 23, - ScEnterSceneNotify = 24, - ScSelfSceneInfo = 25, - ScLeaveSceneNotify = 26, - ScSceneSetLastRecordCampid = 27, - ScSceneUpdateInteractiveProperty = 28, - ScSceneSetVar = 29, - ScSceneRevival = 30, - ScSceneCreateEntity = 31, - ScSceneDestroyEntity = 32, - ScSceneSetSafeZone = 35, - ScSceneQueryEntityExist = 36, - ScSceneLevelScriptStateNotify = 37, - ScSceneQueryInteractiveProperty = 38, - ScSceneUnlockArea = 39, - ScSceneSetTrackPoint = 40, - ScSceneCollectionSync = 42, // - ScSceneCollectionModify = 43, - ScSceneMapMarkSync = 44,// - ScSceneStaticMapMarkModify = 45, - ScSceneTeleport = 46, - ScSceneSubmitItem = 47, - ScSceneSubmitEther = 48, - ScSceneUpdateLevelScriptProperty = 49, - ScSceneResetEntity = 50, - ScSceneLevelScriptResetBegin = 51, - ScSceneLevelScriptResetEnd = 52, - ScSceneSetBattle = 53, - ScSceneLevelScriptEventTrigger = 55, - ScSceneInteractiveEventTrigger = 56, - ScSceneTriggerClientLevelScriptEvent = 57, - ScSceneTriggerClientInteractiveEvent = 58, - ScSceneCrossSceneStatus = 59, - ScSceneDropCreate = 800, - ScSceneDropDelete = 801, - ScSceneDropModify = 802, - ScSceneGradeChangeNotify = 803, - ScSeamlessSceneDestroyNotify = 804, - ScSceneMonsterSpawnerStart = 805, - ScSceneMonsterSpawnerStop = 806, - ScSceneMonsterSpawnerComplete = 807, - ScSceneMonsterSpawnerBeginWave = 808, - ScSceneMonsterSpawnerWaveComplete = 809, - ScSceneMonsterSpawnerObjectDataBegin = 811, - ScSceneMonsterSpawnerObjectDataEnd = 812, - ScSceneLevelScriptTaskStateUpdate = 813, - ScSceneClientIdInfo = 814, - ScSceneLevelScriptTaskProgressUpdate = 815, - ScSceneLevelScriptTaskStartFinish = 816, - ScSceneInteractSpInteractive = 817, - ScSceneUpdateInteractiveMeta = 818, - ScSceneGradeModify = 819, - ScSceneSetStorySafeZone = 820, - ScSceneRepatriate = 821, - ScSceneSubmitRecycle = 822, - ScSceneLevelScriptSetDone = 823, - ScSyncCharBagInfo = 60,// - ScCharBagAddChar = 61, - ScCharBagSetTeam = 62, - ScCharBagSetCurrTeamIndex = 63, - ScCharBagSetTeamName = 64, - ScCharBagSetTeamLeader = 65, - ScCharBagSetMaxTeamMemberCount = 66, - ScCharBagTeamLeaderNotMatchNtf = 67, - ScCharBagDelChar = 68, - ScCharBagAddCharWithConversionNotify = 69, - ScSyncWallet = 70,// - ScWalletSyncMoney = 71, - ScCharSkillInfos = 78, - ScCharPotentialUnlock = 79, - ScCharLevelUp = 80, - ScCharSyncLevelExp = 82, - ScCharSetNormalSkill = 83, - ScCharSkillLevelUp = 84, - ScCharUnlockSkill = 85, - ScCharGainExpToast = 86, - ScCharSyncStatus = 87, - ScCharSetTeamSkill = 89, - ScEquipPuton = 90, - ScEquipPutoff = 91, - ScEquipMedicineModify = 92, - ScEquipRecycle = 93, - ScEquipEnhance = 94, - ScEquipProduce = 96, - ScSyncAllMission = 110,// - ScQuestStateUpdate = 111, - ScMissionStateUpdate = 112, - ScQuestFailed = 113, - ScMissionFailed = 114, - ScTrackMissionChange = 115, - ScQuestObjectivesUpdate = 116, - ScMissionDeleted = 117, - ScRollBlocMission = 120, - ScSyncBlocMissionInfo = 121,// - ScBlocCompletedMissionNumUpdate = 122, - ScQuestRollback = 123, - ScUpdateMissionProperty = 124, - ScSceneTriggerClientMissionEvent = 125, - ScMissionEventTrigger = 126, - ScDailyMissionInfoUpdate = 127, - ScSyncAllDialog = 130,// - ScFinishDialog = 131, - ScSyncAllGuide = 140,// - ScCompleteGuideGroupKeyStep = 141, - ScCompleteGuideGroup = 142, - ScAcceptGuideGroup = 143, - ScSyncAttr = 150, - ScSyncAllUnlock = 160,// - ScUnlockSystem = 161, - ScSyncAllBitset = 165,// - ScBitsetAdd = 166, - ScBitsetRemove = 167, - ScBitsetRemoveAll = 168, - ScFactorySync = 200,// - ScFactoryModifyFormulaMan = 201, - ScFactoryModifyStt = 202, - ScFactoryModifyVisibleFormula = 203, - ScFactoryModifyFormulaMode = 204, - ScFactorySyncOfflineInfo = 205,// - ScFactorySyncScope = 210,// - ScFactoryReleaseScope = 211, - ScFactoryModifyScope = 212, - ScFactoryModifyQuickbar = 213, - ScFactoryManuallyWorkExec = 214, - ScFactoryProductManualUnlock = 215, - ScFactoryModifySoil = 216, - ScFactorySoilReclaim = 217, - ScFactorySoilWater = 218, - ScFactorySoilCancel = 219, - ScFactorySoilHarvest = 220, - ScFactorySyncChapter = 221,// - ScFactoryModifyChapterNodes = 222, - ScFactoryModifyChapterComponents = 223, - ScFactoryModifyChapterScene = 224, - ScFactoryModifyChapterBlackboard = 225, - ScFactoryModifyChapterPinBoard = 226, - ScFactoryModifyChapterMap = 227, - ScFactoryHs = 231, - ScFactoryHsSync = 232,// - ScFactorySyncStatistic = 241, - ScFactoryModifyStatistic = 242, - ScFactoryStatisticRequire = 243, - ScFactoryHubWorkshopMake = 244, - ScFactoryHubTransportRouteModify = 245, - ScFactoryModifyStatisticBookmark = 246, - ScFactoryOpRet = 251, - ScFactoryObserverRet = 259, - ScWeaponPuton = 260, - ScWeaponBreakthrough = 262, - ScWeaponAddExp = 263, - ScWeaponAttachGem = 264, - ScWeaponDetachGem = 265, - ScWeaponRefineUpgrade = 266, - ScRewardToastBegin = 270, - ScRewardToastEnd = 271, - ScRewardDropMoneyToast = 272, - ScRewardToSceneBegin = 273, - ScRewardToSceneEnd = 274, - ScRewardDropSpItemToast = 275, - ScSyncAllBloc = 280,// - ScBlocSyncLevel = 281, - ScBlocTakeLevelReward = 282, - ScBlocShopBuy = 283, - ScDungeonBegin = 300, - ScEnterDungeon = 301, - ScRestartDungeon = 302, - ScLeaveDungeon = 303, - ScSyncStamina = 304, - ScSyncFullDungeonStatus = 306, - ScDungeonEnd = 359, - ScSyncAllMail = 400,// - ScGetMail = 401, - ScReadMail = 402, - ScGetMailAttachment = 403, - ScDelMailNotify = 404, - ScNewMailNotify = 405, - ScMarkStarMail = 406, - ScSyncGameMode = 430, - ScRemoveItemNewTags = 440, - ScSyncAllWiki = 470, - ScSyncAllStat = 500, - ScSyncStat = 501, - ScNewNoticeNotify = 600, - ScCreateOrder = 650, - ScOrderMsg = 651, - ScFriendBegin = 700, - ScFriendRequestSubmit = 701, - ScFriendRequestReject = 702, - ScFriendRequestAccept = 703, - ScFriendDelete = 704, - ScFriendSearchName = 705, - ScFriendRequestListSync = 706, - ScFriendListSync = 707, - ScFriendRequestAddNotify = 708, - ScFriendAddNotify = 709, - ScFriendEnd = 750, - ScUpdateGameVar = 901, - ScSyncAllGameVar = 902,// - ScUpdateMiniGame = 913, - ScSyncAllMiniGame = 914,// - ScCompleteMiniGame = 915, - ScRpgDungeonBegin = 950, - ScRpgDungeonBuy = 951, - ScRpgDungeonSell = 952, - ScRpgDungeonEquipPuton = 953, - ScRpgDungeonEquipPutoff = 954, - ScSyncRpgEquipColumn = 955, - ScSyncRpgDungeonBuffList = 956, - ScSyncRpgTeamLevel = 957, - ScSyncRpgLevelUp = 958, - ScRpgDungeonPickLvAbility = 959, - ScSyncRpgDungeonTimeInfo = 960, - ScSyncRpgDungeonAbility = 961, - ScRpgDungeonEnd = 999, - ScItemBagCommonSync = 1000,// - ScItemBagCommonModify = 1001, - ScItemBagScopeSync = 1002,// - ScItemBagScopeModify = 1003, - ScItemBagUseItem = 1004, - ScItemBagSetQuickBar = 1005, - ScItemBagSetQuickBarPos = 1006, - ScItemBagSetItemLock = 1007, - ScItemBagAbandonInBag = 1008, - ScItemBagBagToFactoryDepot = 1009, - ScItemBagTakeoutLostAndFound = 1031, - ScItemBagGotItemToast = 1032, - ScItemBagTrialCharDepotModify = 1033, - ScItemBagTrialCharDepotClear = 1034, - ScItemBagUseItemCase = 1035, - ScItemBagChgSpaceshipChapter = 1036, - ScItemBagEnd = 1049, - ScAddBuff = 1100, - ScRemoveBuff = 1101, - ScTriggerBuff = 1102, - ScClearBuffs = 1103, - ScCastSkill = 1160, - ScSyncHp = 1161, - ScSyncPoise = 1162, - ScSyncUltimateSpCellCnt = 1163, - ScSpawnEnemy = 1170, - ScSpawnSummon = 1171, - ScEntityPropertyChange = 1172, - ScBattleDebugInfo = 1173, - ScBattleGenerationChange = 1174, - ScAttachServerSkill = 1175, - ScDetachServerSkill = 1176, - ScAddServerBuff = 1177, - ScRemoveServerBuff = 1178, - ScSpaceshipSync = 1200,// - ScSpaceshipModifyRoom = 1201, - ScSpaceshipModifyChar = 1202, - ScSpaceshipPresentCharInfo = 1203, - ScSpaceshipCharFavorabilityChange = 1204, - ScSpaceshipRecvGiftFromChar = 1205, - ScSpaceshipPresentGiftToChar = 1206, - ScSpaceshipSyncRoomLevelUp = 1207, - ScSpaceshipSyncCharSkill = 1208, - ScSpaceshipSyncRoomStation = 1209, - ScSpaceshipManufacturingStationSync = 1210, - ScSpaceshipManufacturingStationStart = 1211, - ScSpaceshipManufacturingStationCancel = 1212, - ScSpaceshipManufacturingStationCollect = 1213, - ScSpaceshipModifyGrowCabin = 1214, - ScSpaceshipGrowCabinBreed = 1215, - ScSpaceshipGrowCabinSow = 1216, - ScSpaceshipGrowCabinHarvest = 1217, - ScSpaceshipGrowCabinCancel = 1218, - ScSpaceshipReportCharWorkModify = 1219, - ScSpaceshipReportOutputModify = 1220, - ScGameMechanicsBegin = 1250, - ScGameMechanicsSync = 1251,// - ScGameMechanicsSyncUnlockCondition = 1252, - ScGameMechanicsModifyRecords = 1253, - ScGameMechanicsSyncChallengeStart = 1254, - ScGameMechanicsSyncChallengeComplete = 1255, - ScGameMechanicsSyncCompletionReward = 1256, - ScGameMechanicsSyncEnterGameInst = 1257, - ScGameMechanicsSyncLeaveGameInst = 1258, - ScGameMechanicsSyncRestartGameInst = 1259, - ScGameMechanicsModifyInstTimeFreeze = 1260, - ScGameMechanicsEnd = 1299, - ScSnsBegin = 1300, - ScSnsGetMomentList = 1301, - ScSnsGetChatList = 1302, - ScSyncSnsAddDialog = 1303, - ScSnsMomentOption = 1304, - ScSyncSnsDialogModify = 1305, - ScSyncSnsAddMoment = 1306, - ScSnsMomentRead = 1307, - ScSnsReadDialog = 1308, - ScSyncSnsChatModify = 1309, - ScSnsEnd = 1330, - ScSettlementBegin = 1331, - ScSettlementSyncAll = 1332,// - ScSettlementSyncModify = 1333, - ScSettlementFinishRequires = 1334, - ScSettlementSetOfficer = 1335, - ScSettlementSelectRequire = 1336, - ScSettlementSetSubmitMode = 1337, - ScSettlementEnd = 1350, - ScShopBegin = 1351, - ScShopSync = 1352,// - ScShopSyncShopGroupCondition = 1353, - ScShopModifyShop = 1354, - ScShopSyncShopCondition = 1355, - ScShopSyncGoodsCondition = 1356, - ScShopModifyFrequencyLimit = 1357, - ScShopDeleteFrequencyLimit = 1358, - ScShopBuyResp = 1359, - ScShopSwapMoney = 1360, - ScShopEnd = 1370, - ScTdBegin = 1371, - ScTdGetTdList = 1372, - ScTdStart = 1373, - ScTdLeave = 1374, - ScSyncTdSettlement = 1375, - ScSyncTdFullStatus = 1376, - ScSyncTdDropItem = 1378, - ScTdPickDropItem = 1379, - ScTdBuyBuilding = 1380, - ScTdEnd = 1400, - ScAdventureBegin = 1401, - ScAdventureLevelModify = 1402, - ScAdventureSyncAll = 1403,// - ScAdventureEnd = 1430, - ScGemRecast = 1431, - ScGemEnd = 1440, - ScResetDailyAdventureTask = 1441, - ScDailyActivationModify = 1443, - ScAdventureTaskModify = 1444, - ScAdventureBookSync = 1445,// - ScAdventureBookStageModify = 1447, - ScTalentBegin = 1490, - ScCharUnlockTalentNode = 1491, - ScTalentEnd = 1529, - ScRacingDungeonBegin = 1530, - ScSyncRacingDungeonPassedLevel = 1531, - ScRacingDungeonEnter = 1532, - ScSyncRacingDungeonSettlement = 1533, - ScSyncRacingDungeonReconnect = 1534, - ScRacingDungeonBattlePassReceiveReward = 1535, - ScRacingDungeonGetBattlePass = 1536, - ScRacingDungeonGetAchievement = 1537, - ScRacingDungeonAchievementReceiveReward = 1538, - ScSyncRacingDungeonBuffModify = 1539, - ScSyncRacingDungeonAchievementModify = 1540, - ScSyncRacingTimerPause = 1541, - ScSyncRacingDungeonCompleteRoom = 1542, - ScSyncRacingDungeonCountdownEvent = 1543, - ScRacingDungeonEnd = 1600, - ScCharBagSetTempTeam = 1601, - ScCharBagRemoveTrialCharacter = 1602, - ScTrialCharacterEquipMedicineModify = 1603, - ScGachaBegin = 1610, - ScGachaSync = 1611,// - ScGachaModifyPoolInfo = 1612, - ScGachaSyncPullResult = 1613, - ScGachaModifyPoolRoleData = 1614, - ScGachaEnd = 1640, - ScGameTimeFreezeBegin = 1641, - ScGameTimeFreezeStartRsp = 1642, - ScGameTimeFreezeEndRsp = 1643, - ScGameTimeFreezeEnd = 1650, - ScActivityBegin = 1651, - ScActivitySync = 1652,// - ScActivityModify = 1653, - ScDailyCheckin = 1661, - ScActivityEnd = 1690, - ScMessageEnd = 4095, + public enum ScMsgId : int + { + ScMessageBegin = 0, + ScLogin = 1, + ScSyncBaseData = 2, + ScNtfErrorCode = 3, + ScGmCommand = 4, + ScPing = 5, + ScReconnectIncr = 6, + ScReconnectFull = 7, + ScFlushSync = 8, + ScNtfCode = 9, + ScSetName = 10, + ScSetGender = 11, + ScCheckName = 12, + ScCheckSensitive = 13, + ScSyncFullDataEnd = 14,// + ScAchieveComplete = 15, + ScSyncAllRoleScene = 20,// + ScObjectEnterView = 21, + ScObjectLeaveView = 22, + ScMoveObjectMove = 23, + ScEnterSceneNotify = 24, + ScSelfSceneInfo = 25, + ScLeaveSceneNotify = 26, + ScSceneSetLastRecordCampid = 27, + ScSceneUpdateInteractiveProperty = 28, + ScSceneSetVar = 29, + ScSceneRevival = 30, + ScSceneCreateEntity = 31, + ScSceneDestroyEntity = 32, + ScSceneSetSafeZone = 35, + ScSceneQueryEntityExist = 36, + ScSceneLevelScriptStateNotify = 37, + ScSceneQueryInteractiveProperty = 38, + ScSceneUnlockArea = 39, + ScSceneSetTrackPoint = 40, + ScSceneCollectionSync = 42, // + ScSceneCollectionModify = 43, + ScSceneMapMarkSync = 44,// + ScSceneStaticMapMarkModify = 45, + ScSceneTeleport = 46, + ScSceneSubmitItem = 47, + ScSceneSubmitEther = 48, + ScSceneUpdateLevelScriptProperty = 49, + ScSceneResetEntity = 50, + ScSceneLevelScriptResetBegin = 51, + ScSceneLevelScriptResetEnd = 52, + ScSceneSetBattle = 53, + ScSceneLevelScriptEventTrigger = 55, + ScSceneInteractiveEventTrigger = 56, + ScSceneTriggerClientLevelScriptEvent = 57, + ScSceneTriggerClientInteractiveEvent = 58, + ScSceneCrossSceneStatus = 59, + ScSceneDropCreate = 800, + ScSceneDropDelete = 801, + ScSceneDropModify = 802, + ScSceneGradeChangeNotify = 803, + ScSeamlessSceneDestroyNotify = 804, + ScSceneMonsterSpawnerStart = 805, + ScSceneMonsterSpawnerStop = 806, + ScSceneMonsterSpawnerComplete = 807, + ScSceneMonsterSpawnerBeginWave = 808, + ScSceneMonsterSpawnerWaveComplete = 809, + ScSceneMonsterSpawnerObjectDataBegin = 811, + ScSceneMonsterSpawnerObjectDataEnd = 812, + ScSceneLevelScriptTaskStateUpdate = 813, + ScSceneClientIdInfo = 814, + ScSceneLevelScriptTaskProgressUpdate = 815, + ScSceneLevelScriptTaskStartFinish = 816, + ScSceneInteractSpInteractive = 817, + ScSceneUpdateInteractiveMeta = 818, + ScSceneGradeModify = 819, + ScSceneSetStorySafeZone = 820, + ScSceneRepatriate = 821, + ScSceneSubmitRecycle = 822, + ScSceneLevelScriptSetDone = 823, + ScSyncCharBagInfo = 60,// + ScCharBagAddChar = 61, + ScCharBagSetTeam = 62, + ScCharBagSetCurrTeamIndex = 63, + ScCharBagSetTeamName = 64, + ScCharBagSetTeamLeader = 65, + ScCharBagSetMaxTeamMemberCount = 66, + ScCharBagTeamLeaderNotMatchNtf = 67, + ScCharBagDelChar = 68, + ScCharBagAddCharWithConversionNotify = 69, + ScSyncWallet = 70,// + ScWalletSyncMoney = 71, + ScCharSkillInfos = 78, + ScCharPotentialUnlock = 79, + ScCharLevelUp = 80, + ScCharSyncLevelExp = 82, + ScCharSetNormalSkill = 83, + ScCharSkillLevelUp = 84, + ScCharUnlockSkill = 85, + ScCharGainExpToast = 86, + ScCharSyncStatus = 87, + ScCharSetTeamSkill = 89, + ScEquipPuton = 90, + ScEquipPutoff = 91, + ScEquipMedicineModify = 92, + ScEquipRecycle = 93, + ScEquipEnhance = 94, + ScEquipProduce = 96, + ScSyncAllMission = 110,// + ScQuestStateUpdate = 111, + ScMissionStateUpdate = 112, + ScQuestFailed = 113, + ScMissionFailed = 114, + ScTrackMissionChange = 115, + ScQuestObjectivesUpdate = 116, + ScMissionDeleted = 117, + ScRollBlocMission = 120, + ScSyncBlocMissionInfo = 121,// + ScBlocCompletedMissionNumUpdate = 122, + ScQuestRollback = 123, + ScUpdateMissionProperty = 124, + ScSceneTriggerClientMissionEvent = 125, + ScMissionEventTrigger = 126, + ScDailyMissionInfoUpdate = 127, + ScSyncAllDialog = 130,// + ScFinishDialog = 131, + ScSyncAllGuide = 140,// + ScCompleteGuideGroupKeyStep = 141, + ScCompleteGuideGroup = 142, + ScAcceptGuideGroup = 143, + ScSyncAttr = 150, + ScSyncAllUnlock = 160,// + ScUnlockSystem = 161, + ScSyncAllBitset = 165,// + ScBitsetAdd = 166, + ScBitsetRemove = 167, + ScBitsetRemoveAll = 168, + ScFactorySync = 200,// + ScFactoryModifyFormulaMan = 201, + ScFactoryModifyStt = 202, + ScFactoryModifyVisibleFormula = 203, + ScFactoryModifyFormulaMode = 204, + ScFactorySyncOfflineInfo = 205,// + ScFactorySyncScope = 210,// + ScFactoryReleaseScope = 211, + ScFactoryModifyScope = 212, + ScFactoryModifyQuickbar = 213, + ScFactoryManuallyWorkExec = 214, + ScFactoryProductManualUnlock = 215, + ScFactoryModifySoil = 216, + ScFactorySoilReclaim = 217, + ScFactorySoilWater = 218, + ScFactorySoilCancel = 219, + ScFactorySoilHarvest = 220, + ScFactorySyncChapter = 221,// + ScFactoryModifyChapterNodes = 222, + ScFactoryModifyChapterComponents = 223, + ScFactoryModifyChapterScene = 224, + ScFactoryModifyChapterBlackboard = 225, + ScFactoryModifyChapterPinBoard = 226, + ScFactoryModifyChapterMap = 227, + ScFactoryHs = 231, + ScFactoryHsSync = 232,// + ScFactorySyncStatistic = 241, + ScFactoryModifyStatistic = 242, + ScFactoryStatisticRequire = 243, + ScFactoryHubWorkshopMake = 244, + ScFactoryHubTransportRouteModify = 245, + ScFactoryModifyStatisticBookmark = 246, + ScFactoryOpRet = 251, + ScFactoryObserverRet = 259, + ScWeaponPuton = 260, + ScWeaponBreakthrough = 262, + ScWeaponAddExp = 263, + ScWeaponAttachGem = 264, + ScWeaponDetachGem = 265, + ScWeaponRefineUpgrade = 266, + ScRewardToastBegin = 270, + ScRewardToastEnd = 271, + ScRewardDropMoneyToast = 272, + ScRewardToSceneBegin = 273, + ScRewardToSceneEnd = 274, + ScRewardDropSpItemToast = 275, + ScSyncAllBloc = 280,// + ScBlocSyncLevel = 281, + ScBlocTakeLevelReward = 282, + ScBlocShopBuy = 283, + ScDungeonBegin = 300, + ScEnterDungeon = 301, + ScRestartDungeon = 302, + ScLeaveDungeon = 303, + ScSyncStamina = 304, + ScSyncFullDungeonStatus = 306, + ScDungeonEnd = 359, + ScSyncAllMail = 400,// + ScGetMail = 401, + ScReadMail = 402, + ScGetMailAttachment = 403, + ScDelMailNotify = 404, + ScNewMailNotify = 405, + ScMarkStarMail = 406, + ScSyncGameMode = 430, + ScRemoveItemNewTags = 440, + ScSyncAllWiki = 470, + ScSyncAllStat = 500, + ScSyncStat = 501, + ScNewNoticeNotify = 600, + ScCreateOrder = 650, + ScOrderMsg = 651, + ScFriendBegin = 700, + ScFriendRequestSubmit = 701, + ScFriendRequestReject = 702, + ScFriendRequestAccept = 703, + ScFriendDelete = 704, + ScFriendSearchName = 705, + ScFriendRequestListSync = 706, + ScFriendListSync = 707, + ScFriendRequestAddNotify = 708, + ScFriendAddNotify = 709, + ScFriendEnd = 750, + ScUpdateGameVar = 901, + ScSyncAllGameVar = 902,// + ScUpdateMiniGame = 913, + ScSyncAllMiniGame = 914,// + ScCompleteMiniGame = 915, + ScRpgDungeonBegin = 950, + ScRpgDungeonBuy = 951, + ScRpgDungeonSell = 952, + ScRpgDungeonEquipPuton = 953, + ScRpgDungeonEquipPutoff = 954, + ScSyncRpgEquipColumn = 955, + ScSyncRpgDungeonBuffList = 956, + ScSyncRpgTeamLevel = 957, + ScSyncRpgLevelUp = 958, + ScRpgDungeonPickLvAbility = 959, + ScSyncRpgDungeonTimeInfo = 960, + ScSyncRpgDungeonAbility = 961, + ScRpgDungeonEnd = 999, + ScItemBagCommonSync = 1000,// + ScItemBagCommonModify = 1001, + ScItemBagScopeSync = 1002,// + ScItemBagScopeModify = 1003, + ScItemBagUseItem = 1004, + ScItemBagSetQuickBar = 1005, + ScItemBagSetQuickBarPos = 1006, + ScItemBagSetItemLock = 1007, + ScItemBagAbandonInBag = 1008, + ScItemBagBagToFactoryDepot = 1009, + ScItemBagTakeoutLostAndFound = 1031, + ScItemBagGotItemToast = 1032, + ScItemBagTrialCharDepotModify = 1033, + ScItemBagTrialCharDepotClear = 1034, + ScItemBagUseItemCase = 1035, + ScItemBagChgSpaceshipChapter = 1036, + ScItemBagEnd = 1049, + ScAddBuff = 1100, + ScRemoveBuff = 1101, + ScTriggerBuff = 1102, + ScClearBuffs = 1103, + ScCastSkill = 1160, + ScSyncHp = 1161, + ScSyncPoise = 1162, + ScSyncUltimateSpCellCnt = 1163, + ScSpawnEnemy = 1170, + ScSpawnSummon = 1171, + ScEntityPropertyChange = 1172, + ScBattleDebugInfo = 1173, + ScBattleGenerationChange = 1174, + ScAttachServerSkill = 1175, + ScDetachServerSkill = 1176, + ScAddServerBuff = 1177, + ScRemoveServerBuff = 1178, + ScSpaceshipSync = 1200,// + ScSpaceshipModifyRoom = 1201, + ScSpaceshipModifyChar = 1202, + ScSpaceshipPresentCharInfo = 1203, + ScSpaceshipCharFavorabilityChange = 1204, + ScSpaceshipRecvGiftFromChar = 1205, + ScSpaceshipPresentGiftToChar = 1206, + ScSpaceshipSyncRoomLevelUp = 1207, + ScSpaceshipSyncCharSkill = 1208, + ScSpaceshipSyncRoomStation = 1209, + ScSpaceshipManufacturingStationSync = 1210, + ScSpaceshipManufacturingStationStart = 1211, + ScSpaceshipManufacturingStationCancel = 1212, + ScSpaceshipManufacturingStationCollect = 1213, + ScSpaceshipModifyGrowCabin = 1214, + ScSpaceshipGrowCabinBreed = 1215, + ScSpaceshipGrowCabinSow = 1216, + ScSpaceshipGrowCabinHarvest = 1217, + ScSpaceshipGrowCabinCancel = 1218, + ScSpaceshipReportCharWorkModify = 1219, + ScSpaceshipReportOutputModify = 1220, + ScGameMechanicsBegin = 1250, + ScGameMechanicsSync = 1251,// + ScGameMechanicsSyncUnlockCondition = 1252, + ScGameMechanicsModifyRecords = 1253, + ScGameMechanicsSyncChallengeStart = 1254, + ScGameMechanicsSyncChallengeComplete = 1255, + ScGameMechanicsSyncCompletionReward = 1256, + ScGameMechanicsSyncEnterGameInst = 1257, + ScGameMechanicsSyncLeaveGameInst = 1258, + ScGameMechanicsSyncRestartGameInst = 1259, + ScGameMechanicsModifyInstTimeFreeze = 1260, + ScGameMechanicsEnd = 1299, + ScSnsBegin = 1300, + ScSnsGetMomentList = 1301, + ScSnsGetChatList = 1302, + ScSyncSnsAddDialog = 1303, + ScSnsMomentOption = 1304, + ScSyncSnsDialogModify = 1305, + ScSyncSnsAddMoment = 1306, + ScSnsMomentRead = 1307, + ScSnsReadDialog = 1308, + ScSyncSnsChatModify = 1309, + ScSnsEnd = 1330, + ScSettlementBegin = 1331, + ScSettlementSyncAll = 1332,// + ScSettlementSyncModify = 1333, + ScSettlementFinishRequires = 1334, + ScSettlementSetOfficer = 1335, + ScSettlementSelectRequire = 1336, + ScSettlementSetSubmitMode = 1337, + ScSettlementEnd = 1350, + ScShopBegin = 1351, + ScShopSync = 1352,// + ScShopSyncShopGroupCondition = 1353, + ScShopModifyShop = 1354, + ScShopSyncShopCondition = 1355, + ScShopSyncGoodsCondition = 1356, + ScShopModifyFrequencyLimit = 1357, + ScShopDeleteFrequencyLimit = 1358, + ScShopBuyResp = 1359, + ScShopSwapMoney = 1360, + ScShopEnd = 1370, + ScTdBegin = 1371, + ScTdGetTdList = 1372, + ScTdStart = 1373, + ScTdLeave = 1374, + ScSyncTdSettlement = 1375, + ScSyncTdFullStatus = 1376, + ScSyncTdDropItem = 1378, + ScTdPickDropItem = 1379, + ScTdBuyBuilding = 1380, + ScTdEnd = 1400, + ScAdventureBegin = 1401, + ScAdventureLevelModify = 1402, + ScAdventureSyncAll = 1403,// + ScAdventureEnd = 1430, + ScGemRecast = 1431, + ScGemEnd = 1440, + ScResetDailyAdventureTask = 1441, + ScDailyActivationModify = 1443, + ScAdventureTaskModify = 1444, + ScAdventureBookSync = 1445,// + ScAdventureBookStageModify = 1447, + ScTalentBegin = 1490, + ScCharUnlockTalentNode = 1491, + ScTalentEnd = 1529, + ScRacingDungeonBegin = 1530, + ScSyncRacingDungeonPassedLevel = 1531, + ScRacingDungeonEnter = 1532, + ScSyncRacingDungeonSettlement = 1533, + ScSyncRacingDungeonReconnect = 1534, + ScRacingDungeonBattlePassReceiveReward = 1535, + ScRacingDungeonGetBattlePass = 1536, + ScRacingDungeonGetAchievement = 1537, + ScRacingDungeonAchievementReceiveReward = 1538, + ScSyncRacingDungeonBuffModify = 1539, + ScSyncRacingDungeonAchievementModify = 1540, + ScSyncRacingTimerPause = 1541, + ScSyncRacingDungeonCompleteRoom = 1542, + ScSyncRacingDungeonCountdownEvent = 1543, + ScRacingDungeonEnd = 1600, + ScCharBagSetTempTeam = 1601, + ScCharBagRemoveTrialCharacter = 1602, + ScTrialCharacterEquipMedicineModify = 1603, + ScGachaBegin = 1610, + ScGachaSync = 1611,// + ScGachaModifyPoolInfo = 1612, + ScGachaSyncPullResult = 1613, + ScGachaModifyPoolRoleData = 1614, + ScGachaEnd = 1640, + ScGameTimeFreezeBegin = 1641, + ScGameTimeFreezeStartRsp = 1642, + ScGameTimeFreezeEndRsp = 1643, + ScGameTimeFreezeEnd = 1650, + ScActivityBegin = 1651, + ScActivitySync = 1652,// + ScActivityModify = 1653, + ScDailyCheckin = 1661, + ScActivityEnd = 1690, + ScMessageEnd = 4095, -} + } } diff --git a/Campofinale/Campofinale.csproj b/Campofinale/Campofinale.csproj index 1302251..c3242e2 100644 --- a/Campofinale/Campofinale.csproj +++ b/Campofinale/Campofinale.csproj @@ -8,6 +8,7 @@ true AnyCPU;x86;ARM32 Program + app.manifest @@ -29,6 +30,7 @@ + diff --git a/Campofinale/Commands/BaseCommands.cs b/Campofinale/Commands/BaseCommands.cs index 3a091ed..31b8241 100644 --- a/Campofinale/Commands/BaseCommands.cs +++ b/Campofinale/Commands/BaseCommands.cs @@ -1,15 +1,4 @@ -using Campofinale.Database; -using Campofinale.Game.Entities; -using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Resource.ResourceManager; - -namespace Campofinale.Commands +namespace Campofinale.Commands { public static class BaseCommands { diff --git a/Campofinale/Commands/CommandManager.cs b/Campofinale/Commands/CommandManager.cs index ee84bb5..61e9689 100644 --- a/Campofinale/Commands/CommandManager.cs +++ b/Campofinale/Commands/CommandManager.cs @@ -1,15 +1,10 @@ namespace Campofinale.Commands { - using Pastel; using System; using System.Collections.Generic; - using System.Drawing; using System.Collections.Immutable; using System.Linq.Expressions; using System.Reflection; - using System.Net.Sockets; - using Campofinale.Protocol; - using Campofinale.Network; public static class CommandManager { diff --git a/Campofinale/Commands/Handlers/CommandAccount.cs b/Campofinale/Commands/Handlers/CommandAccount.cs index c3a6682..fb43107 100644 --- a/Campofinale/Commands/Handlers/CommandAccount.cs +++ b/Campofinale/Commands/Handlers/CommandAccount.cs @@ -1,9 +1,4 @@ using Campofinale.Database; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Commands.Handlers { diff --git a/Campofinale/Commands/Handlers/CommandAdd.cs b/Campofinale/Commands/Handlers/CommandAdd.cs index 8cb9fb3..fd88b2b 100644 --- a/Campofinale/Commands/Handlers/CommandAdd.cs +++ b/Campofinale/Commands/Handlers/CommandAdd.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Campofinale.Game.Character; using Campofinale.Game.Inventory; using Campofinale.Packets.Sc; @@ -28,15 +23,12 @@ public static class CommandAdd case "item": Item item=target.inventoryManager.AddItem(args[1], int.Parse(args[2])); message = $"Item {args[1]} was added to {target.nickname}"; - - target.Send(new PacketScItemBagScopeModify(target, item)); break; case "weapon": Item wep = target.inventoryManager.AddWeapon(args[1], Convert.ToUInt64(args[2])); message = $"Weapon {args[1]} was added to {target.nickname}"; - target.Send(new PacketScItemBagScopeModify(target, wep)); break; case "char": @@ -77,7 +69,7 @@ public static class CommandAdd return; } - target.inventoryManager.Save(); + CommandManager.SendMessage(sender, $"{message}."); } catch (Exception err) diff --git a/Campofinale/Commands/Handlers/CommandCharInfo.cs b/Campofinale/Commands/Handlers/CommandCharInfo.cs index 1e90266..6dc08ef 100644 --- a/Campofinale/Commands/Handlers/CommandCharInfo.cs +++ b/Campofinale/Commands/Handlers/CommandCharInfo.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MongoDB.Bson; using static Campofinale.Resource.ResourceManager; -using Newtonsoft.Json; using Campofinale.Game.Character; using Campofinale.Database; using Campofinale.Game.Inventory; diff --git a/Campofinale/Commands/Handlers/CommandClear.cs b/Campofinale/Commands/Handlers/CommandClear.cs index b2752f6..aeda8b5 100644 --- a/Campofinale/Commands/Handlers/CommandClear.cs +++ b/Campofinale/Commands/Handlers/CommandClear.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Commands.Handlers +namespace Campofinale.Commands.Handlers { public static class CommandClear { diff --git a/Campofinale/Commands/Handlers/CommandHeal.cs b/Campofinale/Commands/Handlers/CommandHeal.cs index 73e84c5..992c2b2 100644 --- a/Campofinale/Commands/Handlers/CommandHeal.cs +++ b/Campofinale/Commands/Handlers/CommandHeal.cs @@ -1,12 +1,6 @@ -using Campofinale.Game.Entities; -using Campofinale.Packets.Sc; +using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Commands.Handlers { diff --git a/Campofinale/Commands/Handlers/CommandHelp.cs b/Campofinale/Commands/Handlers/CommandHelp.cs index 0f015f7..05f4957 100644 --- a/Campofinale/Commands/Handlers/CommandHelp.cs +++ b/Campofinale/Commands/Handlers/CommandHelp.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Commands.Handlers +namespace Campofinale.Commands.Handlers { public static class CommandHelp { diff --git a/Campofinale/Commands/Handlers/CommandIdList.cs b/Campofinale/Commands/Handlers/CommandIdList.cs index a772883..482ac5d 100644 --- a/Campofinale/Commands/Handlers/CommandIdList.cs +++ b/Campofinale/Commands/Handlers/CommandIdList.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Commands.Handlers diff --git a/Campofinale/Commands/Handlers/CommandKick.cs b/Campofinale/Commands/Handlers/CommandKick.cs index fbf0a61..9cc87d9 100644 --- a/Campofinale/Commands/Handlers/CommandKick.cs +++ b/Campofinale/Commands/Handlers/CommandKick.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Commands.Handlers { diff --git a/Campofinale/Commands/Handlers/CommandLevel.cs b/Campofinale/Commands/Handlers/CommandLevel.cs index 955a8c8..757fe87 100644 --- a/Campofinale/Commands/Handlers/CommandLevel.cs +++ b/Campofinale/Commands/Handlers/CommandLevel.cs @@ -1,5 +1,4 @@ using Campofinale.Commands; -using Campofinale.Database; using Campofinale.Packets.Sc; using Campofinale.Resource; @@ -61,7 +60,7 @@ namespace Campofinale.Game.Character } int updatedItemCount = 0; - foreach (var item in target.inventoryManager.items) + foreach (var item in target.inventoryManager.items.items) { if (item.id.StartsWith("wpn_")) { diff --git a/Campofinale/Commands/Handlers/CommandNickname.cs b/Campofinale/Commands/Handlers/CommandNickname.cs index c8a0f47..f58691d 100644 --- a/Campofinale/Commands/Handlers/CommandNickname.cs +++ b/Campofinale/Commands/Handlers/CommandNickname.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Campofinale.Packets.Sc; namespace Campofinale.Commands.Handlers @@ -19,11 +14,6 @@ namespace Campofinale.Commands.Handlers return; } - for (int i=0; i < args.Length; i++) - { - args[i] = Uri.UnescapeDataString(args[i]); - } - target.nickname = string.Join(" ", args); target.Save(); target.Send(new PacketScSetName(target, target.nickname)); diff --git a/Campofinale/Commands/Handlers/CommandPlayers.cs b/Campofinale/Commands/Handlers/CommandPlayers.cs index 78c17c6..804c4b6 100644 --- a/Campofinale/Commands/Handlers/CommandPlayers.cs +++ b/Campofinale/Commands/Handlers/CommandPlayers.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Commands.Handlers +namespace Campofinale.Commands.Handlers { public static class CommandPlayers { diff --git a/Campofinale/Commands/Handlers/CommandRemove.cs b/Campofinale/Commands/Handlers/CommandRemove.cs index 02b8f47..fcec4a7 100644 --- a/Campofinale/Commands/Handlers/CommandRemove.cs +++ b/Campofinale/Commands/Handlers/CommandRemove.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Campofinale.Database; using Campofinale.Game.Character; using Campofinale.Packets.Sc; diff --git a/Campofinale/Commands/Handlers/CommandSpawn.cs b/Campofinale/Commands/Handlers/CommandSpawn.cs index b764ae6..ed3a097 100644 --- a/Campofinale/Commands/Handlers/CommandSpawn.cs +++ b/Campofinale/Commands/Handlers/CommandSpawn.cs @@ -1,10 +1,5 @@ using Campofinale.Game.Entities; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Commands.Handlers { diff --git a/Campofinale/Commands/Handlers/CommandTeleport.cs b/Campofinale/Commands/Handlers/CommandTeleport.cs index 3ab8037..1f1f400 100644 --- a/Campofinale/Commands/Handlers/CommandTeleport.cs +++ b/Campofinale/Commands/Handlers/CommandTeleport.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using Campofinale.Packets.Sc; using MongoDB.Bson; +using System.Globalization; namespace Campofinale.Commands.Handlers { @@ -23,20 +19,25 @@ namespace Campofinale.Commands.Handlers for (int i=0; i < args.Length; i++) { - args[i] = Uri.UnescapeDataString(args[i]).Replace(".", ","); + args[i] = args[i].Replace(",", "."); } - float x, y, z; + float[] pos = [target.position.x, target.position.y, target.position.z]; - x = args[0] == "~" ? target.position.x : float.Parse(args[0]); - y = args[1] == "~" ? target.position.y : float.Parse(args[1]); - z = args[2] == "~" ? target.position.z : float.Parse(args[2]); + for (int i=0; i < args.Length; i++) { + if(args[i] == "~") continue; + + float curPos = pos[i]; + pos[i] = float.Parse(args[i].StartsWith("--") ? args[i].Trim('-') : args[i], CultureInfo.InvariantCulture); + if (args[i].StartsWith('+')) pos[i] += curPos; + if (args[i].StartsWith("--")) pos[i] = curPos - pos[i]; + } Vector3f position = new Vector3f(new Vector() { - X = x, - Y = y, - Z = z + X = pos[0], + Y = pos[1], + Z = pos[2] }); target.position = position; diff --git a/Campofinale/Commands/Handlers/CommandUnlockAll.cs b/Campofinale/Commands/Handlers/CommandUnlockAll.cs index a3829ae..e41555d 100644 --- a/Campofinale/Commands/Handlers/CommandUnlockAll.cs +++ b/Campofinale/Commands/Handlers/CommandUnlockAll.cs @@ -1,12 +1,6 @@ -using Campofinale.Database; -using Campofinale.Packets.Sc; +using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Commands.Handlers { diff --git a/Campofinale/ConfigFile.cs b/Campofinale/ConfigFile.cs index 009bcfa..2f7d1b9 100644 --- a/Campofinale/ConfigFile.cs +++ b/Campofinale/ConfigFile.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale +namespace Campofinale { public class ConfigFile { @@ -14,30 +8,39 @@ namespace Campofinale public ServerOptions serverOptions = new(); public LogSettings logOptions = new(); } - public struct ServerOptions + public class ServerOptions { - public int defaultSceneNumId = 98; + public int defaultSceneNumId = 87; public int maxPlayers = 20; - + public CharactersOptions defaultCharacters = new(); public ServerOptions() { } + public class CharactersOptions + { + public int defaultLevel = 1; + public bool giveAllCharacters = true; + public List characters = new List(); //used if giveAllCharacters is false + public CharactersOptions() { } + } /* public struct WelcomeMail { }*/ } - public struct LogSettings + public class LogSettings { - public bool packets; - public bool debugPrint=false; + public bool packets = true; + public bool packetWarnings = true; + public bool packetBodies = false; + public bool debugPrint = false; public LogSettings() { } } - public struct GameserverSettings + public class GameserverSettings { public string bindAddress = "127.0.0.1"; public int bindPort = 30000; @@ -47,10 +50,9 @@ namespace Campofinale { } } - public struct DispatchServerSettings + public class DispatchServerSettings { public string bindAddress = "127.0.0.1"; - public int bindPort = 5000; public string accessAddress = "127.0.0.1"; public int accessPort = 5000; @@ -60,7 +62,7 @@ namespace Campofinale } } - public struct MongoDatabaseSettings + public class MongoDatabaseSettings { public string uri = "mongodb://localhost:27017"; public string collection = "Campofinale"; diff --git a/Campofinale/Crypto/CSChaCha20.cs b/Campofinale/Crypto/CSChaCha20.cs index 6415cd2..ea9358c 100644 --- a/Campofinale/Crypto/CSChaCha20.cs +++ b/Campofinale/Crypto/CSChaCha20.cs @@ -15,9 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -using System; -using System.IO; -using System.Threading.Tasks; using System.Runtime.Intrinsics; using System.Runtime.CompilerServices; diff --git a/Campofinale/Data/PlayerConsole/index.html b/Campofinale/Data/PlayerConsole/index.html index c79e32d..8021473 100644 --- a/Campofinale/Data/PlayerConsole/index.html +++ b/Campofinale/Data/PlayerConsole/index.html @@ -154,7 +154,7 @@ try { const url = new URL('%dispatchip%/pcSdk/console'); - url.searchParams.append('command', command); + url.searchParams.append('command', btoa(unescape(encodeURIComponent(command)))); url.searchParams.append('token', token); const response = await fetch(url.toString(), { diff --git a/Campofinale/Data/res_versions/2089329-32/index_initial.json b/Campofinale/Data/res_versions/2089329-32/index_initial.json new file mode 100644 index 0000000..efad5f3 --- /dev/null +++ b/Campofinale/Data/res_versions/2089329-32/index_initial.json @@ -0,0 +1 @@ +{"isInitial":true,"files":[{"index":1,"name":"VFS/CA2A581090AB4133/CA2A581090AB4133.blc","hash":"e75b8886d2426ec6b1e7f362bcd5255d","size":302,"urlPath":null,"manifest":7},{"index":2,"name":"VFS/CA2A581090AB4133/0DBA81C558A36AFC1D7D1C0A5A704A09.chk","hash":null,"size":80879438,"urlPath":null,"manifest":0},{"index":3,"name":"VFS/8F0DD938C04FD953/8F0DD938C04FD953.blc","hash":"d236d4691a5815ba973fa365ff6357f9","size":59,"urlPath":null,"manifest":3},{"index":4,"name":"VFS/16BB5AC00009A71B/16BB5AC00009A71B.blc","hash":"689374e7c7ec263dfd66fd255351fded","size":331,"urlPath":null,"manifest":3},{"index":5,"name":"VFS/16BB5AC00009A71B/6A2B02D8FCE1ED28849D1596D779CFA9.chk","hash":null,"size":14236423,"urlPath":null,"manifest":4},{"index":6,"name":"VFS/16BB5AC00009A71B/DA88C18EED8D9DEE8326BAA9AB78AA78.chk","hash":null,"size":1193655,"urlPath":null,"manifest":4},{"index":7,"name":"VFS/AAD6005BEB6AE986/AAD6005BEB6AE986.blc","hash":"51603590679e7d8590a3a1f908a38ed1","size":27360,"urlPath":null,"manifest":3},{"index":8,"name":"VFS/AAD6005BEB6AE986/1745D582258DFD069CDA135DDC740D34.chk","hash":null,"size":124467976,"urlPath":null,"manifest":4},{"index":9,"name":"VFS/B28236B7FAB03015/B28236B7FAB03015.blc","hash":"1baf1a032b9e204652eac0a7256621a7","size":15912,"urlPath":null,"manifest":7},{"index":10,"name":"VFS/B28236B7FAB03015/86BC72728AE017306E7CBE8DC67C93A9.chk","hash":null,"size":46679427,"urlPath":null,"manifest":0}],"types":null,"version":null} \ No newline at end of file diff --git a/Campofinale/Data/res_versions/2089329-32/ori.json b/Campofinale/Data/res_versions/2089329-32/ori.json new file mode 100644 index 0000000..7f7d19f --- /dev/null +++ b/Campofinale/Data/res_versions/2089329-32/ori.json @@ -0,0 +1 @@ +4Fmf1Xuly6yikdJUcayl2cpjWMibo8erW2rBrVmhocjKr1icY2OEppqdy1RxWomquGZ5o2R4l3BqYJ9ieHpnlZhqZaVzaaNtcWGWa2d5dZiWammQlKPFWmVSzpOqoFWeh5xtl5RvmnBvlJhmaW6Yx5uZZ8dpnZVua5LJlmxqaJnJWWKEpaDcnVtqmWJpZFXZ16OGw6afhHKnpdKeY1qgxdOgnMelq4RycK2SrVmhocjKr1icZGOEppqdy1RxWomquGZ5o2R4l3BqYJ9ieHpnlZhqZZJ2eaNwanObZ295ZpqmfXmTdm6maXxgp2d4b2OYpmdvkJWfzVplUs6TqqBVntOsos5eWdWhs5WIbG9oa5uea2maXlnXqqWAx6afWm3S2qOijlSkw6ailsulq1ptlOJjsYSbpcadsVKgZWNaocXSnFicVI2oi2horGJ7fGyXnXpmlnh7m21sX554Z3x3nZhveZJmfaZxbmOUlKObVZCHn5fVmlmcWp1imWibbGmdlphrmmNsxJlyZ5mYmGtpmcudbJVnbshxW1yIpaCymIafbG+OVKzUpImR2ppZcqHZ0aNihJ+Y0KGfldmmWXJm4ZGyWMugm8ewW2qaXlmmlNHKWXCEiH21Z2pmqHRseXaUlWdmm3Nuk3poYZx0eW10p5VnZpJreJlpe17InppaX4bNmKnKVHGEbnFpmWlrnWrHnJyZlGhqxp6dZpyYm2pomZhsZ8iWnMZaZVLZm7GdVZ6YameOVKzUpImR2ppZcqHZ0aNihJ+Y0KGfldmmWXJm4ZGyWMugm8ewW2qbXlmmlNHKWXCEiH21Z2pmqHRseXaUlWdmm3Nuk3poZqdkeWhlqJ19eadjfKZqcWiaa3tpaJ2be22Za3qoeXJeyZqiWl+GzZipylRx0K2lnJJUqqGtyYdxZ5Zkaphsa2OSVKyqn7TGq56EbKXXpKVciJ+YppzKyqqqhGxr32S0Us+gm52rhp9tYoSgmM+dW2qIiH2LYpWbeXiXc3qSaGlgn3NuaXWTqXhumnVomn1+dJ52cHx4qZ1qaJh0eKNxenKdanh5apyTmp7NVGOEoJqjzlRxpqjQ0WNY1Zuxx1pzYZdram5omZFZq9Seh8OsoVKgoKykn5CHpJfQm53Hq61SoGa0ZK6GzqWax6pZnG9lUtSTpJ1VnoeNfLVheKN8b2CWZ3l9dZqmfG+aaGajeX1mlmJsenimm3h7m2ptkJqlk4heWaCU181ZcIRnaJhobGWfYm1vbMmcm26Xa2fDa5phzGtncJSXnZyak1RjhKuiqstUcWpql5tnYoSnqc6ImqTOVHGmqNDRY1jPk6XLnp6j2lRxa7CQ4Fmf0Jac2lpzaJJUpZmgyYdxWLh4ipF5enScYmdtdamnbXena2+YZ2pnmmd7bWuWl2xupnh7km5yc6pzaGtoqKl6bZZie5VsZ5POnVlkVczGqp6EbKXXpKVciKWgspiGn2holmZtmXFwZpJUrKqftMarnoRspdekpVyIn5imnMrKqqqEbGvfZLRSz6CbnauGn3BihKCYz51baoiIfYtippdvaJVoeZl+enKWZWdpaJOnaW6UZW2kb39xqGJqaGSZk5mixVRjhKCao85UcVpkxsadZ8NiapSacpWYYmtuaJbKmJmSk26UbW9mmGOYb1WQh6qf3JdZnGluaZdkY1qo1tGHl9aaWZymrpzSXlmllNLOnZvVplmcb7Zc4VSgppfJ3Vlwk2JjhKaanctUcVqJqrhmeJRqaZVue2esc3loZpSWbGWaaHmlb2tnmGp4fWOVnGpmmHdupXp+aKp1bW92nZh4b5CVn81aZVLOk6qgVZ7TrKLOXlnVobOViGxrbmmbnmtomV5Z16qlgMemn1pt0tqjoo5UpMOmopbLpatabZTilGKEprDSnaxSoKCspJ+Qh62b1KWg0aZbatSno6Sw \ No newline at end of file diff --git a/Campofinale/Database/Database.cs b/Campofinale/Database/Database.cs index 3ef9d80..1f2af8c 100644 --- a/Campofinale/Database/Database.cs +++ b/Campofinale/Database/Database.cs @@ -3,19 +3,12 @@ using Campofinale.Game.Character; using Campofinale.Game.Gacha; using Campofinale.Game.Inventory; using Campofinale.Game.Spaceship; -using Campofinale.Resource; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Driver; -using System; -using System.Collections.Generic; -using System.Linq; using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; -using static Campofinale.Player; using static Campofinale.Resource.ResourceManager; -using static SQLite.SQLite3; namespace Campofinale.Database { @@ -42,6 +35,8 @@ namespace Campofinale.Database public List scenes = new(); public Dictionary> bitsets = new(); public PlayerSafeZoneInfo savedSafeZone = new(); + public Gender gender = Gender.GenFemale; + public Dictionary bag = new(); } public class Account { @@ -141,7 +136,9 @@ namespace Campofinale.Database noSpawnAnymore = player.noSpawnAnymore, scenes=player.sceneManager.scenes, bitsets=player.bitsetManager.bitsets, - savedSafeZone = player.savedSaveZone + savedSafeZone = player.savedSaveZone, + gender=player.gender, + bag=player.inventoryManager.items.bag }; UpsertPlayerData(data); } diff --git a/Campofinale/Database/DatabaseManager.cs b/Campofinale/Database/DatabaseManager.cs index a267ddd..e769373 100644 --- a/Campofinale/Database/DatabaseManager.cs +++ b/Campofinale/Database/DatabaseManager.cs @@ -1,14 +1,9 @@ -using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.Serialization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using MongoDB.Bson.Serialization; using MongoDB.Bson.IO; using MongoDB.Bson; using System.Reflection; using static Campofinale.Game.Factory.FactoryNode; +using Campofinale.Game.Inventory; namespace Campofinale.Database { @@ -68,6 +63,8 @@ namespace Campofinale.Database { BsonSerializer.RegisterSerializer(typeof(Dictionary), new CustomDictionarySerializer()); BsonSerializer.RegisterSerializer(typeof(Dictionary>), new CustomDictionarySerializer>()); + BsonSerializer.RegisterSerializer(typeof(Dictionary), new CustomDictionarySerializer()); + RegisterSubclasses(); Logger.Print("Connecting to MongoDB..."); try diff --git a/Campofinale/Game/BitsetManager.cs b/Campofinale/Game/BitsetManager.cs index fe79911..65c7aba 100644 --- a/Campofinale/Game/BitsetManager.cs +++ b/Campofinale/Game/BitsetManager.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game diff --git a/Campofinale/Game/Character/Character.cs b/Campofinale/Game/Character/Character.cs index b6d01bc..86b8414 100644 --- a/Campofinale/Game/Character/Character.cs +++ b/Campofinale/Game/Character/Character.cs @@ -6,13 +6,6 @@ using Google.Protobuf.Collections; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.IdGenerators; -using MongoDB.Driver; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using static Campofinale.Resource.ResourceManager.CharGrowthTable; using static Campofinale.Resource.ResourceManager.WeaponUpgradeTemplateTable; @@ -149,6 +142,11 @@ namespace Campofinale.Game.Character guid = GetOwner().random.Next(); this.weaponGuid = GetOwner().inventoryManager.AddWeapon(ResourceManager.charGrowthTable[id].defaultWeaponId, 1).guid; this.curHp = CalcAttributes()[AttributeType.MaxHp].val; + if (level < 20) breakNode = ""; + if (level >= 20 && level <= 40) breakNode = "charBreak20"; + if (level > 40 && level <= 60) breakNode = "charBreak40"; + if (level > 60 && level <= 70) breakNode = "charBreak60"; + if (level > 70) breakNode = "charBreak70"; } public int GetSkillMaxLevel() { diff --git a/Campofinale/Game/Dungeons/Dungeon.cs b/Campofinale/Game/Dungeons/Dungeon.cs index 853167c..c22e73d 100644 --- a/Campofinale/Game/Dungeons/Dungeon.cs +++ b/Campofinale/Game/Dungeons/Dungeon.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Resource.ResourceManager; +using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Dungeons { diff --git a/Campofinale/Game/Entities/Entity.cs b/Campofinale/Game/Entities/Entity.cs index 5daac22..4cb04aa 100644 --- a/Campofinale/Game/Entities/Entity.cs +++ b/Campofinale/Game/Entities/Entity.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using static Campofinale.Resource.ResourceManager.LevelScene.LevelData; diff --git a/Campofinale/Game/Entities/EntityCharacter.cs b/Campofinale/Game/Entities/EntityCharacter.cs index dbfc034..806f932 100644 --- a/Campofinale/Game/Entities/EntityCharacter.cs +++ b/Campofinale/Game/Entities/EntityCharacter.cs @@ -1,10 +1,4 @@ -using Campofinale.Game.Character; -using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Campofinale.Protocol; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Entities diff --git a/Campofinale/Game/Entities/EntityInteractive.cs b/Campofinale/Game/Entities/EntityInteractive.cs index 891e63a..f57fafe 100644 --- a/Campofinale/Game/Entities/EntityInteractive.cs +++ b/Campofinale/Game/Entities/EntityInteractive.cs @@ -1,11 +1,6 @@ using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using static Campofinale.Resource.ResourceManager.LevelScene.LevelData; @@ -59,7 +54,7 @@ namespace Campofinale.Game.Entities Type = (int)5, }, - + //Meta =dependencyGroupId, BattleInfo = new() { diff --git a/Campofinale/Game/Entities/EntityMonster.cs b/Campofinale/Game/Entities/EntityMonster.cs index 7493a00..1f79384 100644 --- a/Campofinale/Game/Entities/EntityMonster.cs +++ b/Campofinale/Game/Entities/EntityMonster.cs @@ -1,10 +1,5 @@ using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Entities @@ -88,6 +83,7 @@ namespace Campofinale.Game.Entities Type =(int) ObjectTypeIndex.Enemy, }, + Attrs = { GetAttributes() diff --git a/Campofinale/Game/Entities/EntityNpc.cs b/Campofinale/Game/Entities/EntityNpc.cs index 2cf4b40..3c44da8 100644 --- a/Campofinale/Game/Entities/EntityNpc.cs +++ b/Campofinale/Game/Entities/EntityNpc.cs @@ -1,11 +1,4 @@ -using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Resource.ResourceManager; +using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Entities { diff --git a/Campofinale/Game/Factory/Components/FComponentBusLoader.cs b/Campofinale/Game/Factory/Components/FComponentBusLoader.cs index b9bf4d8..8a7e534 100644 --- a/Campofinale/Game/Factory/Components/FComponentBusLoader.cs +++ b/Campofinale/Game/Factory/Components/FComponentBusLoader.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentPortManager.cs b/Campofinale/Game/Factory/Components/FComponentPortManager.cs index 696919f..43e473d 100644 --- a/Campofinale/Game/Factory/Components/FComponentPortManager.cs +++ b/Campofinale/Game/Factory/Components/FComponentPortManager.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentPowerPole.cs b/Campofinale/Game/Factory/Components/FComponentPowerPole.cs index c7121af..483bc26 100644 --- a/Campofinale/Game/Factory/Components/FComponentPowerPole.cs +++ b/Campofinale/Game/Factory/Components/FComponentPowerPole.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentPowerSave.cs b/Campofinale/Game/Factory/Components/FComponentPowerSave.cs index 99510c5..35a0fa9 100644 --- a/Campofinale/Game/Factory/Components/FComponentPowerSave.cs +++ b/Campofinale/Game/Factory/Components/FComponentPowerSave.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentSelector.cs b/Campofinale/Game/Factory/Components/FComponentSelector.cs index 462637f..c77be14 100644 --- a/Campofinale/Game/Factory/Components/FComponentSelector.cs +++ b/Campofinale/Game/Factory/Components/FComponentSelector.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentStablePower.cs b/Campofinale/Game/Factory/Components/FComponentStablePower.cs index 4082ba7..84fa52d 100644 --- a/Campofinale/Game/Factory/Components/FComponentStablePower.cs +++ b/Campofinale/Game/Factory/Components/FComponentStablePower.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentSubHub.cs b/Campofinale/Game/Factory/Components/FComponentSubHub.cs index b6595a2..ffbc34f 100644 --- a/Campofinale/Game/Factory/Components/FComponentSubHub.cs +++ b/Campofinale/Game/Factory/Components/FComponentSubHub.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/Components/FComponentTravelPole.cs b/Campofinale/Game/Factory/Components/FComponentTravelPole.cs index 3576551..cda4e62 100644 --- a/Campofinale/Game/Factory/Components/FComponentTravelPole.cs +++ b/Campofinale/Game/Factory/Components/FComponentTravelPole.cs @@ -1,9 +1,4 @@ using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Factory.FactoryNode; namespace Campofinale.Game.Factory.Components diff --git a/Campofinale/Game/Factory/FactoryManager.cs b/Campofinale/Game/Factory/FactoryManager.cs index 6e4b232..c30ec1f 100644 --- a/Campofinale/Game/Factory/FactoryManager.cs +++ b/Campofinale/Game/Factory/FactoryManager.cs @@ -1,14 +1,9 @@ -using Campofinale.Game.Factory.Components; +using Campofinale.Game.Entities; +using Campofinale.Game.Factory.Components; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; using MongoDB.Bson.Serialization.Attributes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Factory @@ -133,8 +128,12 @@ namespace Campofinale.Game.Factory GetOwner().Send(new PacketScFactorySyncChapter(GetOwner(), chapterId)); edit.Nodes.Add(node.ToProto()); Logger.Print(Newtonsoft.Json.JsonConvert.SerializeObject(edit, Newtonsoft.Json.Formatting.Indented)); + EntityInteractive e = new(place.TemplateId, GetOwner().roleId, new Vector3f(place.Position), new Vector3f(place.Direction), GetOwner().sceneManager.GetCurScene().sceneNumId, node.guid); + GetOwner().sceneManager.GetCurScene().entities.Add(e); + GetOwner().sceneManager.GetCurScene().SpawnEntity(e); GetOwner().Send(ScMsgId.ScFactoryModifyChapterNodes, edit); GetOwner().Send(new PacketScFactoryOpRet(GetOwner(), node.nodeId,FactoryOpType.Place),seq); + } public FactoryChapter(string chapterId,ulong ownerId) @@ -266,6 +265,7 @@ namespace Campofinale.Game.Factory TemplateId=templateId, StableId= GetStableId(), IsDeactive= deactive, + Power = new() { InPower= InPower(), @@ -278,7 +278,7 @@ namespace Campofinale.Game.Factory Position = position.ToProtoScd(), Direction=direction.ToProtoScd(), MapId=mapId, - + } }; @@ -289,7 +289,7 @@ namespace Campofinale.Game.Factory node.Transform.WorldRotation = direction.ToProto(); node.InteractiveObject = new() { - + ObjectId=guid, }; node.Flag = 0; node.InstKey = ""; diff --git a/Campofinale/Game/Gacha/GachaManager.cs b/Campofinale/Game/Gacha/GachaManager.cs index 313b831..7d16766 100644 --- a/Campofinale/Game/Gacha/GachaManager.cs +++ b/Campofinale/Game/Gacha/GachaManager.cs @@ -1,12 +1,6 @@ using Campofinale.Database; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Gacha @@ -16,7 +10,7 @@ namespace Campofinale.Game.Gacha public Player player; internal ulong upSeqId; - const double fiftyfifty = 0.45; // 50% (make it less than real 50, because the randomness make win fifty fifty every time + const double fiftyfifty = 0.50; private static readonly Random random = new Random(); public GachaManager(Player player) @@ -176,7 +170,6 @@ namespace Campofinale.Game.Gacha RewardIds = { $"reward_{transaction.rarity}starChar_weaponCoin", - }, }); @@ -220,11 +213,7 @@ namespace Campofinale.Game.Gacha } else { - int index = random.Next(0,items.Count); // Miglior randomizzazione - // index = (int)((1 - Math.Pow(random.NextDouble(), 2)) * (items.Count - 1)); - - // Se vuoi evitare di prendere spesso i primi 2-3 elementi: - // index = (int)Math.Pow(random.NextDouble(), 1.5) * items.Count; + int index = random.Next(0,items.Count); if (index > items.Count-1) { index = items.Count-1; diff --git a/Campofinale/Game/Gacha/GachaTransaction.cs b/Campofinale/Game/Gacha/GachaTransaction.cs index 88eddbd..87da47a 100644 --- a/Campofinale/Game/Gacha/GachaTransaction.cs +++ b/Campofinale/Game/Gacha/GachaTransaction.cs @@ -1,10 +1,5 @@ using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using MongoDB.Bson.Serialization.IdGenerators; namespace Campofinale.Game.Gacha diff --git a/Campofinale/Game/GameConstants.cs b/Campofinale/Game/GameConstants.cs index 8878468..fd35d24 100644 --- a/Campofinale/Game/GameConstants.cs +++ b/Campofinale/Game/GameConstants.cs @@ -1,16 +1,33 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Game +namespace Campofinale.Game { public static class GameConstants { + //TODO, have to check if this is really userful for support different platform or if android version doesn't need the GAME_VERSION_ASSET_URL (probably not?) + //So, in case is useful only if the android build it's different than 0.5.28 + /*public static List GAME_VERSIONS = new() + { + new GameVersionConst("0.5.28"), //Windows CBT2 + new GameVersionConst("0.5.5"), //Android CBT2 + + };*/ + + //Not used on top ^ public static string GAME_VERSION = "0.5.28"; //CBT 2 + public static string GAME_VERSION_ANDROID = "0.5.5"; //CBT 2 ANDROID public static string GAME_VERSION_ASSET_URL = "https://beyond.hg-cdn.com/uXUuLlNbIYmMMTlN/0.5/update/6/1/Windows/0.5.28_U1mgxrslUitdn3hb/files";//CBT 2 public static int MAX_TEAMS_NUMBER = 5; //Not used yet public static (long, string) SERVER_UID = (99, "99"); //Not used yet, no friend chat in current Beta } + + /* public class GameVersionConst + { + public string GAME_VERSION = "0.5.28"; + public string GAME_VERSION_ASSET_URL = "https://beyond.hg-cdn.com/uXUuLlNbIYmMMTlN/0.5/update/6/1/Windows/0.5.28_U1mgxrslUitdn3hb/files";//CBT 2 + public GameVersionConst() { } + + public GameVersionConst(string version) + { + this.GAME_VERSION = version; + } + }*/ } diff --git a/Campofinale/Game/Inventory/InventoryList.cs b/Campofinale/Game/Inventory/InventoryList.cs new file mode 100644 index 0000000..39b343e --- /dev/null +++ b/Campofinale/Game/Inventory/InventoryList.cs @@ -0,0 +1,272 @@ +using Campofinale.Database; +using Campofinale.Packets.Sc; + +namespace Campofinale.Game.Inventory +{ + public class InventoryList + { + public List items = new(); + public Dictionary bag = new(); + public int maxBagSize = 30; + + public Player player; + public InventoryList(Player player) + { + this.player = player; + } + public enum FindType + { + Items, + FactoryDepots, + Bag + } + public void UpdateInventoryPacket() + { + + } + public void UpdateBagInventoryPacket() + { + player.Send(new PacketScItemBagScopeSync(this.player,Resource.ItemValuableDepotType.Invalid)); + + } + private void AddToBagAvailableSlot(Item item) + { + for (int i = 0; i < maxBagSize; i++) + { + if (!bag.ContainsKey(i)) + { + bag.Add(i, item); + return; + } + } + } + /// + ///Add a item directly to the bag if there is enough space or increment current stack value + /// + public bool AddToBag(Item item) + { + Item existOne = Find(i=>i.id == item.id && i.amount < item.GetItemTable().maxStackCount,FindType.Bag); + if (existOne != null) + { + + if(existOne.amount+item.amount > item.GetItemTable().maxStackCount) + { + int max = existOne.GetItemTable().maxStackCount; + int toAddInNewSlotAmount = existOne.amount + item.amount - max; + item.amount = toAddInNewSlotAmount; + if (SlotAvailableInBag()) + { + existOne.amount = max; + AddToBagAvailableSlot(item); + UpdateBagInventoryPacket(); + return true; + } + else + { + return false; + } + } + else + { + existOne.amount += item.amount; + UpdateBagInventoryPacket(); + return true; + } + } + else + { + if(bag.Count < maxBagSize) + { + AddToBagAvailableSlot(item); + UpdateBagInventoryPacket(); + return true; + } + else + { + return false; + } + } + } + public bool SlotAvailableInBag() + { + bool availableSlot = false; + for (int i = 0; i < maxBagSize; i++) + { + if (!bag.ContainsKey(i)) + { + return true; + } + } + return availableSlot; + } + public Item FindInAll(Predicate match) + { + var item = items.Find(match); + if (item != null) + { + return item; + } + var itemB = bag.Values.ToList().Find(match); + if (itemB != null) + { + return itemB; + } + return null; + } + public Item Find(Predicate match,FindType findType = FindType.Items) + { + switch (findType) + { + case FindType.Items: + var item = items.Find(match); + if (item != null) + { + return item; + } + break; + case FindType.FactoryDepots: + //TODO + break; + case FindType.Bag: + var itemB = bag.Values.ToList().Find(match); + if (itemB != null) + { + return itemB; + } + break; + } + + return null; + } + public List FindAll(Predicate match, FindType findType = FindType.Items) + { + switch (findType) + { + case FindType.Items: + return items.FindAll(match); + break; + case FindType.FactoryDepots: + //TODO + break; + case FindType.Bag: + var itemB = bag.Values.ToList().FindAll(match); + if (itemB != null) + { + return itemB; + } + break; + } + + return null; + } + /// + ///Add an item to the inventory (or increment it's amount if it's not an instance type, else add a new one or add to bag if it's a Factory item + /// + public Item Add(Item item) + { + if (item.StorageSpace() == Resource.ItemStorageSpace.BagAndFactoryDepot) + { + AddToBag(item); + return null; + } + if (item.InstanceType()) + { + items.Add(item); + DatabaseManager.db.UpsertItem(item); + return item; + } + else + { + Item exist=Find(i=>i.id==item.id); + if (exist != null) + { + exist.amount += item.amount; + DatabaseManager.db.UpsertItem(exist); + return exist; + } + else + { + items.Add(item); + DatabaseManager.db.UpsertItem(item); + return item; + } + } + + } + /// + /// Get the item amount from all depots + /// + /// + /// + public int GetItemAmount(string id) + { + int amt = 0; + Item item=Find(i=>i.id==id); + if (item != null) + { + amt += item.amount; + } + List bagItems = FindAll(i=>i.id==id,FindType.Bag); + foreach (Item bagItem in bagItems) + { + amt += bagItem.amount; + } + + return amt; + } + public void Remove(Item item) + { + if (items.Remove(item)) + { + this.player.Send(new PacketScItemBagScopeModify(this.player, item)); + DatabaseManager.db.DeleteItem(item); + } + else if (RemoveFromBag(item)) + { + UpdateBagInventoryPacket(); + } + } + + private bool RemoveFromBag(Item item) + { + for (int i = 0; i < maxBagSize; i++) + { + Item bagItem = null; + if (bag.ContainsKey(i)) + { + bagItem = bag[i]; + if (bagItem.guid == item.guid) + { + bag.Remove(i); + return true; + } + } + } + return false; + } + /// + /// Move item from bag grid to another position + /// + /// + /// + public void MoveBagItem(int fromGrid, int toGrid) + { + Item item1 = bag[fromGrid]; + Item item2 = null; + if (bag.ContainsKey(toGrid)) + { + item2 = bag[toGrid]; + } + bag[toGrid] = item1; + if (item2 != null) + { + bag[fromGrid] = item2; + } + else + { + bag.Remove(fromGrid); + } + UpdateBagInventoryPacket(); + } + } +} diff --git a/Campofinale/Game/Inventory/InventoryManager.cs b/Campofinale/Game/Inventory/InventoryManager.cs index 3ded7b1..fa7b733 100644 --- a/Campofinale/Game/Inventory/InventoryManager.cs +++ b/Campofinale/Game/Inventory/InventoryManager.cs @@ -1,13 +1,6 @@ using Campofinale.Database; using Campofinale.Packets.Sc; -using Campofinale.Resource; using Google.Protobuf.Collections; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Game.Inventory @@ -15,7 +8,7 @@ namespace Campofinale.Game.Inventory public class InventoryManager { public Player owner; - public List items= new List(); + public InventoryList items; public int item_diamond_amt { @@ -36,12 +29,12 @@ namespace Campofinale.Game.Inventory public Item GetItemById(string id) { - return items.Find(i => i.id == id); + return items.FindInAll(i => i.id == id); } public InventoryManager(Player o) { owner = o; - + items=new(o); } public void AddRewards(string rewardTemplateId, Vector3f pos, int sourceType=1) { @@ -110,46 +103,25 @@ namespace Campofinale.Game.Inventory } public void Save() { - foreach (Item item in items) + foreach (Item item in items.items) { DatabaseManager.db.UpsertItem(item); } } public void Load() { - items = DatabaseManager.db.LoadInventoryItems(owner.roleId); + items.items = DatabaseManager.db.LoadInventoryItems(owner.roleId); } - public Item AddItem(string id, int amt) + public Item AddItem(string id, int amt, bool notify=false) { - Item it = new() + Item item = new Item(owner.roleId, id, amt); + + Item itemNew = items.Add(item); + if (notify && itemNew != null) { - id = id, - }; - if(!it.InstanceType()) - { - - Item item = items.Find(i=>i.id == id); - if (item != null) - { - // Logger.Print(id + ": " + amt+" added to existing"); - item.amount += amt; - return item; - } - else - { - // Logger.Print(id + ": " + amt + " added to new"); - item = new Item(owner.roleId, id, amt); - items.Add(item); - return item; - } + this.owner.Send(new PacketScItemBagScopeModify(this.owner, itemNew)); } - else - { - //Logger.Print(id + ": " + amt + " added to new as instance"); - Item item = new Item(owner.roleId, id, amt); - items.Add(item); - return item; - } + return item; } public void RemoveItem(Item item,int amt) { @@ -157,9 +129,46 @@ namespace Campofinale.Game.Inventory if(item.amount <= 0) { items.Remove(item); - DatabaseManager.db.DeleteItem(item); } - this.owner.Send(new PacketScItemBagScopeModify(this.owner, item)); + else + { + this.owner.Send(new PacketScItemBagScopeModify(this.owner, item)); + items.UpdateBagInventoryPacket(); + } + } + + public bool ConsumeItem(string id, int amt) + { + Item item=items.FindInAll(i=>i.id== id); + if (item != null) + { + if(item.amount >= amt) + { + item.amount -= amt; + + if(item.amount < 1) + { + items.Remove(item); + } + else + { + this.owner.Send(new PacketScItemBagScopeModify(this.owner, item)); + items.UpdateBagInventoryPacket(); + } + return true; + } + else + { + int toConsume = amt - item.amount; + item.amount = 0; + items.Remove(item); + return ConsumeItem(id, toConsume); + } + } + else + { + return false; + } } public bool ConsumeItems(MapField costItemId2Count) { @@ -179,16 +188,8 @@ namespace Campofinale.Game.Inventory bool found = true; foreach (ItemInfo item in items) { - Item i= GetItemById(item.ResId); - if (i != null) - { - if(i.amount < item.ResCount) - { - found = false; - break; - } - } - else + int amount = this.items.GetItemAmount(item.ResId); + if(amount < item.ResCount) { found = false; break; @@ -196,14 +197,7 @@ namespace Campofinale.Game.Inventory } foreach (ItemInfo item in items) { - Item i = GetItemById(item.ResId); - if (i != null) - { - if (i.amount >= item.ResCount) - { - RemoveItem(i,item.ResCount); - } - } + ConsumeItem(item.ResId, item.ResCount); } return found; } @@ -211,13 +205,37 @@ namespace Campofinale.Game.Inventory public Dictionary GetInventoryChapter(string chapterId) { Dictionary dir= new Dictionary(); - List citems = items.FindAll(i=>!i.InstanceType()); + /*List citems = items.FindAll(i=>!i.InstanceType()); foreach (Item item in citems) { dir.Add((uint)ResourceManager.strIdNumTable.item_id.dic[item.id], item.amount); - } + }*/ return dir; } + + public void DropItemsBag(CsItemBagAbandonInBag req) + { + if(req.TargetObjectId == 0) + { + foreach (var i in req.GridCut) + { + Item item = items.bag[i.Key]; + item.amount -= i.Value; + if(item.amount <= 0) + { + items.bag.Remove(i.Key); + } + owner.sceneManager.CreateDrop(owner.position, new RewardTable.ItemBundle() + { + count=i.Value, + id=item.id, + }); + + } + + } + items.UpdateBagInventoryPacket(); + } } } diff --git a/Campofinale/Game/Inventory/Item.cs b/Campofinale/Game/Inventory/Item.cs index 2a5bf89..d887947 100644 --- a/Campofinale/Game/Inventory/Item.cs +++ b/Campofinale/Game/Inventory/Item.cs @@ -48,6 +48,10 @@ namespace Campofinale.Game.Inventory this.level = level; guid = GetOwner().random.Next(); } + public ItemStorageSpace StorageSpace() + { + return ResourceManager.itemTypeTable[GetItemTable().type].storageSpace; + } public ulong GetDefaultLevel() { switch (ItemType) @@ -68,10 +72,15 @@ namespace Campofinale.Game.Inventory } public ItemValuableDepotType ItemType { - get{ + get + { return ResourceManager.GetItemTable(id).valuableTabType; } } + public ItemTable GetItemTable() + { + return ResourceManager.GetItemTable(id); + } public virtual ScdItemGrid ToProto() { try diff --git a/Campofinale/Game/Mail.cs b/Campofinale/Game/Mail.cs index 7e8209f..6e47f44 100644 --- a/Campofinale/Game/Mail.cs +++ b/Campofinale/Game/Mail.cs @@ -1,11 +1,6 @@ using Campofinale.Resource; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using MongoDB.Bson.Serialization.IdGenerators; namespace Campofinale.Game diff --git a/Campofinale/Game/MissionSys/MissionSystem.cs b/Campofinale/Game/MissionSys/MissionSystem.cs new file mode 100644 index 0000000..04ea850 --- /dev/null +++ b/Campofinale/Game/MissionSys/MissionSystem.cs @@ -0,0 +1,252 @@ +using Campofinale.Database; +using Campofinale.Protocol; +using Campofinale.Resource; +using Campofinale.Resource.Table; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace Campofinale.Game.MissionSys +{ + public class MissionSystem + { + public Player owner; + public List missions=new(); + public List quests=new(); + public string curMission = "e0m0"; + + public MissionSystem(Player o) + { + owner = o; + } + public ScSyncAllMission ToProto() + { + ScSyncAllMission sync = new ScSyncAllMission(); + sync.TrackMissionId = curMission; + missions.ForEach(m => + { + sync.Missions.Add(m.missionId, new Mission() + { + MissionId = m.missionId, + MissionState = (int)m.state, + + }); + }); + + quests.ForEach(q => + { + Quest quest=new Quest() + { + QuestId = q.questId, + QuestState = (int)q.state, + + }; + var data = GetQuestData(q.questId); + data.objectiveList.ForEach(o => + { + quest.QuestObjectives.Add(new QuestObjective() + { + ConditionId = o.condition.uniqueId, + Values = + { + {o.condition.uniqueId,0 } + } + }); + }); + sync.CurQuests.Add(q.questId, quest); + + }); + return sync; + } + public MissionDataTable.QuestInfo GetQuestData(string id) + { + MissionDataTable.QuestInfo quest = null; + foreach(MissionDataTable m in ResourceManager.missionDataTable) + { + if(m.questDic.TryGetValue(id, out quest)) + { + return quest; + } + }; + + return quest; + } + public void Save() + { + + } + public void Load() + { + + if (ResourceManager.missionDataTable.Count < 1) + { + //Disabling if no missions + return; + } + //TODO Saving and first initialization + AddMission("e0m0",MissionState.Processing); + } + public void AddMission(string id,MissionState state = MissionState.Available, bool notify=false) + { + MissionDataTable data = ResourceManager.missionDataTable.Find(m=>m.missionId == id); + if (data != null) + { + missions.Add(new GameMission(id, state)); + if (notify) + { + ScMissionStateUpdate s = new() + { + MissionId = data.missionId, + MissionState = (int)state, + SucceedId=-1, + + }; + } + + int i = 0; + foreach (var q in data.questDic.Values) + { + AddQuest(q, false); + } + } + } + public GameQuest GetQuestById(string id) + { + return quests.Find(q => q.questId == id); + } + public void AddQuest(MissionDataTable.QuestInfo data,bool notify=false) + { + GameQuest quest = GetQuestById(data.questId); + if (quest == null) + { + quest = new GameQuest(data.questId); + quest.state = QuestState.Available; + if (notify) + { + ScQuestObjectivesUpdate upd = new() + { + QuestId = data.questId, + + }; + data.objectiveList.ForEach(o => + { + upd.QuestObjectives.Add(new QuestObjective() + { + ConditionId=o.condition.uniqueId, + Values = + { + {o.condition.uniqueId,0 } + } + }); + }); + ScQuestStateUpdate update = new() + { + QuestId = quest.questId, + QuestState = (int)quest.state, + RoleBaseInfo = owner.GetRoleBaseInfo() + }; + owner.Send(ScMsgId.ScQuestStateUpdate, update); + owner.Send(ScMsgId.ScQuestObjectivesUpdate, upd); + } + + quests.Add(quest); + } + } + public void ProcessQuest(string id) + { + GameQuest quest = GetQuestById(id); + if (quest != null) + { + + quest.state = QuestState.Processing; + var data = GetQuestData(id); + ScQuestStateUpdate update = new() + { + QuestId = quest.questId, + QuestState = (int)quest.state, + RoleBaseInfo = owner.GetRoleBaseInfo() + }; + ScQuestObjectivesUpdate upd = new() + { + QuestId = data.questId, + + }; + data.objectiveList.ForEach(o => + { + upd.QuestObjectives.Add(new QuestObjective() + { + ConditionId = o.condition.uniqueId, + Values = + { + {o.condition.uniqueId,0 } + } + }); + }); + owner.Send(ScMsgId.ScQuestObjectivesUpdate, upd); + owner.Send(ScMsgId.ScQuestStateUpdate, update); + + } + } + public void CompleteQuest(string id) + { + GameQuest quest = GetQuestById(id); + if (quest != null) + { + quest.state = QuestState.Completed; + var data = GetQuestData(id); + ScQuestStateUpdate update = new() + { + QuestId = quest.questId, + QuestState=(int)quest.state, + }; + ScQuestObjectivesUpdate upd = new() + { + QuestId = data.questId, + + }; + data.objectiveList.ForEach(o => + { + upd.QuestObjectives.Add(new QuestObjective() + { + ConditionId = o.condition.uniqueId, + IsComplete=true, + Values = + { + {o.condition.uniqueId,1 } + } + }); + }); + owner.Send(ScMsgId.ScQuestObjectivesUpdate, upd); + owner.Send(ScMsgId.ScQuestStateUpdate, update); + quests.Remove(quest); + } + } + } + public class GameQuest + { + public string questId; + public QuestState state; + public GameQuest() + { + + } + public GameQuest(string id, QuestState state = QuestState.Available) + { + questId = id; + this.state = state; + } + } + public class GameMission + { + public string missionId; + public MissionState state; + + public GameMission() + { + + } + public GameMission(string id, MissionState state = MissionState.Available) + { + missionId = id; + this.state = state; + } + } +} diff --git a/Campofinale/Game/SceneManager.cs b/Campofinale/Game/SceneManager.cs index 781ade0..220ac67 100644 --- a/Campofinale/Game/SceneManager.cs +++ b/Campofinale/Game/SceneManager.cs @@ -3,14 +3,7 @@ using Campofinale.Game.Inventory; using Campofinale.Packets.Sc; using Campofinale.Resource; using MongoDB.Bson.Serialization.Attributes; -using SharpCompress.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; using System.Text.Json.Serialization; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using static Campofinale.Resource.ResourceManager.LevelScene.LevelData; @@ -308,7 +301,7 @@ namespace Campofinale.Game lv_scene.levelData.interactives.ForEach(en => { - if (en.defaultHide || GetOwner().noSpawnAnymore.Contains(en.levelLogicId)) + if (GetOwner().noSpawnAnymore.Contains(en.levelLogicId) && sceneNumId != 87) { return; } @@ -325,7 +318,7 @@ namespace Campofinale.Game }); lv_scene.levelData.factoryRegions.ForEach(en => { - if (en.defaultHide || GetOwner().noSpawnAnymore.Contains(en.levelLogicId)) + if (GetOwner().noSpawnAnymore.Contains(en.levelLogicId) && sceneNumId!=87) { return; } @@ -336,11 +329,13 @@ namespace Campofinale.Game levelLogicId = en.levelLogicId, type = en.entityType, }; + entities.Add(entity); }); lv_scene.levelData.enemies.ForEach(en => { - if(en.defaultHide || GetOwner().noSpawnAnymore.Contains(en.levelLogicId)) return; + if(GetOwner().noSpawnAnymore.Contains(en.levelLogicId) && sceneNumId != 87) return; + if (en.defaultHide) return; EntityMonster entity = new(en.entityDataIdKey,en.level,ownerId,en.position,en.rotation, sceneNumId, en.levelLogicId) { type=en.entityType, @@ -362,43 +357,92 @@ namespace Campofinale.Game }; entities.Add(entity); }); - /*GetEntityExcludingChar().ForEach(e => + GetEntityExcludingChar().ForEach(e => { - GetOwner().Send(new PacketScObjectEnterView(GetOwner(),new List() { e})); - });*/ + // GetOwner().Send(new PacketScObjectEnterView(GetOwner(), new List() { e})); + + }); UpdateShowEntities(); + + } + public void SpawnEntity(Entity en,bool spawnedCheck=true) + { + en.spawned = true; + List toSpawn = new List(); + if(en.belongLevelScriptId != 0) + if (spawnedCheck) + { + foreach (Entity e in GetEntityExcludingChar().FindAll(e => e.belongLevelScriptId == en.belongLevelScriptId && e.spawned == false)) + { + e.spawned = true; + toSpawn.Add(e); + } + } + else + { + foreach (Entity e in GetEntityExcludingChar().FindAll(e => e.belongLevelScriptId == en.belongLevelScriptId && e != en)) + { + e.spawned = true; + toSpawn.Add(e); + } + } + toSpawn.Add(en); + toSpawn.ForEach(e => + { + GetOwner().Send(new PacketScObjectEnterView(GetOwner(), new List() { e})); + }); + } public void UpdateShowEntities() { foreach(Entity en in GetEntityExcludingChar()) { - if (en.Position.Distance(GetOwner().position) < 200) + if (en.Position.Distance(GetOwner().position) < 100) { if (!en.spawned) { - en.spawned = true; - GetOwner().Send(new PacketScObjectEnterView(GetOwner(), new List() { en })); + SpawnEntity(en); + + } } else { - if (en.spawned) + + /*if (en.spawned) { en.spawned = false; GetOwner().Send(new PacketScObjectLeaveView(GetOwner(), new List() { en.guid })); en.Position=en.BornPos; en.Rotation = en.Rotation; - } + }*/ } } } - + public Player GetOwner() { return Server.clients.Find(c => c.roleId == ownerId); } + + public void SpawnEnemy(ulong v) + { + LevelScene lv_scene = ResourceManager.GetLevelData(sceneNumId); + LevelEnemyData en = lv_scene.levelData.enemies.Find(e=>e.levelLogicId == v); + if(en!=null) + { + EntityMonster entity = new(en.entityDataIdKey, en.level, ownerId, en.position, en.rotation, sceneNumId, en.levelLogicId) + { + type = en.entityType, + belongLevelScriptId = en.belongLevelScriptId, + levelLogicId = en.levelLogicId + }; + entities.Add(entity); + SpawnEntity(entity); + } + } } } diff --git a/Campofinale/Game/Spaceship/SpaceshipChar.cs b/Campofinale/Game/Spaceship/SpaceshipChar.cs index 22127f9..0e19865 100644 --- a/Campofinale/Game/Spaceship/SpaceshipChar.cs +++ b/Campofinale/Game/Spaceship/SpaceshipChar.cs @@ -1,11 +1,5 @@ using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Resource.ResourceManager; using MongoDB.Bson.Serialization.IdGenerators; using Campofinale.Resource; @@ -46,6 +40,7 @@ namespace Campofinale.Game.Spaceship IsWorking = isWorking, PhysicalStrength = physicalStrength, StationedRoomId = stationedRoomId, + Skills = { new ScdSpaceshipCharSkill() diff --git a/Campofinale/Game/Spaceship/SpaceshipManager.cs b/Campofinale/Game/Spaceship/SpaceshipManager.cs index 441a2d8..aabdaaa 100644 --- a/Campofinale/Game/Spaceship/SpaceshipManager.cs +++ b/Campofinale/Game/Spaceship/SpaceshipManager.cs @@ -1,15 +1,6 @@ using Campofinale.Database; -using Campofinale.Game.Inventory; -using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MongoDB.Bson.Serialization.IdGenerators; -using static Campofinale.Resource.ResourceManager; using Campofinale.Resource; +using Campofinale.Resource.Table; namespace Campofinale.Game.Spaceship { @@ -84,6 +75,39 @@ namespace Campofinale.Game.Spaceship } } } + + public void GiftToChar(CsSpaceshipPresentGiftToChar req) + { + SpaceshipChar chara = GetChar(req.CharId); + if (chara != null) + { + foreach (var item in req.Gifts) + { + GiftItemTable giftItem = ResourceManager.giftItemTable[item.Id]; + chara.favorability += giftItem.favorablePoint * item.Count; + //TODO item consume + } + ScSpaceshipPresentGiftToChar confirm = new() + { + CurFav = chara.favorability, + CharId = chara.id, + RecvGiftCnt = req.Gifts.Count, + }; + //TODO packet class + /*ScSpaceshipCharFavorabilityChange change = new() + { + ChangeInfos = + { + new SpaceshipCharFavorabilityChangeInfo() + { + CharId = chara.id, + CurFav=chara.favorability, + } + } + };*/ + owner.Send(Protocol.ScMsgId.ScSpaceshipPresentGiftToChar, confirm); + } + } } diff --git a/Campofinale/Game/Spaceship/SpaceshipRoom.cs b/Campofinale/Game/Spaceship/SpaceshipRoom.cs index f50e417..a320d4b 100644 --- a/Campofinale/Game/Spaceship/SpaceshipRoom.cs +++ b/Campofinale/Game/Spaceship/SpaceshipRoom.cs @@ -1,10 +1,5 @@ using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; using Campofinale.Resource; using MongoDB.Bson.Serialization.IdGenerators; diff --git a/Campofinale/Game/Team.cs b/Campofinale/Game/Team.cs index 232e5de..5fce7ff 100644 --- a/Campofinale/Game/Team.cs +++ b/Campofinale/Game/Team.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Game +namespace Campofinale.Game { public class Team { diff --git a/Campofinale/Http/Dispatch.cs b/Campofinale/Http/Dispatch.cs index b5df882..9d2e621 100644 --- a/Campofinale/Http/Dispatch.cs +++ b/Campofinale/Http/Dispatch.cs @@ -1,18 +1,5 @@ -using Campofinale.Database; -using Campofinale.Game; -using Campofinale.Game.Gacha; -using Google.Protobuf.WellKnownTypes; +using Campofinale.Game; using HttpServerLite; -using MongoDB.Bson.IO; -using SQLite; -using SQLiteNetExtensions.Extensions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Channels; -using System.Threading.Tasks; -using static Campofinale.Game.Gacha.GachaManager; namespace Campofinale.Http { @@ -65,7 +52,17 @@ namespace Campofinale.Http await data(ctx); } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/serverStatus")] + public static async Task serverStatus(HttpContext ctx) + { + string resp = "{\"maxPlayers\":" + Server.config.serverOptions.maxPlayers + ", \"players\":" + Server.clients.Count + ", \"status\":\"Online\", \"gameVersion\": \"" + GameConstants.GAME_VERSION + "\", \"serverVersion\": \"" + Server.ServerVersion + "\"}"; + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } [StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/pay/getAllProductList")] public static async Task getAllProductList(HttpContext ctx) { @@ -77,6 +74,7 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } + //WINDOWS [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/game/get_latest")] public static async Task get_latest(HttpContext ctx) { @@ -89,6 +87,18 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } + //ANDROID + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/game/get_latest_game_info")] + public static async Task get_latest_game_info(HttpContext ctx) + { + string resp = "{\"version\":\""+ GameConstants.GAME_VERSION_ANDROID + "\",\"action\":0,\"update_type\":0,\"update_info\":{\"package\":null,\"patch\":null,\"custom_info\":\"\",\"source_package\":null},\"client_version\":\"\"}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/1003/prod-cbt/default/default/network_config")] public static async Task network_config(HttpContext ctx) { @@ -100,32 +110,11 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/network_config")] - public static async Task network_config_cn(HttpContext ctx) - { - string resp = "{\"asset\":\"https://beyond.hg-cdn.com/asset/\",\"hgage\":\"\",\"sdkenv\":\"2\",\"u8root\":\"https://u8.gryphline.com/u8\",\"appcode\":4,\"channel\":\"prod\",\"netlogid\":\"GFz8RRMDN45w\",\"gameclose\":false,\"netlogurl\":\"http://native-log-collect.gryphline.com:32000/\",\"accounturl\":\"https://binding-api-account-prod.gryphline.com\",\"launcherurl\":\"https://launcher.gryphline.com\"}"; - - ctx.Response.StatusCode = 200; - ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/1003/prod-cbt/default/Windows/game_config")] public static async Task game_config(HttpContext ctx) { - string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": false, \"enableEntitySpawnLog\": false}"; - - ctx.Response.StatusCode = 200; - ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/game_config")] - public static async Task game_config_cn(HttpContext ctx) - { - string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": false, \"enableEntitySpawnLog\": false}"; + string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": false, \"enableEntitySpawnLog\": false, \"enableCBT2AccessForbidden\": false}"; ctx.Response.StatusCode = 200; ctx.Response.ContentLength = resp.Length; @@ -133,6 +122,7 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/gameBulletin/version")] public static async Task Version(HttpContext ctx) { @@ -151,8 +141,27 @@ namespace Campofinale.Http [StaticRoute(HttpServerLite.HttpMethod.GET, "/app/v1/config")] public static async Task config_check(HttpContext ctx) { + string appCode = ctx.Request.Query.Elements["appCode"]; + + string resp = "{\"data\":{\"agreementUrl\":{\"register\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"privacy\":\"https://user.gryphline.com/{language}/protocol/plain/privacy_policy\",\"unbind\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\",\"account\":\"https://user.gryphline.com/{language}/protocol/plain/terms_of_service\",\"game\":\"https://user.gryphline.com/{language}/protocol/plain/endfield/privacy_policy\"},\"app\":{\"googleAndroidClientId\":\"\",\"googleIosClientId\":\"\",\"enableAutoLogin\":true,\"enablePayment\":true,\"enableGuestRegister\":false,\"needShowName\":true,\"displayName\":{\"en-us\":\"Arknights: Endfield\",\"ja-jp\":\"アークナイツ:エンドフィールド\",\"ko-kr\":\"명일방주:엔드필드\",\"zh-cn\":\"明日方舟:终末地\",\"zh-tw\":\"明日方舟:終末地\"},\"unbindAgreement\":[],\"unbindLimitedDays\":30,\"unbindCoolDownDays\":14,\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"enableUnbindGrant\":false},\"customerServiceUrl\":\"https://gryphline.helpshift.com/hc/{language}/4-arknights-endfield\",\"thirdPartyRedirectUrl\":\"https://web-api.gryphline.com/callback/thirdPartyAuth.html\",\"scanUrl\":{\"login\":\"yj://scan_login\"},\"loginChannels\":[],\"userCenterUrl\":\"https://user.gryphline.com/pcSdk/userInfo?language={language}\"},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}"; + if(appCode == "a65356244d22261b") + { + resp = "{ \"data\": { \"antiAddiction\": { \"minorPeriodEnd\": 21, \"minorPeriodStart\": 20 }, \"payment\": [ { \"key\": \"alipay\", \"recommend\": true }, { \"key\": \"wechat\", \"recommend\": false }, { \"key\": \"pcredit\", \"recommend\": false } ], \"customerServiceUrl\": \"https://chat.hypergryph.com/chat/h5/v2/index.html?sysnum=889ee281e3564ddf883942fe85764d44&channelid=2\", \"cancelDeactivateUrl\": \"https://user-stable.hypergryph.com/cancellation\", \"agreementUrl\": { \"game\": \"https://hg-protocol-static-web-stable.hypergryph.net/protocol/plain/ak/index\", \"unbind\": \"https://hg-protocol-static-web-stable.hypergryph.net/protocol/plain/ak/cancellation\", \"gameService\": \"https://hg-protocol-static-web-stable.hypergryph.net/protocol/plain/ak/service\", \"account\": \"https://user.hypergryph.com/protocol/plain/index\", \"privacy\": \"https://user.hypergryph.com/protocol/plain/privacy\", \"register\": \"https://user.hypergryph.com/protocol/plain/registration\", \"updateOverview\": \"https://user.hypergryph.com/protocol/plain/overview_of_changes\", \"childrenPrivacy\": \"https://user.hypergryph.com/protocol/plain/children_privacy\" }, \"app\": { \"enablePayment\": true, \"enableAutoLogin\": true, \"enableAuthenticate\": true, \"enableAntiAddiction\": true, \"enableUnbindGrant\": true, \"wechatAppId\": \"wxeea7cc50e03edb28\", \"alipayAppId\": \"2021004129658342\", \"oneLoginAppId\": \"496b284079be97612a46266a9fdbfbd7\", \"enablePaidApp\": false, \"appName\": \"明日方舟终末地\", \"appAmount\": 600, \"needShowName\": true, \"customerServiceUrl\": \"https://web-biz-platform-cs-center-stable.hypergryph.net/hg/?hg_token={hg_token}&source_from=sdk\", \"needAntiAddictionAlert\": true, \"enableScanLogin\": false, \"deviceCheckMode\": 0, \"enableGiftCode\": false }, \"scanUrl\": { \"login\": \"hypergryph://scan_login\" }, \"userCenterUrl\": \"https://user-center-account-stable.hypergryph.net/pcSdk/userInfo\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}"; + } + + ctx.Response.StatusCode = 200; + //ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/general/v1/server_time")] + public static async Task server_time(HttpContext ctx) + { + string resp = "{\"data\":{\"serverTime\":1748021408,\"isHoliday\":true},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}"; + ctx.Response.StatusCode = 200; @@ -169,35 +178,8 @@ namespace Campofinale.Http public string password; } - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/res_version")] - public static async Task cn_res_version(HttpContext ctx) - { - - string resp = "{\"version\": \"2089329-32\", \"kickFlag\": true}"; - - - ctx.Response.StatusCode = 200; - //ctx.Response.ContentLength = resp.Length; - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } - - [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/server_config_China")] - public static async Task server_config_China(HttpContext ctx) - { - string requestBody = ctx.Request.DataAsString; - Console.WriteLine(requestBody); - string resp = "{\"addr\": \"" + Server.config.gameServer.accessAddress + "\", \"port\": " + Server.config.gameServer.accessPort + "}"; - - - - ctx.Response.StatusCode = 200; - - ctx.Response.ContentType = "application/json"; - - await ctx.Response.SendAsync(resp); - } + + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/1003/prod-cbt/default/default/server_config_EUAndUS")] public static async Task server_config_EUAndUS(HttpContext ctx) { diff --git a/Campofinale/Http/DispatchCN.cs b/Campofinale/Http/DispatchCN.cs new file mode 100644 index 0000000..44b3daf --- /dev/null +++ b/Campofinale/Http/DispatchCN.cs @@ -0,0 +1,90 @@ +using HttpServerLite; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Campofinale.Http +{ + internal class DispatchCN + { + //SERVER + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/server_config_China")] + public static async Task server_config_China(HttpContext ctx) + { + string requestBody = ctx.Request.DataAsString; + Console.WriteLine(requestBody); + string resp = "{\"addr\": \"" + Server.config.gameServer.accessAddress + "\", \"port\": " + Server.config.gameServer.accessPort + "}"; + + + + ctx.Response.StatusCode = 200; + + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //DEFAULT + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/default/network_config")] + public static async Task network_config_cn(HttpContext ctx) + { + string resp = "{ \"asset\": \"https://beyond.hycdn.cn/asset/\", \"hgage\": \"https://web.hycdn.cn/endfield/protocol/cadpa-age.txt\", \"sdkenv\": \"2\", \"u8root\": \"https://as.hypergryph.com/u8\", \"appcode\": 4, \"channel\": \"prod\", \"netlogid\": \"56RqF5G2gU9j\", \"gameclose\": false, \"netlogurl\": \"http://native-log-collect.hypergryph.com:32000\", \"accounturl\": \"https://binding-api-account-prod.hypergryph.com\", \"launcherurl\": \"https://launcher.hypergryph.com\"}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //WINDOWS + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/res_version")] + public static async Task cn_res_version(HttpContext ctx) + { + + string resp = "{\"version\": \"2089329-32\", \"kickFlag\": false}"; + ctx.Response.StatusCode = 200; + //ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Windows/game_config")] + public static async Task game_config_cn_windows(HttpContext ctx) + { + string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": true, \"enableEntitySpawnLog\": false, \"enableCBT2AccessForbidden\": false}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + //ANDROID + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Android/res_version")] + public static async Task cn_android_res_version(HttpContext ctx) + { + + string resp = "{\"version\": \"2377591-182\", \"kickFlag\": false}"; + + + ctx.Response.StatusCode = 200; + //ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/api/remote_config/get_remote_config/3/prod-cbt/default/Android/game_config")] + public static async Task game_config_cn_android(HttpContext ctx) + { + string resp = "{\"mockLogin\": false, \"selectSrv\": false, \"enableHotUpdate\": true, \"enableNpcOptimize\": false, \"enableEntitySpawnLog\": false, \"enableCBT2AccessForbidden\": false, \"enableMobileFullScreenWaterMark\": false}"; + + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } + + } +} diff --git a/Campofinale/Http/PCDispatch.cs b/Campofinale/Http/PCDispatch.cs index 37d1275..70b0a73 100644 --- a/Campofinale/Http/PCDispatch.cs +++ b/Campofinale/Http/PCDispatch.cs @@ -1,10 +1,6 @@ using Campofinale.Commands; -using Campofinale.Commands.Handlers; using Campofinale.Database; using HttpServerLite; -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; @@ -30,7 +26,8 @@ namespace Campofinale.Http [StaticRoute(HttpServerLite.HttpMethod.GET, "/pcSdk/console")] public static async Task ConsoleResponce(HttpContext ctx) { - string cmd = ctx.Request.Query.Elements["command"].Replace("+"," "); + string encodedCmd = Uri.UnescapeDataString(ctx.Request.Query.Elements["command"]); + string cmd = Encoding.UTF8.GetString(Convert.FromBase64String(encodedCmd)); string token = ctx.Request.Query.Elements["token"]; string message = ""; string[] split = cmd.Split(" "); diff --git a/Campofinale/Http/SDK.cs b/Campofinale/Http/SDK.cs index 96edd0f..f6261a4 100644 --- a/Campofinale/Http/SDK.cs +++ b/Campofinale/Http/SDK.cs @@ -1,11 +1,5 @@ using Campofinale.Database; -using Campofinale.Resource; using HttpServerLite; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Game.Gacha.GachaManager; using static Campofinale.Http.Dispatch; @@ -78,8 +72,12 @@ namespace Campofinale.Http await ctx.Response.SendAsync(resp); } - - + + [StaticRoute(HttpServerLite.HttpMethod.GET, "/batch_event")] + public static async Task batch_event(HttpContext ctx) + { + await ctx.Response.SendAsync("OK"); + } [StaticRoute(HttpServerLite.HttpMethod.GET, "/user/info/v1/basic")] public static async Task account_info_get(HttpContext ctx) { @@ -88,7 +86,10 @@ namespace Campofinale.Http string resp = "{\"data\":{\"hgId\":\"1799321925\",\"email\":\"dispatch@endfield.ps\",\"realEmail\":\"dispatch@endfield.ps\",\"isLatestUserAgreement\":true,\"nickName\":\"Campofinale\"},\"msg\":\"OK\",\"status\":0,\"type\":1}"; if (account != null) { - resp = "{\"data\":{\"idCardNum\": 110102200610048887,\"hgId\":\"" + account.id + "\",\"email\":\"" + account.username +Server.config.dispatchServer.emailFormat +"\",\"realEmail\":\"" + account.username + Server.config.dispatchServer.emailFormat + "\",\"isLatestUserAgreement\":true,\"nickName\":\"" + account.username + "\",\"name\":\"AAAA\"},\"msg\":\"OK\",\"status\":0,\"type\":1}"; + /* + * {"data":{"hgId":"1326618825955","phone":"153****5243","email":null,"identityNum":"5002**********1619","identityName":"金*","isMinor":false,"isLatestUserAgreement":true},"msg":"OK","status":0,"type":"A"} + */ + resp = "{\"data\":{\"phone\":\"153****5243\", \"identityNum\": \"5002**********1619\",\"identityName\":\"金*\",\"isMinor\":false,\"hgId\":\"" + account.id + "\",\"email\":\"" + account.username +Server.config.dispatchServer.emailFormat +"\",\"realEmail\":\"" + account.username + Server.config.dispatchServer.emailFormat + "\",\"isLatestUserAgreement\":true,\"nickName\":\"" + account.username + "\"},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}"; } else { @@ -138,7 +139,8 @@ namespace Campofinale.Http string resp = "{\"msg\": \"Error\", \"status\": 2, \"type\": \"A\"}"; if (account != null) { - resp = "{\"data\": { \"uid\": \"" + account.id + "\", \"code\": \"" + account.grantToken + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}"; + + resp = "{\"data\": { \"token\": \"" + account.token + "\", \"uid\": \"" + account.id + "\", \"code\": \"" + account.grantToken + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}"; } ctx.Response.StatusCode = 200; diff --git a/Campofinale/Logger.cs b/Campofinale/Logger.cs index e634add..fab9939 100644 --- a/Campofinale/Logger.cs +++ b/Campofinale/Logger.cs @@ -1,9 +1,7 @@ using Campofinale; + using Pastel; -using System; using System.Diagnostics; -using System.IO; -using static System.Net.Mime.MediaTypeNames; public static class Logger { @@ -20,6 +18,10 @@ public static class Logger var method = frame?.GetMethod(); return method?.DeclaringType?.Name ?? "Server"; } + /// + /// Print a text in the console + /// + /// public static void Print(string text) { string className = GetCallingClassName(); @@ -27,6 +29,10 @@ public static class Logger string prefix = "<" + "INFO".Pastel("03fcce") + $":{className.Pastel("999")}>"; Console.WriteLine($"{prefix} " + text); } + /// + /// Print a text in the console as Error + /// + /// public static void PrintError(string text) { string className = GetCallingClassName(); @@ -34,8 +40,15 @@ public static class Logger string prefix = "<" + "ERROR".Pastel("eb4034") + $":{className.Pastel("999")}>"; Console.WriteLine($"{prefix} " + text.Pastel("917e7e")); } + /// + /// Print a text in the console as a Warn + /// + /// public static void PrintWarn(string text) { + if (!Server.config.logOptions.packetWarnings) + return; + string className = GetCallingClassName(); Logger.Log(text); string prefix = "<" + "WARN".Pastel("ff9100") + $":{className.Pastel("999")}>"; @@ -43,7 +56,9 @@ public static class Logger } public static string GetColor(string c) { - if (ClassColors.ContainsKey(c)) return ClassColors[c]; + if (ClassColors.ContainsKey(c)) + return ClassColors[c]; + return "999"; } private static StreamWriter logWriter; @@ -52,23 +67,26 @@ public static class Logger public static void Initialize(bool hideLogs = false) { Logger.hideLogs = hideLogs; + logWriter = new StreamWriter("latest.log", false); + logWriter.AutoFlush = true; } - - public static void Log(string message) + /// + /// Log a message + /// + /// + private static void Log(string message) { - if (!hideLogs) + if(hideLogs) + return; + + try + { + logWriter.WriteLine($"{DateTime.Now}: {message}"); + } + catch(Exception e) { - try - { - logWriter.WriteLine($"{DateTime.Now}: {message}"); - logWriter.Flush(); - } - catch(Exception e) - { - } - } } @@ -76,4 +94,4 @@ public static class Logger { logWriter.Close(); } -} \ No newline at end of file +} diff --git a/Campofinale/Network/Packet.cs b/Campofinale/Network/Packet.cs index d3a990e..2e0437c 100644 --- a/Campofinale/Network/Packet.cs +++ b/Campofinale/Network/Packet.cs @@ -1,20 +1,9 @@ using Campofinale.Protocol; using Google.Protobuf; using Pastel; -using System; -using System.Buffers.Binary; -using System.Collections.Generic; using System.Drawing; -using System.Linq; using System.Net; -using System.Net.Sockets; -using System.Reflection; -using System.Runtime.InteropServices; using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; - -using static System.Runtime.InteropServices.JavaScript.JSType; namespace Campofinale.Network { @@ -61,6 +50,11 @@ namespace Campofinale.Network byte networkValue = buf[index]; return networkValue; } + /// + /// Parse the body using a specific IMessage proto class + /// + /// + /// public TBody DecodeBody() where TBody : IMessage, new() { return new MessageParser(() => new()).ParseFrom(finishedBody); @@ -76,35 +70,10 @@ namespace Campofinale.Network Buffer.BlockCopy(source, 0, destination, offset, source.Length); } - public static byte[] ToByteArray(IntPtr ptr, int length) - { - if (ptr == IntPtr.Zero) - { - throw new ArgumentException("Pointer cannot be null", nameof(ptr)); - } - - byte[] byteArray = new byte[length]; - Marshal.Copy(ptr, byteArray, 0, length); - return byteArray; - } - public static IntPtr ByteArrayToIntPtr(byte[] data) - { - if (data == null) throw new ArgumentNullException(nameof(data)); - - // Allocate unmanaged memory - IntPtr ptr = Marshal.AllocHGlobal(data.Length); - - // Copy the byte array to the unmanaged memory - Marshal.Copy(data, 0, ptr, data.Length); - - return ptr; - } public static byte[] EncryptWithPublicKey(byte[] data, string publicKey) { - // Crea un oggetto RSA using (RSA rsa = RSA.Create()) { - publicKey = publicKey.Replace("-----BEGIN PUBLIC KEY-----", ""); publicKey = publicKey.Replace("\r", ""); publicKey = publicKey.Replace("\n", ""); @@ -112,24 +81,44 @@ namespace Campofinale.Network publicKey = publicKey.Trim(); Logger.Print(publicKey); byte[] publicKey_ = Convert.FromBase64String(publicKey); - // Importa la chiave pubblica rsa.ImportSubjectPublicKeyInfo(publicKey_, out _); - - // Crittografa i dati return rsa.Encrypt(data, RSAEncryptionPadding.OaepSHA256); } } + /// + /// Set the data of the packet with the Message Id and the body + /// + /// + /// The proto message + /// The current Packet public Packet SetData(ScMsgId msgId, IMessage body) { set_body = body; cmdId = (int)msgId; return this; } + /// + /// Encode the packet using the Packet class + /// + /// The packet + /// the sequence id + /// the pack count + /// + /// public static byte[] EncodePacket(Packet packet,ulong seq = 0, uint totalPackCount = 1, uint currentPackIndex = 0) { return EncodePacket(packet.cmdId,packet.set_body,seq, totalPackCount, currentPackIndex); } public static ulong seqNext = 1; + /// + /// Encode the packet using the msgId and the body + /// + /// + /// + /// + /// + /// + /// public static byte[] EncodePacket(int msgId, IMessage body, ulong seqNext_ = 0, uint totalPackCount=1,uint currentPackIndex=0) { if (seqNext_ == 0) @@ -145,10 +134,19 @@ namespace Campofinale.Network PutByteArray(data, head.ToByteArray(), 3); PutByteArray(data, body.ToByteArray(), 3+head.ToByteArray().Length); if(Server.config.logOptions.packets && !Server.scMessageToHide.Contains((ScMsgId)msgId)) - Logger.Print($"Sending packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} id: {msgId} with {data.Length} bytes"); + Logger.Print($"Sending Packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} Id: {msgId} with {data.Length} Bytes"); return data; } + /// + /// Encode the packet with msgId and body as byte array + /// + /// + /// + /// + /// + /// + /// public static byte[] EncodePacket(int msgId, byte[] body, ulong seqNext_ = 0, uint totalPackCount = 1, uint currentPackIndex = 0) { if (seqNext_ == 0) @@ -168,10 +166,16 @@ namespace Campofinale.Network PutByteArray(data, head.ToByteArray(), 3); PutByteArray(data, body, 3 + head.ToByteArray().Length); if (Server.config.logOptions.packets && !Server.scMessageToHide.Contains((ScMsgId)msgId)) - Logger.Print($"Sending packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} id: {msgId} with {data.Length} bytes"); + Logger.Print($"Sending Packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} Id: {msgId} with {data.Length} Bytes"); return data; } + /// + /// Read the byteArray as a valid packet + /// + /// + /// + /// The decoded packet public static Packet Read(Player client,byte[] byteArray) { byte headLength = GetByte(byteArray, 0); @@ -182,10 +186,10 @@ namespace Campofinale.Network Array.Copy(byteArray, 3, csHeadBytes, 0, headLength); Array.Copy(byteArray, 3+ headLength, BodyBytes, 0, bodyLength); CSHead csHead_ = CSHead.Parser.ParseFrom(csHeadBytes); - if (Server.config.logOptions.packets) + /*if (Server.config.logOptions.packets && !Server.csMessageToHide.Contains((CsMsgId)csHead_.Msgid)) { Logger.Print(csHead_.ToString()); - } + }*/ seqNext = csHead_.UpSeqid; return new Packet() { csHead = csHead_, finishedBody = BodyBytes,cmdId=csHead_.Msgid }; } diff --git a/Campofinale/NotifyManager.cs b/Campofinale/NotifyManager.cs index c49a42f..c508d2d 100644 --- a/Campofinale/NotifyManager.cs +++ b/Campofinale/NotifyManager.cs @@ -7,7 +7,6 @@ using System.Collections.Immutable; using System.Linq.Expressions; using System.Reflection; - using System.Net.Sockets; using Campofinale.Protocol; using Campofinale.Network; diff --git a/Campofinale/Packets/Cs/HandleCsBattleOp.cs b/Campofinale/Packets/Cs/HandleCsBattleOp.cs index 509c64e..8446e08 100644 --- a/Campofinale/Packets/Cs/HandleCsBattleOp.cs +++ b/Campofinale/Packets/Cs/HandleCsBattleOp.cs @@ -2,16 +2,6 @@ using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using MongoDB.Driver.Core.Clusters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsBitsetAdd.cs b/Campofinale/Packets/Cs/HandleCsBitsetAdd.cs index 97010fd..44f108d 100644 --- a/Campofinale/Packets/Cs/HandleCsBitsetAdd.cs +++ b/Campofinale/Packets/Cs/HandleCsBitsetAdd.cs @@ -1,17 +1,7 @@ -using Campofinale.Game.Character; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsBitsetRemove.cs b/Campofinale/Packets/Cs/HandleCsBitsetRemove.cs index 91350c3..b8e0988 100644 --- a/Campofinale/Packets/Cs/HandleCsBitsetRemove.cs +++ b/Campofinale/Packets/Cs/HandleCsBitsetRemove.cs @@ -1,17 +1,7 @@ -using Campofinale.Game.Character; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharBagSetCurrTeamIndex.cs b/Campofinale/Packets/Cs/HandleCsCharBagSetCurrTeamIndex.cs index 5bf8884..c17ecda 100644 --- a/Campofinale/Packets/Cs/HandleCsCharBagSetCurrTeamIndex.cs +++ b/Campofinale/Packets/Cs/HandleCsCharBagSetCurrTeamIndex.cs @@ -1,21 +1,7 @@ -using BeyondTools.VFS.Crypto; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; - -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; -using static Campofinale.Resource.ResourceManager; -using static System.Net.Mime.MediaTypeNames; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharBagSetTeam.cs b/Campofinale/Packets/Cs/HandleCsCharBagSetTeam.cs index b6cfd9e..e588c68 100644 --- a/Campofinale/Packets/Cs/HandleCsCharBagSetTeam.cs +++ b/Campofinale/Packets/Cs/HandleCsCharBagSetTeam.cs @@ -1,15 +1,6 @@ using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharBagSetTeamLeader.cs b/Campofinale/Packets/Cs/HandleCsCharBagSetTeamLeader.cs index db68e56..f4673a1 100644 --- a/Campofinale/Packets/Cs/HandleCsCharBagSetTeamLeader.cs +++ b/Campofinale/Packets/Cs/HandleCsCharBagSetTeamLeader.cs @@ -1,15 +1,5 @@ using Campofinale.Network; -using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharBagSetTeamName.cs b/Campofinale/Packets/Cs/HandleCsCharBagSetTeamName.cs index eee9396..0554b0b 100644 --- a/Campofinale/Packets/Cs/HandleCsCharBagSetTeamName.cs +++ b/Campofinale/Packets/Cs/HandleCsCharBagSetTeamName.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharLevelUp.cs b/Campofinale/Packets/Cs/HandleCsCharLevelUp.cs index 4f6ce96..a4d0714 100644 --- a/Campofinale/Packets/Cs/HandleCsCharLevelUp.cs +++ b/Campofinale/Packets/Cs/HandleCsCharLevelUp.cs @@ -1,15 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsCharPotentialUnlock.cs b/Campofinale/Packets/Cs/HandleCsCharPotentialUnlock.cs index c51f230..bf2b64b 100644 --- a/Campofinale/Packets/Cs/HandleCsCharPotentialUnlock.cs +++ b/Campofinale/Packets/Cs/HandleCsCharPotentialUnlock.cs @@ -1,16 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; -using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { @@ -26,6 +16,7 @@ namespace Campofinale.Packets.Cs if (character != null) { character.potential=req.Level; + //TODO consume Item ID ScCharPotentialUnlock unlock = new() diff --git a/Campofinale/Packets/Cs/HandleCsCharUnlockTalentNode.cs b/Campofinale/Packets/Cs/HandleCsCharUnlockTalentNode.cs index 262a745..0d2ea8a 100644 --- a/Campofinale/Packets/Cs/HandleCsCharUnlockTalentNode.cs +++ b/Campofinale/Packets/Cs/HandleCsCharUnlockTalentNode.cs @@ -1,16 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; -using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsEnterDungeon.cs b/Campofinale/Packets/Cs/HandleCsEnterDungeon.cs index a3d75f9..12ff9e8 100644 --- a/Campofinale/Packets/Cs/HandleCsEnterDungeon.cs +++ b/Campofinale/Packets/Cs/HandleCsEnterDungeon.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsEquipPutoff.cs b/Campofinale/Packets/Cs/HandleCsEquipPutoff.cs index 137a510..3cbc030 100644 --- a/Campofinale/Packets/Cs/HandleCsEquipPutoff.cs +++ b/Campofinale/Packets/Cs/HandleCsEquipPutoff.cs @@ -1,15 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsEquipPuton.cs b/Campofinale/Packets/Cs/HandleCsEquipPuton.cs index b00625c..0c719b4 100644 --- a/Campofinale/Packets/Cs/HandleCsEquipPuton.cs +++ b/Campofinale/Packets/Cs/HandleCsEquipPuton.cs @@ -1,15 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsFactoryHsFb.cs b/Campofinale/Packets/Cs/HandleCsFactoryHsFb.cs index 8a01e76..853efe5 100644 --- a/Campofinale/Packets/Cs/HandleCsFactoryHsFb.cs +++ b/Campofinale/Packets/Cs/HandleCsFactoryHsFb.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsFactoryOp.cs b/Campofinale/Packets/Cs/HandleCsFactoryOp.cs index 4b84f52..9fb3346 100644 --- a/Campofinale/Packets/Cs/HandleCsFactoryOp.cs +++ b/Campofinale/Packets/Cs/HandleCsFactoryOp.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsFactoryStatisticRequire.cs b/Campofinale/Packets/Cs/HandleCsFactoryStatisticRequire.cs index dd5a13e..0c8d54a 100644 --- a/Campofinale/Packets/Cs/HandleCsFactoryStatisticRequire.cs +++ b/Campofinale/Packets/Cs/HandleCsFactoryStatisticRequire.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsFinishDialog.cs b/Campofinale/Packets/Cs/HandleCsFinishDialog.cs index ff3496b..80693e5 100644 --- a/Campofinale/Packets/Cs/HandleCsFinishDialog.cs +++ b/Campofinale/Packets/Cs/HandleCsFinishDialog.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsFlushSync.cs b/Campofinale/Packets/Cs/HandleCsFlushSync.cs index 1b4b999..0aad914 100644 --- a/Campofinale/Packets/Cs/HandleCsFlushSync.cs +++ b/Campofinale/Packets/Cs/HandleCsFlushSync.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsGachaTenPullReq.cs b/Campofinale/Packets/Cs/HandleCsGachaTenPullReq.cs index 4ad968a..407d1b5 100644 --- a/Campofinale/Packets/Cs/HandleCsGachaTenPullReq.cs +++ b/Campofinale/Packets/Cs/HandleCsGachaTenPullReq.cs @@ -1,17 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Campofinale.Resource; -using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; -using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsGetMail.cs b/Campofinale/Packets/Cs/HandleCsGetMail.cs index b3aff0b..c18e701 100644 --- a/Campofinale/Packets/Cs/HandleCsGetMail.cs +++ b/Campofinale/Packets/Cs/HandleCsGetMail.cs @@ -2,7 +2,6 @@ using Campofinale.Packets.Sc; using Campofinale.Protocol; - namespace Campofinale.Packets.Cs { public class HandleCsGetMail diff --git a/Campofinale/Packets/Cs/HandleCsItemBagAbandonInBag.cs b/Campofinale/Packets/Cs/HandleCsItemBagAbandonInBag.cs new file mode 100644 index 0000000..e0caa05 --- /dev/null +++ b/Campofinale/Packets/Cs/HandleCsItemBagAbandonInBag.cs @@ -0,0 +1,17 @@ +using Campofinale.Network; +using Campofinale.Protocol; + +namespace Campofinale.Packets.Cs +{ + public class HandleCsItemBagAbandonInBag + { + + [Server.Handler(CsMsgId.CsItemBagAbandonInBag)] + public static void Handle(Player session, CsMsgId cmdId, Packet packet) + { + CsItemBagAbandonInBag req = packet.DecodeBody(); + session.inventoryManager.DropItemsBag(req); + } + + } +} diff --git a/Campofinale/Packets/Cs/HandleCsItemBagMoveInBag.cs b/Campofinale/Packets/Cs/HandleCsItemBagMoveInBag.cs new file mode 100644 index 0000000..ad603de --- /dev/null +++ b/Campofinale/Packets/Cs/HandleCsItemBagMoveInBag.cs @@ -0,0 +1,17 @@ +using Campofinale.Network; +using Campofinale.Protocol; + +namespace Campofinale.Packets.Cs +{ + public class HandleCsItemBagMoveInBag + { + + [Server.Handler(CsMsgId.CsItemBagMoveInBag)] + public static void Handle(Player session, CsMsgId cmdId, Packet packet) + { + CsItemBagMoveInBag req = packet.DecodeBody(); + session.inventoryManager.items.MoveBagItem(req.FromGrid, req.ToGrid); + } + + } +} diff --git a/Campofinale/Packets/Cs/HandleCsLeaveDungeon.cs b/Campofinale/Packets/Cs/HandleCsLeaveDungeon.cs index 63216f3..c41097c 100644 --- a/Campofinale/Packets/Cs/HandleCsLeaveDungeon.cs +++ b/Campofinale/Packets/Cs/HandleCsLeaveDungeon.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsLogin.cs b/Campofinale/Packets/Cs/HandleCsLogin.cs index bc40444..78c475d 100644 --- a/Campofinale/Packets/Cs/HandleCsLogin.cs +++ b/Campofinale/Packets/Cs/HandleCsLogin.cs @@ -7,17 +7,21 @@ using Campofinale.Protocol; using Campofinale.Resource; using System.Security.Cryptography; using static Campofinale.Resource.ResourceManager; -using System.Reflection; namespace Campofinale.Packets.Cs { public class HandleCsLogin { - [Server.Handler(CsMsgId.CsCreateRole)] - public static void HandleCsCreateRole(Player session, CsMsgId cmdId, Packet packet) + [Server.Handler(CsMsgId.CsSetGender)] + public static void HandleCsSetGender(Player session, CsMsgId cmdId, Packet packet) { - CsCreateRole req = packet.DecodeBody(); - + CsSetGender req = packet.DecodeBody(); + ScSetGender rsp = new() + { + Gender = req.Gender, + }; + session.gender = rsp.Gender; + session.Send(ScMsgId.ScSetGender, rsp); } [Server.Handler(CsMsgId.CsLogin)] @@ -53,7 +57,7 @@ namespace Campofinale.Packets.Cs // rsp.ServerPublicKey = ByteString.CopyFrom(encryptedEncKey); CSChaCha20 cipher = new CSChaCha20(encKey, serverEncrypNonce, 1); - if (req.ClientVersion == GameConstants.GAME_VERSION) + if (req.ClientVersion == GameConstants.GAME_VERSION || req.ClientVersion == GameConstants.GAME_VERSION_ANDROID) { if (account == null) { @@ -65,9 +69,18 @@ namespace Campofinale.Packets.Cs session.Disconnect(); return; } - session.Load(account.id); + bool exist=session.Load(account.id); rsp.Uid = ""+session.accountId; + if (!exist) + { + rsp.IsFirstLogin = true; + //session.gender = Gender.GenInvalid; + + //session.Send(ScMsgId.ScLogin, rsp); + //session.Send(new PacketScSyncBaseData(session)); + //return; + } session.Send(ScMsgId.ScLogin, rsp); } @@ -113,70 +126,131 @@ namespace Campofinale.Packets.Cs session.Send(new PacketScItemBagScopeSync(session, ItemValuableDepotType.SpecialItem)); session.Send(new PacketScSyncAllMail(session)); session.Send(new PacketScSceneCollectionSync(session)); - /*ScSyncAllMission missions = new() - { - Missions = - { - {"e0m0", - new Mission() - { - MissionId="e0m0", - MissionState=(int)MissionState.Processing, - Properties = - { - {1,new DynamicParameter() - { - ValueType=1, - RealType=1, - ValueBoolList = - { - true - } - } - }, - {2,new DynamicParameter() - { - ValueType=1, - RealType=1, - ValueBoolList = - { - false - } - } - }, - {3,new DynamicParameter() - { - ValueType=1, - RealType=1, - ValueBoolList = - { - false - } - } - } - } - } - } - }, - TrackMissionId= "e0m0", - CurQuests = - { - {"e0m0#1", new Quest(){ - QuestId="e0m0#1", - QuestState=2, - QuestObjectives = - { - - } - }} - } - };*/ - //session.Send(ScMessageId.ScSyncAllMission, missions); string json1 = File.ReadAllText("44_ScSyncAllMission.json"); + + ScSyncAllMission m = Newtonsoft.Json.JsonConvert.DeserializeObject(json1); m.TrackMissionId = ""; - session.Send(ScMsgId.ScSyncAllMission, m); + //Disabled the hardcoded one and enable the missionSystem one + //session.Send(ScMsgId.ScSyncAllMission, session.missionSystem.ToProto()); + session.Send(ScMsgId.ScSyncAllMission, m); + /*ession.Send(ScMsgId.ScSyncAllMission, new ScSyncAllMission() + { + NewMissionTags = + { + + }, + + Missions = + { + {"e0m0", new Mission() + { + MissionId="e0m0", + MissionState=(int)MissionState.Processing, + SucceedId=-1, + Properties = + { + {1,new DynamicParameter() + { + RealType=1, + ValueType=1, + ValueBoolList = + { + false + } + } } + } + } } + }, + TrackMissionId = "e0m0", + + CurQuests = + { + + {"e0m0_q#1", new Quest() + { + QuestId="e0m0_q#1", + QuestState=(int)QuestState.Processing, + QuestObjectives = + { + new QuestObjective() + { + ConditionId="f6415b84", + + IsComplete=false + } + } + } }, + {"e0m0_q#2", new Quest() + { + QuestId="e0m0_q#2", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + new QuestObjective() + { + ConditionId="81736ca7", + IsComplete=false, + } + } + } }, + {"e0m0_q#3", new Quest() + { + QuestId="e0m0_q#3", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } }, + {"e0m0_q#4", new Quest() + { + QuestId="e0m0_q#4", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } }, + {"e0m0_q#5", new Quest() + { + QuestId="e0m0_q#5", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } }, + {"e0m0_q#6", new Quest() + { + QuestId="e0m0_q#6", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } }, + {"e0m0_q#7", new Quest() + { + QuestId="e0m0_q#7", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } }, + {"e0m0_q#8", new Quest() + { + QuestId="e0m0_q#8", + QuestState=(int)QuestState.Available, + QuestObjectives = + { + + } + } } + } + });*/ session.Send(new PacketScGachaSync(session)); ScSettlementSyncAll settlements = new ScSettlementSyncAll() @@ -232,7 +306,7 @@ namespace Campofinale.Packets.Cs session.Send(new PacketScSpaceshipSync(session)); session.Send(new PacketScSyncFullDungeonStatus(session)); session.Send(new PacketScActivitySync(session)); - + session.Send(new PacketScSnsGetChatList(session)); session.Send(ScMsgId.ScSyncFullDataEnd, new ScSyncFullDataEnd()); session.EnterScene(); session.Initialized = true; diff --git a/Campofinale/Packets/Cs/HandleCsMergeMsg.cs b/Campofinale/Packets/Cs/HandleCsMergeMsg.cs index 15542ff..a9deac4 100644 --- a/Campofinale/Packets/Cs/HandleCsMergeMsg.cs +++ b/Campofinale/Packets/Cs/HandleCsMergeMsg.cs @@ -1,14 +1,9 @@ -using Campofinale.Network; +using System.Drawing; + +using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; + +using Pastel; namespace Campofinale.Packets.Cs { @@ -39,8 +34,9 @@ namespace Campofinale.Packets.Cs }; if (Server.config.logOptions.packets) { - Logger.Print("CmdId: " + (CsMsgId)packet.csHead.Msgid); - Logger.Print(BitConverter.ToString(packet.finishedBody).Replace("-", string.Empty).ToLower()); + Logger.Print("Recieved Packet: " + ((CsMsgId)packet.csHead.Msgid).ToString().Pastel(Color.LightCyan) + $" Id: {packet.csHead.Msgid} with {packet.finishedBody.Length} Bytes"); + if (Server.config.logOptions.packetBodies) + Logger.Print(BitConverter.ToString(packet.finishedBody).Replace("-", string.Empty).ToLower()); } try diff --git a/Campofinale/Packets/Cs/HandleCsMoveObjectMove.cs b/Campofinale/Packets/Cs/HandleCsMoveObjectMove.cs index b8bb46d..dafe2a2 100644 --- a/Campofinale/Packets/Cs/HandleCsMoveObjectMove.cs +++ b/Campofinale/Packets/Cs/HandleCsMoveObjectMove.cs @@ -1,15 +1,6 @@ using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Cs diff --git a/Campofinale/Packets/Cs/HandleCsPing.cs b/Campofinale/Packets/Cs/HandleCsPing.cs index e00fa53..f3cccf3 100644 --- a/Campofinale/Packets/Cs/HandleCsPing.cs +++ b/Campofinale/Packets/Cs/HandleCsPing.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSceneInteractSpInteractive.cs b/Campofinale/Packets/Cs/HandleCsSceneInteractSpInteractive.cs index 0925866..eb39054 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneInteractSpInteractive.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneInteractSpInteractive.cs @@ -1,18 +1,8 @@ -using Campofinale.Game.Character; -using Campofinale.Game.Entities; +using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Cs diff --git a/Campofinale/Packets/Cs/HandleCsSceneInteractiveEventTrigger.cs b/Campofinale/Packets/Cs/HandleCsSceneInteractiveEventTrigger.cs index 323271c..d4cbf2b 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneInteractiveEventTrigger.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneInteractiveEventTrigger.cs @@ -1,16 +1,6 @@ -using Campofinale.Game.Character; -using Campofinale.Game.Entities; +using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSceneLoadFinish.cs b/Campofinale/Packets/Cs/HandleCsSceneLoadFinish.cs index a1e0c46..55c7904 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneLoadFinish.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneLoadFinish.cs @@ -1,21 +1,8 @@ -using BeyondTools.VFS.Crypto; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; - -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using static Campofinale.Resource.ResourceManager; -using static System.Net.Mime.MediaTypeNames; namespace Campofinale.Packets.Cs { @@ -31,11 +18,11 @@ namespace Campofinale.Packets.Cs session.sceneManager.LoadCurrentTeamEntities(); session.sceneManager.LoadCurrent(); session.LoadFinish = true; - /*session.Send(ScMessageId.ScSceneClientIdInfo, new ScSceneClientIdInfo() + session.Send(ScMsgId.ScSceneClientIdInfo, new ScSceneClientIdInfo() { RoleIdx = (uint)session.roleId, LastMaxIdx = session.random.usedGuids.Max() - });*/ + }); if (session.curSceneNumId == 98) { session.Send(new PacketScSyncGameMode(session, "spaceship")); diff --git a/Campofinale/Packets/Cs/HandleCsSceneMoveStateSet.cs b/Campofinale/Packets/Cs/HandleCsSceneMoveStateSet.cs index d177b0b..fde66ad 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneMoveStateSet.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneMoveStateSet.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { @@ -19,7 +10,7 @@ namespace Campofinale.Packets.Cs public static void Handle(Player session, CsMsgId cmdId, Packet packet) { CsSceneMoveStateSet req = packet.DecodeBody(); - + //req. } diff --git a/Campofinale/Packets/Cs/HandleCsSceneRepatriate.cs b/Campofinale/Packets/Cs/HandleCsSceneRepatriate.cs index 0b06392..75b40ad 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneRepatriate.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneRepatriate.cs @@ -1,5 +1,4 @@ using Campofinale.Network; -using Campofinale.Packets.Sc; using Campofinale.Protocol; namespace Campofinale.Packets.Cs diff --git a/Campofinale/Packets/Cs/HandleCsSceneSetLastSafeZone.cs b/Campofinale/Packets/Cs/HandleCsSceneSetLastSafeZone.cs index d85216e..9a3e459 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneSetLastSafeZone.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneSetLastSafeZone.cs @@ -1,16 +1,5 @@ -using Campofinale.Game; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; -using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs b/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs new file mode 100644 index 0000000..48e5f0b --- /dev/null +++ b/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs @@ -0,0 +1,204 @@ +using Campofinale.Game.Character; +using Campofinale.Game.Entities; +using Campofinale.Network; +using Campofinale.Protocol; +using Campofinale.Resource; +using Campofinale.Resource.Table; +using Pastel; + +namespace Campofinale.Packets.Cs +{ + public class HandleCsSceneSetLevelScriptActive + { + [Server.Handler(CsMsgId.CsSceneSetLevelScriptActive)] + public static void Handle(Player session, CsMsgId cmdId, Packet packet) + { + CsSceneSetLevelScriptActive req = packet.DecodeBody(); + if (req.IsActive) + { + + ScSceneLevelScriptStateNotify rsp = new ScSceneLevelScriptStateNotify() + { + SceneNumId = req.SceneNumId, + ScriptId = req.ScriptId, + + State = 3 + }; + session.Send(ScMsgId.ScSceneLevelScriptStateNotify, rsp); + } + + + } + + [Server.Handler(CsMsgId.CsSceneSetLevelScriptStart)] + public static void HandleCsSceneSetLevelScriptStart(Player session, CsMsgId cmdId, Packet packet) + { + CsSceneSetLevelScriptStart req = packet.DecodeBody(); + if (req.IsStart) + { + ScSceneLevelScriptStateNotify rsp = new ScSceneLevelScriptStateNotify() + { + SceneNumId = req.SceneNumId, + ScriptId = req.ScriptId, + + State = 4 + }; + session.Send(ScMsgId.ScSceneLevelScriptStateNotify, rsp); + } + + + } + + public static void ExecuteEventAction(Player player, ScriptAction action) + { + switch (action.action) + { + case ScriptActionType.CompleteQuest: + player.missionSystem.CompleteQuest(action.valueStr[0]); + break; + case ScriptActionType.ProcessQuest: + player.missionSystem.ProcessQuest(action.valueStr[0]); + break; + case ScriptActionType.SpawnEnemy: + player.sceneManager.GetCurScene().SpawnEnemy(action.valueUlong[0]); + break; + default: + Logger.PrintWarn("Script Action not implemented"); + break; + } + } + [Server.Handler(CsMsgId.CsSceneLevelScriptEventTrigger)] + public static void HandleCsSceneLevelScriptEventTrigger(Player session, CsMsgId cmdId, Packet packet) + { + + CsSceneLevelScriptEventTrigger req = packet.DecodeBody(); + Logger.Print(req.Properties.ToString()); + + if (ResourceManager.levelScriptsEvents.TryGetValue(req.EventName, out LevelScriptEvent levelScriptEvent)) + { + Logger.Print($"Event {req.EventName.Pastel(ConsoleColor.Yellow)} Executed."); + Logger.Print($"{levelScriptEvent.comment}"); + levelScriptEvent.actions.ForEach(a => + { + ExecuteEventAction(session, a); + }); + } + else + { + Logger.PrintWarn($"Event {req.EventName.Pastel(ConsoleColor.White)} is NOT implemented. INFO: ["); + Logger.PrintWarn($" Scene: {req.SceneNumId.ToString().Pastel(ConsoleColor.White)}, Pos: {session.position.ToProto().ToString()} "); + Logger.PrintWarn($" ScriptID: {req.ScriptId.ToString().Pastel(ConsoleColor.White)} "); + Logger.PrintWarn($"]"); + } + /*if(req.EventName== "#8777e316") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#1", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#2", + QuestState = (int)QuestState.Processing, + }); + } + if(req.EventName== "#6ea2690d") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#2", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#3", + QuestState = (int)QuestState.Processing, + }); + } + if (req.EventName == "#bb79de30") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#3", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#4", + QuestState = (int)QuestState.Processing, + }); + } + if (req.EventName == "#4c76ec3c") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#4", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#5", + QuestState = (int)QuestState.Processing, + }); + } + if (req.EventName == "#251df3ad") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#5", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#6", + QuestState = (int)QuestState.Processing, + }); + } + if (req.EventName == "#e6ac322b") + { + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#6", + QuestState = (int)QuestState.Completed, + }); + session.Send(ScMsgId.ScQuestStateUpdate, new ScQuestStateUpdate() + { + QuestId = "e0m0_q#7", + QuestState = (int)QuestState.Processing, + }); + }*/ + + ScSceneUpdateLevelScriptProperty update1 = new() + { + SceneNumId = req.SceneNumId, + ScriptId = req.ScriptId, + + }; + session.Send(ScMsgId.ScSceneUpdateLevelScriptProperty, update1); + ScSceneTriggerClientLevelScriptEvent trigger = new() + { + EventName = req.EventName, + SceneNumId = req.SceneNumId, + ScriptId = req.ScriptId, + + }; + session.Send(ScMsgId.ScSceneTriggerClientLevelScriptEvent, trigger); + ScSceneUpdateLevelScriptProperty update2 = new() + { + SceneNumId = req.SceneNumId, + ScriptId = req.ScriptId, + + + }; + session.Send(ScMsgId.ScSceneUpdateLevelScriptProperty, update2); + ScSceneLevelScriptEventTrigger rsp = new ScSceneLevelScriptEventTrigger() + { + + }; + + session.Send(ScMsgId.ScSceneLevelScriptEventTrigger, rsp,packet.csHead.UpSeqid); + + } + } +} \ No newline at end of file diff --git a/Campofinale/Packets/Cs/HandleCsSceneSetSafeZone.cs b/Campofinale/Packets/Cs/HandleCsSceneSetSafeZone.cs index 1d90e2f..777c92e 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneSetSafeZone.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneSetSafeZone.cs @@ -1,16 +1,6 @@ -using Campofinale.Game; -using Campofinale.Game.Entities; +using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Cs @@ -22,7 +12,12 @@ namespace Campofinale.Packets.Cs public static void Handle(Player session, CsMsgId cmdId, Packet packet) { CsSceneSetSafeZone req = packet.DecodeBody(); - + ScSceneSetSafeZone rsp = new() + { + Id = req.Id, + InZone = req.InZone, + }; + session.Send(ScMsgId.ScSceneSetSafeZone, rsp); if (req.InZone) { var entity = session.sceneManager.GetEntity(req.Id) as EntityInteractive; diff --git a/Campofinale/Packets/Cs/HandleCsSceneSetTrackPoint.cs b/Campofinale/Packets/Cs/HandleCsSceneSetTrackPoint.cs index faec2d4..1a9519e 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneSetTrackPoint.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneSetTrackPoint.cs @@ -1,15 +1,6 @@ using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSceneTeleport.cs b/Campofinale/Packets/Cs/HandleCsSceneTeleport.cs index 97cc91b..086b3c0 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneTeleport.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneTeleport.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSpaceshipPresentGiftToChar.cs b/Campofinale/Packets/Cs/HandleCsSpaceshipPresentGiftToChar.cs new file mode 100644 index 0000000..f02ba72 --- /dev/null +++ b/Campofinale/Packets/Cs/HandleCsSpaceshipPresentGiftToChar.cs @@ -0,0 +1,18 @@ +using Campofinale.Network; +using Campofinale.Protocol; + +namespace Campofinale.Packets.Cs +{ + public class HandleCsSpaceshipPresentGiftToChar + { + + [Server.Handler(CsMsgId.CsSpaceshipPresentGiftToChar)] + public static void Handle(Player session, CsMsgId cmdId, Packet packet) + { + CsSpaceshipPresentGiftToChar req = packet.DecodeBody(); + session.spaceshipManager.GiftToChar(req); + + } + + } +} diff --git a/Campofinale/Packets/Cs/HandleCsSpaceshipStationChar.cs b/Campofinale/Packets/Cs/HandleCsSpaceshipStationChar.cs index 0df56a1..c7ba586 100644 --- a/Campofinale/Packets/Cs/HandleCsSpaceshipStationChar.cs +++ b/Campofinale/Packets/Cs/HandleCsSpaceshipStationChar.cs @@ -1,15 +1,6 @@ using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsSpaceshipStationCharChangeWorkState.cs b/Campofinale/Packets/Cs/HandleCsSpaceshipStationCharChangeWorkState.cs index 8bf17ae..9f91d25 100644 --- a/Campofinale/Packets/Cs/HandleCsSpaceshipStationCharChangeWorkState.cs +++ b/Campofinale/Packets/Cs/HandleCsSpaceshipStationCharChangeWorkState.cs @@ -1,15 +1,6 @@ using Campofinale.Network; using Campofinale.Packets.Sc; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsTrackMission.cs b/Campofinale/Packets/Cs/HandleCsTrackMission.cs new file mode 100644 index 0000000..b2b07f8 --- /dev/null +++ b/Campofinale/Packets/Cs/HandleCsTrackMission.cs @@ -0,0 +1,20 @@ +using Campofinale.Network; +using Campofinale.Protocol; + +namespace Campofinale.Packets.Cs +{ + internal class HandleCsTrackMission + { + [Server.Handler(CsMsgId.CsTrackMission)] + public static void Handle(Player session, CsMsgId msgId, Packet packet) + { + CsTrackMission req = packet.DecodeBody(); + session.missionSystem.curMission = req.MissionId; + ScTrackMissionChange rsp = new() + { + MissionId = req.MissionId + }; + session.Send(ScMsgId.ScTrackMissionChange, rsp); + } + } +} diff --git a/Campofinale/Packets/Cs/HandleCsUpdateQuestObjective.cs b/Campofinale/Packets/Cs/HandleCsUpdateQuestObjective.cs index 66560a8..a815e23 100644 --- a/Campofinale/Packets/Cs/HandleCsUpdateQuestObjective.cs +++ b/Campofinale/Packets/Cs/HandleCsUpdateQuestObjective.cs @@ -1,14 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsWeaponAddExp.cs b/Campofinale/Packets/Cs/HandleCsWeaponAddExp.cs index b58bce7..d464dcf 100644 --- a/Campofinale/Packets/Cs/HandleCsWeaponAddExp.cs +++ b/Campofinale/Packets/Cs/HandleCsWeaponAddExp.cs @@ -1,16 +1,6 @@ -using Campofinale.Game.Character; -using Campofinale.Game.Inventory; +using Campofinale.Game.Inventory; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Cs/HandleCsWeaponPuton.cs b/Campofinale/Packets/Cs/HandleCsWeaponPuton.cs index 60bd5c2..6e2c56a 100644 --- a/Campofinale/Packets/Cs/HandleCsWeaponPuton.cs +++ b/Campofinale/Packets/Cs/HandleCsWeaponPuton.cs @@ -1,15 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using Google.Protobuf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; namespace Campofinale.Packets.Cs { diff --git a/Campofinale/Packets/Sc/PacketScActivitySync.cs b/Campofinale/Packets/Sc/PacketScActivitySync.cs index 44a22e3..5bf730a 100644 --- a/Campofinale/Packets/Sc/PacketScActivitySync.cs +++ b/Campofinale/Packets/Sc/PacketScActivitySync.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScAdventureBookSync.cs b/Campofinale/Packets/Sc/PacketScAdventureBookSync.cs index 458be18..bf2a0b9 100644 --- a/Campofinale/Packets/Sc/PacketScAdventureBookSync.cs +++ b/Campofinale/Packets/Sc/PacketScAdventureBookSync.cs @@ -1,12 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScAdventureSyncAll.cs b/Campofinale/Packets/Sc/PacketScAdventureSyncAll.cs index 2b8c735..3b149f3 100644 --- a/Campofinale/Packets/Sc/PacketScAdventureSyncAll.cs +++ b/Campofinale/Packets/Sc/PacketScAdventureSyncAll.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScBitsetAdd.cs b/Campofinale/Packets/Sc/PacketScBitsetAdd.cs index 8dfa1fa..6580c7d 100644 --- a/Campofinale/Packets/Sc/PacketScBitsetAdd.cs +++ b/Campofinale/Packets/Sc/PacketScBitsetAdd.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScBitsetRemove.cs b/Campofinale/Packets/Sc/PacketScBitsetRemove.cs index 29f2653..5ca90f0 100644 --- a/Campofinale/Packets/Sc/PacketScBitsetRemove.cs +++ b/Campofinale/Packets/Sc/PacketScBitsetRemove.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScCharBagAddChar.cs b/Campofinale/Packets/Sc/PacketScCharBagAddChar.cs index 3343686..7c6617d 100644 --- a/Campofinale/Packets/Sc/PacketScCharBagAddChar.cs +++ b/Campofinale/Packets/Sc/PacketScCharBagAddChar.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScCharBagDelChar.cs b/Campofinale/Packets/Sc/PacketScCharBagDelChar.cs index efa3860..9ba09d7 100644 --- a/Campofinale/Packets/Sc/PacketScCharBagDelChar.cs +++ b/Campofinale/Packets/Sc/PacketScCharBagDelChar.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScCharBagSetCurrTeamIndex.cs b/Campofinale/Packets/Sc/PacketScCharBagSetCurrTeamIndex.cs index 2fbdeed..99af587 100644 --- a/Campofinale/Packets/Sc/PacketScCharBagSetCurrTeamIndex.cs +++ b/Campofinale/Packets/Sc/PacketScCharBagSetCurrTeamIndex.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScCharBagSetTeamName.cs b/Campofinale/Packets/Sc/PacketScCharBagSetTeamName.cs index b069b45..1b34feb 100644 --- a/Campofinale/Packets/Sc/PacketScCharBagSetTeamName.cs +++ b/Campofinale/Packets/Sc/PacketScCharBagSetTeamName.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScCharUnlockTalentNode.cs b/Campofinale/Packets/Sc/PacketScCharUnlockTalentNode.cs index 1cb04de..0a65011 100644 --- a/Campofinale/Packets/Sc/PacketScCharUnlockTalentNode.cs +++ b/Campofinale/Packets/Sc/PacketScCharUnlockTalentNode.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Character; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScEnterSceneNotify.cs b/Campofinale/Packets/Sc/PacketScEnterSceneNotify.cs index 98dedba..8c851ed 100644 --- a/Campofinale/Packets/Sc/PacketScEnterSceneNotify.cs +++ b/Campofinale/Packets/Sc/PacketScEnterSceneNotify.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScFactoryOpRet.cs b/Campofinale/Packets/Sc/PacketScFactoryOpRet.cs index d649328..9057871 100644 --- a/Campofinale/Packets/Sc/PacketScFactoryOpRet.cs +++ b/Campofinale/Packets/Sc/PacketScFactoryOpRet.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScFactorySync.cs b/Campofinale/Packets/Sc/PacketScFactorySync.cs index f2df4b9..586cb41 100644 --- a/Campofinale/Packets/Sc/PacketScFactorySync.cs +++ b/Campofinale/Packets/Sc/PacketScFactorySync.cs @@ -1,6 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScFactorySyncChapter.cs b/Campofinale/Packets/Sc/PacketScFactorySyncChapter.cs index 2189cd4..f154a82 100644 --- a/Campofinale/Packets/Sc/PacketScFactorySyncChapter.cs +++ b/Campofinale/Packets/Sc/PacketScFactorySyncChapter.cs @@ -1,15 +1,8 @@ using Campofinale.Game.Factory; -using Campofinale.Game.Inventory; using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; using Campofinale.Resource.Table; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScGachaSync.cs b/Campofinale/Packets/Sc/PacketScGachaSync.cs index dcb25e7..c1c4601 100644 --- a/Campofinale/Packets/Sc/PacketScGachaSync.cs +++ b/Campofinale/Packets/Sc/PacketScGachaSync.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Gacha; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc @@ -36,8 +30,50 @@ namespace Campofinale.Packets.Sc WeaponGachaPool = new() { - } + }, + }; + foreach(var item in gachaWeaponPoolTable) + { + (int fiveStarPity, int sixStarPity, GachaTransaction? lastSixStar, bool isFiftyFiftyLost) + PityInfo = client.gachaManager.GetCurrentPity(item.Value.id); + ScdGachaPoolInfo wPool = new ScdGachaPoolInfo() + { + GachaPoolId = item.Value.id, + IsClosed = false, + CloseTime = DateTime.UtcNow.AddDays(20).ToUnixTimestampMilliseconds() / 1000, + OpenTime = DateTime.UtcNow.ToUnixTimestampMilliseconds() / 1000, + PublicCloseReason = 0, + + + }; + if (item.Value.closeTimes.Count == 0) + { + wPool.CloseTime = 0; + wPool.OpenTime = 0; + } + proto.WeaponGachaPool.GachaPoolInfos.Add(wPool); + proto.WeaponGachaPool.GachaPoolRoleDatas.Add(new ScdGachaPoolRoleData() + { + GachaPoolId = item.Value.id, + IsClosed = false, + PersonalCloseReason = 0, + SoftGuaranteeProgress = PityInfo.sixStarPity, + TotalPullCount = PityInfo.sixStarPity, + Star5SoftGuaranteeProgress = PityInfo.fiveStarPity, + HardGuaranteeProgress = PityInfo.sixStarPity, + + }); + proto.WeaponGachaPool.GachaPoolCategoryRoleDatas.Add(new ScdGachaPoolCategoryRoleData() + { + GachaPoolType = item.Value.type, + TotalPullCount = PityInfo.sixStarPity, + Star5SoftGuaranteeProgress = PityInfo.fiveStarPity, + SoftGuaranteeProgress = PityInfo.sixStarPity, + + }); + + } //TODO: Implement banner config for opentime etc foreach (var item in gachaCharPoolTable) { diff --git a/Campofinale/Packets/Sc/PacketScGameMechanicsSync.cs b/Campofinale/Packets/Sc/PacketScGameMechanicsSync.cs index 8b728c7..36b91e8 100644 --- a/Campofinale/Packets/Sc/PacketScGameMechanicsSync.cs +++ b/Campofinale/Packets/Sc/PacketScGameMechanicsSync.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScGetMail.cs b/Campofinale/Packets/Sc/PacketScGetMail.cs index 76a44e5..ead7e6e 100644 --- a/Campofinale/Packets/Sc/PacketScGetMail.cs +++ b/Campofinale/Packets/Sc/PacketScGetMail.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScItemBagScopeModify.cs b/Campofinale/Packets/Sc/PacketScItemBagScopeModify.cs index abea4a1..ccc887c 100644 --- a/Campofinale/Packets/Sc/PacketScItemBagScopeModify.cs +++ b/Campofinale/Packets/Sc/PacketScItemBagScopeModify.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Inventory; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { @@ -15,6 +9,11 @@ namespace Campofinale.Packets.Sc public PacketScItemBagScopeModify(Player client, Item item) { + if (item == null) + { + SetData(ScMsgId.ScItemBagScopeModify, new ScItemBagScopeModify()); + return; + } ScItemBagScopeModify proto = new ScItemBagScopeModify() { Depot = diff --git a/Campofinale/Packets/Sc/PacketScItemBagScopeSync.cs b/Campofinale/Packets/Sc/PacketScItemBagScopeSync.cs index 6b8584a..a78a197 100644 --- a/Campofinale/Packets/Sc/PacketScItemBagScopeSync.cs +++ b/Campofinale/Packets/Sc/PacketScItemBagScopeSync.cs @@ -2,12 +2,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { @@ -19,10 +13,10 @@ namespace Campofinale.Packets.Sc { Bag = new() { - GridLimit = 30, + GridLimit = client.inventoryManager.items.maxBagSize, Grids = { - new ScdItemGrid() + /*new ScdItemGrid() { GridIndex=0, Count=1, @@ -79,7 +73,7 @@ namespace Campofinale.Packets.Sc InstId=300000000004, }, - } + }*/ } }, FactoryDepot = @@ -114,7 +108,18 @@ namespace Campofinale.Packets.Sc proto.Bag = null; } proto.Depot.Add(i, new ScdItemDepot()); - List items = client.inventoryManager.items.FindAll(item => item.ItemType == (ItemValuableDepotType)i); + if(proto.Bag!=null) + foreach (var item in client.inventoryManager.items.bag) + { + proto.Bag.Grids.Add(new ScdItemGrid() + { + Count=item.Value.amount, + GridIndex=item.Key, + Id=item.Value.id, + Inst=item.Value.ToProto().Inst, + }); + } + List items = client.inventoryManager.items.items.FindAll(item => item.ItemType == (ItemValuableDepotType)i); items.ForEach(item => { if (item.InstanceType()) diff --git a/Campofinale/Packets/Sc/PacketScObjectEnterView.cs b/Campofinale/Packets/Sc/PacketScObjectEnterView.cs index 2b5b7aa..856153b 100644 --- a/Campofinale/Packets/Sc/PacketScObjectEnterView.cs +++ b/Campofinale/Packets/Sc/PacketScObjectEnterView.cs @@ -1,13 +1,6 @@ using Campofinale.Game.Entities; using Campofinale.Network; using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScObjectLeaveView.cs b/Campofinale/Packets/Sc/PacketScObjectLeaveView.cs index b0643ab..047a4c1 100644 --- a/Campofinale/Packets/Sc/PacketScObjectLeaveView.cs +++ b/Campofinale/Packets/Sc/PacketScObjectLeaveView.cs @@ -1,13 +1,5 @@ -using Campofinale.Game.Entities; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSceneCollectionSync.cs b/Campofinale/Packets/Sc/PacketScSceneCollectionSync.cs index 171fd96..23b41ee 100644 --- a/Campofinale/Packets/Sc/PacketScSceneCollectionSync.cs +++ b/Campofinale/Packets/Sc/PacketScSceneCollectionSync.cs @@ -1,13 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using Campofinale.Resource; using Campofinale.Game; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScSceneSetTrackPoint.cs b/Campofinale/Packets/Sc/PacketScSceneSetTrackPoint.cs index 383e011..6f5d0c7 100644 --- a/Campofinale/Packets/Sc/PacketScSceneSetTrackPoint.cs +++ b/Campofinale/Packets/Sc/PacketScSceneSetTrackPoint.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSelfSceneInfo.cs b/Campofinale/Packets/Sc/PacketScSelfSceneInfo.cs index c00f6ff..cb08b06 100644 --- a/Campofinale/Packets/Sc/PacketScSelfSceneInfo.cs +++ b/Campofinale/Packets/Sc/PacketScSelfSceneInfo.cs @@ -1,13 +1,6 @@ -using Campofinale.Game.Entities; -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { @@ -73,12 +66,13 @@ namespace Campofinale.Packets.Sc { ScriptId = l.scriptId, IsDone = false, - State = 1, - + State = 2, + }; int i = 0; foreach (var item in l.properties) { + DynamicParameter p=item.ToProto(); if (p != null) script.Properties.Add(l.GetPropertyId(item.key,script.Properties.Keys.ToList()), p); diff --git a/Campofinale/Packets/Sc/PacketScSetName.cs b/Campofinale/Packets/Sc/PacketScSetName.cs index 088faa5..5d90a5f 100644 --- a/Campofinale/Packets/Sc/PacketScSetName.cs +++ b/Campofinale/Packets/Sc/PacketScSetName.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSnsGetChatList.cs b/Campofinale/Packets/Sc/PacketScSnsGetChatList.cs new file mode 100644 index 0000000..f1cc441 --- /dev/null +++ b/Campofinale/Packets/Sc/PacketScSnsGetChatList.cs @@ -0,0 +1,27 @@ +using Campofinale.Network; +using Campofinale.Protocol; +using Campofinale.Resource; + +namespace Campofinale.Packets.Sc +{ + public class PacketScSnsGetChatList : Packet + { + public PacketScSnsGetChatList(Player player) { + ScSnsGetChatList proto = new ScSnsGetChatList() { + + }; + foreach (var chat in ResourceManager.snsChatTable) + { + var chatInfo = new SnsChatInfo() + { + ChatId = chat.Value.chatId, + ChatType = chat.Value.chatType, + Timestamp = DateTime.UtcNow.ToUnixTimestampMilliseconds(), + + }; + proto.ChatList.Add(chatInfo); + } + SetData(ScMsgId.ScSnsGetChatList, proto); + } + } +} diff --git a/Campofinale/Packets/Sc/PacketScSpaceshipSync.cs b/Campofinale/Packets/Sc/PacketScSpaceshipSync.cs index 7573185..24dac98 100644 --- a/Campofinale/Packets/Sc/PacketScSpaceshipSync.cs +++ b/Campofinale/Packets/Sc/PacketScSpaceshipSync.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSpaceshipSyncRoomStation.cs b/Campofinale/Packets/Sc/PacketScSpaceshipSyncRoomStation.cs index 3574a78..9253234 100644 --- a/Campofinale/Packets/Sc/PacketScSpaceshipSyncRoomStation.cs +++ b/Campofinale/Packets/Sc/PacketScSpaceshipSyncRoomStation.cs @@ -1,12 +1,6 @@ using Campofinale.Game.Spaceship; using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllBitset.cs b/Campofinale/Packets/Sc/PacketScSyncAllBitset.cs index 9eb3c96..d875ef5 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllBitset.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllBitset.cs @@ -1,12 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllBloc.cs b/Campofinale/Packets/Sc/PacketScSyncAllBloc.cs index 083aa60..b50aa26 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllBloc.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllBloc.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScSyncAllDialog.cs b/Campofinale/Packets/Sc/PacketScSyncAllDialog.cs index 0fd4788..5aa9651 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllDialog.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllDialog.cs @@ -1,12 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllGameVar.cs b/Campofinale/Packets/Sc/PacketScSyncAllGameVar.cs index 4523079..1f4f7d7 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllGameVar.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllGameVar.cs @@ -1,12 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllMail.cs b/Campofinale/Packets/Sc/PacketScSyncAllMail.cs index 2c7fd2d..37309a8 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllMail.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllMail.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllMiniGame.cs b/Campofinale/Packets/Sc/PacketScSyncAllMiniGame.cs index d7ccc89..431300b 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllMiniGame.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllMiniGame.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncAllRoleScene.cs b/Campofinale/Packets/Sc/PacketScSyncAllRoleScene.cs index 0ada96d..db30cad 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllRoleScene.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllRoleScene.cs @@ -1,13 +1,6 @@ using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using Campofinale.Resource.Table; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc diff --git a/Campofinale/Packets/Sc/PacketScSyncAllUnlock.cs b/Campofinale/Packets/Sc/PacketScSyncAllUnlock.cs index 43e4b9e..464b922 100644 --- a/Campofinale/Packets/Sc/PacketScSyncAllUnlock.cs +++ b/Campofinale/Packets/Sc/PacketScSyncAllUnlock.cs @@ -1,13 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Resource.ResourceManager; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncBaseData.cs b/Campofinale/Packets/Sc/PacketScSyncBaseData.cs index dfb2763..305bc6d 100644 --- a/Campofinale/Packets/Sc/PacketScSyncBaseData.cs +++ b/Campofinale/Packets/Sc/PacketScSyncBaseData.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { @@ -18,13 +12,12 @@ namespace Campofinale.Packets.Sc { Roleid = client.roleId, Level = client.level, - Exp=client.xp, + Exp = client.xp, RoleName = client.nickname, - Gender = Gender.GenFemale, - ShortId="1", - - }; + Gender = client.gender, + ShortId = "1", + }; SetData(ScMsgId.ScSyncBaseData, proto); } diff --git a/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs b/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs index 6820ff0..2fdc500 100644 --- a/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs +++ b/Campofinale/Packets/Sc/PacketScSyncCharBagInfo.cs @@ -1,12 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using Campofinale.Resource; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { @@ -17,6 +10,7 @@ namespace Campofinale.Packets.Sc ScSyncCharBagInfo proto = new() { + ScopeName=1, CharInfo = @@ -32,7 +26,10 @@ namespace Campofinale.Packets.Sc }, }; - client.chars.ForEach(c => proto.CharInfo.Add(c.ToProto())); + client.chars.ForEach(c => + { + proto.CharInfo.Add(c.ToProto()); + }); client.teams.ForEach(c => { proto.TeamInfo.Add(new CharTeamInfo() diff --git a/Campofinale/Packets/Sc/PacketScSyncFullDungeonStatus.cs b/Campofinale/Packets/Sc/PacketScSyncFullDungeonStatus.cs index 35b5195..495a736 100644 --- a/Campofinale/Packets/Sc/PacketScSyncFullDungeonStatus.cs +++ b/Campofinale/Packets/Sc/PacketScSyncFullDungeonStatus.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncGameMode.cs b/Campofinale/Packets/Sc/PacketScSyncGameMode.cs index b44a7c4..9dd4cc4 100644 --- a/Campofinale/Packets/Sc/PacketScSyncGameMode.cs +++ b/Campofinale/Packets/Sc/PacketScSyncGameMode.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncStamina.cs b/Campofinale/Packets/Sc/PacketScSyncStamina.cs index a9739dc..361c5e3 100644 --- a/Campofinale/Packets/Sc/PacketScSyncStamina.cs +++ b/Campofinale/Packets/Sc/PacketScSyncStamina.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Packets/Sc/PacketScSyncWallet.cs b/Campofinale/Packets/Sc/PacketScSyncWallet.cs index eb6611d..e7fb633 100644 --- a/Campofinale/Packets/Sc/PacketScSyncWallet.cs +++ b/Campofinale/Packets/Sc/PacketScSyncWallet.cs @@ -1,11 +1,5 @@ using Campofinale.Network; using Campofinale.Protocol; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; namespace Campofinale.Packets.Sc { diff --git a/Campofinale/Player.cs b/Campofinale/Player.cs index 59d1e66..78f1ddd 100644 --- a/Campofinale/Player.cs +++ b/Campofinale/Player.cs @@ -1,16 +1,6 @@ - -using Campofinale.Network; +using Campofinale.Network; using Campofinale.Protocol; using Google.Protobuf; -using Google.Protobuf.Collections; -using Pastel; -using SQLite; -using SQLiteNetExtensions.Attributes; -using System.Drawing; -using System.Linq; -using System.Numerics; -using MongoDB.Bson.Serialization.Attributes; -using System.Reflection; using System.Net.Sockets; using Campofinale.Packets.Sc; using Campofinale.Game.Character; @@ -23,6 +13,9 @@ using Campofinale.Game.Gacha; using Campofinale.Game.Spaceship; using Campofinale.Game.Dungeons; using Campofinale.Game.Factory; +using Campofinale.Game.MissionSys; +using Pastel; +using System.Drawing; namespace Campofinale @@ -89,6 +82,7 @@ namespace Campofinale public string accountId = ""; public string nickname = "Endministrator"; public ulong roleId= 1; + public Gender gender=Gender.GenFemale; public uint level = 20; public uint xp = 0; // @@ -103,6 +97,7 @@ namespace Campofinale public GachaManager gachaManager; public BitsetManager bitsetManager; public FactoryManager factoryManager; + public MissionSystem missionSystem; public int teamIndex = 0; public List teams= new List(); public List mails = new List(); @@ -132,6 +127,7 @@ namespace Campofinale gachaManager = new(this); spaceshipManager = new(this); factoryManager = new(this); + missionSystem = new(this); receivorThread = new Thread(new ThreadStart(Receive)); } @@ -139,7 +135,7 @@ namespace Campofinale { return chars.FindAll(c=> teams[teamIndex].members.Contains(c.guid)); } - public void Load(string accountId) + public bool Load(string accountId) { this.accountId = accountId; PlayerData data = DatabaseManager.db.GetPlayerById(this.accountId); @@ -161,9 +157,12 @@ namespace Campofinale maxDashEnergy = data.maxDashEnergy; curStamina = data.curStamina; nextRecoverTime=data.nextRecoverTime; + if (data.gender > 0) gender = data.gender; + LoadCharacters(); mails = DatabaseManager.db.LoadMails(roleId); inventoryManager.Load(); + if (data.bag != null) inventoryManager.items.bag = data.bag; spaceshipManager.Load(); if (data.scenes != null) { @@ -176,40 +175,65 @@ namespace Campofinale { Initialize(); //only if no account found } + missionSystem.Load(); sceneManager.Load(); factoryManager.Load(); + return (data != null); } public void LoadCharacters() { chars = DatabaseManager.db.LoadCharacters(roleId); } - //Added in 1.0.7 + /// + /// Get the character using the guid *Added in 1.0.7* + /// + /// + /// public Character GetCharacter(ulong guid) { return chars.Find(c => c.guid == guid); } - + /// + /// Get the character using the template id + /// + /// + /// Character public Character GetCharacter(string templateId) { return chars.Find(c => c.id==templateId); } public void Initialize() { - foreach (var item in ResourceManager.characterTable) + if (Server.config.serverOptions.defaultCharacters.giveAllCharacters) { - chars.Add(new Character(roleId,item.Key,20)); + foreach (var item in ResourceManager.characterTable) + { + chars.Add(new Character(roleId, item.Key, Server.config.serverOptions.defaultCharacters.defaultLevel)); + } } + else + { + foreach (var item in Server.config.serverOptions.defaultCharacters.characters) + { + chars.Add(new Character(roleId, item, Server.config.serverOptions.defaultCharacters.defaultLevel)); + } + } + foreach(var item in itemTable) { - if(item.Value.maxStackCount == -1) + if(item.Value.GetStorage()!= ItemStorageSpace.BagAndFactoryDepot) { - inventoryManager.items.Add(new Item(roleId, item.Value.id, 10000000)); - } - else - { - inventoryManager.items.Add(new Item(roleId, item.Value.id, item.Value.maxStackCount)); + if (item.Value.maxStackCount == -1) + { + inventoryManager.items.Add(new Item(roleId, item.Value.id, 10000000)); + } + else + { + inventoryManager.items.Add(new Item(roleId, item.Value.id, item.Value.maxStackCount)); + } } + } teams.Add(new Team() { @@ -244,68 +268,6 @@ namespace Campofinale } public void UnlockImportantSystems() { - /*unlockedSystems.Add((int)UnlockSystemType.Watch); - unlockedSystems.Add((int)UnlockSystemType.Weapon); - unlockedSystems.Add((int)UnlockSystemType.Equip); - unlockedSystems.Add((int)UnlockSystemType.EquipEnhance); - unlockedSystems.Add((int)UnlockSystemType.NormalAttack); - unlockedSystems.Add((int)UnlockSystemType.NormalSkill); - unlockedSystems.Add((int)UnlockSystemType.UltimateSkill); - unlockedSystems.Add((int)UnlockSystemType.TeamSkill); - unlockedSystems.Add((int)UnlockSystemType.ComboSkill); - unlockedSystems.Add((int)UnlockSystemType.TeamSwitch); - unlockedSystems.Add((int)UnlockSystemType.Dash); - unlockedSystems.Add((int)UnlockSystemType.Jump); - unlockedSystems.Add((int)UnlockSystemType.Friend); - unlockedSystems.Add((int)UnlockSystemType.SNS); - unlockedSystems.Add((int)UnlockSystemType.Settlement); - unlockedSystems.Add((int)UnlockSystemType.Map); - - unlockedSystems.Add((int)UnlockSystemType.FacTechTree); - unlockedSystems.Add((int)UnlockSystemType.FacZone); - unlockedSystems.Add((int)UnlockSystemType.FacSplitter); - unlockedSystems.Add((int)UnlockSystemType.FacConveyor); - unlockedSystems.Add((int)UnlockSystemType.FacBridge); - unlockedSystems.Add((int)UnlockSystemType.FacPipe); - unlockedSystems.Add((int)UnlockSystemType.FacBuildingPin); - unlockedSystems.Add((int)UnlockSystemType.FacBUS); - unlockedSystems.Add((int)UnlockSystemType.FacPipeConnector); - unlockedSystems.Add((int)UnlockSystemType.FacOverview); - unlockedSystems.Add((int)UnlockSystemType.FacCraftPin); - unlockedSystems.Add((int)UnlockSystemType.FacMerger); - unlockedSystems.Add((int)UnlockSystemType.FacYieldStats); - unlockedSystems.Add((int)UnlockSystemType.FacTransferPort); - unlockedSystems.Add((int)UnlockSystemType.FacHub); - unlockedSystems.Add((int)UnlockSystemType.FacMode); - unlockedSystems.Add((int)UnlockSystemType.FacSystem); - unlockedSystems.Add((int)UnlockSystemType.FacPipeSplitter); - unlockedSystems.Add((int)UnlockSystemType.FacPipeConverger); - unlockedSystems.Add((int)UnlockSystemType.AdventureBook); - unlockedSystems.Add((int)UnlockSystemType.CharUI); - unlockedSystems.Add((int)UnlockSystemType.EquipProduce); - unlockedSystems.Add((int)UnlockSystemType.EquipTech); - unlockedSystems.Add((int)UnlockSystemType.Gacha); - unlockedSystems.Add((int)UnlockSystemType.Inventory); - unlockedSystems.Add((int)UnlockSystemType.ItemQuickBar); - unlockedSystems.Add((int)UnlockSystemType.ItemSubmitRecycle); - unlockedSystems.Add((int)UnlockSystemType.ItemUse); - unlockedSystems.Add((int)UnlockSystemType.Mail); - unlockedSystems.Add((int)UnlockSystemType.ValuableDepot); - unlockedSystems.Add((int)UnlockSystemType.Wiki); - unlockedSystems.Add((int)UnlockSystemType.AIBark); - unlockedSystems.Add((int)UnlockSystemType.AdventureExpAndLv); - unlockedSystems.Add((int)UnlockSystemType.CharTeam); - - - unlockedSystems.Add((int)UnlockSystemType.SpaceshipSystem); - unlockedSystems.Add((int)UnlockSystemType.SpaceshipControlCenter); - - unlockedSystems.Add((int)UnlockSystemType.PRTS); - unlockedSystems.Add((int)UnlockSystemType.Dungeon); - unlockedSystems.Add((int)UnlockSystemType.RacingDungeon); - unlockedSystems.Add((int)UnlockSystemType.CheckIn); - unlockedSystems.Add((int)UnlockSystemType.SubmitEther);*/ - foreach(UnlockSystemType type in Enum.GetValues(typeof(UnlockSystemType))) { unlockedSystems.Add((int)type); @@ -483,8 +445,9 @@ namespace Campofinale if (Server.config.logOptions.packets && !Server.csMessageToHide.Contains((CsMsgId)packet.csHead.Msgid)) { - Logger.Print("CmdId: " + (CsMsgId)packet.csHead.Msgid); - Logger.Print(BitConverter.ToString(packet.finishedBody).Replace("-", string.Empty).ToLower()); + Logger.Print("Recieved Packet: " + ((CsMsgId)packet.csHead.Msgid).ToString().Pastel(Color.LightCyan) + $" Id: {packet.csHead.Msgid} with {packet.finishedBody.Length} Bytes"); + if (Server.config.logOptions.packetBodies) + Logger.Print(BitConverter.ToString(packet.finishedBody).Replace("-", string.Empty).ToLower()); } try @@ -645,5 +608,33 @@ namespace Campofinale return ""; } } + + public RoleBaseInfo GetRoleBaseInfo() + { + long curtimestamp = DateTime.UtcNow.ToUnixTimestampMilliseconds(); + try + { + return new RoleBaseInfo() + { + LeaderCharId = teams[teamIndex].leader, + LeaderPosition = position.ToProto(), + LeaderRotation = rotation.ToProto(), + ServerTs = (ulong)curtimestamp, + SceneName = ResourceManager.levelDatas.Find(l => l.idNum == curSceneNumId).mapIdStr + }; + } + catch (Exception e) + { + + return new RoleBaseInfo() + { + LeaderCharId = teams[teamIndex].leader, + LeaderPosition = position.ToProto(), + LeaderRotation = rotation.ToProto(), + ServerTs = (ulong)curtimestamp + }; + } + + } } } diff --git a/Campofinale/Program.cs b/Campofinale/Program.cs index bd0a3aa..0d54c17 100644 --- a/Campofinale/Program.cs +++ b/Campofinale/Program.cs @@ -1,5 +1,4 @@ -// See https://aka.ms/new-console-template for more information -using Campofinale; +using Campofinale; using Newtonsoft.Json; class Program @@ -13,7 +12,7 @@ class Program { Console.Title = "Initializing..."; - bool disableLogs = args.Length > 0 && args[0].ToLower() == "nologs"; + //bool disableLogs = args.Length > 0 && args[0].ToLower() == "nologs"; ConfigFile config = new ConfigFile(); if (File.Exists("server_config.json")) @@ -24,7 +23,7 @@ class Program new Thread(() => { - new Server().Start(disableLogs, config); + new Server().Start(config); }).Start(); AppDomain.CurrentDomain.ProcessExit += (_, _) => { diff --git a/Campofinale/Resource/GameEnums.cs b/Campofinale/Resource/GameEnums.cs index 3296149..f53c5f5 100644 --- a/Campofinale/Resource/GameEnums.cs +++ b/Campofinale/Resource/GameEnums.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Resource +namespace Campofinale.Resource { public enum MissionState : int// TypeDefIndex: 33630 { @@ -14,6 +8,15 @@ namespace Campofinale.Resource Completed = 3, Failed = 4 } + public enum QuestState + { + + None = 0, + Available = 1, + Processing = 2, + Completed = 3, + Failed = 4, + } public enum InteractiveComponentType { TriggerObserver = 0, diff --git a/Campofinale/Resource/LongBitSet.cs b/Campofinale/Resource/LongBitSet.cs index 319e19d..b6308a8 100644 --- a/Campofinale/Resource/LongBitSet.cs +++ b/Campofinale/Resource/LongBitSet.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Resource +namespace Campofinale.Resource { /// /// Utility class for supporting long bit set @@ -38,10 +32,18 @@ namespace Campofinale.Resource max = values.Max(); } InitializeWithBitCount(max); - foreach(var i in values) + try { - SetBit(i, true); + foreach (var i in values) + { + SetBit(i, true); + } } + catch (Exception ex) + { + + } + } public LongBitSet(ulong[] bits) diff --git a/Campofinale/Resource/ResourceLoader.cs b/Campofinale/Resource/ResourceLoader.cs new file mode 100644 index 0000000..b411eff --- /dev/null +++ b/Campofinale/Resource/ResourceLoader.cs @@ -0,0 +1,94 @@ +using Newtonsoft.Json; +using System.Reflection; + +namespace Campofinale.Resource +{ + public class ResourceLoader + { + /// + /// Load table cfg automatically inside ResourceManager fields + /// + public static void LoadTableCfg() + { + var tableCfgTypes = GetAllTableCfgTypes(); + + foreach (var type in tableCfgTypes) + { + var attr = type.GetCustomAttribute(); + string json = ResourceManager.ReadJsonFile(attr.Name); + FieldInfo field = GetResourceField(type); + if (field != null && json.Length > 0) + { + object deserializedData = DeserializeJson(json, field.FieldType, type); + field.SetValue(null, deserializedData); + //Logger.Print($"Loaded {attr.Name} into {field.Name}"); + } + } + } + private static object DeserializeJson(string json, Type fieldType, Type valueType) + { + if (fieldType.IsGenericType) + { + var genericTypeDef = fieldType.GetGenericTypeDefinition(); + + if (genericTypeDef == typeof(Dictionary<,>)) + { + var keyType = fieldType.GetGenericArguments()[0]; + var valType = fieldType.GetGenericArguments()[1]; + return JsonConvert.DeserializeObject(json, typeof(Dictionary<,>).MakeGenericType(keyType, valType)); + } + else if (genericTypeDef == typeof(List<>)) + { + return JsonConvert.DeserializeObject(json, typeof(List<>).MakeGenericType(valueType)); + } + } + + return JsonConvert.DeserializeObject(json, valueType); + } + + public static List GetAllTableCfgTypes() + { + return Assembly.GetExecutingAssembly() + .GetTypes() + .Where(t => t.IsClass && !t.IsAbstract && t.GetCustomAttribute() != null) + .ToList(); + } + public static FieldInfo GetResourceField(Type type) + { + var resourceManagerType = typeof(ResourceManager); + var fields = resourceManagerType.GetFields(BindingFlags.Public | BindingFlags.Static); + + foreach (var field in fields) + { + var fieldType = field.FieldType; + + if (fieldType.IsGenericType) + { + var genericTypeDef = fieldType.GetGenericTypeDefinition(); + + if (genericTypeDef == typeof(Dictionary<,>)) + { + var valueType = fieldType.GetGenericArguments()[1]; + if (valueType == type) + { + return field; + } + } + else if (genericTypeDef == typeof(List<>) && fieldType.GetGenericArguments()[0] == type) + { + return field; + } + } + else + { + if (fieldType == type) + { + return field; + } + } + } + + return null; + } + } +} diff --git a/Campofinale/Resource/ResourceManager.cs b/Campofinale/Resource/ResourceManager.cs index efeb9ca..16adb7a 100644 --- a/Campofinale/Resource/ResourceManager.cs +++ b/Campofinale/Resource/ResourceManager.cs @@ -1,12 +1,5 @@ - -using Campofinale.Resource.Table; +using Campofinale.Resource.Table; using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Campofinale.Resource.ResourceManager.LevelScene; namespace Campofinale.Resource @@ -27,47 +20,57 @@ namespace Campofinale.Resource //TODO Move all tables to separated class public class ResourceManager { + public static Dictionary levelScriptsEvents = new(); // public static Dictionary sceneAreaTable = new(); - public static StrIdNumTable strIdNumTable = new StrIdNumTable(); - public static Dictionary characterTable = new(); - public static Dictionary systemJumpTable = new(); + public static StrIdNumTable strIdNumTable = new StrIdNumTable();// + public static Dictionary characterTable = new(); // + public static Dictionary systemJumpTable = new(); // public static Dictionary settlementBasicDataTable = new(); public static Dictionary blocMissionTable = new(); - public static MissionAreaTable missionAreaTable = new(); + public static MissionAreaTable missionAreaTable = new(); // public static Dictionary dialogTextTable = new(); public static Dictionary gameSystemConfigTable = new(); public static Dictionary wikiGroupTable = new(); public static Dictionary blocUnlockTable = new(); public static Dictionary gameMechanicTable = new(); public static Dictionary weaponBasicTable= new(); - public static Dictionary blocDataTable = new(); + public static Dictionary blocDataTable = new(); // public static Dictionary itemTable = new(); public static Dictionary domainDataTable = new(); public static Dictionary collectionTable = new(); - public static Dictionary gachaCharPoolTable = new(); public static Dictionary charBreakNodeTable = new(); public static Dictionary enemyAttributeTemplateTable = new(); public static Dictionary charLevelUpTable = new(); public static Dictionary expItemDataMap = new(); public static Dictionary charGrowthTable = new(); public static Dictionary weaponUpgradeTemplateTable = new(); + //Gacha + public static Dictionary gachaCharPoolTable = new(); public static Dictionary gachaCharPoolContentTable = new(); public static Dictionary gachaCharPoolTypeTable = new(); + + public static Dictionary gachaWeaponPoolTable = new(); + // public static Dictionary enemyTable = new(); public static Dictionary equipTable = new(); public static Dictionary equipSuitTable = new(); public static Dictionary spaceShipCharBehaviourTable = new(); public static Dictionary spaceshipRoomInsTable = new(); public static Dictionary dungeonTable = new(); - public static Dictionary levelGradeTable = new(); + public static Dictionary levelGradeTable = new(); // public static Dictionary rewardTable = new(); public static Dictionary adventureTaskTable = new(); - public static StrIdNumTable dialogIdTable = new(); + public static DialogIdTable dialogIdTable = new();// public static Dictionary levelShortIdTable = new(); public static Dictionary factoryBuildingTable = new(); public static Dictionary facSTTNodeTable = new(); public static Dictionary facSTTLayerTable = new(); - public static InteractiveTable interactiveTable = new(); + public static Dictionary itemTypeTable = new(); // + public static Dictionary snsChatTable = new();// + public static Dictionary giftItemTable = new(); + public static List missionDataTable = new(); + + public static InteractiveTable interactiveTable = new(); // public static List levelDatas = new(); public static List interactiveData = new(); @@ -77,6 +80,11 @@ namespace Campofinale.Resource return levelDatas.Find(a => a.id == name).idNum; } public static bool missingResources = false; + /// + /// Utility method for read a json file + /// + /// The file path + /// Return the file content if the file exist, else it return an empty string public static string ReadJsonFile(string path) { try @@ -103,7 +111,7 @@ namespace Campofinale.Resource dialogTextTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/DialogTextTable.json")); gameSystemConfigTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/GameSystemConfigTable.json")); wikiGroupTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/WikiGroupTable.json")); - dialogIdTable = JsonConvert.DeserializeObject(ReadJsonFile("Json/GameplayConfig/DialogIdTable.json")); + dialogIdTable = JsonConvert.DeserializeObject(ReadJsonFile("Json/GameplayConfig/DialogIdTable.json")); blocUnlockTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/BlocUnlockTable.json")); gameMechanicTable= JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/GameMechanicTable.json")); weaponBasicTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/WeaponBasicTable.json")); @@ -134,10 +142,12 @@ namespace Campofinale.Resource factoryBuildingTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/FactoryBuildingTable.json")); facSTTNodeTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/FacSTTNodeTable.json")); facSTTLayerTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/FacSTTLayerTable.json")); + itemTypeTable = JsonConvert.DeserializeObject>(ReadJsonFile("TableCfg/ItemTypeTable.json")); interactiveTable = JsonConvert.DeserializeObject(ReadJsonFile("Json/Interactive/InteractiveTable.json")); LoadInteractiveData(); - LoadLevelDatas(); - + LoadLevelDatas(); + ResourceLoader.LoadTableCfg(); + if (missingResources) { Logger.PrintWarn("Missing some resources. The gameserver will probably crash."); @@ -406,15 +416,7 @@ namespace Campofinale.Resource { public List list; } - public class InteractiveTable - { - public Dictionary interactiveDataDict = new(); - - public class InteractiveTemplate - { - public string templateId; - } - } + public class WikiGroup { public string groupId; @@ -688,14 +690,15 @@ namespace Campofinale.Resource public float ToFloat() { - int intValueFromBit64 = (int)valueBit64; // Converti long in int - float floatValueFromBit64 = BitConverter.ToSingle(BitConverter.GetBytes(intValueFromBit64), 0); + int intValueFromBit64 = (int)valueBit64; + float floatValueFromBit64 = (float)BitConverter.Int64BitsToDouble(valueBit64); + //float floatValueFromBit64 = BitConverter.ToSingle(BitConverter.GetBytes(intValueFromBit64), 0); return floatValueFromBit64; } public int ToInt() { - int intValueFromBit64 = (int)valueBit64; // Converti long in int - + int intValueFromBit64 = (int)valueBit64; + return intValueFromBit64; } } @@ -783,19 +786,6 @@ namespace Campofinale.Resource public string settlementId; public string domainId; } - public class StrIdNumTable - { - public StrIdDic skill_group_id; - public StrIdDic item_id; - public Dictionary dialogStrToNum; - public StrIdDic chapter_map_id; - public StrIdDic char_voice_id; - public StrIdDic char_doc_id; - public StrIdDic area_id; - public StrIdDic map_mark_temp_id; - public StrIdDic wiki_id; - public StrIdDic client_game_var_string_id; - } public class GachaCharPoolTable { public string id; @@ -823,10 +813,7 @@ namespace Campofinale.Resource { } - public class SystemJumpTable - { - public int bindSystem; - } + public class StrIdDic { public Dictionary dic; @@ -843,6 +830,7 @@ namespace Campofinale.Resource public string enemyId; public string templateId; } + public class ItemTable { public ItemValuableDepotType valuableTabType; @@ -850,6 +838,12 @@ namespace Campofinale.Resource public int maxStackCount; public bool backpackCanDiscard; public string modelKey; + public int type; + + public ItemStorageSpace GetStorage() + { + return ResourceManager.itemTypeTable[type].storageSpace; + } } public class WeaponBasicTable { @@ -908,15 +902,7 @@ namespace Campofinale.Resource public string id; public int count; } - public class CharacterTable - { - public List attributes; - public string charId; - public int weaponType; - public string engName; - public int rarity; - - } + public class Attributes { public int breakStage; diff --git a/Campofinale/Resource/Table/BlocDataTable.cs b/Campofinale/Resource/Table/BlocDataTable.cs index d8c910f..dc95217 100644 --- a/Campofinale/Resource/Table/BlocDataTable.cs +++ b/Campofinale/Resource/Table/BlocDataTable.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Resource.Table +namespace Campofinale.Resource.Table { - public class BlocDataTable + [TableCfgType("TableCfg/BlocDataTable.json", LoadPriority.LOW)] + public class BlocDataTable : TableCfgResource { public string blocId; } diff --git a/Campofinale/Resource/Table/CharacterTable.cs b/Campofinale/Resource/Table/CharacterTable.cs new file mode 100644 index 0000000..0544207 --- /dev/null +++ b/Campofinale/Resource/Table/CharacterTable.cs @@ -0,0 +1,15 @@ +using static Campofinale.Resource.ResourceManager; + +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/CharacterTable.json", LoadPriority.LOW)] + public class CharacterTable : TableCfgResource + { + public List attributes; + public string charId; + public int weaponType; + public string engName; + public int rarity; + + } +} diff --git a/Campofinale/Resource/Table/DialogIdTable.cs b/Campofinale/Resource/Table/DialogIdTable.cs new file mode 100644 index 0000000..50ab8a2 --- /dev/null +++ b/Campofinale/Resource/Table/DialogIdTable.cs @@ -0,0 +1,7 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("Json/GameplayConfig/DialogIdTable.json", LoadPriority.LOW)] + public class DialogIdTable : StrIdNumTable + { + } +} diff --git a/Campofinale/Resource/Table/GachaWeaponPoolTable.cs b/Campofinale/Resource/Table/GachaWeaponPoolTable.cs new file mode 100644 index 0000000..fb1be48 --- /dev/null +++ b/Campofinale/Resource/Table/GachaWeaponPoolTable.cs @@ -0,0 +1,11 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/GachaWeaponPoolTable.json", LoadPriority.LOW)] + public class GachaWeaponPoolTable + { + public string id; + public int type; + public List upWeaponIds; + public List closeTimes; + } +} diff --git a/Campofinale/Resource/Table/GiftItemTable.cs b/Campofinale/Resource/Table/GiftItemTable.cs new file mode 100644 index 0000000..57c7029 --- /dev/null +++ b/Campofinale/Resource/Table/GiftItemTable.cs @@ -0,0 +1,9 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/GiftItemTable.json", LoadPriority.LOW)] + public class GiftItemTable + { + public int favorablePoint; + public string id; + } +} diff --git a/Campofinale/Resource/Table/InteractiveTable.cs b/Campofinale/Resource/Table/InteractiveTable.cs new file mode 100644 index 0000000..e809199 --- /dev/null +++ b/Campofinale/Resource/Table/InteractiveTable.cs @@ -0,0 +1,13 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("Json/Interactive/InteractiveTable.json", LoadPriority.LOW)] + public class InteractiveTable : TableCfgResource + { + public Dictionary interactiveDataDict = new(); + + public class InteractiveTemplate + { + public string templateId; + } + } +} diff --git a/Campofinale/Resource/Table/ItemTypeTable.cs b/Campofinale/Resource/Table/ItemTypeTable.cs new file mode 100644 index 0000000..27b0921 --- /dev/null +++ b/Campofinale/Resource/Table/ItemTypeTable.cs @@ -0,0 +1,9 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/ItemTypeTable.json", LoadPriority.LOW)] + public class ItemTypeTable + { + public int itemType; + public ItemStorageSpace storageSpace; + } +} diff --git a/Campofinale/Resource/Table/LevelGradeTable.cs b/Campofinale/Resource/Table/LevelGradeTable.cs index fe78c01..7d4c8b7 100644 --- a/Campofinale/Resource/Table/LevelGradeTable.cs +++ b/Campofinale/Resource/Table/LevelGradeTable.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Resource.Table +namespace Campofinale.Resource.Table { - public class LevelGradeTable + [TableCfgType("TableCfg/LevelGradeTable.json", LoadPriority.LOW)] + public class LevelGradeTable : TableCfgResource { public string name; public List grades; diff --git a/Campofinale/Resource/Table/LevelScriptEvent.cs b/Campofinale/Resource/Table/LevelScriptEvent.cs new file mode 100644 index 0000000..ee6fbdc --- /dev/null +++ b/Campofinale/Resource/Table/LevelScriptEvent.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Campofinale.Resource.Table +{ + [TableCfgType("Json/LevelScriptEvents.json", LoadPriority.LOW)] + public class LevelScriptEvent : TableCfgResource + { + public string eventName; + public string comment; + public List actions; + } + public class ScriptAction + { + public ScriptActionType action; + public string[] valueStr; + public ulong[] valueUlong; + } + public enum ScriptActionType + { + None = 0, + CompleteQuest = 1, + ProcessQuest = 2, + SpawnEnemy = 3 + + } +} diff --git a/Campofinale/Resource/Table/MissionAreaTable.cs b/Campofinale/Resource/Table/MissionAreaTable.cs index 54dc6a9..5c6719e 100644 --- a/Campofinale/Resource/Table/MissionAreaTable.cs +++ b/Campofinale/Resource/Table/MissionAreaTable.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Campofinale.Resource.Table +namespace Campofinale.Resource.Table { - public class MissionAreaTable + [TableCfgType("Json/GameplayConfig/MissionAreaTable.json", LoadPriority.LOW)] + public class MissionAreaTable : TableCfgResource { public Dictionary> m_areas; } diff --git a/Campofinale/Resource/Table/MissionDataTable.cs b/Campofinale/Resource/Table/MissionDataTable.cs new file mode 100644 index 0000000..b85485d --- /dev/null +++ b/Campofinale/Resource/Table/MissionDataTable.cs @@ -0,0 +1,49 @@ +namespace Campofinale.Resource.Table +{ + //Beyond.Gameplay.MissionRuntimeAsset + [TableCfgType("TableCfg/MissionDataTable.json", LoadPriority.LOW)] + public class MissionDataTable + { + public string missionId; + public string rewardId; + //public MissionType missionType; + public string charId; + public string levelId; + public Dictionary questDic; + public int onMissionAcceptId; + public int onMissionCompletedId; + public int onMissionFailedId; + + public class QuestInfo + { + public string questId; + public bool optional; + public bool autoSucceed; + public bool autoRestartWhenFailed; + public int objectiveConditionNum; + public string rewardId; + public List objectiveList; + + public class QuestObjective + { + public ObjectiveCond condition; + + public class ObjectiveCond + { + public string uniqueId; + } + } + } + public enum MissionType + { + Main = 0, + Char = 1, + Factory = 2, + Bloc = 3, + Hide = 4, + Misc = 5, + Dungeon = 6, + World = 7, + } + } +} diff --git a/Campofinale/Resource/Table/SNSChatTable.cs b/Campofinale/Resource/Table/SNSChatTable.cs new file mode 100644 index 0000000..e5716ca --- /dev/null +++ b/Campofinale/Resource/Table/SNSChatTable.cs @@ -0,0 +1,10 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/SNSChatTable.json", LoadPriority.LOW)] + public class SNSChatTable + { + public string chatId; + public int chatType; + public int tagType; + } +} diff --git a/Campofinale/Resource/Table/StrIdNumTable.cs b/Campofinale/Resource/Table/StrIdNumTable.cs new file mode 100644 index 0000000..1fcb1d9 --- /dev/null +++ b/Campofinale/Resource/Table/StrIdNumTable.cs @@ -0,0 +1,19 @@ +using static Campofinale.Resource.ResourceManager; + +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/StrIdNumTable.json", LoadPriority.LOW)] + public class StrIdNumTable : TableCfgResource + { + public StrIdDic skill_group_id; + public StrIdDic item_id; + public Dictionary dialogStrToNum; + public StrIdDic chapter_map_id; + public StrIdDic char_voice_id; + public StrIdDic char_doc_id; + public StrIdDic area_id; + public StrIdDic map_mark_temp_id; + public StrIdDic wiki_id; + public StrIdDic client_game_var_string_id; + } +} diff --git a/Campofinale/Resource/Table/SystemJumpTable.cs b/Campofinale/Resource/Table/SystemJumpTable.cs new file mode 100644 index 0000000..48101c5 --- /dev/null +++ b/Campofinale/Resource/Table/SystemJumpTable.cs @@ -0,0 +1,8 @@ +namespace Campofinale.Resource.Table +{ + [TableCfgType("TableCfg/SystemJumpTable.json", LoadPriority.LOW)] + public class SystemJumpTable + { + public int bindSystem; + } +} diff --git a/Campofinale/Resource/TableCfgResource.cs b/Campofinale/Resource/TableCfgResource.cs new file mode 100644 index 0000000..e640d89 --- /dev/null +++ b/Campofinale/Resource/TableCfgResource.cs @@ -0,0 +1,38 @@ +namespace Campofinale.Resource +{ + public abstract class TableCfgResource + { + /// + /// Not implemented yet + /// + public void OnLoad() + { + + } + } + [AttributeUsage(AttributeTargets.Class, Inherited = false)] + public class TableCfgTypeAttribute : Attribute + { + /// + /// Path of the Resource + /// + public string Name { get; } + /// + /// Priority of load (still not implemented) + /// + public LoadPriority Priority { get; } + + public TableCfgTypeAttribute(string name, LoadPriority priority) + { + Name = name; + Priority = priority; + } + } + + public enum LoadPriority + { + HIGH, + MEDIUM, + LOW + } +} diff --git a/Campofinale/Server.cs b/Campofinale/Server.cs index 0c61e82..502d443 100644 --- a/Campofinale/Server.cs +++ b/Campofinale/Server.cs @@ -1,29 +1,15 @@ - -using BeyondTools.VFS.Crypto; -using Campofinale.Commands; +using Campofinale.Commands; using Campofinale.Database; using Campofinale.Game; using Campofinale.Http; -using Campofinale.Network; using Campofinale.Protocol; using Campofinale.Resource; -using Google.Protobuf; -using Newtonsoft.Json; using Pastel; -using SQLite; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using static Campofinale.Http.Dispatch; - +using System.ServiceProcess; namespace Campofinale { @@ -62,9 +48,11 @@ namespace Campofinale public delegate void HandlerDelegate(Player sender, string command, string[] args, Player target); } public static List clients = new List(); - public static string ServerVersion = "1.1.2-dev"; + public static string ServerVersion = "1.1.5"; public static bool Initialized = false; public static bool showLogs = true; + public static bool showWarningLogs = true; + public static bool showBodyLogs = false; public static Dispatch dispatch; public static ResourceManager resourceManager; public static ConfigFile config; @@ -74,7 +62,7 @@ namespace Campofinale { return resourceManager; } - public void Start(bool hideLogs = false, ConfigFile config = null) + public void Start(ConfigFile config) { { Assembly assembly = Assembly.GetExecutingAssembly(); @@ -91,10 +79,15 @@ namespace Campofinale } Logger.Initialize(); - Logger.Print($"Starting server version {ServerVersion} with supported client version {GameConstants.GAME_VERSION}"); - showLogs = !hideLogs; - Logger.Print($"Logs are {(showLogs ? "enabled" : "disabled")}"); Server.config = config; + showLogs = config.logOptions.packets; + showWarningLogs = config.logOptions.packetWarnings; + showBodyLogs = config.logOptions.packetBodies; + Logger.Print($"Starting server version {ServerVersion} with supported client version: WINDOWS-{GameConstants.GAME_VERSION} and MOBILE-{GameConstants.GAME_VERSION_ANDROID}"); + Logger.Print($"Logs are {(showLogs ? "enabled" : "disabled")}"); + Logger.Print($"Warning logs are {(showWarningLogs ? "enabled" : "disabled")}"); + Logger.Print($"Packet body logs are {(showBodyLogs ? "enabled" : "disabled")}"); + StartDBService(); DatabaseManager.Init(); ResourceManager.Init(); new Thread(new ThreadStart(DispatchServer)).Start(); @@ -116,11 +109,20 @@ namespace Campofinale if (clientSocket.Connected) { - Player client = new Player(clientSocket); - clients.Add(client); - client.receivorThread.Start(); + Logger.Print("Connected new client: " + clients.Count()+1); + try + { + Player client = new Player(clientSocket); + clients.Add(client); + client.receivorThread.Start(); + } + catch (Exception e) + { + Logger.PrintError($" {e.Message}"); + } + - Logger.Print("Connected new client: " + clients.Count()); + } @@ -192,5 +194,27 @@ namespace Campofinale player.Kick(CODE.ErrServerClosed); } } + private static void StartDBService() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + try + { + string mongodbService = "MongoDB"; + using (ServiceController service = new ServiceController(mongodbService)) + { + if (service.Status != ServiceControllerStatus.Running) + { + Logger.Print($"Starting {mongodbService} service..."); + service.Start(); + service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30)); + Logger.Print($"Started {mongodbService} service"); + } + } + } + catch (Exception e) + { + Logger.PrintError($"Failed to Start MongoDB service: {e}"); + } + } } } diff --git a/Campofinale/app.manifest b/Campofinale/app.manifest new file mode 100644 index 0000000..04608b9 --- /dev/null +++ b/Campofinale/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 5daec0c..926f71f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Campofinale [EN](README.md) | [IT](docs/README_it-IT.md) | [RU](docs/README_ru-RU.md) | [CN](docs/README_zh-CN.md) | [NL](docs/README_nl-NL.md) -![Logo]() - Campofinale is a experimental server implementation for a certain factory building game. ## Current Features @@ -14,6 +12,93 @@ Campofinale is a experimental server implementation for a certain factory buildi * Save data with MongoDB * Combat system +## TODO +* Android Support +* Mission System +* Working buffs + +## Installation Steps (Windows) + +1. Install: + * [.NET SDK](https://dotnet.microsoft.com/en-us/download) (8.0.12 is recommended) + * [MongoDB](https://www.mongodb.com/try/download/community) + * [Fiddler Classic](https://www.telerik.com/fiddler/fiddler-classic) OR [mitmproxy](https://mitmproxy.org/) + + 1. When installing *Fiddler Classic*, make sure to **enable** "Decrypt HTTPS traffic" and **install** the certificate! + 1. You have to enable two features via Tools (top left in menubar) -> Options -> HTTPS -> Check "Capture HTTPS CONNECTs" and "Decrypt HTTPS traffic". You can also re-install the certificate via Actions (right next to "Capture HTTPS CONNECTs") -> Trust Root Certificate and press "Yes" +2. Download the [precompiled build](https://github.com/Campofinale/Campofinale/releases/latest) or build it by yourself +3. Put the `Json`, `TableCfg` and `DynamicAssets` folders inside the `Campofinale.exe` folder (you can download a copy [here](https://github.com/PotRooms/EndFieldData/tree/main)) +4. Run the server (`Campofinale.exe`) +5. Overwrite the `C:\Users\\Documents\Fiddler2\Scripts\CustomRules.js` script (or backup the default one and create a new file with the same name) with the following script: + * You can also run *Fiddler Classic*, go to `Rules -> Customize Rules` (CTRL + R) and save it, or by selecting the *FiddlerScript* tab + + ```javascript + import System; + import System.Windows.Forms; + import Fiddler; + import System.Text.RegularExpressions; + + class Handlers + { + static function OnBeforeRequest(oS: Session) { + if( + oS.fullUrl.Contains("discord") || + oS.fullUrl.Contains("steam") || + oS.fullUrl.Contains("git") || + oS.fullUrl.Contains("yandex") + //you can add any addresses if some sites don't work + ) { + oS.Ignore(); + } + + if (!oS.oRequest.headers.HTTPMethod.Equals("CONNECT")) { + if(oS.fullUrl.Contains("gryphline.com") || oS.fullUrl.Contains("hg-cdn.com")) { + oS.fullUrl = oS.fullUrl.Replace("https://", "http://"); + oS.host = "localhost"; // place another ip if you need + oS.port = 5000; //and port + } + } + } + }; + ``` + By Xannix + Or you can use the mitmproxy command: + + ```shell + mitmproxy -s ak.py + ``` + + ak.py: + + ```py + import mitmproxy + from mitmproxy import ctx, http + class EndFieldModifier: + def requestheaders(self,flow: mitmproxy.http.HTTPFlow): + if "gryphline.com" in flow.request.host or "hg-cdn.com" in flow.request.host: + if flow.request.method=="CONNECT": + return + + flow.request.scheme="http" + flow.request.cookies.update({ + "OriginalHost":flow.request.host, + "OriginalUrl":flow.request.url + }) + flow.request.host="localhost" + flow.request.port=5000 + ctx.log.info("URL:"+flow.request.url) + + + + addons=[ + EndFieldModifier() + ] + ``` + +6. Run *Fiddler Classic* - it should start with the new *Custom Rules script* (you can check it in the *FiddlerScript* tab) +7. Run the Game Client and start to play! (Note: Only OS client is supported for now) +8. You must create an account using `account create (username)` in the server console, then login in the game with an email like `(username)@randomemailformathere.whatyouwant`. There is no password so you can input a random password for its field. + ## Additional Information You can find the description of all server commands [here](docs/CommandList/commands_en-US.md).
@@ -26,8 +111,8 @@ If you want to open the in-game console, go to `Settings -> Platform & Account - ## Discord for support -If you want to discuss, ask for support or help with this project, join our [Discord Server](https://discord.gg/gPvqhfdMU6)! +If you want to discuss, ask for support or help with this project, join our [Discord Server](https://discord.gg/YZGYtAxeZk)! ## Note -This project is developed independently, and all rights to the original game assets and intellectual property belong to their respective owners. \ No newline at end of file +This project is developed independently, and all rights to the original game assets and intellectual property belong to their respective owners. diff --git a/docs/CommandList/commands_zh-CN.md b/docs/CommandList/commands_zh-CN.md index fdb8b19..fb53ad5 100644 --- a/docs/CommandList/commands_zh-CN.md +++ b/docs/CommandList/commands_zh-CN.md @@ -24,5 +24,5 @@ | idlist | 显示所有角色(chars)、敌人(enemies)和场景(scenes)的id | `` | 否 | idlist `` | idlist chars | --- -> [!WARNING]警告 +> [!WARNING] > `level` 指令: 如果你没有指定具体的`id`字段, 那么等级变化将会被应用在**所有**武器和干员身上 \ No newline at end of file diff --git a/docs/EnemiesTable.md b/docs/EnemiesTable.md index 5301683..3a4f1f3 100644 --- a/docs/EnemiesTable.md +++ b/docs/EnemiesTable.md @@ -25,7 +25,7 @@ | eny_0059_erhound | Blighted Tuskbeast| 侵蚀牙兽 | | eny_0060_lbmad | Blighted Klaw| 侵蚀爪牙 | | eny_0061_palecore | Marble Agellomoirai| 白垩界卫一阶段 | -| eny_0062_paletent | Marble Appendage| 白垩界卫一阶段触手 | +| eny_0062_paletent | Marble Appendage| 白垩附肢 | | eny_0063_agmelee2 | Ram α | 大角天使α | | eny_0064_agrange2 | Sting α | 针刺天使α | | eny_0065_lbmob2 | Elite Raider | 精锐劫掠者 | diff --git a/docs/README_ru-RU.md b/docs/README_ru-RU.md new file mode 100644 index 0000000..71ecc5e --- /dev/null +++ b/docs/README_ru-RU.md @@ -0,0 +1,32 @@ +# Campofinale +[EN](/README.md) | [IT](./README_it-IT.md) | [RU](./README_ru-RU.md) | [CN](./README_zh-CN.md) | [NL](./README_nl-NL.md) + +Campofinale - экспериментальная реализация сервера для кое-какой игры по постройке фабрик. + +> **Внимание: наш старый Discord сервер был подвергнут крашу (все участники были выгнаны), поэтому настоятельно просим вас присоединиться заново по этой ссылке: https://discord.gg/eGGXymVd4K** + +## Текущие возможности + +* Переключение персонажей; +* Переключение отрядов; +* Переключение сцен; +* Сохранение данных с помощью MongoDB; +* Система боёвки; + +## Дополнительно + +Описание всех команд сервера вы можете найти [здесь](./CommandList/commands_ru-RU.md).
+Список всех сцен находится [тут](./LevelsTable.md).
+Список всех врагов - [тут](./EnemiesTable.md).
+Список всех персонажей - [тут](./CharactersTable.md).
+Список всех предметов - [тут](./ItemsTable.md).
+ +Вы можете открыть внутриигровую консоль, перейдя во вкладку `Settings -> Platform & Account -> Account Settings (кнопка Access Account)`. Чтобы просмотреть доступные команды, пропишите `help`. + +## Discord поддержка + +Если вы хотите обсудить проект или помочь в его разработке, присоединяйтесь к нашему [Discord серверу](https://discord.gg/eGGXymVd4K)! + +## Примечание + +Этот проект разрабатывается независимо от чего-либо, все права на ассеты из оригинальной игры и вся интеллектуальная собственность принадлежит их правообладателям. diff --git a/docs/README_zh-CN.md b/docs/README_zh-CN.md new file mode 100644 index 0000000..6cda30c --- /dev/null +++ b/docs/README_zh-CN.md @@ -0,0 +1,43 @@ +# Campofinale +[EN](../README.md) | [IT](./README_it-IT.md) | [RU](./README_ru-RU.md) | [CN](./README_zh-CN.md) | [NL](./README_nl-NL.md) + +![Logo]() + +Campofinale 是为某个工厂建造游戏提供的实验性本地服务器实现 + +> **我们的旧 Discord 服务器遭到了袭击(攻击者踢走了所有成员),请使用以下新邀请链接重新加入我们的社区:[https://discord.gg/eGGXymVd4K](https://discord.gg/eGGXymVd4K)** + +## 当前功能 + +* 登录 +* 切换角色 +* 切换配队 +* 场景切换 +* 通过MongoDB保存存档 +* 战斗系统 + +## 补充信息 + +您可以在[这里](./CommandList/commands_zh-CN.md)找到所有服务端指令的详细说明。 + +所有场景的列表[在此](./LevelsTable.md)。 + +所有敌人的列表[在此](./EnemiesTable.md)。 + +所有干员的列表[在此](./CharactersTable.md)。 + +所有物品的列表[在此](./ItemsTable_zh-CN.md)。 + +如果你想使用游戏内控制台,请前往 `设置 → 平台与账号 → 账号设置("点击前往")`。要查看可用命令,请输入 `help`。 + +## 教程 + +新的教程将会在几天后添加到Wiki上,目前您可以在Discord服务器上寻求帮助 + +## 在Discord上寻求帮助 + +如果你想讨论、寻求帮助或者协助我们完善和改进此项目,请加入我们的[Discord服务器](https://discord.gg/eGGXymVd4K)! + +## 附录 + +本项目为独立开发,所有原始游戏资产和知识产权均归其各自所有者所有