- Fixed "UTiledata" spelling in ULandscape.pas

- Added ISerializable and IInvalidate interfaces
- Implemented a TConfig class and XML storage
- Added some more detailed messages when a login fails to the server console
- Removed obsolete IStream interface references
- Readded lbHue in TfrmHueSettings
This commit is contained in:
Andreas Schneider 2008-03-06 22:55:49 +01:00
parent 04a459b524
commit 12773fd63e
18 changed files with 2346 additions and 2525 deletions

View File

@ -5,7 +5,6 @@ object frmHueSettings: TfrmHueSettings
Width = 217 Width = 217
HorzScrollBar.Page = 216 HorzScrollBar.Page = 216
VertScrollBar.Page = 206 VertScrollBar.Page = 206
ActiveControl = lbHue
BorderIcons = [] BorderIcons = []
BorderStyle = bsToolWindow BorderStyle = bsToolWindow
Caption = 'Hue Settings' Caption = 'Hue Settings'
@ -15,14 +14,23 @@ object frmHueSettings: TfrmHueSettings
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
OnDeactivate = FormDeactivate OnDeactivate = FormDeactivate
LCLVersion = '0.9.25'
object lblHue: TLabel object lblHue: TLabel
Left = 8 Left = 8
Height = 16 Height = 12
Top = 12 Top = 12
Width = 26 Width = 27
Caption = 'Hue:' Caption = 'Hue:'
ParentColor = False ParentColor = False
end end
object edHue: TEdit
Left = 48
Height = 23
Top = 10
Width = 80
OnEditingDone = edHueEditingDone
TabOrder = 0
end
object lbHue: TListBox object lbHue: TListBox
Left = 8 Left = 8
Height = 160 Height = 160
@ -32,14 +40,7 @@ object frmHueSettings: TfrmHueSettings
OnDrawItem = lbHueDrawItem OnDrawItem = lbHueDrawItem
OnSelectionChange = lbHueSelectionChange OnSelectionChange = lbHueSelectionChange
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 0
end
object edHue: TEdit
Left = 48
Height = 23
Top = 10
Width = 80
OnEditingDone = edHueEditingDone
TabOrder = 1 TabOrder = 1
TopIndex = -1
end end
end end

View File

@ -32,7 +32,7 @@ interface
uses uses
SysUtils, Classes, math, contnrs, LCLIntf, GL, GLU, ImagingOpenGL, SysUtils, Classes, math, contnrs, LCLIntf, GL, GLU, ImagingOpenGL,
Imaging, ImagingClasses, ImagingTypes, ImagingUtility, Imaging, ImagingClasses, ImagingTypes, ImagingUtility,
UGenericIndex, UMap, UStatics, UArt, UTexture, UTileData, UHue, UWorldItem, UGenericIndex, UMap, UStatics, UArt, UTexture, UTiledata, UHue, UWorldItem,
UMulBlock, UMulBlock,
UListSort, UVector, UEnhancedMemoryStream, UListSort, UVector, UEnhancedMemoryStream,
UCacheManager, ULinkedList; UCacheManager, ULinkedList;

View File

@ -16,8 +16,8 @@ object frmLogin: TfrmLogin
Position = poScreenCenter Position = poScreenCenter
ShowInTaskBar = stAlways ShowInTaskBar = stAlways
object lblCopyright: TLabel object lblCopyright: TLabel
Height = 17 Height = 19
Top = 248 Top = 246
Width = 489 Width = 489
Align = alBottom Align = alBottom
Alignment = taCenter Alignment = taCenter
@ -146,6 +146,7 @@ object frmLogin: TfrmLogin
233023312332233323342335517451745174222C0A2251745174517451745174 233023312332233323342335517451745174222C0A2251745174517451745174
51745174517451745174517451745174517451745174227D3B0A 51745174517451745174517451745174517451745174227D3B0A
} }
Transparent = False
end end
object imgUsername: TImage object imgUsername: TImage
Left = 6 Left = 6
@ -237,6 +238,7 @@ object frmLogin: TfrmLogin
233123322333233423355174517451745174222C0A2251745174517451745174 233123322333233423355174517451745174222C0A2251745174517451745174
51745174517451745174517451745174517451745174227D3B0A 51745174517451745174517451745174517451745174227D3B0A
} }
Transparent = False
end end
object imgPassword: TImage object imgPassword: TImage
Left = 6 Left = 6
@ -318,6 +320,7 @@ object frmLogin: TfrmLogin
5174222C0A2251742349234A236E234B51745174517451745174517451745174 5174222C0A2251742349234A236E234B51745174517451745174517451745174
517451745174227D3B0A 517451745174227D3B0A
} }
Transparent = False
end end
object edHost: TEdit object edHost: TEdit
Left = 101 Left = 101
@ -433,103 +436,40 @@ object frmLogin: TfrmLogin
Width = 23 Width = 23
Color = clBtnFace Color = clBtnFace
Glyph.Data = { Glyph.Data = {
010C00002F2A2058504D202A2F0A7374617469632063686172202A6772617068 36040000424D3604000000000000360000002800000010000000100000000100
69635B5D203D207B0A223136203136203135332032222C0A222E2E2063204E6F 2000000000000004000064000000640000000000000000000000BA6A36FFB969
6E65222C0A222E2C20632023333636424243222C0A222E2D2063202333363642 35FFB86935FFB76835FFB56835FFB46734FFB26634FFB06533FFAE6433FFAC63
4242222C0A222E2A20632023333636414242222C0A222E612063202333393643 32FFAA6232FFA96132FFA86031FFA76031FFA66031FFA86131FFBA6A35FFEBC6
4243222C0A222E6220632023334236454244222C0A222E632063202333413644 ADFFEAC5ADFFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFB
4242222C0A222E6420632023333836424242222C0A222E652063202333453730 F8FFFEFBF8FFFEFBF8FFFEFBF8FFC89A7CFFC79879FFA76031FFBA6B37FFEDCA
4242222C0A222E6620632023443145304636222C0A222E672063202344314530 B3FFE0A27AFFFEFAF7FF62C088FF62C088FF62C088FF62C088FF62C088FF62C0
4637222C0A222E6820632023463846424645222C0A222E692063202346374642 88FF62C088FF62C088FFFDF9F6FFCA8D65FFC99B7CFFA76031FFBB6C38FFEECC
4645222C0A222E6A20632023463646394644222C0A222E6B2063202346304635 B6FFE1A27AFFFEFAF7FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDC
4643222C0A222E6C20632023454146304641222C0A222E6D2063202345444632 C2FFBFDCC2FFBFDCC2FFFDF9F6FFCD9068FFCC9E81FFA86132FFBB6B38FFEFCE
4642222C0A222E6E20632023463746414644222C0A222E6F2063202345424631 B8FFE1A279FFFEFAF7FF62C088FF62C088FF62C088FF62C088FF62C088FF62C0
4642222C0A222E7020632023444645394638222C0A222E712063202342444430 88FF62C088FF62C088FFFDF9F6FFCF936AFFCEA384FFAA6132FFBA6A36FFEFD0
4543222C0A222E7220632023354538394339222C0A222E732063202344314446 BBFFE2A27AFFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFB
4636222C0A222E7420632023383041414539222C0A222E752063202346364641 F8FFFEFBF8FFFEFBF8FFFEFBF8FFD3966DFFD2A78AFFAB6232FFBB6A36FFF0D2
4645222C0A222E7620632023463646414644222C0A222E772063202336343843 BEFFE2A37AFFE2A37AFFE1A37AFFE2A37BFFE1A37BFFE0A178FFDE9F77FFDD9F
4338222C0A222E7820632023454546334642222C0A222E792063202345414631 76FFDC9D74FFD99B72FFD89971FFD69970FFD5AB8EFFAD6333FFBB6A36FFF2D5
4642222C0A222E7A20632023463246364643222C0A222E412063202346314636 C2FFE3A37AFFE3A37AFFE2A37BFFE2A37BFFE2A47BFFE1A279FFE0A178FFDEA0
4643222C0A222E4220632023453245434639222C0A222E432063202344424537 77FFDE9E75FFDC9D74FFDA9B73FFD99B73FFDAB095FFAF6433FFBB6A36FFF2D8
4638222C0A222E4420632023424144304545222C0A222E452063202344304446 C5FFE3A47BFFE3A37AFFE3A47AFFE2A47BFFE2A37BFFE1A37BFFE1A279FFDFA0
4636222C0A222E4620632023374541384538222C0A222E472063202345394631 77FFDE9F76FFDD9E74FFDB9C72FFDC9D74FFDDB59AFFB16534FFBB6B36FFF4D9
4641222C0A222E4820632023454546344642222C0A222E492063202345384630 C7FFE6A67DFFC88C64FFC98D65FFC98E67FFCB926CFFCB926DFFCA9069FFC88C
4641222C0A222E4A20632023444445384638222C0A222E4B2063202344424536 65FFC88C64FFC88C64FFC88C64FFDA9C74FFE1BA9FFFB36634FFBB6B36FFF4DC
4637222C0A222E4C20632023374141334531222C0A222E4D2063202343334435 C9FFE7A77DFFF9ECE1FFF9ECE1FFF9EDE3FFFCF4EEFFFDFAF7FFFDF7F3FFFAED
4546222C0A222E4E20632023333536394237222C0A222E4F2063202343434444 E5FFF7E7DBFFF7E5D9FFF6E5D8FFDEA077FFE4BEA4FFB46734FFBC6B36FFF5DD
4635222C0A222E5020632023374541384537222C0A222E512063202336363844 CCFFE7A87EFFFAF0E8FFFAF0E8FFC98D66FFFAF0E9FFFDF8F3FFFEFAF8FFFCF4
4339222C0A222E5220632023453946304641222C0A222E532063202346334638 EFFFF9E9DFFFF7E7DBFFF7E5D9FFE0A278FFE7C2A9FFB66835FFBC6B36FFF6DF
4644222C0A222E5420632023463846414645222C0A222E552063202345464634 D0FFE8A87EFFFCF6F1FFFCF6F1FFC88C64FFFAF1E9FFFBF4EEFFFDFAF7FFFDF9
4643222C0A222E5620632023444645394639222C0A222E572063202344424537 F6FFFAF0E8FFF8E8DDFFF7E6DBFFE1A37AFFEFD5C3FFB76935FFBC6B36FFF6DF
4637222C0A222E5820632023443945354637222C0A222E592063202337384132 D1FFE9AA80FFFEFAF6FFFDFAF6FFC88C64FFFBF3EEFFFBF1EAFFFCF6F2FFFEFB
4530222C0A222E5A20632023413943324537222C0A222E302063202333353638 F8FFFCF6F1FFF9ECE2FFF8E7DBFFEED0BAFFECD0BDFFBB703EFFBC6B36FFF6E0
4236222C0A222E3120632023433944434634222C0A222E322063202337444137 D1FFF7E0D1FFFEFBF8FFFEFBF7FFFDF9F6FFFCF5F0FFFAF0EAFFFBF2EDFFFDF9
4537222C0A222E3320632023453145434639222C0A222E342063202345334544 F6FFFDFAF7FFFBF1EBFFF8E9DFFFECD0BDFFC9895EFF0000000000000000BC6B
4639222C0A222E3520632023454546344643222C0A222E362063202346334637 36FFBC6B36FFBC6B36FFBC6B36FFBB6B36FFBB6B36FFBB6A36FFBB6A36FFBC6C
4644222C0A222E3720632023453545444641222C0A222E382063202344384535 39FFBD6E3BFFBB6D3AFFBB6B38FFBB703EFF0000000000000000
4636222C0A222E3920632023373741304445222C0A222E402063202341344245
4534222C0A222E2320632023333436374234222C0A222E3B2063202343374439
4634222C0A222E3A20632023374441364536222C0A222E3D2063202336353844
4339222C0A222E2B20632023363738454339222C0A222E252063202336433932
4342222C0A222E2420632023364439324342222C0A222E282063202336393930
4341222C0A222E2920632023363538434338222C0A222E5B2063202337343943
4441222C0A222E5D20632023394642414531222C0A222C2E2063202333343636
4233222C0A222C2C20632023433544384632222C0A222C2D2063202337424134
4533222C0A222C2A20632023374141334533222C0A222C612063202337414134
4533222C0A222C6220632023374241344532222C0A222C632063202337424133
4532222C0A222C6420632023374241334531222C0A222C652063202337394132
4531222C0A222C6620632023373741304446222C0A222C672063202337363946
4445222C0A222C6820632023373439454444222C0A222C692063202337323943
4442222C0A222C6A20632023373439444443222C0A222C6B2063202339414235
4444222C0A222C6C20632023333436354231222C0A222C6D2063202343324435
4632222C0A222C6E20632023373841314530222C0A222C6F2063202337353945
4445222C0A222C7020632023373339424441222C0A222C712063202337333942
4439222C0A222C7220632023393542304441222C0A222C732063202333333634
4146222C0A222C7420632023424544324630222C0A222C752063202337414133
4532222C0A222C7620632023373739464445222C0A222C772063202337363946
4444222C0A222C7820632023373239424439222C0A222C792063202337313939
4438222C0A222C7A20632023373039394436222C0A222C412063202338454142
4435222C0A222C4220632023333336334144222C0A222C432063202333363641
4241222C0A222C4420632023424244304546222C0A222C452063202337414132
4532222C0A222C4620632023364439364433222C0A222C472063202338414137
4432222C0A222C4820632023333236324142222C0A222C492063202342384345
4546222C0A222C4A20632023463746414645222C0A222C4B2063202338384330
3632222C0A222C4C20632023364139334346222C0A222C4D2063202338344133
4345222C0A222C4E20632023333236314141222C0A222C4F2063202333383643
4242222C0A222C5020632023423643434545222C0A222C512063202337414132
4531222C0A222C5220632023433244434246222C0A222C532063202336383930
4344222C0A222C5420632023383139454343222C0A222C552063202333323631
4138222C0A222C5620632023333736424241222C0A222C572063202342334341
4544222C0A222C5820632023374141324530222C0A222C592063202336353844
4341222C0A222C5A20632023374339424339222C0A222C302063202333313630
4137222C0A222C3120632023333536414241222C0A222C322063202341444336
4542222C0A222C3320632023414443354541222C0A222C342063202337433941
4338222C0A222C3520632023373939384337222C0A222C362063202333353639
4239222C0A222C3720632023333536394238222C0A222C382063202333353638
4237222C0A222C3920632023333536384235222C0A222C402063202333343636
4232222C0A222C2320632023333336354230222C0A222C3B2063202333333634
4145222C0A222C3A20632023333236334143222C0A222C3D2063202333323632
4141222C0A222C2B20632023333236314139222C0A222C252063202333313630
4138222C0A222C2420632023333136304136222C0A222C282063202333313631
4138222C0A222E2E2E2C2E2C2E2C2E2C2E2D2E2D2E2A2E2A2E612E622E632E64
2E652E2E2E2E222C0A222E2C2E662E672E682E692E6A2E6B2E6C2E6D2E6A2E6E
2E6F2E702E712E722E2E222C0A222E2C2E732E742E752E762E772E782E792E7A
2E682E412E422E432E442E712E65222C0A222E2C2E452E462E412E412E772E47
2E482E6E2E6A2E492E4A2E4B2E4C2E4D2E4E222C0A222E2C2E4F2E502E492E49
2E512E522E532E542E552E562E572E582E592E5A2E30222C0A222E2D2E312E32
2E332E332E342E352E6E2E362E372E572E582E382E392E402E23222C0A222E2D
2E3B2E3A2E772E3D2E2B2E252E242E282E292E772E772E772E5B2E5D2C2E222C
0A222E2A2C2C2C2D2C2A2C612C622C632C642C652C662C672C682C692C6A2C6B
2C6C222C0A222E2A2C6D2C2A2C2A2C632C632C622C652C6E2E392C6F2C6A2C70
2C712C722C73222C0A222E2A2C742C752C752E4C2C632C642C6E2C762C772C6A
2C782C792C7A2C412C42222C0A222C432C442C452E682E682E682E682E682E68
2E682E682E682E682C462C472C48222C0A222E642C492C652C4A2C4B2C4B2C4B
2C4B2C4B2C4B2C4B2C4B2E6A2C4C2C4D2C4E222C0A222C4F2C502C512C4A2C52
2C522C522C522C522C522C522C522E6A2C532C542C55222C0A222C562C572C58
2C4A2C4B2C4B2C4B2C4B2C4B2C4B2C4B2C4B2E6A2C592C5A2C30222C0A222C31
2C322C332E682E682E682E682E682E682E682E682E682E682C342C352C30222C
0A222C432C362C372C382C392E232C402C232C3B2C3A2C3D2C2B2C252C302C24
2C28227D0A
} }
NumGlyphs = 0 NumGlyphs = 0
OnClick = btnSaveProfileClick OnClick = btnSaveProfileClick
@ -545,71 +485,40 @@ object frmLogin: TfrmLogin
Width = 23 Width = 23
Color = clBtnFace Color = clBtnFace
Glyph.Data = { Glyph.Data = {
100800002F2A2058504D202A2F0A7374617469632063686172202A6772617068 36040000424D3604000000000000360000002800000010000000100000000100
69635B5D203D207B0A2231362031362039302032222C0A222E2E2063204E6F6E 2000000000000004000064000000640000000000000000000000000000000000
65222C0A222E2C20632023464637373741222C0A222E2D206320234645373637 0000000000000000000000000000000000000000000000000000000000000000
39222C0A222E2A20632023463836313634222C0A222E61206320234639363836 0000000000000000000000000000000000000000000000000000000000000000
41222C0A222E6220632023463335313534222C0A222E63206320234646374538 0000000000000000000000000000000000000000000000000000000000000000
31222C0A222E6420632023464537453831222C0A222E65206320234644373137 0000000000000000000000000000000000000000000000000000000000000000
34222C0A222E6620632023463835463632222C0A222E67206320234642364436 0000000000004F4CF2FF403EEDFF000000000000000000000000000000000000
46222C0A222E6820632023464637433745222C0A222E69206320234645373137 0000000000002422E4FF312FEAFF000000000000000000000000000000000000
34222C0A222E6A20632023464537413744222C0A222E6B206320234646383738 00005856F5FF6361FAFF5855F6FF413FEDFF0000000000000000000000000000
41222C0A222E6C20632023464437393743222C0A222E6D206320234642363936 00002C2AE6FF413FF1FF4C4AF6FF312FEAFF0000000000000000000000000000
43222C0A222E6E20632023463835453631222C0A222E6F206320234641364336 00005B58F6FF6562FAFF7170FFFF5956F6FF4240EEFF00000000000000003532
45222C0A222E7020632023464637413744222C0A222E71206320234637354636 E9FF4745F2FF6362FFFF4A48F4FF2F2DE9FF0000000000000000000000000000
31222C0A222E7220632023463034363439222C0A222E73206320234643364236 0000000000005B59F6FF6663FAFF7471FFFF5A58F6FF4341EEFF3E3CECFF504D
45222C0A222E7420632023464437343737222C0A222E75206320234646383238 F4FF6867FFFF504EF5FF3634EBFF000000000000000000000000000000000000
36222C0A222E7620632023464337333736222C0A222E77206320234638363236 000000000000000000005C5AF6FF6764FAFF7472FFFF7370FFFF706EFFFF6E6C
34222C0A222E7820632023463735443630222C0A222E79206320234641364136 FFFF5755F7FF3F3DEEFF00000000000000000000000000000000000000000000
44222C0A222E7A20632023464637393742222C0A222E41206320234546343534 00000000000000000000000000005D5BF7FF7976FFFF5956FFFF5754FFFF7270
38222C0A222E4220632023463936333636222C0A222E43206320234642364437 FFFF4846F0FF0000000000000000000000000000000000000000000000000000
30222C0A222E4420632023464637453830222C0A222E45206320234646374237 00000000000000000000000000005D5AF6FF7D79FFFF5E5BFFFF5B58FFFF7674
45222C0A222E4620632023464637393743222C0A222E47206320234646373737 FFFF4643EFFF0000000000000000000000000000000000000000000000000000
39222C0A222E4820632023463735433545222C0A222E49206320234546343434 000000000000000000006663F9FF706DFBFF807EFFFF7E7BFFFF7C79FFFF7977
37222C0A222E4A20632023463635413544222C0A222E4B206320234646373937 FFFF5E5CF7FF4744EFFF00000000000000000000000000000000000000000000
44222C0A222E4C20632023464635423545222C0A222E4D206320234646353835 0000000000006E6BFCFF7774FDFF8682FFFF7673FCFF6462F8FF605DF7FF6D6A
42222C0A222E4E20632023464637343736222C0A222E4F206320234546343334 FAFF7B79FFFF605DF7FF4845EFFF000000000000000000000000000000000000
36222C0A222E5020632023463735423544222C0A222E51206320234646373637 00007471FEFF7D7AFEFF8A87FFFF7C79FDFF6C69FBFF0000000000000000615E
39222C0A222E5220632023464635363539222C0A222E53206320234646353435 F8FF6E6CFAFF7D7AFFFF615FF7FF4946F0FF0000000000000000000000000000
37222C0A222E5420632023464637303732222C0A222E55206320234630343634 00007A77FFFF817EFFFF817EFEFF7471FDFF0000000000000000000000000000
38222C0A222E5620632023463635413543222C0A222E57206320234641363436 0000625FF8FF6F6DFBFF7E7CFFFF625FF8FF0000000000000000000000000000
37222C0A222E5820632023464637323734222C0A222E59206320234646373037 0000000000007A77FFFF7976FEFF000000000000000000000000000000000000
33222C0A222E5A20632023464636453730222C0A222E30206320234646364336 0000000000006461F8FF6A68F9FF5451F3FF0000000000000000000000000000
45222C0A222E3120632023463735353537222C0A222E32206320234545334433 0000000000000000000000000000000000000000000000000000000000000000
46222C0A222E3320632023463635393542222C0A222E34206320234641363336 0000000000000000000000000000000000000000000000000000000000000000
36222C0A222E3520632023464637313734222C0A222E36206320234636353835 0000000000000000000000000000000000000000000000000000000000000000
41222C0A222E3720632023454534313433222C0A222E38206320234543334333 0000000000000000000000000000000000000000000000000000
45222C0A222E3920632023463434443530222C0A222E40206320234646363736
38222C0A222E2320632023463534453530222C0A222E3B206320234542333433
36222C0A222E3A20632023463635383542222C0A222E3D206320234641363236
35222C0A222E2B20632023464637303731222C0A222E25206320234636353635
39222C0A222E2420632023454534303432222C0A222E28206320234539333233
35222C0A222E2920632023463234353437222C0A222E5B206320234646363236
33222C0A222E5D20632023463434383441222C0A222C2E206320234539324432
46222C0A222C2C20632023463535363538222C0A222C2D206320234641363136
33222C0A222C2A20632023463635353538222C0A222C61206320234544334634
31222C0A222C6220632023453632413243222C0A222C63206320234631334634
31222C0A222C6420632023463634413443222C0A222C65206320234541324633
31222C0A222C6620632023463234433446222C0A222C67206320234544334534
30222C0A222C6820632023453432323234222C0A222E2E2E2E2E2E2E2E2E2E2E
2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E222C0A222E2E2E2E2E2E2E
2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E222C0A222E2E2E
2E2E2E2E2C2E2D2E2E2E2E2E2E2E2E2E2E2E2E2E2A2E612E622E2E2E2E222C0A
222E2E2E2E2E2C2E632E642E652E2E2E2E2E2E2E2E2E662E672E682E662E2E2E
2E222C0A222E2E2E2E2E692E6A2E6B2E6C2E6D2E2E2E2E2E6E2E6F2E702E712E
722E2E2E2E222C0A222E2E2E2E2E2E2E732E742E752E762E772E782E792E7A2E
782E412E2E2E2E2E2E222C0A222E2E2E2E2E2E2E2E2E422E432E442E452E462E
472E482E492E2E2E2E2E2E2E2E222C0A222E2E2E2E2E2E2E2E2E2E2E4A2E4B2E
4C2E4D2E4E2E4F2E2E2E2E2E2E2E2E2E2E222C0A222E2E2E2E2E2E2E2E2E2E2E
502E512E522E532E542E552E2E2E2E2E2E2E2E2E2E222C0A222E2E2E2E2E2E2E
2E2E562E572E582E592E5A2E302E312E322E2E2E2E2E2E2E2E222C0A222E2E2E
2E2E2E2E332E342E352E362E372E382E392E402E232E3B2E2E2E2E2E2E222C0A
222E2E2E2E2E3A2E3D2E2B2E252E242E2E2E2E2E282E292E5B2E5D2C2E2E2E2E
2E222C0A222E2E2E2E2C2C2C2D2C2A2C612E2E2E2E2E2E2E2E2C622C632C642C
652E2E2E2E222C0A222E2E2E2E2E2E2C662C672E2E2E2E2E2E2E2E2E2E2E2E2C
682C652E2E2E2E2E2E222C0A222E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E
2E2E2E2E2E2E2E2E2E2E2E2E2E222C0A222E2E2E2E2E2E2E2E2E2E2E2E2E2E2E
2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E227D0A
} }
NumGlyphs = 0 NumGlyphs = 0
OnClick = btnDeleteProfileClick OnClick = btnDeleteProfileClick

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2008 Andreas Schneider
*) *)
unit UAccount; unit UAccount;
@ -30,16 +30,20 @@ unit UAccount;
interface interface
uses uses
Classes, SysUtils, md5, contnrs, math, UEnums; Classes, SysUtils, md5, contnrs, math, DOM, UXmlHelper, UInterfaces,
UEnums;
type type
{ TAccount } { TAccount }
TAccount = class(TObject) TAccount = class(TObject, ISerializable, IInvalidate)
constructor Create(AAccountString: string); constructor Create(AOwner: IInvalidate; AName, APasswordHash: string;
constructor Create(AName, APasswordHash: string; AAccessLevel: TAccessLevel); AAccessLevel: TAccessLevel);
constructor Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
procedure Serialize(AElement: TDOMElement);
protected protected
FOwner: IInvalidate;
FName: string; FName: string;
FAccessLevel: TAccessLevel; FAccessLevel: TAccessLevel;
FPasswordHash: string; FPasswordHash: string;
@ -52,17 +56,22 @@ type
property AccessLevel: TAccessLevel read FAccessLevel write SetAccessLevel; property AccessLevel: TAccessLevel read FAccessLevel write SetAccessLevel;
property PasswordHash: string read FPasswordHash write SetPasswordHash; property PasswordHash: string read FPasswordHash write SetPasswordHash;
property LastPos: TPoint read FLastPos write SetLastPos; property LastPos: TPoint read FLastPos write SetLastPos;
procedure Flush; procedure Invalidate;
end; end;
{ TAccountList } { TAccountList }
TAccountList = class(TObjectList) TAccountList = class(TObjectList, ISerializable, IInvalidate)
constructor Create; reintroduce; constructor Create(AOwner: IInvalidate); reintroduce;
constructor Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
procedure Serialize(AElement: TDOMElement);
protected
FOwner: IInvalidate;
public public
function IndexOf(AName: string): Integer; function IndexOf(AName: string): Integer;
function Find(AName: string): TAccount; function Find(AName: string): TAccount;
procedure Delete(AName: string); procedure Delete(AName: string);
procedure Invalidate;
end; end;
implementation implementation
@ -72,75 +81,80 @@ uses
{ TAccount } { TAccount }
constructor TAccount.Create(AAccountString: string); constructor TAccount.Create(AOwner: IInvalidate; AName, APasswordHash: string;
var
i: Integer;
attribs: TStringList;
begin
inherited Create;
i := Pos('=', AAccountString);
if i > 0 then
FName := Trim(Copy(AAccountString, 1, i-1));
AAccountString := Copy(AAccountString, i+1, Length(AAccountString));
attribs := TStringList.Create;
if ExtractStrings([':'], [' '], PChar(AAccountString), attribs) >= 2 then
begin
FAccessLevel := TAccessLevel(StrToInt(attribs.Strings[0]));
FPasswordHash := attribs.Strings[1];
end;
if attribs.Count >= 4 then
begin
FLastPos.x := EnsureRange(StrToInt(attribs.Strings[2]), 0, Config.ReadInteger('Parameters', 'Width', 0) * 8 - 1);
FLastPos.y := EnsureRange(StrToInt(attribs.Strings[3]), 0, Config.ReadInteger('Parameters', 'Height', 0) * 8 - 1);
end else
begin
FLastPos.x := 0;
FLastPos.y := 0;
end;
attribs.Free;
end;
constructor TAccount.Create(AName, APasswordHash: string;
AAccessLevel: TAccessLevel); AAccessLevel: TAccessLevel);
begin begin
inherited Create; inherited Create;
FOwner := AOwner;
FName := AName; FName := AName;
FPasswordHash := APasswordHash; FPasswordHash := APasswordHash;
FAccessLevel := AAccessLevel; FAccessLevel := AAccessLevel;
Flush; end;
constructor TAccount.Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
begin
inherited Create;
FOwner := AOwner;
FName := TXmlHelper.ReadString(AElement, 'Name', '');
FAccessLevel := TAccessLevel(TXmlHelper.ReadInteger(AElement, 'AccessLevel', 0));
FPasswordHash := TXmlHelper.ReadString(AElement, 'PasswordHash', '');
FLastPos := Point(0, 0);
TXmlHelper.ReadCoords(AElement, 'LastPos', FLastPos.X, FLastPos.Y);
end; end;
procedure TAccount.SetAccessLevel(const AValue: TAccessLevel); procedure TAccount.SetAccessLevel(const AValue: TAccessLevel);
begin begin
FAccessLevel := AValue; FAccessLevel := AValue;
Flush; Invalidate;
end; end;
procedure TAccount.SetPasswordHash(const AValue: string); procedure TAccount.SetPasswordHash(const AValue: string);
begin begin
FPasswordHash := AValue; FPasswordHash := AValue;
Flush; Invalidate;
end; end;
procedure TAccount.SetLastPos(const AValue: TPoint); procedure TAccount.SetLastPos(const AValue: TPoint);
begin begin
FLastPos.x := EnsureRange(AValue.x, 0, CEDServerInstance.Landscape.CellWidth - 1); FLastPos.x := EnsureRange(AValue.x, 0, CEDServerInstance.Landscape.CellWidth - 1);
FLastPos.y := EnsureRange(AValue.y, 0, CEDServerInstance.Landscape.CellHeight - 1); FLastPos.y := EnsureRange(AValue.y, 0, CEDServerInstance.Landscape.CellHeight - 1);
Flush; Invalidate;
end; end;
procedure TAccount.Flush; procedure TAccount.Invalidate;
begin begin
Config.WriteString('Accounts', FName, IntToStr(Byte(FAccessLevel)) + ':' + FOwner.Invalidate;
FPasswordHash + ':' + IntToStr(FLastPos.x) + ':' + IntToStr(FLastPos.y)); end;
procedure TAccount.Serialize(AElement: TDOMElement);
begin
TXmlHelper.WriteString(AElement, 'Name', FName);
TXmlHelper.WriteString(AElement, 'PasswordHash', FPasswordHash);
TXmlHelper.WriteInteger(AElement, 'AccessLevel', Integer(FAccessLevel));
TXmlHelper.WriteCoords(AElement, 'LastPos', FLastPos.X, FLastPos.Y);
end; end;
{ TAccountList } { TAccountList }
constructor TAccountList.Create; constructor TAccountList.Create(AOwner: IInvalidate);
begin begin
inherited Create(True); inherited Create(True);
FOwner := AOwner;
end;
constructor TAccountList.Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
var
nodelist: TDOMNodeList;
i: Integer;
begin
Create(AOwner);
nodeList := AElement.GetChildNodes;
for i := 0 to nodeList.Count - 1 do
begin
if nodeList.Item[i].NodeName = 'Account' then
Add(TAccount.Deserialize(Self, TDOMElement(nodeList.Item[i])));
end;
nodeList.Free;
end; end;
function TAccountList.IndexOf(AName: string): Integer; function TAccountList.IndexOf(AName: string): Integer;
@ -177,5 +191,23 @@ begin
inherited Delete(i); inherited Delete(i);
end; end;
procedure TAccountList.Invalidate;
begin
FOwner.Invalidate;
end;
procedure TAccountList.Serialize(AElement: TDOMElement);
var
i: Integer;
xmlAccount: TDOMElement;
begin
for i := 0 to Count - 1 do
begin
xmlAccount := AElement.OwnerDocument.CreateElement('Account');
AElement.AppendChild(xmlAccount);
TAccount(Items[i]).Serialize(xmlAccount);
end;
end;
end. end.

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2008 Andreas Schneider
*) *)
unit UAdminHandling; unit UAdminHandling;
@ -81,6 +81,7 @@ end;
procedure OnFlushPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState); procedure OnFlushPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState);
begin begin
CEDServerInstance.Landscape.Flush; CEDServerInstance.Landscape.Flush;
Config.Flush;
end; end;
procedure OnQuitPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState); procedure OnQuitPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState);
@ -99,7 +100,7 @@ begin
username := ABuffer.ReadStringNull; username := ABuffer.ReadStringNull;
password := ABuffer.ReadStringNull; password := ABuffer.ReadStringNull;
accessLevel := TAccessLevel(ABuffer.ReadByte); accessLevel := TAccessLevel(ABuffer.ReadByte);
account := Accounts.Find(username); account := Config.Accounts.Find(username);
if account <> nil then if account <> nil then
begin begin
if password <> '' then if password <> '' then
@ -120,14 +121,16 @@ begin
CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muModified, account)); CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muModified, account));
end else end else
begin begin
account := TAccount.Create(username, MD5Print(MD5String(password)), accessLevel); account := TAccount.Create(Config.Accounts, username,
MD5Print(MD5String(password)), accessLevel);
if (username = '') or (Pos('=', username) > 0) then if (username = '') or (Pos('=', username) > 0) then
begin begin
CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muInvalidUsername, account)); CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muInvalidUsername, account));
account.Free; account.Free;
Exit; Exit;
end; end;
Accounts.Add(account); Config.Accounts.Add(account);
Config.Invalidate;
CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muAdded, account)); CEDServerInstance.SendPacket(ANetState, TModifyUserResponsePacket.Create(muAdded, account));
end; end;
end; end;
@ -140,10 +143,9 @@ var
netState: TNetState; netState: TNetState;
begin begin
username := ABuffer.ReadStringNull; username := ABuffer.ReadStringNull;
account := Accounts.Find(username); account := Config.Accounts.Find(username);
if (account <> nil) and (account <> ANetState.Account) then if (account <> nil) and (account <> ANetState.Account) then
begin begin
Config.DeleteKey('Accounts', username);
CEDServerInstance.TCPServer.IterReset; CEDServerInstance.TCPServer.IterReset;
while CEDServerInstance.TCPServer.IterNext do while CEDServerInstance.TCPServer.IterNext do
begin begin
@ -154,7 +156,8 @@ begin
netState.Account := nil; netState.Account := nil;
end; end;
end; end;
Accounts.Remove(account); Config.Accounts.Remove(account);
Config.Invalidate;
CEDServerInstance.SendPacket(ANetState, TDeleteUserResponsePacket.Create(duDeleted, username)); CEDServerInstance.SendPacket(ANetState, TDeleteUserResponsePacket.Create(duDeleted, username));
end else end else
CEDServerInstance.SendPacket(ANetState, TDeleteUserResponsePacket.Create(duNotFound, username)); CEDServerInstance.SendPacket(ANetState, TDeleteUserResponsePacket.Create(duNotFound, username));
@ -195,10 +198,10 @@ var
begin begin
inherited Create($03, 0); inherited Create($03, 0);
FStream.WriteByte($07); FStream.WriteByte($07);
FStream.WriteWord(Accounts.Count); FStream.WriteWord(Config.Accounts.Count);
for i := 0 to Accounts.Count - 1 do for i := 0 to Config.Accounts.Count - 1 do
begin begin
account := TAccount(Accounts.Items[i]); account := TAccount(Config.Accounts.Items[i]);
FStream.WriteStringNull(account.Name); FStream.WriteStringNull(account.Name);
FStream.WriteByte(Byte(account.AccessLevel)); FStream.WriteByte(Byte(account.AccessLevel));
end; end;

View File

@ -109,14 +109,9 @@ end;
constructor TCEDServer.Create; constructor TCEDServer.Create;
begin begin
inherited Create; inherited Create;
FLandscape := TLandscape.Create(Config.ReadString('Paths', 'map', 'map0.mul'), FLandscape := TLandscape.Create(Config.Map.MapFile, Config.Map.StaticsFile,
Config.ReadString('Paths', 'statics', 'statics0.mul'), Config.Map.StaIdxFile, Config.Tiledata, Config.Radarcol, Config.Map.Width,
Config.ReadString('Paths', 'staidx', 'staidx0.mul'), Config.Map.Height, FValid);
Config.ReadString('Paths', 'tiledata', 'tiledata.mul'),
Config.ReadString('Paths', 'radarcol', 'radarcol.mul'),
Config.ReadInteger('Parameters', 'Width', 0),
Config.ReadInteger('Parameters', 'Height', 0),
FValid);
FTCPServer := TLTcp.Create(nil); FTCPServer := TLTcp.Create(nil);
FTCPServer.OnAccept := @OnAccept; FTCPServer.OnAccept := @OnAccept;
FTCPServer.OnCanSend := @OnCanSend; FTCPServer.OnCanSend := @OnCanSend;
@ -295,7 +290,7 @@ begin
Exit; Exit;
end; end;
if FTCPServer.Listen(Config.ReadInteger('Network', 'Port', 2597)) then if FTCPServer.Listen(Config.Port) then
begin begin
repeat repeat
FTCPServer.CallAction; FTCPServer.CallAction;
@ -303,6 +298,7 @@ begin
if SecondsBetween(FLastFlush, Now) >= 60 then if SecondsBetween(FLastFlush, Now) >= 60 then
begin begin
FLandscape.Flush; FLandscape.Flush;
Config.Flush;
FLastFlush := Now; FLastFlush := Now;
end; end;
Sleep(1); Sleep(1);
@ -351,6 +347,7 @@ end;
initialization initialization
{$IFDEF Linux} {$IFDEF Linux}
FpSignal(SIGINT, @OnSigInt); FpSignal(SIGINT, @OnSigInt);
FpSignal(SIGTERM, @OnSigInt); //SIGTERM should shutdown the server cleanly too
//FpSignal(SIGSEGV, @OnSigSegv); //FpSignal(SIGSEGV, @OnSigSegv);
{$ENDIF} {$ENDIF}
{$IFDEF Windows} {$IFDEF Windows}

View File

@ -116,7 +116,7 @@ procedure OnGotoClientPosPacket(ABuffer: TEnhancedMemoryStream;
var var
account: TAccount; account: TAccount;
begin begin
account := Accounts.Find(ABuffer.ReadStringNull); account := Config.Accounts.Find(ABuffer.ReadStringNull);
if account <> nil then if account <> nil then
CEDServerInstance.SendPacket(ANetState, TSetClientPosPacket.Create(account.LastPos)); CEDServerInstance.SendPacket(ANetState, TSetClientPosPacket.Create(account.LastPos));
end; end;

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2008 Andreas Schneider
*) *)
unit UConfig; unit UConfig;
@ -30,22 +30,78 @@ unit UConfig;
interface interface
uses uses
Classes, SysUtils, IniFiles, md5, Keyboard, UAccount; Classes, SysUtils, DOM, XMLRead, XMLWrite, md5, Keyboard, UAccount,
UXmlHelper, UInterfaces, UEnums;
type
TInvalidConfigVersionExeption = class(Exception);
{ TMapInfo }
TMapInfo = class(TObject, ISerializable)
constructor Create(AOwner: IInvalidate);
constructor Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
procedure Serialize(AElement: TDOMElement);
protected
FOwner: IInvalidate;
FMapFile: string;
FStaticsFile: string;
FStaIdxFile: string;
FWidth: Word;
FHeight: Word;
procedure SetHeight(const AValue: Word);
procedure SetMapFile(const AValue: string);
procedure SetStaIdxFile(const AValue: string);
procedure SetStaticsFile(const AValue: string);
procedure SetWidth(const AValue: Word);
public
property MapFile: string read FMapFile write SetMapFile;
property StaticsFile: string read FStaticsFile write SetStaticsFile;
property StaIdxFile: string read FStaIdxFile write SetStaIdxFile;
property Width: Word read FWidth write SetWidth;
property Height: Word read FHeight write SetHeight;
end;
{ TConfig }
TConfig = class(TObject, ISerializable, IInvalidate)
constructor Create(AFilename: string);
constructor Init(AFilename: string);
destructor Destroy; override;
procedure Serialize(AElement: TDOMElement);
protected
FFilename: string;
FPort: Integer;
FMap: TMapInfo;
FTiledata: string;
FRadarcol: string;
FAccounts: TAccountList;
FChanged: Boolean;
procedure SetPort(const AValue: Integer);
procedure SetRadarcol(const AValue: string);
procedure SetTiledata(const AValue: string);
public
property Port: Integer read FPort write SetPort;
property Map: TMapInfo read FMap;
property Tiledata: string read FTiledata write SetTiledata;
property Radarcol: string read FRadarcol write SetRadarcol;
property Accounts: TAccountList read FAccounts;
procedure Flush;
procedure Invalidate;
end;
var var
AppDir: string; AppDir: string;
Config: TIniFile; ConfigFile: string;
Accounts: TAccountList; Config: TConfig;
procedure InitConfig;
function LoadConfig: Boolean;
function TimeStamp: string; function TimeStamp: string;
implementation implementation
const const
CONFIGVERSION = 2; CONFIGVERSION = 3;
function QueryPassword: String; function QueryPassword: String;
var var
@ -70,47 +126,139 @@ begin
writeln(''); writeln('');
end; end;
procedure InitConfig; function TimeStamp: string;
begin
Result := '[' + DateTimeToStr(Now) + '] ';
end;
{ TMapInfo }
constructor TMapInfo.Create(AOwner: IInvalidate);
begin
inherited Create;
FOwner := AOwner;
end;
constructor TMapInfo.Deserialize(AOwner: IInvalidate; AElement: TDOMElement);
begin
Create(AOwner);
FMapFile := TXmlHelper.ReadString(AElement, 'Map', 'map0.mul');
FStaIdxFile := TXmlHelper.ReadString(AElement, 'StaIdx', 'staidx0.mul');
FStaticsFile := TXmlHelper.ReadString(AElement, 'Statics', 'statics0.mul');
FWidth := TXmlHelper.ReadInteger(AElement, 'Width', 768);
FHeight := TXmlHelper.ReadInteger(AElement, 'Height', 512);
end;
procedure TMapInfo.Serialize(AElement: TDOMElement);
begin
TXmlHelper.WriteString(AElement, 'Map', FMapFile);
TXmlHelper.WriteString(AElement, 'StaIdx', FStaIdxFile);
TXmlHelper.WriteString(AElement, 'Statics', FStaticsFile);
TXmlHelper.WriteInteger(AElement, 'Width', FWidth);
TXmlHelper.WriteInteger(AElement, 'Height', FHeight);
end;
procedure TMapInfo.SetHeight(const AValue: Word);
begin
FHeight := AValue;
FOwner.Invalidate;
end;
procedure TMapInfo.SetMapFile(const AValue: string);
begin
FMapFile := AValue;
FOwner.Invalidate;
end;
procedure TMapInfo.SetStaIdxFile(const AValue: string);
begin
FStaIdxFile := AValue;
FOwner.Invalidate;
end;
procedure TMapInfo.SetStaticsFile(const AValue: string);
begin
FStaticsFile := AValue;
FOwner.Invalidate;
end;
procedure TMapInfo.SetWidth(const AValue: Word);
begin
FWidth := AValue;
FOwner.Invalidate;
end;
{ TConfig }
constructor TConfig.Create(AFilename: string);
var
xmlDoc: TXMLDocument;
version: Integer;
xmlElement: TDOMElement;
begin
inherited Create;
FFilename := AFilename;
ReadXMLFile(xmlDoc, AFilename);
if not ((xmlDoc.DocumentElement.NodeName = 'CEDConfig') and
TryStrToInt(xmlDoc.DocumentElement.AttribStrings['Version'], version) and
(version = CONFIGVERSION)) then
raise TInvalidConfigVersionExeption.Create(Format('%d <> %d', [version, CONFIGVERSION]));
FPort := TXmlHelper.ReadInteger(xmlDoc.DocumentElement, 'Port', 2597);
xmlElement := TDOMElement(xmlDoc.DocumentElement.FindNode('Map'));
if not assigned(xmlElement) then
raise TInvalidConfigVersionExeption.Create('Map information not found');
FMap := TMapInfo.Deserialize(Self, xmlElement);
FTiledata := TXmlHelper.ReadString(xmlDoc.DocumentElement, 'Tiledata', 'tiledata.mul');
FRadarcol := TXmlHelper.ReadString(xmlDoc.DocumentElement, 'Radarcol', 'radarcol.mul');
xmlElement := TDOMElement(xmlDoc.DocumentElement.FindNode('Accounts'));
if not assigned(xmlElement) then
raise TInvalidConfigVersionExeption.Create('Account information not found');
FAccounts := TAccountList.Deserialize(Self, xmlElement);
xmlDoc.Free;
FChanged := False;
end;
constructor TConfig.Init(AFilename: string);
var var
configFile: string;
stringValue, password: string; stringValue, password: string;
intValue: Integer; intValue: Integer;
begin begin
configFile := ChangeFileExt(ParamStr(0), '.ini'); inherited Create;
DeleteFile(configFile); FFilename := AFilename;
Config := TIniFile.Create(configFile); FMap := TMapInfo.Create(Self);
Config.WriteInteger('Config', 'Version', CONFIGVERSION); FAccounts := TAccountList.Create(Self);
Writeln('Configuring Network'); Writeln('Configuring Network');
Writeln('==================='); Writeln('===================');
Write ('Port [2597]: '); Write ('Port [2597]: ');
Readln (stringValue); Readln (stringValue);
if not TryStrToInt(stringValue, intValue) then intValue := 2597; if not TryStrToInt(stringValue, intValue) then intValue := 2597;
Config.WriteInteger('Network', 'Port', intValue); FPort := intValue;
Writeln(''); Writeln('');
Writeln('Configuring Paths'); Writeln('Configuring Paths');
Writeln('================='); Writeln('=================');
Write ('map [map0.mul]: '); Write ('map [map0.mul]: ');
Readln (stringValue); Readln (FMap.MapFile);
if stringValue = '' then stringValue := 'map0.mul'; if FMap.MapFile = '' then FMap.MapFile := 'map0.mul';
Config.WriteString('Paths', 'map', stringValue);
Write ('statics [statics0.mul]: '); Write ('statics [statics0.mul]: ');
Readln (stringValue); Readln (FMap.StaticsFile);
if stringValue = '' then stringValue := 'statics0.mul'; if FMap.StaticsFile = '' then FMap.StaticsFile := 'statics0.mul';
Config.WriteString('Paths', 'statics', stringValue);
Write ('staidx [staidx0.mul]: '); Write ('staidx [staidx0.mul]: ');
Readln (stringValue); Readln (FMap.StaIdxFile);
if stringValue = '' then stringValue := 'staidx0.mul'; if FMap.StaIdxFile = '' then FMap.StaIdxFile := 'staidx0.mul';
Config.WriteString('Paths', 'staidx', stringValue);
Write ('tiledata [tiledata.mul]: '); Write ('tiledata [tiledata.mul]: ');
Readln (stringValue); Readln (FTiledata);
if stringValue = '' then stringValue := 'tiledata.mul'; if FTiledata = '' then FTiledata := 'tiledata.mul';
Config.WriteString('Paths', 'tiledata', stringValue);
Write ('radarcol [radarcol.mul]: '); Write ('radarcol [radarcol.mul]: ');
Readln (stringValue); Readln (FRadarcol);
if stringValue = '' then stringValue := 'radarcol.mul'; if FRadarcol = '' then FRadarcol := 'radarcol.mul';
Config.WriteString('Paths', 'radarcol', stringValue);
Writeln(''); Writeln('');
Writeln('Parameters'); Writeln('Parameters');
@ -118,11 +266,11 @@ begin
Write ('Map width [768]: '); Write ('Map width [768]: ');
Readln (stringValue); Readln (stringValue);
if not TryStrToInt(stringValue, intValue) then intValue := 768; if not TryStrToInt(stringValue, intValue) then intValue := 768;
Config.WriteInteger('Parameters', 'Width', intValue); FMap.Width := intValue;
Write ('Map height [512]: '); Write ('Map height [512]: ');
Readln (stringValue); Readln (stringValue);
if not TryStrToInt(stringValue, intValue) then intValue := 512; if not TryStrToInt(stringValue, intValue) then intValue := 512;
Config.WriteInteger('Parameters', 'Height', intValue); FMap.Height := intValue;
Writeln(''); Writeln('');
Writeln('Admin account'); Writeln('Admin account');
@ -133,36 +281,65 @@ begin
until stringValue <> ''; until stringValue <> '';
Write ('Password [hidden]: '); Write ('Password [hidden]: ');
password := QueryPassword; password := QueryPassword;
Config.WriteString('Accounts', stringValue, '255:' + MD5Print(MD5String(password))); FAccounts.Add(TAccount.Create(FAccounts, stringValue,
MD5Print(MD5String(password)), alAdministrator));
FChanged := True;
end; end;
function LoadConfig: Boolean; destructor TConfig.Destroy;
begin
if Assigned(FMap) then FreeAndNil(FMap);
if Assigned(FAccounts) then FreeAndNil(FAccounts);
inherited Destroy;
end;
procedure TConfig.Serialize(AElement: TDOMElement);
begin
TXmlHelper.WriteInteger(AElement, 'Port', FPort);
FMap.Serialize(TXmlHelper.AssureElement(AElement, 'Map'));
TXmlHelper.WriteString(AElement, 'Tiledata', FTiledata);
TXmlHelper.WriteString(AElement, 'Radarcol', FRadarcol);
FAccounts.Serialize(TXmlHelper.AssureElement(AElement, 'Accounts'));
end;
procedure TConfig.SetPort(const AValue: Integer);
begin
FPort := AValue;
Invalidate;
end;
procedure TConfig.SetRadarcol(const AValue: string);
begin
FRadarcol := AValue;
Invalidate;
end;
procedure TConfig.SetTiledata(const AValue: string);
begin
FTiledata := AValue;
Invalidate;
end;
procedure TConfig.Flush;
var var
configFile: string; xmlDoc: TXMLDocument;
values: TStringList;
i: Integer;
begin begin
configFile := ChangeFileExt(ParamStr(0), '.ini'); if FChanged then
if FileExists(configFile) then
begin begin
Config := TIniFile.Create(configFile); xmlDoc := TXMLDocument.Create;
Result := (Config.ReadInteger('Config', 'Version', 0) = CONFIGVERSION); xmlDoc.AppendChild(xmlDoc.CreateElement('CEDConfig'));
if Result then xmlDoc.DocumentElement.AttribStrings['Version'] := IntToStr(CONFIGVERSION);
begin Serialize(xmlDoc.DocumentElement);
Accounts := TAccountList.Create; WriteXMLFile(xmlDoc, FFilename);
values := TStringList.Create; xmlDoc.Free;
Config.ReadSectionRaw('Accounts', values); FChanged := False;
for i := 0 to values.Count - 1 do end;
Accounts.Add(TAccount.Create(values.Strings[i]));
values.Free;
end;
end else
Result := False;
end; end;
function TimeStamp: string; procedure TConfig.Invalidate;
begin begin
Result := '[' + DateTimeToStr(Now) + '] '; FChanged := True;
end; end;
initialization initialization
@ -170,12 +347,10 @@ begin
AppDir := ExtractFilePath(ParamStr(0)); AppDir := ExtractFilePath(ParamStr(0));
if AppDir[Length(AppDir)] <> PathDelim then if AppDir[Length(AppDir)] <> PathDelim then
AppDir := AppDir + PathDelim; AppDir := AppDir + PathDelim;
end;
finalization {TODO : add command line parameter to specify the config}
begin Config := nil;
if Config <> nil then FreeAndNil(Config); ConfigFile := ChangeFileExt(ParamStr(0), '.xml');
if Accounts <> nil then FreeAndNil(Accounts);
end; end;
end. end.

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2008 Andreas Schneider
*) *)
unit UConnectionHandling; unit UConnectionHandling;
@ -85,7 +85,7 @@ var
begin begin
username := ABuffer.ReadStringNull; username := ABuffer.ReadStringNull;
passwordHash := MD5Print(MD5String(ABuffer.ReadStringNull)); passwordHash := MD5Print(MD5String(ABuffer.ReadStringNull));
account := Accounts.Find(username); account := Config.Accounts.Find(username);
if account <> nil then if account <> nil then
begin begin
if account.AccessLevel > alNone then if account.AccessLevel > alNone then
@ -120,16 +120,19 @@ begin
end; end;
end else end else
begin begin
Writeln(TimeStamp, 'Invalid password for ', username);
CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsInvalidPassword)); CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsInvalidPassword));
CEDServerInstance.Disconnect(ANetState.Socket); CEDServerInstance.Disconnect(ANetState.Socket);
end; end;
end else end else
begin begin
Writeln(TimeStamp, 'Access denied for ', username);
CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsNoAccess)); CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsNoAccess));
CEDServerInstance.Disconnect(ANetState.Socket); CEDServerInstance.Disconnect(ANetState.Socket);
end; end;
end else end else
begin begin
Writeln(TimeStamp, 'Invalid account specified: ', ANetState.Socket.PeerAddress);
CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsInvalidUser)); CEDServerInstance.SendPacket(ANetState, TLoginResponsePacket.Create(lsInvalidUser));
CEDServerInstance.Disconnect(ANetState.Socket); CEDServerInstance.Disconnect(ANetState.Socket);
end; end;
@ -160,8 +163,8 @@ begin
if AState = lsOK then if AState = lsOK then
begin begin
FStream.WriteByte(Byte(AAccessLevel)); FStream.WriteByte(Byte(AAccessLevel));
FStream.WriteWord(Config.ReadInteger('Parameters', 'Width', 768)); FStream.WriteWord(Config.Map.Width);
FStream.WriteWord(Config.ReadInteger('Parameters', 'Height', 512)); FStream.WriteWord(Config.Map.Height);
end; end;
end; end;

View File

@ -30,7 +30,7 @@ unit ULandscape;
interface interface
uses uses
SysUtils, Classes, contnrs, UGenericIndex, UMap, UStatics, UTileData, SysUtils, Classes, contnrs, UGenericIndex, UMap, UStatics, UTiledata,
UWorldItem, UMulBlock, math, UWorldItem, UMulBlock, math,
UTileDataProvider, URadarMap, UTileDataProvider, URadarMap,
UListSort, UCacheManager, ULinkedList, UBufferedStreams, UListSort, UCacheManager, ULinkedList, UBufferedStreams,

View File

@ -14,7 +14,6 @@
</VersionInfo> </VersionInfo>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
@ -29,7 +28,7 @@
<PackageName Value="lnetbase"/> <PackageName Value="lnetbase"/>
</Item1> </Item1>
</RequiredPackages> </RequiredPackages>
<Units Count="8"> <Units Count="9">
<Unit0> <Unit0>
<Filename Value="cedserver.lpr"/> <Filename Value="cedserver.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -70,6 +69,11 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ULargeScaleOperations"/> <UnitName Value="ULargeScaleOperations"/>
</Unit7> </Unit7>
<Unit8>
<Filename Value="../UInterfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="UInterfaces"/>
</Unit8>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
@ -89,7 +93,7 @@
<Optimizations> <Optimizations>
<OptimizationLevel Value="3"/> <OptimizationLevel Value="3"/>
</Optimizations> </Optimizations>
<TargetOS Value="Win32"/> <TargetOS Value="Linux"/>
</CodeGeneration> </CodeGeneration>
<Linking> <Linking>
<Debugging> <Debugging>

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2007 Andreas Schneider * Portions Copyright 2008 Andreas Schneider
*) *)
program cedserver; program cedserver;
@ -44,20 +44,16 @@ begin
Writeln(''); Writeln('');
{$IFDEF Windows} {$IFDEF Windows}
if not LoadConfig then if FileExists(ConfigFile) then
begin Config := TConfig.Create(ConfigFile)
InitConfig; else
Writeln(''); Config := TConfig.Init(ConfigFile);
end;
{$ELSE} {$ELSE}
if ParamStr(1) = '--init' then if ParamStr(1) = '--init' then
begin Config := TConfig.Init(ConfigFile)
InitConfig; else if FileExists(ConfigFile) then
Halt; Config := TConfig.Create(ConfigFile)
end; else begin
if not LoadConfig then
begin
Writeln('No valid config file was found. Use --init to create one.'); Writeln('No valid config file was found. Use --init to create one.');
Halt; Halt;
end; end;
@ -69,7 +65,9 @@ begin
Writeln('Done'); Writeln('Done');
CEDServerInstance.Run; CEDServerInstance.Run;
Write(TimeStamp, 'Terminating ... '); Write(TimeStamp, 'Terminating ... ');
CEDServerInstance.Free; FreeAndNil(CEDServerInstance);
Config.Flush;
FreeAndNil(Config);
Writeln('Done'); Writeln('Done');
end. end.

View File

@ -1,75 +0,0 @@
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2007 Andreas Schneider
*)
{This unit contains the interface for objects which offer read/write access and
therefore streaming capability.
@author(Andreas Schneider <aksdb@gmx.de>)
@created(2007-07-08)
@lastmod(2007-11-14)}
unit UIStream;
{$mode objfpc}{$H+}
{$interfaces corba}
interface
uses
Classes;
type
{@abstract(The @name interface is used in objects which offer read/write access and
therefore streaming capability.)}
IStream = interface
function ReadBoolean: Boolean; //<Reads a @link(Boolean) at the current position. @returns(The @link(Boolean) at the current position.)
function ReadByte: Byte; //<Reads a @link(Byte) at the current position. @returns(The @link(Byte) at the current position.)
function ReadCardinal: Cardinal; //<Reads a @link(Cardinal) at the current position. @returns(The @link(Cardinal) at the current position.)
function ReadInteger: Integer; //<Reads a @link(Integer) at the current position. @returns(The @link(Integer) at the current position.)
function ReadInt64: Int64; //<Reads a @link(Int64) at the current position. @returns(The @link(Int64) at the current position.)
function ReadSmallInt: SmallInt; //<Reads a @link(SmallInt) at the current position. @returns(The @link(SmallInt) at the current position.)
function ReadWord: Word; //<Reads a @link(Word) at the current position. @returns(The @link(Word) at the current position.)
function ReadString: string; //<Reads a @link(String) at the current position, by first querying the size (read as @link(Integer)). @returns(The @link(String) at the current position.)
function ReadStringFixed(ALength: Integer): string; //<Reads a @link(String) at the current position with the given length. @param(ALength The length of the @link(String) to be read.) @returns(The @link(String) at the current position.)
procedure WriteBoolean(AValue: Boolean); //<Writes a @link(Boolean) to the current position. @param(AValue The @link(Boolean) value to be written.)
procedure WriteByte(AValue: Byte); //<Writes a @link(Byte) to the current position. @param(AValue The @link(Byte) value to be written.)
procedure WriteCardinal(AValue: Cardinal); //<Writes a @link(Cardinal) to the current position. @param(AValue The @link(Cardinal) value to be written.)
procedure WriteInteger(AValue: Integer); //<Writes a @link(Integer) to the current position. @param(AValue The @link(Integer) value to be written.)
procedure WriteInt64(AValue: Int64); //<Writes a @link(Int64) to the current position. @param(AValue The @link(Int64) value to be written.)
procedure WriteSmallInt(AValue: SmallInt); //<Writes a @link(SmallInt) to the current position. @param(AValue The @link(SmallInt) value to be written.)
procedure WriteWord(AValue: Word); //<Writes a @link(Word) to the current position. @param(AValue The @link(Word) value to be written.)
procedure WriteString(AValue: string); //<Writes a @link(String) to the current position, preceeded by the length as @link(Integer). @param(AValue The @link(String) value to be written.)
procedure WriteStringFixed(AValue: string; ALength: Integer); //<Writes a @link(String) with the given length to the current position. @param(AValue The @link(String) value to be written.) @param(ALength The length of the @link(String).)
function Read(ABuffer: PByte; ACount: Cardinal): Cardinal; //<Reads a given number of bytes from the stream. @param(ABuffer A Pointer to the memory to write to.) @param(ACount The number of bytes to read.) @returns(The number of bytes actually read.)
function Write(ABuffer: PByte; ACount: Cardinal): Cardinal; //<Writes a given buffer to the stream. @param(ABuffer A Pointer to the memory to write to the stream.) @param(ACount The number of bytes to write.) @returns(The number of bytes actually written.)
procedure Skip(ACount: Cardinal); //<Skips a certain number of bytes from the current position. @param(ACount The number of bytes to skip.)
end;
implementation
end.

47
UInterfaces.pas Normal file
View File

@ -0,0 +1,47 @@
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
*)
unit UInterfaces;
{$mode objfpc}{$H+}
{$interfaces corba}
interface
uses
Classes, SysUtils, DOM;
type
ISerializable = interface
procedure Serialize(AElement: TDOMElement);
end;
IInvalidate = interface
procedure Invalidate;
end;
implementation
end.

View File

@ -43,7 +43,7 @@ unit UStreamHelper;
interface interface
uses uses
Classes, RtlConsts, SysUtils, UIStream; Classes, RtlConsts, SysUtils;
type type
{@name is the stub for the method which will handle the OnProgress callbacks. {@name is the stub for the method which will handle the OnProgress callbacks.
@ -94,7 +94,7 @@ type
//generic TStreamWrapper<TStreamType> = class(TObject{, IStream}) //generic TStreamWrapper<TStreamType> = class(TObject{, IStream})
{@abstract(@name implements @link(IStream) and offers a bunch of functions to {@abstract(@name implements @link(IStream) and offers a bunch of functions to
ease reading and writing special types (like @link(Integer)s or @link(String)s.))} ease reading and writing special types (like @link(Integer)s or @link(String)s.))}
TStreamWrapper = class(TObject, IStream) TStreamWrapper = class(TObject)
constructor Create(AStream: TStreamType; AOwnsStream: Boolean = True); //<Creates a new instance of @classname. @param(AStream The underlying stream to perform the actual operations on.) @param(AOwnsStream Defines wheather to free the stream on destruction of @classname or not. Defaults to @false.) constructor Create(AStream: TStreamType; AOwnsStream: Boolean = True); //<Creates a new instance of @classname. @param(AStream The underlying stream to perform the actual operations on.) @param(AOwnsStream Defines wheather to free the stream on destruction of @classname or not. Defaults to @false.)
destructor Destroy; override; //<Is called when the current instance of @classname is destroyed. If it owns the underlying stream it is destroyed aswell. destructor Destroy; override; //<Is called when the current instance of @classname is destroyed. If it owns the underlying stream it is destroyed aswell.
protected protected

140
UXmlHelper.pas Normal file
View File

@ -0,0 +1,140 @@
(*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* http://www.opensource.org/licenses/cddl1.php.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* http://www.opensource.org/licenses/cddl1.php. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying * information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2008 Andreas Schneider
*)
unit UXmlHelper;
{$mode delphi}{$H+}
interface
uses
Classes, SysUtils, dom;
type
{ TXmlHelper }
TXmlHelper = class(TObject)
class function AssureElement(AParent: TDOMElement; AName: string): TDOMElement;
class procedure WriteString(AParent: TDOMElement; AName, AValue: string);
class function ReadString(AParent: TDOMElement; AName, ADefault: string): string;
class procedure WriteInteger(AParent: TDOMElement; AName: string; AValue: Integer);
class function ReadInteger(AParent: TDOMElement; AName: string; ADefault: Integer): Integer;
class procedure WriteBoolean(AParent: TDOMElement; AName: string; AValue: Boolean);
class function ReadBoolean(AParent: TDOMElement; AName: string; ADefault: Boolean): Boolean;
class procedure WriteCoords(AParent: TDOMElement; AName: string; AX, AY: Integer);
class function ReadCoords(AParent: TDOMElement; AName: string; out X, Y: Integer): Boolean;
end;
implementation
{ TXmlHelper }
class function TXmlHelper.AssureElement(AParent: TDOMElement; AName: string): TDOMElement;
begin
Result := TDOMElement(AParent.FindNode(AName));
if not assigned(Result) then
begin
Result := AParent.OwnerDocument.CreateElement(AName);
AParent.AppendChild(Result);
end;
end;
class procedure TXmlHelper.WriteString(AParent: TDOMElement; AName, AValue: string);
var
element: TDOMElement;
begin
element := AssureElement(AParent, AName);
if assigned(element.FirstChild) then
TDOMText(element.FirstChild).NodeValue := AValue
else
element.AppendChild(AParent.OwnerDocument.CreateTextNode(AValue));
end;
class function TXmlHelper.ReadString(AParent: TDOMElement; AName, ADefault: string): string;
var
element: TDOMElement;
begin
element := TDOMElement(AParent.FindNode(AName));
if assigned(element) and assigned(element.FirstChild) then
Result := TDOMText(element.FirstChild).Data
else
Result := ADefault;
end;
class procedure TXmlHelper.WriteInteger(AParent: TDOMElement; AName: string;
AValue: Integer);
begin
WriteString(AParent, AName, IntToStr(AValue));
end;
class function TXmlHelper.ReadInteger(AParent: TDOMElement; AName: string;
ADefault: Integer): Integer;
begin
if not TryStrToInt(ReadString(AParent, AName, ''), Result) then
Result := ADefault;
end;
class procedure TXmlHelper.WriteBoolean(AParent: TDOMElement; AName: string;
AValue: Boolean);
begin
WriteString(AParent, AName, BoolToStr(AValue));
end;
class function TXmlHelper.ReadBoolean(AParent: TDOMElement; AName: string;
ADefault: Boolean): Boolean;
begin
Result := StrToBool(ReadString(AParent, AName, BoolToStr(ADefault)));
end;
class procedure TXmlHelper.WriteCoords(AParent: TDOMElement; AName: string; AX,
AY: Integer);
var
element: TDOMElement;
begin
element := AssureElement(AParent, AName);
element.AttribStrings['x'] := IntToStr(AX);
element.AttribStrings['y'] := IntToStr(AY);
end;
class function TXmlHelper.ReadCoords(AParent: TDOMElement; AName: string; out
X, Y: Integer): Boolean;
var
element: TDOMElement;
tempX, tempY: Integer;
begin
element := TDOMElement(AParent.FindNode(AName));
Result := assigned(element) and TryStrToInt(element.AttribStrings['x'], tempX)
and TryStrToInt(element.AttribStrings['y'], tempY);
if Result then
begin
X := tempX;
Y := tempY;
end;
end;
end.