Skip to content

Commit

Permalink
add same function
Browse files Browse the repository at this point in the history
  • Loading branch information
xxpniu committed Sep 18, 2016
1 parent 6a39282 commit 54c43c3
Show file tree
Hide file tree
Showing 41 changed files with 634 additions and 622 deletions.
Binary file modified ExcelConfig/items.xlsx
Binary file not shown.
Binary file modified GameCore/BehaviorTree/BehaviorTree.dll
Binary file not shown.
Binary file modified GameCore/BehaviorTree/BehaviorTree.dll.mdb
Binary file not shown.
94 changes: 47 additions & 47 deletions Server/Configs/ItemData.json

Large diffs are not rendered by default.

491 changes: 10 additions & 481 deletions Server/GServer/GServer.txt

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions Server/GServer/GServer.userprefs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<Properties StartupItem="MapServer/MapServer.csproj">
<Properties StartupConfiguration="{82CECA50-8A36-4234-B7FF-701C11B29054}|Default">
<MonoDevelop.Ide.ItemProperties.LoginServer PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.ItemProperties.MapServer PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.Workbench ActiveDocument="MapServer/Appliaction.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="LoginServer/Responsers/C2L_RegResponser.cs">
<Files>
<File FileName="MapServer/Managers/SimulaterManager.cs" Line="73" Column="10" />
<File FileName="MapServer/ServerWorldSimluater.cs" Line="45" Column="42" />
<File FileName="GServer/Responsers/C2G_GMToolResponser.cs" Line="7" Column="25" />
<File FileName="ServerUtility/RequestHandle.cs" Line="167" Column="85" />
<File FileName="MapServer/Responsers/C2B_ExitBattleResponser.cs" Line="21" Column="38" />
<File FileName="MapServer/TaskHandlers/Task_L2B_ExitUserHandler.cs" Line="18" Column="69" />
<File FileName="MapServer/Appliaction.cs" Line="140" Column="15" />
<File FileName="LoginServer/Responsers/C2L_LoginResponser.cs" Line="29" Column="68" />
<File FileName="LoginServer/Responsers/G2L_RegResponser.cs" Line="39" Column="34" />
<File FileName="LoginServer/Responsers/C2L_RegResponser.cs" Line="31" Column="56" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release|x86" />
Expand Down
13 changes: 12 additions & 1 deletion Server/GServer/GServer/Appliaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,24 @@ internal Client GetClientByUserID(long userID)
return res;
}

public MySqlConnection Connection
private MySqlConnection Connection
{
get
{
return new MySqlConnection(this.ConnectionString);
}
}

public DataBaseContext.GameDb GetDBContext()
{
var db = new DataBaseContext.GameDb(Connection);
if (NetProtoTool.EnableLog)
{
db.Log = Console.Out;
}
return db;
}

public static Appliaction Current { private set; get; }

//玩家访问端口
Expand Down
7 changes: 6 additions & 1 deletion Server/GServer/GServer/Managers/UserData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,14 @@ public void RevertPackage()
Package = packagetemp;
Gold = goldTemp;
Coin = coinTemp;
ClearRecord();
}

public void ClearRecord()
{
packagetemp = null;
goldTemp = -1;
coinTemp = 1;
coinTemp = -1;
}
}
}
Expand Down
18 changes: 8 additions & 10 deletions Server/GServer/GServer/Managers/UserDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ public class UserDataManager:IMonitor

public void OnExit()
{
using (var db = new DataBaseContext.GameDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext() )
{
if (ServerUtility.NetProtoTool.EnableLog)
db.Log = Console.Out;

foreach (var i in userData)
{
SaveUser(i.Key, i.Value,db);
Expand Down Expand Up @@ -98,7 +95,7 @@ public void OnTick()
if ((DateTime.Now - lastTick).TotalSeconds > 60)
{
lastTick = DateTime.Now;
using (var db = new DataBaseContext.GameDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext())
{
foreach (var i in userData)
{
Expand All @@ -108,21 +105,22 @@ public void OnTick()
userData.Remove(i.Key);
}
}
db.SubmitChanges();
}
}
}

public bool TryToCreateUser(long userID,int heroID)
{
using (var db = new DataBaseContext.GameDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext())
{
var query = db.TBGAmePlayer.Where(t => t.UserID == userID);
if (query.Count() > 0)
{
return false;
}

var gamePlayer = new DataBaseContext.TBGAmePlayer
var gamePlayer = new TBGAmePlayer
{
Coin = 100,
UserID = userID,
Expand All @@ -133,7 +131,7 @@ public bool TryToCreateUser(long userID,int heroID)

db.TBGAmePlayer.InsertOnSubmit(gamePlayer);

var hero = new DataBaseContext.TBPLayerHero
var hero = new TBPLayerHero
{
UserID = userID,
HeroID = heroID,
Expand All @@ -144,7 +142,7 @@ public bool TryToCreateUser(long userID,int heroID)
};
db.TBPLayerHero.InsertOnSubmit(hero);

var equip = new DataBaseContext.TBPLayerEquip
var equip = new TBPLayerEquip
{
UserID = userID,
UserEquipValues = string.Empty
Expand All @@ -165,7 +163,7 @@ public bool TryToGetUserData(long userID, out UserData data, bool reload = false

if (!userData.TryToGetValue(userID, out data))
{
using (var db = new GameDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext())
{
var user = db.TBGAmePlayer.Where(t => t.UserID == userID).SingleOrDefault();
if (user == null)
Expand Down
4 changes: 4 additions & 0 deletions Server/GServer/GServer/Responsers/C2G_SaleItemResponser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public override G2C_SaleItem DoResponse(C2G_SaleItem request, Client client)
{
userData.RevertPackage();
}
else
{
userData.ClearRecord();
}

return new G2C_SaleItem
{
Expand Down
34 changes: 24 additions & 10 deletions Server/GServer/LoginServer.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
[Log](06:29:09 09/15):Proto.G2L_Reg-->{"Version":10002,"Host":"127.0.0.1","Port":1700,"ServiceHost":"127.0.0.1","ServicesProt":2000,"ServerID":1,"MaxPlayer":100000,"CurrentPlayer":2}
[Log](06:29:09 09/15):1.923ms-->Proto.G2L_Reg
[Log](06:29:09 09/15):Proto.L2G_Reg-->{"Code":1}
[Log](06:29:16 09/15):Proto.C2L_Login-->{"Version":10002,"UserName":"xxp","Password":"54249636"}
[Log](06:29:16 09/15):367.196ms-->Proto.C2L_Login
[Log](06:29:16 09/15):Proto.L2C_Login-->{"Code":1,"UserID":4,"Session":"636095321565873300","Server":{"Host":"127.0.0.1","Port":1700,"ServerID":1,"MaxServiceCount":0}}
[Log](06:29:16 09/15):The socket is not connected
[Log](06:29:16 09/15):Proto.G2L_CheckUserSession-->{"UserID":4,"Session":"636095321565873300"}
[Log](06:29:16 09/15):0.622ms-->Proto.G2L_CheckUserSession
[Log](06:29:16 09/15):Proto.L2G_CheckUserSession-->{"Code":1}
[Log](01:35:52 09/18):Proto.G2L_Reg-->{"Version":10002,"Host":"127.0.0.1","Port":1700,"ServiceHost":"127.0.0.1","ServicesProt":2000,"ServerID":1,"MaxPlayer":100000,"CurrentPlayer":2}
[Log](01:35:52 09/18):2.119ms-->Proto.G2L_Reg
[Log](01:35:52 09/18):Proto.L2G_Reg-->{"Code":1}
[Log](01:35:56 09/18):Proto.C2L_Login-->{"Version":10002,"UserName":"xxp","Password":"54249636"}
SELECT PASSWORD(?p0) as Pwd
-- ?p0: Input String (Size = 8; Prec = 0; Scale = 0) [54249636]
-- Context: MySQL Model: AttributedMetaModel Build: 0.20.0.0
SELECT `CreateDateTime`, `ID`, `LastLoginDateTime`, `LoginCount`, `Password`, `ServerID`, `UserName`
FROM `game_account_db`.`TB_Account`
WHERE ((`UserName` = ?UserName) AND (`Password` = ?pwd)) LIMIT 2
-- ?UserName: Input String (Size = 3; Prec = 0; Scale = 0) [xxp]
-- ?pwd: Input String (Size = 41; Prec = 0; Scale = 0) [*979263A5AC00FA43A4F1C844690FA1D01E83F0D6]
-- Context: MySQL Model: AttributedMetaModel Build: 0.20.0.0
UPDATE `game_account_db`.`TB_Account` SET `LastLoginDateTime` = ?LastLoginDateTime, `LoginCount` = ?LoginCount WHERE `ID` = ?ID
-- ?ID: Input Int64 (Size = 0; Prec = 0; Scale = 0) [4]
-- ?LastLoginDateTime: Input DateTime (Size = 0; Prec = 0; Scale = 0) [2016/9/18 5:35:57]
-- ?LoginCount: Input Int64 (Size = 0; Prec = 0; Scale = 0) [374]
-- Context: MySQL Model: AttributedMetaModel Build: 0.20.0.0
[Log](01:35:57 09/18):417.854ms-->Proto.C2L_Login
[Log](01:35:57 09/18):Proto.L2C_Login-->{"Code":1,"UserID":4,"Session":"636097737570547990","Server":{"Host":"127.0.0.1","Port":1700,"ServerID":1,"MaxServiceCount":0}}
[Log](01:35:57 09/18):The socket is not connected
[Log](01:35:57 09/18):Proto.G2L_CheckUserSession-->{"UserID":4,"Session":"636097737570547990"}
[Log](01:35:57 09/18):0.544ms-->Proto.G2L_CheckUserSession
[Log](01:35:57 09/18):Proto.L2G_CheckUserSession-->{"Code":1}
11 changes: 10 additions & 1 deletion Server/GServer/LoginServer/Appliaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void Tick()

private string ConnectionString;

public MySqlConnection Connection
private MySqlConnection Connection
{
get
{
Expand All @@ -118,6 +118,15 @@ public void SetSession(long userID, string session)
_sessions.Add(userID, session);
}

public DataBaseContext.GameAccountDb GetDBContext()
{
var db = new DataBaseContext.GameAccountDb(this.Connection);
if (NetProtoTool.EnableLog)
{
db.Log = Console.Out;
}
return db;
}

}
}
Expand Down
27 changes: 27 additions & 0 deletions Server/GServer/LoginServer/DBTools.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Linq;

namespace LoginServer
{
public class DBTools
{
public class PwdResult
{
public string Pwd { set; get; }
}

public DBTools()
{
}
public static string GetPwd(string password, DataBaseContext.GameAccountDb db)
{
var result = db.ExecuteQuery<PwdResult>
("SELECT PASSWORD({0}) as Pwd", password)
.FirstOrDefault();

var pwd = result.Pwd;
return pwd;
}

}
}
1 change: 1 addition & 0 deletions Server/GServer/LoginServer/LoginServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="Responsers\B2L_EndBattleResponser.cs" />
<Compile Include="Responsers\B2L_CheckSessionResponser.cs" />
<Compile Include="Responsers\G2L_GetLastBattleResponser.cs" />
<Compile Include="DBTools.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\GameCore\XNet\XNet.Libs.csproj">
Expand Down
7 changes: 4 additions & 3 deletions Server/GServer/LoginServer/Responsers/C2L_LoginResponser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace LoginServer.Responsers
{

[HandleType(typeof(C2L_Login),HandleResponserType.CLIENT_SERVER)]
public class C2L_LoginResponser : Responser<C2L_Login,L2C_Login>
{
Expand All @@ -21,11 +22,11 @@ public override L2C_Login DoResponse(C2L_Login request, Client client)
{
return new L2C_Login { Code = ErrorCode.VersionError };
}
using (var db = new DataBaseContext.GameAccountDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext())
{

var pwd =DBTools.GetPwd(request.Password,db);
var query = db.TbaCCount
.Where(t => t.UserName == request.UserName && t.Password == request.Password)
.Where(t => t.UserName == request.UserName && t.Password == pwd)
.SingleOrDefault();
if (query == null)
{
Expand Down
5 changes: 3 additions & 2 deletions Server/GServer/LoginServer/Responsers/C2L_RegResponser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override L2C_Reg DoResponse(C2L_Reg request, Client client)
}


using (var db = new DataBaseContext.GameAccountDb(Appliaction.Current.Connection))
using (var db = Appliaction.Current.GetDBContext())
{
var query = db.TbaCCount.Where(t => t.UserName == request.UserName).Count();
if (query > 0)
Expand All @@ -39,10 +39,11 @@ public override L2C_Reg DoResponse(C2L_Reg request, Client client)
};
}
else {
var pwd = DBTools.GetPwd(request.Password,db);
var acc = new DataBaseContext.TbaCCount
{
UserName = request.UserName,
Password = request.Password,
Password = pwd,
CreateDateTime = DateTime.UtcNow,
LoginCount =0,
LastLoginDateTime = DateTime.UtcNow,
Expand Down
2 changes: 1 addition & 1 deletion client/Assets/CSharpScripts/RequestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public override void Handle(Message message)
IHandler handler;
if (_handlers.TryGetValue(requestIndex, out handler))
{
handler.OnHandle(true, response);
_handlers.Remove(requestIndex);
handler.OnHandle(true, response);
}
}
else if (message.Class == MessageClass.Task)
Expand Down
2 changes: 2 additions & 0 deletions client/Assets/CSharpScripts/UUI/Windows/UUIDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UGameTools;
using Proto;
using ExcelConfig;
using UnityEngine;

namespace Windows
{
Expand Down Expand Up @@ -40,6 +41,7 @@ protected override void OnShow()
t_descript.text = config.Description;
t_name.text = config.Name;
t_prices.text = "售价 " + config.SalePrice;
Icon.texture =ResourcesManager.S.LoadResources<Texture2D>("Icon/" + config.Icon);
}
protected override void OnHide()
{
Expand Down
2 changes: 2 additions & 0 deletions client/Assets/CSharpScripts/UUI/Windows/UUIPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UGameTools;
using Proto;
using ExcelConfig;
using UnityEngine;

namespace Windows
{
Expand Down Expand Up @@ -34,6 +35,7 @@ public void SetItem(PlayerItem item)
Config = itemconfig;
pItem = item;
Template.Text.text = item.Num>1? item.Num.ToString():string.Empty;
Template.RawImage.texture =ResourcesManager.S.LoadResources<Texture2D>("Icon/" + itemconfig.Icon);
}
}

Expand Down
2 changes: 2 additions & 0 deletions client/Assets/CSharpScripts/UUI/Windows/UUISaleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UGameTools;
using Proto;
using ExcelConfig;
using UnityEngine;

namespace Windows
{
Expand Down Expand Up @@ -58,6 +59,7 @@ protected override void OnShow()
base.OnShow();
config = ExcelToJSONConfigManager.Current.GetConfigByID<ItemData>(Item.ItemID);
t_name.text = config.Name;

s_salenum.minValue = 0;
s_salenum.maxValue = Item.Num;
s_salenum.value = saleNum = Item.Num;
Expand Down
9 changes: 9 additions & 0 deletions client/Assets/Resources/Icon.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added client/Assets/Resources/Icon/equip01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 54c43c3

Please sign in to comment.