|
|
المشاركات 2,362 |
+التقييم 0.85 |
تاريخ التسجيل Apr 2019 |
الاقامة Egypt |
نظام التشغيل windows 7 |
رقم العضوية 1 |


// زرار "+" جنب سى بى النقابة: اللاعب يحوّل سى بى من رصيده لصندوق سى بى النقابة (1 بـ 1، بحد أقصى في الداتا).
using System;
using Qahr.Mobile.Game.MsgServer;
using Qahr.Mobile.Phone;
namespace Qahr.Mobile.GuildFund
{
/// <summary>
/// QahrMobile: the guild fund "+" button (CFDlgFactionEMoneyTrans::OnSure -> CFactionRecruitMgr::FactionEMoneyTransReq =
/// CMsgSyndicate mobile 63, the CPs at +8). Data\mobile_layouts\guild.txt maps it in as 1063. The phone checks
/// 0 < amount <= maxEMoneyTrans (2000) and amount <= CRole::GetEmoney (normal CPs) before it sends; the server checks
/// again. Order: check -> take the CPs once -> add to the guild CP fund (2267 "CPs", the hall's CP line) and the
/// member's CP donation -> log, under lock(client) and the guild lock. Then the reply 63 (CMsgSyndicate::Process case 63:
/// tip STR_FACTION_DONATE_EMONEY_SUCCESS, then the client asks 12 for the guild info), the 2267 info, and the guild file
/// is saved at once. Numbers: Data\GuildFund\cp_transfer.txt. Hook: GuildJoinNet.TryHandle.
/// </summary>
public static class GuildCpTransfer
{
/// <summary>Mobile 63 as the layout maps it in.</summary>
public const uint ActIn = 1063;
/// <summary>Server 63 out = mobile 63 (no out mapping).</summary>
public const uint ActReply = 63;
sealed class Config
{
public uint Max = 2000, Rate = 1;
public static Config Parse(string[] lines)
{
var cfg = new Config();
foreach (var line in DataFile.Clean(lines))
{
var w = DataFile.Words(line);
uint v;
if (w.Length < 2 || !uint.TryParse(w[1], out v) || v == 0)
{
MyConsole.WriteLine("[GuildFund] GuildFund\\cp_transfer.txt: bad line skipped: " + line, ConsoleColor.Red);
continue;
}
if (w[0] == "max") cfg.Max = v;
else if (w[0] == "rate") cfg.Rate = v;
else MyConsole.WriteLine("[GuildFund] GuildFund\\cp_transfer.txt: unknown key skipped: " + line, ConsoleColor.Red);
}
return cfg;
}
}
static readonly DataFile<Config> File = new DataFile<Config>("GuildFund\\cp_transfer.txt", "GuildFund", Config.Parse);
/// <summary>true = handled here (even when refused).</summary>
public static bool TryHandle(Client.GameClient c, ServerSockets.Packet stream, ushort packetId)
{
if (packetId != Game.GamePackets.MsgSyndicate || stream.Size < 12) return false;
stream.Seek(4);
uint action = stream.ReadUInt32();
uint amount = stream.ReadUInt32();
stream.Seek(4);
if (action != ActIn) return false;
if (c == null || c.Player == null || !MobileClient.Is(c)) return true;
try { Transfer(c, amount); }
catch (Exception e) { MyConsole.WriteLine("[GuildFund] " + c.Player.Name + " CP transfer of " + amount + ": " + e.Message, ConsoleColor.Red); }
return true;
}
static void Transfer(Client.GameClient c, uint amount)
{
Config cfg = File.Value;
Role.Instance.Guild guild;
ulong added;
lock (c)
{
guild = c.Player.MyGuild;
string refused = Check(c, guild, amount, cfg);
if (refused != null)
{
PlayerMsg.Tell(c, refused);
return;
}
added = (ulong)amount * cfg.Rate;
lock (guild)
{
if (added > uint.MaxValue - guild.Info.ConquerPointFund)
{
PlayerMsg.Tell(c, "The guild CP fund is full.");
return;
}
uint before = c.Player.ConquerPoints;
c.Player.ConquerPoints = before - amount;// the setter logs the CPs change and updates the phone
guild.Info.ConquerPointFund += (uint)added;
var me = c.Player.MyGuildMember;
me.CpsDonate = (uint)Math.Min(uint.MaxValue, (ulong)me.CpsDonate + amount);
guild.AddMessage("STR_SYNDICATE_EVENT_DONATE_EMONEY@@" + c.Player.Name + "@@" + amount + "@@");
Database.ServerDatabase.LoginQueue.Enqueue("[GUILD-CP] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " | UID=" + c.Player.UID
+ " | Name=" + c.Player.Name + " | Guild=" + guild.Info.GuildID + " | CPs=" + before + "->" + c.Player.ConquerPoints
+ " | Fund+" + added + "=" + guild.Info.ConquerPointFund);
MyConsole.WriteLine("[GuildFund] " + c.Player.Name + " moved " + amount + " CPs to the CP fund of guild " + guild.Info.GuildID
+ " (fund now " + guild.Info.ConquerPointFund + ")", ConsoleColor.White);
}
}
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
c.Send(stream.GuildRequestCreate((MsgGuildProces.GuildAction)ActReply, amount, new int[4]));
}
guild.SendThat(c.Player);
Database.GuildTable.SaveOne(guild.Info.GuildID, guild);
}
/// <summary>null = allowed, else the line for the player (nothing taken).</summary>
static string Check(Client.GameClient c, Role.Instance.Guild guild, uint amount, Config cfg)
{
if (guild == null || guild.Info == null || c.Player.MyGuildMember == null) return "You are not in a guild.";
if (!c.Player.OnMyOwnServer) return "You cannot do this on another server.";
if (c.InTrade) return "You cannot do this while trading.";
if (amount == 0) return "Enter the CPs to convert.";
if (amount > cfg.Max) return "You can only convert up to " + cfg.Max.ToString("N0") + " CPs at a time.";
if (c.Player.ConquerPoints < amount) return "Failed to convert due to insufficient CPs.";
return null;
}
}
}
using Qahr.Mobile.Database.DBActions;
using Qahr.Mobile.Role.Instance;
namespace Qahr.Mobile.Database
{
public partial class GuildTable
{
static readonly object SaveSync = new object();
/// <summary>QahrMobile: writes one guild file (Guilds\<id>.txt) and its DB copy. Used by the periodic Save and
/// right after an economy change of one guild (Mobile\GuildFund). The lock keeps two writers off the same file
/// (Write.Execute goes through one ".tmp" name per file).</summary>
internal static void SaveOne(uint key, Guild guild)
{
if (guild == null || !guild.CanSave)
return;
lock (SaveSync)
{
using (Write write = new Write("Guilds\\" + key.ToString() + ".txt"))
{
write.Add(guild.ToString()).Add(GuildTable.ToStringAlly(guild)).Add(GuildTable.ToStringEnemy(guild)).Add(guild.CTF_Exploits.ToString()).Add(guild.CTF_Next_ConquerPoints.ToString()).Add(guild.CTF_Next_Money.ToString()).Add(guild.CTF_Rank.ToString()).Add(guild.ClaimCtfReward.ToString()).Add(GuildTable.ToStringMessages(guild)).Add(GuildTable.ToStringConstruct(guild));
write.Execute(Mode.Open);
global::Qahr.Mobile.Database.Storage.SocialStorage.OnGuildSaved(key);
}
}
}
}
}
internal static void Save()
{
foreach (KeyValuePair<uint, Guild> keyValuePair in Guild.GuildPoll)
SaveOne(keyValuePair.Key, keyValuePair.Value);
}
if (global::Qahr.Mobile.GuildBoss.GuildBossNet.TryHandle(c, stream, packetId)) return true;
if (global::Qahr.Mobile.GuildFund.GuildCpTransfer.TryHandle(c, stream, packetId)) return true;
# QahrMobile: guild fund "+" (CFDlgFactionEMoneyTrans, CMsgSyndicate mobile 63), read by Mobile\GuildFund\GuildCpTransfer.cs.
# Reloaded when the file changes. The client text (STR_BANGPAI_BPTSZH_TISHI): "1 Personal CP = 1 Guild CP. The conversion
# is irreversible ... You may convert up to 2,000 CPs per time." The phone checks the same cap itself (luacfg\faction.dat
# maxEMoneyTrans = 2000) and pays with normal CPs (CRole::GetEmoney), not bound CPs.
# key value
max 2000 # CPs per transfer (the client refuses more with STR_FACTION_TRAN_EMONEY_MAX)
rate 1 # guild CPs added per personal CP
# QahrMobile packet layouts: Guilds (syndicates). The format is described in Networking\Mobile\MobileLayouts.Loader.cs.
# CMsgSyndicateAttributeInfo 10172 (103 bytes): guild id 4, contribution 8, silver fund u64 12, CP fund 20,
# members 24, my rank 28, leader name 32 (32), recruit level 64 / members 68 / classes 72, recruit type 76,
# level u8 80, title u16 81, join date 83, badge 87, impeach 91, impeach time u64 95 (CMsgSyndicateAttributeInfo::Process).
# Server (MsgGuildInformation, 97 bytes): id 4, silver u64 8, CPs 16, members 20, rank 24, leader 28, level u16 60,
# creation date 63, leader id 67, material u64 71, recruit off u8 79, battle power 80, on u8 84, prestige u64 85.
[2267 MsgSyndicateAttributeInfo struct 97 103]
4 4 u32
8 12 u64
16 20 u32
20 24 u32
24 28 u32
28 32 str:32
60 80 u8
63 83 u32
# CMsgSyndicate 10167 (44 bytes + strings): action u16 4, id 8, id/value 12, args 16 20 24 28, string list 43
# (CMsgSyndicate::Create*: "Create(action, id)" writes 8, "Create(action, text, id)" writes 12; Process reads 12/16).
# Server (MsgGuildProces.GuildRequest / GuildRequestCreate, 29 bytes + strings): action u32 4, uid 8, args 12 16 20 24,
# string list 28 (the same u8 count + u16 length format). The actions are the same numbers (1 accept, 2 invite,
# 3 quit, 6 name, 7..10 ally / enemy, 11 / 20 donate, 12 show, ...) except create: mobile 68 = server 51, invite 69 = 2, accept 70 = 1 (tester2).
[2038 MsgSyndicate struct 29 44]
# Join Guild window (CDlgFactionJoin): mobile 51 apply = server 55 Join (GuildApply); mobile 56 quick join, 57 join
# requirements and 64 cancel application have no server number: 1056 / 1057 / 1064 are handled by Mobile\GuildJoin\GuildJoinNet.cs.
# Applicants (CFactionAddMemberItem::OnBtnAdd/OnBtnDel, CFDlgFactionAddList::OnBtnAddAll/OnBtnDelAll): mobile 52 / 53 / 65 / 66
# = server 56 agree / 57 refuse / 58 agree all / 59 refuse all (GuildApply). Mobile 55 banner flag (ChangeFactionFlagReq),
# 58 leader info (CFdlgFactionJoin) and 59 ally request cancel (CMakeRelationItem) would hit server Join / agree all / refuse all:
# they go in as 1055 / 1058 / 1059 (logged by GuildJoinNet, not implemented). Mobile 24 (ChangeJoinReq) keeps 24 for GuildJoinReq.
# Guild window open (CFDlgFactionMain::onInit): mobile 71 = CFactionRecruitMgr::QuerySynInfo() = server 12 Show (Guild.SendThat:
# bulletin + 2267 attributes, so fund / members / rank are fresh). Mobile 60 = QueryAllayApplyInfo (ally requests): no server
# list, CMsgSyndicate::Process has no case 60, so it stays unanswered (empty list).
4 4 u16 map 51=68 2<69 1<70 12<71 55<51 1056<56 1057<57 1064<64 56<52 57<53 58<65 59<66 1055<55 1058<58 1059<59 # in only: invite 69 (CFactionRecruitMgr::InviteJoinSynReq), accept 70 (AcceptJoinFactionReq); out the popup is the old case 2
8 8 u32
8 12 u32 out
12 12 u32 in
16 16 u32
20 20 u32
24 24 u32
# Incoming CMsgSyndicate::Create(action, text, id) writes the string list at 40, not 43 (create 68 seen on the phone:
# count @40 = 1, length @41, name from @43); a list read at 43 gave the server an empty guild name. Out stays at 43.
28 40 strings in
28 43 strings out
# QahrMobile packet layouts: Guilds (syndicates). The format is described in Networking\Mobile\MobileLayouts.Loader.cs.
# CMsgSyndicateAttributeInfo 10172 (103 bytes): guild id 4, contribution 8, silver fund u64 12, CP fund 20,
# members 24, my rank 28, leader name 32 (32), recruit level 64 / members 68 / classes 72, recruit type 76,
# level u8 80, title u16 81, join date 83, badge 87, impeach 91, impeach time u64 95 (CMsgSyndicateAttributeInfo::Process).
# Server (MsgGuildInformation, 97 bytes): id 4, silver u64 8, CPs 16, members 20, rank 24, leader 28, level u16 60,
# creation date 63, leader id 67, material u64 71, recruit off u8 79, battle power 80, on u8 84, prestige u64 85.
[2267 MsgSyndicateAttributeInfo struct 97 103]
4 4 u32
8 12 u64
16 20 u32
20 24 u32
24 28 u32
28 32 str:32
60 80 u8
63 83 u32
# CMsgSyndicate 10167 (44 bytes + strings): action u16 4, id 8, id/value 12, args 16 20 24 28, string list 43
# (CMsgSyndicate::Create*: "Create(action, id)" writes 8, "Create(action, text, id)" writes 12; Process reads 12/16).
# Server (MsgGuildProces.GuildRequest / GuildRequestCreate, 29 bytes + strings): action u32 4, uid 8, args 12 16 20 24,
# string list 28 (the same u8 count + u16 length format). The actions are the same numbers (1 accept, 2 invite,
# 3 quit, 6 name, 7..10 ally / enemy, 11 / 20 donate, 12 show, ...) except create: mobile 68 = server 51, invite 69 = 2, accept 70 = 1 (tester2).
[2038 MsgSyndicate struct 29 44]
# Join Guild window (CDlgFactionJoin): mobile 51 apply = server 55 Join (GuildApply); mobile 56 quick join, 57 join
# requirements and 64 cancel application have no server number: 1056 / 1057 / 1064 are handled by Mobile\GuildJoin\GuildJoinNet.cs.
# Applicants (CFactionAddMemberItem::OnBtnAdd/OnBtnDel, CFDlgFactionAddList::OnBtnAddAll/OnBtnDelAll): mobile 52 / 53 / 65 / 66
# = server 56 agree / 57 refuse / 58 agree all / 59 refuse all (GuildApply). Mobile 55 banner flag (ChangeFactionFlagReq),
# 58 leader info (CFdlgFactionJoin) and 59 ally request cancel (CMakeRelationItem) would hit server Join / agree all / refuse all:
# they go in as 1055 / 1058 / 1059 (logged by GuildJoinNet, not implemented). Mobile 24 (ChangeJoinReq) keeps 24 for GuildJoinReq.
# Guild window open (CFDlgFactionMain::onInit): mobile 71 = CFactionRecruitMgr::QuerySynInfo() = server 12 Show (Guild.SendThat:
# bulletin + 2267 attributes, so fund / members / rank are fresh). Mobile 60 = QueryAllayApplyInfo (ally requests): no server
# list, CMsgSyndicate::Process has no case 60, so it stays unanswered (empty list).
# Guild fund "+" (CFDlgFactionEMoneyTrans::OnSure -> CFactionRecruitMgr::FactionEMoneyTransReq): mobile 63 with the CPs at 8
# goes in as 1063 (Mobile\GuildFund\GuildCpTransfer.cs); the reply is server 63 out (case 63: success tip, then the client asks 12).
4 4 u16 map 51=68 2<69 1<70 12<71 55<51 1056<56 1057<57 1064<64 56<52 57<53 58<65 59<66 1055<55 1058<58 1059<59 1063<63 # in only: invite 69 (CFactionRecruitMgr::InviteJoinSynReq), accept 70 (AcceptJoinFactionReq); out the popup is the old case 2
8 8 u32
8 12 u32 out
12 12 u32 in
16 16 u32
20 20 u32
24 24 u32
# Incoming CMsgSyndicate::Create(action, text, id) writes the string list at 40, not 43 (create 68 seen on the phone:
# count @40 = 1, length @41, name from @43); a list read at 43 gave the server an empty guild name. Out stays at 43.
28 40 strings in
28 43 strings out
| الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
| الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
| Npcs تحويل الجولد لسي بي | Amr Khalid | تطوير سيرفرات كونكر | 5 | 2020-11-07 10:20 PM |
| npc تحويل السي بي لجولد والعكس | Hazem | تطوير سورسات 5095 | 4 | 2020-08-16 08:05 PM |
| تحويل ل 2دي | mohamedomar | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2020-02-05 04:27 PM |
| ايتم تحويل الولد لبنت والعكس | Hazem | تطوير سيرفرات كونكر | 5 | 2019-09-14 03:23 PM |
| انبي سي تحويل الايتم من مقيد لفري | Hazem | تطوير سيرفرات كونكر | 2 | 2019-06-12 05:18 PM |