* Added password change support (references #95)

* Fixed 64bit support
* Repaired line endings
* Bumped protocol version
This commit is contained in:
Andreas Schneider 2013-11-20 18:12:52 +01:00
parent 9676549ac3
commit 829a604c30
35 changed files with 21115 additions and 20710 deletions

View File

@ -17,11 +17,11 @@
<VersionInfo>
<UseVersionInfo Value="True"/>
<MinorVersionNr Value="6"/>
<RevisionNr Value="3"/>
<BuildNr Value="241"/>
<StringTable CompanyName="AKS DataBasis" ProductName="CentrED" InternalName="CentrED" LegalCopyright="(c) 2012 Andreas Schneider" ProductVersion="0.6.3" FileDescription="UO CentrED" OriginalFilename="CentrED.exe"/>
<RevisionNr Value="4"/>
<BuildNr Value="245"/>
<StringTable CompanyName="AKS DataBasis" FileDescription="UO CentrED" InternalName="CentrED" LegalCopyright="(c) 2013 Andreas Schneider" OriginalFilename="CentrED.exe" ProductName="CentrED" ProductVersion="0.6.4"/>
</VersionInfo>
<BuildModes Count="3">
<BuildModes Count="4">
<Item1 Name="default" Default="True"/>
<Item2 Name="Release Win32">
<MacroValues Count="1">
@ -127,9 +127,61 @@
</Other>
</CompilerOptions>
</Item3>
<Item4 Name="Release Linux GTK2 x64">
<MacroValues Count="1">
<Macro2 Name="LCLWidgetType" Value="gtk2"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="../bin/CentrED"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);../Imaging;.."/>
<OtherUnitFiles Value="..;../UOLib;../MulProvider;../Imaging;../Imaging/JpegLib;../Imaging/ZLib;Tools"/>
<UnitOutputDirectory Value="../obj/$(TargetCPU)-$(TargetOS)"/>
<SrcPath Value="$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType);..;../UOLib;../MulProvider;../Imaging;../Imaging/JpegLib;../Imaging/ZLib;Tools"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="x86_64"/>
<TargetOS Value="linux"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<UseLineInfoUnit Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<IgnoredMessages idx4079="True" idx4080="True" idx4081="True" idx5024="True" idx5028="True"/>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CustomOptions Value="-FE../bin/
-dNoLogging"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item4>
<SharedMatrixOptions Count="2">
<Item1 ID="851019893220" Modes="Release Win32" Type="IDEMacro" MacroName="LCLWidgetType" Value="win32"/>
<Item2 ID="521965364444" Modes="Release Linux GTK2 x86" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
<Item2 ID="521965364444" Modes="Release Linux GTK2 x86,Release Linux GTK2 x64" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
</SharedMatrixOptions>
</BuildModes>
<PublishOptions>
@ -172,7 +224,7 @@
<MinVersion Major="4" Minor="5" Release="1" Valid="True"/>
</Item6>
</RequiredPackages>
<Units Count="48">
<Units Count="49">
<Unit0>
<Filename Value="CentrED.lpr"/>
<IsPartOfProject Value="True"/>
@ -190,6 +242,7 @@
<Filename Value="UdmNetwork.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="dmNetwork"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
<UnitName Value="UdmNetwork"/>
</Unit2>
@ -197,6 +250,7 @@
<Filename Value="UfrmLogin.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmLogin"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="UfrmLogin"/>
</Unit3>
@ -455,6 +509,14 @@
<IsPartOfProject Value="True"/>
<UnitName Value="UContnrExt"/>
</Unit47>
<Unit48>
<Filename Value="UfrmChangePassword.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmChangePassword"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="UfrmChangePassword"/>
</Unit48>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -141,6 +141,7 @@ initialization
//$06-$0B --> handled by TLandscape
//$0C --> ClientHandling, done by TfrmMain
//$0D --> RadarMapHandling, done by TfrmRadarMap
//$0E --> LargeScaleCommands, done by TfrmLargeScaleCommands
finalization
for i := 0 to $FF do
if PacketHandlers[i] <> nil then

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2009 Andreas Schneider
* Portions Copyright 2013 Andreas Schneider
*)
unit UPackets;
@ -134,6 +134,12 @@ type
constructor Create(AUsername: string);
end;
{ TChangePasswordPacket }
TChangePasswordPacket = class(TPacket)
constructor Create(AOldPassword, ANewPassword: String);
end;
{ TRequestRadarChecksumPacket }
TRequestRadarChecksumPacket = class(TPacket)
@ -346,6 +352,16 @@ begin
FStream.WriteStringNull(AUsername);
end;
{ TChangePasswordPacket }
constructor TChangePasswordPacket.Create(AOldPassword, ANewPassword: String);
begin
inherited Create($0C, 0);
FStream.WriteByte($08);
FStream.WriteStringNull(AOldPassword);
FStream.WriteStringNull(ANewPassword);
end;
{ TRequestRadarChecksumPacket }
constructor TRequestRadarChecksumPacket.Create;

View File

@ -78,7 +78,8 @@ uses
UGameResources, UfrmAccountControl, UfrmEditAccount, UfrmDrawSettings,
UfrmBoundaries, UfrmElevateSettings, UfrmConfirmation, UfrmMoveSettings,
UfrmAbout, UfrmHueSettings, UfrmRadar, UfrmLargeScaleCommand,
UfrmVirtualLayer, UfrmFilter, UfrmRegionControl, UfrmLightlevel;
UfrmVirtualLayer, UfrmFilter, UfrmRegionControl, UfrmLightlevel,
UfrmChangePassword;
{$I version.inc}
@ -212,6 +213,7 @@ begin
frmVirtualLayer := TfrmVirtualLayer.Create(frmMain);
frmLightlevel := TfrmLightlevel.Create(frmMain);
frmAbout := TfrmAbout.Create(frmMain);
frmChangePassword := TfrmChangePassword.Create(frmMain);
frmMain.Show;
frmInitialize.Hide;
tmNoOp.Enabled := True;
@ -308,6 +310,7 @@ begin
FreeAndNil(frmLargeScaleCommand);
FreeAndNil(frmRadarMap);
FreeAndNil(frmLightlevel);
FreeAndNil(frmChangePassword);
if frmMain <> nil then
begin

View File

@ -0,0 +1,129 @@
object frmChangePassword: TfrmChangePassword
Left = 283
Height = 145
Top = 193
Width = 315
BorderStyle = bsDialog
Caption = 'Change Password'
ClientHeight = 145
ClientWidth = 315
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '1.3'
object Label1: TLabel
AnchorSideTop.Control = edOldPwd
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edOldPwd
Left = 32
Height = 15
Top = 13
Width = 88
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Old Password:'
ParentColor = False
end
object Label2: TLabel
AnchorSideTop.Control = edNewPwd
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edNewPwd
Left = 26
Height = 15
Top = 46
Width = 94
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'New Password:'
ParentColor = False
end
object lblNewPwdRepeat: TLabel
AnchorSideTop.Control = edNewPwdRepeat
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edNewPwdRepeat
Left = 9
Height = 15
Top = 79
Width = 111
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Repeat Password:'
ParentColor = False
end
object edOldPwd: TEdit
Left = 128
Height = 25
Top = 8
Width = 176
EchoMode = emPassword
PasswordChar = '*'
TabOrder = 0
end
object edNewPwd: TEdit
AnchorSideLeft.Control = edOldPwd
AnchorSideTop.Control = edOldPwd
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edOldPwd
AnchorSideRight.Side = asrBottom
Left = 128
Height = 25
Top = 41
Width = 176
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
EchoMode = emPassword
OnChange = edNewPwdChange
PasswordChar = '*'
TabOrder = 1
end
object edNewPwdRepeat: TEdit
AnchorSideLeft.Control = edNewPwd
AnchorSideTop.Control = edNewPwd
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edNewPwd
AnchorSideRight.Side = asrBottom
Left = 128
Height = 25
Top = 74
Width = 176
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
EchoMode = emPassword
OnChange = edNewPwdChange
PasswordChar = '*'
TabOrder = 2
end
object btnOK: TButton
AnchorSideTop.Control = btnCancel
AnchorSideRight.Control = btnCancel
Left = 149
Height = 25
Top = 112
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = '&OK'
Default = True
Enabled = False
ModalResult = 1
OnClick = btnOKClick
TabOrder = 3
end
object btnCancel: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 232
Height = 25
Top = 112
Width = 75
Anchors = [akRight, akBottom]
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Cancel = True
Caption = 'Cancel'
ModalResult = 2
OnClick = btnCancelClick
TabOrder = 4
end
end

View File

@ -0,0 +1,81 @@
unit UfrmChangePassword;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TfrmChangePassword }
TfrmChangePassword = class(TForm)
btnOK: TButton;
btnCancel: TButton;
edOldPwd: TEdit;
edNewPwd: TEdit;
edNewPwdRepeat: TEdit;
Label1: TLabel;
Label2: TLabel;
lblNewPwdRepeat: TLabel;
procedure btnCancelClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure edNewPwdChange(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
frmChangePassword: TfrmChangePassword;
implementation
uses
UdmNetwork, UPackets, UEnums;
{$R *.lfm}
{ TfrmChangePassword }
procedure TfrmChangePassword.FormShow(Sender: TObject);
begin
edOldPwd.Text := '';
edNewPwd.Text := '';
edNewPwdRepeat.Text := '';
end;
procedure TfrmChangePassword.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TfrmChangePassword.btnOKClick(Sender: TObject);
begin
dmNetwork.Send(TChangePasswordPacket.Create(edOldPwd.Text,
edNewPwd.Text));
end;
procedure TfrmChangePassword.edNewPwdChange(Sender: TObject);
var
pwdValid: Boolean;
begin
if edNewPwd.Text <> edNewPwdRepeat.Text then
begin
pwdValid := False;
lblNewPwdRepeat.Font.Color := clRed;
end else
begin
pwdValid := True;
lblNewPwdRepeat.Font.Color := clDefault;
end;
btnOK.Enabled := (Length(edNewPwd.Text) > 0) and pwdValid;
end;
end.

View File

@ -5,7 +5,7 @@ object frmMain: TfrmMain
Width = 755
ActiveControl = oglGameWindow
Caption = 'UO CentrED'
ClientHeight = 559
ClientHeight = 558
ClientWidth = 755
Constraints.MinHeight = 500
Constraints.MinWidth = 750
@ -23,7 +23,7 @@ object frmMain: TfrmMain
object pnlBottom: TPanel
Left = 0
Height = 31
Top = 528
Top = 527
Width = 755
Align = alBottom
BevelOuter = bvNone
@ -34,7 +34,7 @@ object frmMain: TfrmMain
Left = 11
Height = 13
Top = 7
Width = 9
Width = 11
Caption = 'X:'
ParentColor = False
end
@ -42,7 +42,7 @@ object frmMain: TfrmMain
Left = 88
Height = 13
Top = 7
Width = 8
Width = 10
Caption = 'Y:'
ParentColor = False
end
@ -50,15 +50,15 @@ object frmMain: TfrmMain
Left = 240
Height = 13
Top = 7
Width = 3
Width = 4
Caption = ' '
ParentColor = False
end
object lblTip: TLabel
Left = 524
Left = 501
Height = 31
Top = 0
Width = 223
Width = 246
Align = alRight
Alignment = taRightJustify
BorderSpacing.Right = 8
@ -67,10 +67,10 @@ object frmMain: TfrmMain
ParentColor = False
end
object lblTipC: TLabel
Left = 502
Left = 473
Height = 31
Top = 0
Width = 22
Width = 28
Align = alRight
Caption = 'Tip: '
Font.Height = -11
@ -81,7 +81,7 @@ object frmMain: TfrmMain
end
object edX: TSpinEdit
Left = 24
Height = 21
Height = 25
Top = 3
Width = 55
MaxValue = 100000
@ -89,7 +89,7 @@ object frmMain: TfrmMain
end
object edY: TSpinEdit
Left = 104
Height = 21
Height = 25
Top = 3
Width = 52
MaxValue = 100000
@ -108,7 +108,7 @@ object frmMain: TfrmMain
end
object pcLeft: TPageControl
Left = 0
Height = 504
Height = 503
Top = 24
Width = 224
ActivePage = tsTiles
@ -117,16 +117,16 @@ object frmMain: TfrmMain
TabOrder = 1
object tsTiles: TTabSheet
Caption = 'Tiles'
ClientHeight = 478
ClientWidth = 216
ClientHeight = 472
ClientWidth = 218
object lblFilter: TLabel
AnchorSideLeft.Control = cbTerrain
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbTerrain
Left = 75
Left = 89
Height = 13
Top = 8
Width = 29
Width = 31
BorderSpacing.Left = 16
Caption = 'Filter:'
ParentColor = False
@ -140,10 +140,10 @@ object frmMain: TfrmMain
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = spTileList
Left = 4
Height = 240
Height = 224
Hint = '-'
Top = 50
Width = 208
Top = 60
Width = 210
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4
BorderSpacing.Top = 4
@ -200,12 +200,12 @@ object frmMain: TfrmMain
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 183
Top = 295
Width = 216
Top = 289
Width = 218
Anchors = [akTop, akLeft, akRight, akBottom]
Caption = 'Random pool'
ClientHeight = 165
ClientWidth = 212
ClientHeight = 169
ClientWidth = 216
TabOrder = 1
object btnAddRandom: TSpeedButton
AnchorSideLeft.Control = gbRandom
@ -359,10 +359,10 @@ object frmMain: TfrmMain
object btnRandomPresetSave: TSpeedButton
AnchorSideTop.Control = cbRandomPreset
AnchorSideRight.Control = btnRandomPresetDelete
Left = 160
Left = 164
Height = 22
Hint = 'Save Preset'
Top = 140
Top = 138
Width = 22
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
@ -411,10 +411,10 @@ object frmMain: TfrmMain
AnchorSideTop.Control = btnRandomPresetSave
AnchorSideRight.Control = gbRandom
AnchorSideRight.Side = asrBottom
Left = 186
Left = 190
Height = 22
Hint = 'Delete Preset'
Top = 140
Top = 138
Width = 22
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
@ -469,9 +469,9 @@ object frmMain: TfrmMain
AnchorSideBottom.Control = cbRandomPreset
Cursor = 63
Left = 4
Height = 112
Height = 110
Top = 24
Width = 204
Width = 208
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4
BorderSpacing.Top = 2
@ -517,14 +517,14 @@ object frmMain: TfrmMain
AnchorSideBottom.Control = gbRandom
AnchorSideBottom.Side = asrBottom
Left = 4
Height = 21
Top = 140
Width = 152
Height = 27
Top = 138
Width = 156
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
ItemHeight = 13
ItemHeight = 0
OnChange = cbRandomPresetChange
Sorted = True
Style = csDropDownList
@ -538,8 +538,8 @@ object frmMain: TfrmMain
Cursor = crVSplit
Left = 0
Height = 5
Top = 290
Width = 216
Top = 284
Width = 218
Align = alNone
Anchors = [akLeft, akRight, akBottom]
ResizeAnchor = akBottom
@ -549,10 +549,10 @@ object frmMain: TfrmMain
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = vdtTiles
AnchorSideBottom.Side = asrBottom
Left = 108
Height = 21
Left = 110
Height = 23
Hint = 'Append S or T to restrict the search to Statics or Terrain.'
Top = 261
Top = 253
Width = 96
Anchors = [akRight, akBottom]
BorderSpacing.Right = 8
@ -571,10 +571,10 @@ object frmMain: TfrmMain
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = tsTiles
AnchorSideRight.Side = asrBottom
Left = 75
Height = 21
Left = 89
Height = 23
Top = 21
Width = 125
Width = 113
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 16
OnEditingDone = edFilterEditingDone
@ -585,10 +585,10 @@ object frmMain: TfrmMain
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = cbTerrain
AnchorSideTop.Side = asrBottom
Left = 5
Height = 19
Top = 27
Width = 53
Left = 3
Height = 24
Top = 32
Width = 71
Caption = 'Statics'
Checked = True
OnChange = cbStaticsChange
@ -599,9 +599,9 @@ object frmMain: TfrmMain
AnchorSideLeft.Control = tsTiles
AnchorSideTop.Control = tsTiles
Left = 4
Height = 19
Height = 24
Top = 8
Width = 55
Width = 69
BorderSpacing.Left = 4
BorderSpacing.Top = 8
Caption = 'Terrain'
@ -613,8 +613,8 @@ object frmMain: TfrmMain
end
object tsClients: TTabSheet
Caption = 'Clients'
ClientHeight = 478
ClientWidth = 216
ClientHeight = 472
ClientWidth = 218
object lbClients: TListBox
Left = 0
Height = 478
@ -624,14 +624,16 @@ object frmMain: TfrmMain
ItemHeight = 0
OnDblClick = mnuGoToClientClick
PopupMenu = pmClients
ScrollWidth = 214
Sorted = True
TabOrder = 0
TopIndex = -1
end
end
object tsLocations: TTabSheet
Caption = 'Locations'
ClientHeight = 478
ClientWidth = 216
ClientHeight = 472
ClientWidth = 218
object btnClearLocations: TSpeedButton
AnchorSideLeft.Control = btnDeleteLocation
AnchorSideLeft.Side = asrBottom
@ -1027,7 +1029,7 @@ object frmMain: TfrmMain
AnchorSideBottom.Control = spChat
Left = 224
Height = 22
Top = 392
Top = 391
Width = 531
Anchors = [akLeft, akRight, akBottom]
BevelInner = bvRaised
@ -1040,7 +1042,7 @@ object frmMain: TfrmMain
Left = 10
Height = 18
Top = 2
Width = 100
Width = 113
Align = alLeft
BorderSpacing.Left = 8
Caption = 'Chat and Messages'
@ -1061,7 +1063,7 @@ object frmMain: TfrmMain
AnchorSideBottom.Control = pnlBottom
Left = 224
Height = 109
Top = 419
Top = 418
Width = 531
Anchors = [akTop, akLeft, akRight, akBottom]
BevelOuter = bvNone
@ -1072,7 +1074,7 @@ object frmMain: TfrmMain
object vstChat: TVirtualStringTree
Cursor = 63
Left = 0
Height = 88
Height = 86
Top = 0
Width = 531
Align = alClient
@ -1092,7 +1094,7 @@ object frmMain: TfrmMain
item
Position = 2
Text = 'Message'
Width = 377
Width = 379
end>
Header.DefaultHeight = 17
Header.MainColumn = 2
@ -1110,8 +1112,8 @@ object frmMain: TfrmMain
end
object edChat: TEdit
Left = 0
Height = 21
Top = 88
Height = 23
Top = 86
Width = 531
Align = alBottom
OnKeyPress = edChatKeyPress
@ -1126,7 +1128,7 @@ object frmMain: TfrmMain
Cursor = crVSplit
Left = 224
Height = 5
Top = 414
Top = 413
Width = 531
Align = alNone
Anchors = [akLeft, akRight, akBottom]
@ -1143,7 +1145,7 @@ object frmMain: TfrmMain
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlChatHeader
Left = 224
Height = 368
Height = 367
Top = 24
Width = 531
Anchors = [akTop, akLeft, akRight, akBottom]
@ -1164,6 +1166,13 @@ object frmMain: TfrmMain
top = 33
object mnuCentrED: TMenuItem
Caption = '&CentrED'
object mnuChangePassword: TMenuItem
Caption = '&Change Password'
OnClick = mnuChangePasswordClick
end
object mnuSeparator1: TMenuItem
Caption = '-'
end
object mnuDisconnect: TMenuItem
Caption = '&Disconnect'
Bitmap.Data = {
@ -1205,9 +1214,6 @@ object frmMain: TfrmMain
ImageIndex = 0
OnClick = mnuDisconnectClick
end
object mnuSeparator1: TMenuItem
Caption = '-'
end
object mnuExit: TMenuItem
Caption = 'E&xit'
OnClick = mnuExitClick

View File

@ -103,6 +103,7 @@ type
lblY: TLabel;
lbClients: TListBox;
MainMenu1: TMainMenu;
mnuChangePassword: TMenuItem;
mnuWhiteBackground: TMenuItem;
mnuSecurityQuestion: TMenuItem;
mnuShowAnimations: TMenuItem;
@ -222,6 +223,7 @@ type
procedure lblChatHeaderCaptionClick(Sender: TObject);
procedure lblChatHeaderCaptionMouseEnter(Sender: TObject);
procedure lblChatHeaderCaptionMouseLeave(Sender: TObject);
procedure mnuChangePasswordClick(Sender: TObject);
procedure mnuAboutClick(Sender: TObject);
procedure mnuAccountControlClick(Sender: TObject);
procedure mnuDisconnectClick(Sender: TObject);
@ -407,7 +409,7 @@ uses
UfrmBoundaries, UfrmElevateSettings, UfrmConfirmation, UfrmMoveSettings,
UfrmAbout, UPacketHandlers, UfrmHueSettings, UfrmRadar, UfrmLargeScaleCommand,
UfrmLogin, UResourceManager, UfrmVirtualLayer, UfrmFilter, UfrmRegionControl,
Logging, LConvEncoding, LCLType, UfrmLightlevel;
Logging, LConvEncoding, LCLType, UfrmLightlevel, UfrmChangePassword;
type
TGLArrayf4 = array[0..3] of GLfloat;
@ -1417,6 +1419,11 @@ begin
lblChatHeaderCaption.Font.Underline := False;
end;
procedure TfrmMain.mnuChangePasswordClick(Sender: TObject);
begin
frmChangePassword.ShowModal;
end;
procedure TfrmMain.mnuAboutClick(Sender: TObject);
begin
frmAbout.ShowModal;
@ -3060,6 +3067,7 @@ var
i: Integer;
accessLevel: TAccessLevel;
accessChangedListener: TAccessChangedListener;
pwdChangeStatus: TPasswordChangeStatus;
begin
case ABuffer.ReadByte of
$01: //client connected
@ -3117,6 +3125,23 @@ begin
for accessChangedListener in FAccessChangedListeners.Reversed do
accessChangedListener(accessLevel);
end;
$08: //password change status
begin
pwdChangeStatus := TPasswordChangeStatus(ABuffer.ReadByte);
case pwdChangeStatus of
pcSuccess:
Messagedlg('Password Change', 'Your password has been changed', mtInformation, [mbOK], 0);
pcOldPwInvalid:
Messagedlg('Password Change', 'The old password is wrong.' + sLineBreak +
'Your password has NOT been changed.', mtWarning, [mbOK], 0);
pcNewPwInvalid:
Messagedlg('Password Change', 'The new password is not allowed.' + sLineBreak +
'Your password has NOT been changed.', mtWarning, [mbOK], 0);
pcIdentical:
Messagedlg('Password Change', 'The new password matched the old password.' + sLineBreak +
'Your password has NOT been changed.', mtWarning, [mbOK], 0);
end;
end;
end;
end;

View File

@ -336,7 +336,7 @@ implementation
uses
{$IF Defined(LCL)}
{$IF Defined(LCLGTK2)}
GLib2, GDK2, GTK2, GTKDef, GTKProc,
GLib2, GDK2, GTK2, Gtk2Def, Gtk2Proc,
{$ELSEIF Defined(LCLGTK)}
GDK, GTK, GTKDef, GTKProc,
{$IFEND}

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
* Portions Copyright 2013 Andreas Schneider
*)
unit UAccount;
@ -37,7 +37,7 @@ type
{ TAccount }
TAccount = class(TObject, ISerializable, IInvalidate)
constructor Create(AOwner: IInvalidate; AName, APasswordHash: string;
constructor Create(AOwner: IInvalidate; AName, APassword: string;
AAccessLevel: TAccessLevel; ARegions: TStringList);
constructor Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
destructor Destroy; override;
@ -58,7 +58,9 @@ type
property PasswordHash: string read FPasswordHash write SetPasswordHash;
property LastPos: TPoint read FLastPos write SetLastPos;
property Regions: TStringList read FRegions;
function CheckPassword(APassword: String): Boolean;
procedure Invalidate;
procedure UpdatePassword(APassword: String);
end;
{ TAccountList }
@ -79,17 +81,17 @@ type
implementation
uses
UCEDServer, UConfig;
UCEDServer, UConfig, md5;
{ TAccount }
constructor TAccount.Create(AOwner: IInvalidate; AName, APasswordHash: string;
constructor TAccount.Create(AOwner: IInvalidate; AName, APassword: string;
AAccessLevel: TAccessLevel; ARegions: TStringList);
begin
inherited Create;
FOwner := AOwner;
FName := AName;
FPasswordHash := APasswordHash;
FPasswordHash := MD5Print(MD5String(APassword));
FAccessLevel := AAccessLevel;
if ARegions <> nil then
FRegions := ARegions
@ -154,11 +156,27 @@ begin
Invalidate;
end;
function TAccount.CheckPassword(APassword: String): Boolean;
var
testHash: String;
begin
//Since I want to change to PBKDF2 sometime, we compare strings instead
//of MD5Digest, so we can (later) check what type of hash the string has
//been created with.
testHash := MD5Print(MD5String(APassword));
Result := FPasswordHash = testHash;
end;
procedure TAccount.Invalidate;
begin
FOwner.Invalidate;
end;
procedure TAccount.UpdatePassword(APassword: String);
begin
PasswordHash := MD5Print(MD5String(APassword));
end;
procedure TAccount.Serialize(AElement: TDOMElement);
var
i: Integer;

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
* Portions Copyright 2013 Andreas Schneider
*)
unit UAdminHandling;
@ -88,7 +88,7 @@ var
implementation
uses
md5, UCEDServer, UPackets, UClientHandling;
UCEDServer, UPackets, UClientHandling;
procedure AdminBroadcast(AAccessLevel: TAccessLevel; APacket: TPacket);
var
@ -146,7 +146,7 @@ begin
if account <> nil then
begin
if password <> '' then
account.PasswordHash := MD5Print(MD5String(password));
account.UpdatePassword(password);
account.AccessLevel := accessLevel;
@ -181,8 +181,8 @@ begin
for i := 0 to regionCount - 1 do
regions.Add(ABuffer.ReadStringNull);
account := TAccount.Create(Config.Accounts, username,
MD5Print(MD5String(password)), accessLevel, regions);
account := TAccount.Create(Config.Accounts, username, password,
accessLevel, regions);
Config.Accounts.Add(account);
Config.Accounts.Invalidate;

View File

@ -217,7 +217,7 @@ begin
try
buffer := ANetState.ReceiveQueue;
buffer.Position := 0;
while (buffer.Size >= 1) and ANetState.Socket.Connected do
while (buffer.Size >= 1) and (ANetState.Socket.ConnectionStatus = scConnected) do
begin
packetID := buffer.ReadByte;
packetHandler := PacketHandlers[packetID];
@ -268,7 +268,7 @@ begin
netState := TNetState(FTCPServer.Iterator.UserData);
if netState <> nil then
begin
if FTCPServer.Iterator.Connected then
if FTCPServer.Iterator.ConnectionStatus = scConnected then
begin
if (SecondsBetween(netState.LastAction, Now) > 120) then
begin
@ -326,7 +326,7 @@ begin
while FTCPServer.IterNext do
begin
netState := TNetState(FTCPServer.Iterator.UserData);
if (netState <> nil) and (FTCPServer.Iterator.Connected) then
if (netState <> nil) and (FTCPServer.Iterator.ConnectionStatus = scConnected) then
begin
netState.SendQueue.Seek(0, soFromEnd);
netState.SendQueue.CopyFrom(APacket.Stream, 0);
@ -340,7 +340,7 @@ end;
procedure TCEDServer.Disconnect(ASocket: TLSocket);
begin
if ASocket.Connected then
if ASocket.ConnectionStatus = scConnected then
begin
ASocket.Disconnect;
//OnDisconnect(ASocket);

View File

@ -71,6 +71,12 @@ type
constructor Create(AAccount: TAccount);
end;
{ TPasswordChangeStatusPacket }
TPasswordChangeStatusPacket = class(TPacket)
constructor Create(AResult: TPasswordChangeStatus);
end;
procedure OnClientHandlerPacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
procedure OnUpdateClientPosPacket(ABuffer: TEnhancedMemoryStream;
@ -79,6 +85,8 @@ procedure OnChatMessagePacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
procedure OnGotoClientPosPacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
procedure OnChangePasswordPacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
procedure WriteAccountRestrictions(AStream: TEnhancedMemoryStream;
AAccount: TAccount);
@ -130,6 +138,44 @@ begin
TSetClientPosPacket.Create(account.LastPos));
end;
procedure OnChangePasswordPacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
var
oldPwd, newPwd: String;
begin
oldPwd := ABuffer.ReadStringNull;
newPwd := ABuffer.ReadStringNull;
if ANetState.Account.CheckPassword(oldPwd) then
begin
//Check if the passwords actually differ. Changing them isn't allowed
//otherwise. Might be open for configuration, though.
if oldPwd <> newPwd then
begin
//Just a simple restriction to disallow too easy passwords.
//TODO: Configurable restrictions
if Length(newPwd) >= 4 then
begin
//Everything fine, update the password and report success.
ANetState.Account.UpdatePassword(newPwd);
CEDServerInstance.SendPacket(ANetState,
TPasswordChangeStatusPacket.Create(pcSuccess));
end else
begin
CEDServerInstance.SendPacket(ANetState,
TPasswordChangeStatusPacket.Create(pcNewPwInvalid));
end;
end else
begin
CEDServerInstance.SendPacket(ANetState,
TPasswordChangeStatusPacket.Create(pcIdentical));
end;
end else
begin
CEDServerInstance.SendPacket(ANetState,
TPasswordChangeStatusPacket.Create(pcOldPwInvalid));
end;
end;
procedure WriteAccountRestrictions(AStream: TEnhancedMemoryStream;
AAccount: TAccount);
var
@ -236,6 +282,15 @@ begin
WriteAccountRestrictions(FStream, AAccount);
end;
{ TPasswordChangeStatusPacket }
constructor TPasswordChangeStatusPacket.Create(AResult: TPasswordChangeStatus);
begin
inherited Create($0C, 0);
FStream.WriteByte($08);
FStream.WriteByte(Byte(AResult));
end;
{$WARNINGS OFF}
var
i: Integer;
@ -246,6 +301,7 @@ initialization
ClientPacketHandlers[$04] := TPacketHandler.Create(0, @OnUpdateClientPosPacket);
ClientPacketHandlers[$05] := TPacketHandler.Create(0, @OnChatMessagePacket);
ClientPacketHandlers[$06] := TPacketHandler.Create(0, @OnGotoClientPosPacket);
ClientPacketHandlers[$08] := TPacketHandler.Create(0, @OnChangePasswordPacket);
finalization
for i := 0 to $FF do
if ClientPacketHandlers[i] <> nil then

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
* Portions Copyright 2013 Andreas Schneider
*)
unit UConfig;
@ -30,8 +30,8 @@ unit UConfig;
interface
uses
Classes, SysUtils, DOM, XMLRead, XMLWrite, md5, Keyboard, UAccount,
UXmlHelper, UInterfaces, UEnums, URegions;
Classes, SysUtils, DOM, XMLRead, XMLWrite, Keyboard, UAccount, UXmlHelper,
UInterfaces, UEnums, URegions;
type
@ -292,8 +292,8 @@ begin
until stringValue <> '';
Write ('Password [hidden]: ');
password := QueryPassword;
FAccounts.Add(TAccount.Create(FAccounts, stringValue,
MD5Print(MD5String(password)), alAdministrator, nil));
FAccounts.Add(TAccount.Create(FAccounts, stringValue, password,
alAdministrator, nil));
FChanged := True;
end;

View File

@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
* Portions Copyright 2013 Andreas Schneider
*)
unit UConnectionHandling;
@ -63,7 +63,7 @@ var
implementation
uses
md5, UCEDServer, UClientHandling, UPackets;
UCEDServer, UClientHandling, UPackets;
procedure OnConnectionHandlerPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState);
var
@ -77,19 +77,19 @@ end;
procedure OnLoginRequestPacket(ABuffer: TEnhancedMemoryStream;
ANetState: TNetState);
var
username, passwordHash: string;
username, password: string;
account: TAccount;
netState: TNetState;
invalid: Boolean;
begin
username := ABuffer.ReadStringNull;
passwordHash := MD5Print(MD5String(ABuffer.ReadStringNull));
password := ABuffer.ReadStringNull;
account := Config.Accounts.Find(username);
if account <> nil then
begin
if account.AccessLevel > alNone then
begin
if account.PasswordHash = passwordHash then
if account.CheckPassword(password) then
begin
invalid := False;
CEDServerInstance.TCPServer.IterReset;

View File

@ -139,7 +139,7 @@ begin
begin
subscriptions := CEDServerInstance.Landscape.BlockSubscriptions[ACoords[i].X, ACoords[i].Y];
subscriptions.Delete(ANetState);
subscriptions.Add(Integer(ANetState), ANetState);
subscriptions.Add(PtrInt(ANetState), ANetState);
if ANetState.Subscriptions.IndexOf(subscriptions) = -1 then
ANetState.Subscriptions.Add(subscriptions);
end;

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
@ -13,9 +13,9 @@
<VersionInfo>
<UseVersionInfo Value="True"/>
<MinorVersionNr Value="6"/>
<RevisionNr Value="3"/>
<RevisionNr Value="4"/>
<BuildNr Value="240"/>
<StringTable CompanyName="AKS DataBasis" ProductName="CentrED" InternalName="CentrED Server" LegalCopyright="(c) 2012 Andreas Schneider" ProductVersion="0.6.3" FileDescription="CentrED Server" OriginalFilename="cedserver.exe"/>
<StringTable CompanyName="AKS DataBasis" FileDescription="CentrED Server" InternalName="CentrED Server" LegalCopyright="(c) 2013 Andreas Schneider" OriginalFilename="cedserver.exe" ProductName="CentrED" ProductVersion="0.6.4"/>
</VersionInfo>
<BuildModes Count="3">
<Item1 Name="default" Default="True"/>
@ -69,7 +69,7 @@
</Item2>
<Item3 Name="Release Win32">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
<Macro2 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
@ -115,6 +115,10 @@
</Other>
</CompilerOptions>
</Item3>
<SharedMatrixOptions Count="2">
<Item1 ID="285940101796" Modes="Release Linux i686" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
<Item2 ID="285439860087" Modes="Release Win32" Type="IDEMacro" MacroName="LCLWidgetType" Value="win32"/>
</SharedMatrixOptions>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
@ -231,7 +235,6 @@
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>

View File

@ -118,7 +118,7 @@ var
length: Integer;
begin
Result := '';
buffer := Pointer(LongInt(Memory) + Position);
buffer := Pointer(PtrInt(Memory) + Position);
length := 0;
while (buffer[length] <> #0) and (length < (Size - Position)) do
begin
@ -138,7 +138,7 @@ var
length: Integer;
begin
Result := '';
buffer := Pointer(LongInt(FMemory) + FPosition);
buffer := Pointer(PtrInt(FMemory) + FPosition);
length := 0;
while (length < ALength) and (length < (FSize - (FPosition - FLockOffset))) do
begin
@ -158,7 +158,7 @@ var
length: Integer;
begin
Result := '';
buffer := Pointer(LongInt(FMemory) + FPosition);
buffer := Pointer(PtrInt(FMemory) + FPosition);
length := 0;
while (buffer^[length] <> 0) and (length < (FSize - (FPosition - FLockOffset))) do
begin

View File

@ -57,6 +57,11 @@ type
TDeleteRegionStatus = (drNotFound = 0,
drDeleted = 1);
TPasswordChangeStatus = (pcSuccess = 0,
pcOldPwInvalid = 1,
pcNewPwInvalid = 2,
pcIdentical = 3);
function GetAccessLevelString(AAccessLevel: TAccessLevel): string;
implementation

Binary file not shown.

View File

@ -1,2 +1,2 @@
const
ProtocolVersion = 6;
ProtocolVersion = 7;