Autor Beitrag
Novo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Mo 28.05.07 17:04 
Wie kann ich bestimmte Infos aus einer Datei mangosd.conf laden und ändern?
z.B.

Max. Level 70 auslesen, auf 80 ändern

bildupload.sro.at/a/.../2-Novo%20Update.JPG
hier das Bildteil rechts oben!
^^


-------------------------------
PS: zu dem gecloseden Thread
www.delphi-forum.de/viewtopic.php?p=442543

-> Der Mangos WoW Emulator ist NICHT Illegal, er ist Open Source!
Die SQL Datenbank mit den Game Inhalten ist illegal, diese vertreibe ich aber nicht,
sondern ich Mache nur eien GUI für den mangos Consolen Emulator.
-------------------------------

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
# MaNGOS Configuration file
ConfVersion=2006082301

# RealmID must match the realmlist
RealmID = 1

# 0 NORMAL 1 PVP 4 NORMAL 6 RP 8 RPPVP
GameType = 1

# Data directory setting.
# Important: DataDir needs to be quoted, as it is a string which may
# contain space characters.
DataDir = "data"

# Database connection settings for the world server.
# Default: hostname;port;username;password;database
#          .;somenumber;username;password;database - use named pipes at Windows
#                Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini
#          .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux
#                Unix sockets: experimental, not tested
LoginDatabaseInfo = "127.0.0.1;3306;root;mangos;realmd"
WorldDatabaseInfo = "127.0.0.1;3306;root;mangos;mangos"

# Settings for maximum database-ping interval (minutes between pings)
MaxPingTime = 30

# Enable logging of GM commands - all SQL code will be written to a log file
# All commands are written to a file: YYYY-MM-DD_logSQL.sql
# If a new day starts (00:00:00) then a new file is created - the old
# file will not be deleted.
# 0 - Do not log
# 1 - Write SQL code to logfile
LogSQL = 1

# Server console level of logging
# 0 = Minimum; 1 = Basic&Error; 2 = Detail; 3 = Full/Debug
# Default: 0
# recommend: 1
LogLevel = 3

# Logfile name
#    empty name disable creating log file: LogFile = 
# Default: ""
LogFile = "Logs/Server.log"

# Server file level of logging
# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug
# Default: 0
LogFileLevel = 1

# Packet logging for the worldserver
# Default: 0 (false)
#          1 (true)
LogWorld = 0

# Log filters
# 0 (default) - include in log if log level permit, 1 - not include with any log level
LogFilter_TransportMoves = 1
LogFilter_CreatureMoves = 1

# Color for messages (format "normal_color details_color debug_color error_color)
# Colors: 0 - BLACK, 1 - RED, 2 - GREEN,  3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 -  CYAN, 7 - GREY, 
#         8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE
# Default: "" - none colors
#          "13 7 11 9" - for example :)
LogColors = "13 7 11 1"

# Log file of DB errors detected at server run.
# Default: ""
DBErrorLogFile = "Logs/DBErrors.log"

# Log file of gm commands
# Default: "" (Disable)
GmLogFile = "Logs/GMLog.log"

# Used processors mask for multi-processors system (Used only at Windows)
# Default: 0 (selected by OS)
#          number (bitmask value of selected processors)
UseProcessors = 0

# Process proirity setting (Used only at Windows)
#          0 (Normal)
# Default: 1 (HIGH)
ProcessPriority = 1

# Compression level for update packages sended to client (1..9)
# Default: 1 (speed) 
#          9 (best compression) 
Compression = 2

# Maximum number of players in the world. Excluding GM's
# Default: 100
PlayerLimit = 100

# Max level that can reached by player for expirience (in range from 1 to 255).
# Change not recommended
# Default: 60
MaxPlayerLevel = 70

# Activate weather system
# Default: 1 (true)
#          0 (false)
ActivateWeather = 1

# Ignore level requirement to enter instance
#      1 (true)
# Default: 0 (false)
IgnoreATLevelRequirement = 0

# Max count that player can learn the primary trade skill.
# Default: 2
# Max : 9 
MaxPrimaryTradeSkill = 2 

# Min signatures count to creating guild (0..9).
# Default: 9
MinPetitionSigns = 9 

# Max distance to creature for group memeber to get XP at creature death.
# Default: 74
MaxGroupXPDistance = 74

# Max level different with creature for group member to get XP at creature death.
# Default: 10
MaxGroupXPLevelDiff = 10

# Allow or not accounts to create characters in the 2 teams in any game type.
# Defaullt: 0 (Not allowed)
#           1 (Allowed)
AllowTwoSide.Accounts = 1

# Allow or not common :chat(say,yell);channel(chat)group(join)guild(join);trade for players from different teams.
# Defaullt: 0 (Not allowed)
#           1 (Allowed)
AllowTwoSide.Interaction.Chat = 1
AllowTwoSide.Interaction.Channel = 1
AllowTwoSide.Interaction.Group = 1
AllowTwoSide.Interaction.Guild = 1
AllowTwoSide.Interaction.Trade = 1

# Allow or not show player from both team in who list.
# Defaullt: 0 (Not allowed)
#           1 (Allowed)
AllowTwoSide.WhoList = 1

# Is GM accept whispers from player by default.
# Default: 0 (false)
#          1 (true) 
GM.WhisperingTo = 1

# Is GM showed in GM list (if visible) in non-GM state (.gmoff)
# Default: 0 (false)
#          1 (true) 
GM.InGMList = 1

# Is GM showed in who list (if visible).
# Default: 0 (false)
#          1 (true) 
GM.InWhoList = 1

# GM mode at login
#          0 (disable)
#          1 (enable) 
# Default: 2 (last save state)
GM.LoginState = 2

# Include GM trade and trade slot enchanting operations in GM log if it enable
#          0 (not include)
# Default: 1 (include)
GM.LogTrade = 1

# Group visibility modes
# Default: 0 (standard setting: only members from same group can 100% auto detect invisible player)
#          1 (raid members 100% auto detect invisible player from same raid)
#          2 (players from same team can 100% auto detect invisible player)
GroupVisibility = 0

# Mail delivery delay time in case sending item
# Default: 3600 sec (1 hour)
MailDeliveryDelay = 3600

# Message of the Day. Displayed at worldlogin for every user ('@' for a newline).
Motd = "Wilkommen zu Novos Mangos..."

# Health and power regeneration.
# Power1 - Mana; Power2 - Rage; Power3 - Focus (?).
Rate.Health = 3;
Rate.Power1 = 3;
Rate.Power2 = 3;
Rate.Power3 = 3;
Rate.Loyalty= 3;

# Drop rates
# Default: 1
Rate.Drop.Items = 6
Rate.Drop.Money = 6

# XP rates
# Default: 1
Rate.XP.Kill    = 9
Rate.XP.Quest   = 9
Rate.XP.Explore = 6

# Creature Damage Rate.
# Examples: 2 - creatures will damage 2x, 1.7 - 1.7x.
Rate.Creature.Normal.Damage = 1
Rate.Creature.Elite.Elite.Damage = 1
Rate.Creature.Elite.RAREELITE.Damage = 1
Rate.Creature.Elite.WORLDBOSS.Damage = 1
Rate.Creature.Elite.RARE.Damage = 1

# Creature Health Ammount Modifier.
# Examples: 2 - creatures have 2x health, 1.7 - 1.7x.
Rate.Creature.Normal.HP = 1
Rate.Creature.Elite.Elite.HP = 1
Rate.Creature.Elite.RAREELITE.HP = 1
Rate.Creature.Elite.WORLDBOSS.HP = 1
Rate.Creature.Elite.RARE.HP = 1

# Resting points grow rates (1 - normal, 2 - double rate, 0.5 - half rate, etc) from standard values
Rate.Rest.InGame = 1
Rate.Rest.Offline.InTavernOrCity = 1
Rate.Rest.Offline.InWilderness = 1

# Damage after fall rate. (1 - standard, 2 - double damage, 0.5 - half damage, etc)
Rate.Damage.Fall = 1

# Auction rates (auction time, deposit get at auction start, auction cut from price at auction end)
Rate.Auction.Time = 1
Rate.Auction.Deposit = 1
Rate.Auction.Cut = 1

# Mining Rates (Mining.Amount changes minimum/maximum usetimes of a deposit, Mining.Next changes chance to have next use of a deposit)
Rate.Mining.Amount = 1
Rate.Mining.Next   = 1

# Save respawn time for creatures at death, for gameobjects at use/open
#          0 (save creature/gameobject respawn time at grid unload)
# Default: 1 (save creature/gameobject respawn time without waiting grid unload)
SaveRespawnTimeImmediately = 1

# Skill chance values (0..100) 
# default: 100-75-25-0
SkillChance.Orange = 100
SkillChance.Yellow = 75
SkillChance.Green  = 25
SkillChance.Grey   = 0

#Aggro radius percent or off.
#          0   - off (0%)
# Default: 1   - 100% 
#          1.5 - 150%
Rate.Creature.Aggro = 1

# Enable console
#          0 - off
# Default: 1 - on
Console.Enable = 1

# Enable remote console
# Default: 0 - off
Ra.Enable = 0

# Default remote console port
Ra.Port = 3443

# Log remote console connections
Ra.Log = 1

# Minimum level that's required to login,3 by default
Ra.MinLevel = 3

# Kick client on wrong pass
Ra.Secure = 1

# Maximum overspeed ping count before player kick (minimum is 2, 0 used for disable check)
# Default: 2
MaxOverspeedPings = 2

# Unload grids (if you have lot memory you can disbale it to speed up player move to new grids second time)
#          0 (not unload grids)
# Default: 1 (unload grids)
GridUnload = 1;

# All times are in milliseconds.

# Default socket select time
SocketSelectTime = 10000

# Default grid clean up delay
GridCleanUpDelay = 300000

# Default map update interval
MapUpdateInterval = 100

# Default weather update interval
ChangeWeatherInterval = 600000

# Default PlayerSaveInterval
PlayerSaveInterval = 900000

# Default WorldServerPort
WorldServerPort = 8085

# Beep at mangosd start finished (mostly work only at Unix/Linux systems)
# Default: 1 
BeepAtStart = 1


# Auction House Bot

AuctionHouseBot.Account = 0

AuctionHouseBot.GUID = 0

AuctionHouseBot.AllianceItems = 0

AuctionHouseBot.HordeItems = 0

AuctionHouseBot.NeutralItems = 0

AuctionHouseBot.MinTime = 8

AuctionHouseBot.MaxTime = 24

AuctionHouseBot.PercentWhiteTradeGoods = 25

AuctionHouseBot.PercentGreenTradeGoods = 13

AuctionHouseBot.PercentBlueTradeGoods = 8

AuctionHouseBot.PercentPurpleTradeGoods = 4

AuctionHouseBot.PercentWhiteItems = 5

AuctionHouseBot.PercentGreenItems = 25

AuctionHouseBot.PercentBlueItems = 15

AuctionHouseBot.PercentPurpleItems = 5

AuctionHouseBot.MinPriceWhite = 150

AuctionHouseBot.MaxPriceWhite = 250

AuctionHouseBot.BidPriceWhite = 100

AuctionHouseBot.MinPriceGreen = 200

AuctionHouseBot.MaxPriceGreen = 300

AuctionHouseBot.BidPriceGreen = 100

AuctionHouseBot.MinPriceBlue = 250

AuctionHouseBot.MaxPriceBlue = 350

AuctionHouseBot.BidPriceBlue = 100

AuctionHouseBot.MinPricePurple = 300

AuctionHouseBot.MaxPricePurple = 450

AuctionHouseBot.BidPricePurple = 100

# Enable/Disable VMmap support for line of Sofgt and height calculation
# Default: 1 (true)
#        : 0 (false)
vmap.enableLOS = 0
vmap.enableHeight = 0
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Di 29.05.07 07:25 
Eine Möglichkeit wäre das Laden und Speichern mit Hilfe einer StringList:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var s : TStringList;
    i : Integer;
begin
  s := TStringList.Create; //StringList erzeugen und initialisieren
  s.LoadFromFile('c\mangosd.conf'); //oder in welchem Pfad auch immer ide Datei steht
  for i := 0 to s.Count -1 do if pos('MaxPlayerLevel =',s[i]) = 1 then s[i] := 'MaxPlayerLevel = 80';
  s.SaveToFile('c\mangosd.conf'); //oder in welchem Pfad auch immer ide Datei steht
  s . Free;
end;

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Di 29.05.07 07:43 
Eventuell kannst du auch mit den Names und Values aus der Stringliste arbeiten, ich weiss nciht genau, ob die mit den Leerzeichen klarkommt. Ansonsten würd ich mir ne eigene Klasse bauen, die die Datei einliest und die Werte in nem assiozativen Array mit dem Tokenname als Index speichert.

Nebenbei bemerkt: OpenSource ist nicht das Gegenteil von illegal, auch OS-Projekte können illegal sein. Das Sphere-Projekt (Ultima Online - Server) wurde damals nur deshalb nicht endgültig juristisch angegangen, weil Origin die Kosten und den Imageverlust fürchtete. Das sehe ich bei Blizzard (noch) nicht.

_________________
Bravery calls my name in the sound of the wind in the night...
Clemens L.
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 158

Win Xp SP3
D6 Enterprise, Turbo Delphi Explorer
BeitragVerfasst: Di 29.05.07 08:59 
Zitat:

-> Der Mangos WoW Emulator ist NICHT Illegal, er ist Open Source!
Die SQL Datenbank mit den Game Inhalten ist illegal, diese vertreibe ich aber nicht,
sondern ich Mache nur eien GUI für den mangos Consolen Emulator.


MaNGOS ist illegal, und nicht nur die SQL-Datenbank. Der Emulator benutzt ja sogar aus dem Spiel extrahierte und urheberrechtlich geschützte Dateien. Und es mussten auch schon Betreiber von WoW-Emulatoren Strafen an Blizzard zahlen.
Novo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Di 29.05.07 13:25 
Zitat:

user profile iconhackerTreff
MaNGOS ist illegal, und nicht nur die SQL-Datenbank. Der Emulator benutzt ja sogar aus dem Spiel extrahierte und urheberrechtlich geschützte Dateien. Und es mussten auch schon Betreiber von WoW-Emulatoren Strafen an Blizzard zahlen.


Stimmt nicht.
ich beschäftige mich mit WoW Emulatoren schon lange genug.
Mangos ist frei mit C++ programmiert und benutzt keine aus dem Spiel extrahierten Code!
Mangos ist frei selbst programmiert.
Nur die Datenbank wird erstellt, indem man Datenpakete abfängt aus dem Game.



greez Novo
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Di 29.05.07 13:45 
Ob legal oder nicht kann letzten Endes nur ein Gericht klären.
Fakt ist jedoch, dass die Nutzungsbestimmungen von WoW die Verwendung mit anderen als Blizzards offiziellen Servern ausschliessen. Von daher mag die Verbreitung des Servers zwar legal sein, die Benutzung als WoW-Spielserver verstösst aber auf jeden Fall gegen die WoW-Lizenz.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Di 29.05.07 14:38 
Siehe : www.delphi-forum.de/viewtopic.php?t=73187



Wenn ich das richtig verstanden habe, hast Du noch ein Problem mit meiner Lösung (siehe oben).

Was genau hast Du nicht verstanden ? (Eigentlich brauchst Du doch nur noch den Pfad anpassen)

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
Novo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Di 29.05.07 14:54 
Nun, erklär mal ,was der code da macht, ich checks nicht.

Wie kann ich das so erweitern, dass ich die MaxPlayerLevel =
mit einem Editierfeld einstellen kann?

So meine ich es:
bildupload.sro.at/a/.../2-Novo%20Update.JPG

Ich hab das jetzt so, aber es geht nicht.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm2.btnConfigOkClick(Sender: TObject);
var s : TStringList;
    i : Integer;
    z : integer;
begin
edit1.Text := IntToStr (z);
  s := TStringList.Create; //StringList erzeugen und initialisieren
  s.LoadFromFile('mangosd.conf');
   for i := 0 to s.Count -1 do
    if pos('MaxPlayerLevel =',s[i]) = 1
    then s[i] := 'MaxPlayerLevel =' + StrToInt (z);
  s.SaveToFile('mangosd.conf');
  s . Free;
end;


So geht es auch nicht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm2.btnConfigOkClick(Sender: TObject);
var s : TStringList;
    i : Integer;
    z : string;
begin
edit1.Text := z;
  s := TStringList.Create; //StringList erzeugen und initialisieren
  s.LoadFromFile('mangosd.conf');
   for i := 0 to s.Count -1 do
    if pos('MaxPlayerLevel =',s[i]) = 1
    then s[i] := 'MaxPlayerLevel =' + z;
  s.SaveToFile('mangosd.conf');
  s . Free;
end;



greez Novo
Novo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Di 29.05.07 18:36 
help me please, ganz kurz noch ^^



danke
Novo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Di 29.05.07 19:47 
Kommt schon, habe alle meine Fragen bezüglich dieses Projektes beantwortet bekommen oder selbst beantwortet.
Dies ist die letzte noch unbeantwortete frage!
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Mi 30.05.07 06:38 
Also,

1. Um sicher zu stellen, dass nur Zahlen eingegeben werden:
im OnKeyPress Event des Editfeldes (ich gehe von Edit1 als Name aus) folgendes eintragen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not Key in ['0'..'9',#8] then Key := #0;
end;


und im OnClick Event des Button
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm2.btnConfigOkClick(Sender: TObject);
var s : TStringList;
    i : Integer;
    z : integer;
begin
  s := TStringList.Create; //StringList erzeugen und initialisieren
  s.LoadFromFile('mangosd.conf');
  for i := 0 to s.Count -1 do if pos('MaxPlayerLevel =',s[i]) = 1 then s[i] := 'MaxPlayerLevel = ' + Edit1.Text;
  s.SaveToFile('mangosd.conf');
  s . Free;
end;



That's it

CU Chris

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
fuba
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Win7
D7 Ent.
BeitragVerfasst: Mi 30.05.07 17:22 
Ok,

zuerstmal möchte ich hier loswerden, das WIR hier nicht das recht besitzen, irgendwen zu verurteilen! (MEINE Meinung)

Novo hat eine frage gestellt und diese wird gleich mal abgeblockt, da man das SCHLIMMSTE vermutet...

Aber egal, soll jeder machen was er will ;)

@ Novo
Erstell dir mal ein simples Formular mit >> Edit1, Button1 und Button2
Hab bemerkt das deine *.conf file im "grunde" wie ne INI-File aufgebaut ist, also wird das nicht so schwer.

1. zu Lesen des wetes aus der Datei:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.Button1Click(Sender: TObject);
var
  ConfFile, TempFile: string;
  TL: TStringList;
begin
  ConfFile:=ExtractFilePath(ParamStr(0))+ 'mangosd.conf';  // angabe wo die *.conf file ist
  TempFile:=ExtractFilePath(ParamStr(0))+ 'mangosd.tmp';    // Temporäre datei (später benötigt)

  // Eine Temporäre datei erzeugen
  TL := TStringList.Create;
  TL.LoadFromFile(ConfFile);  // *.conf file in ne TStringList laden
  TL.Insert(0, '[TEMP]');  // An Position "0" der TStringlist wird Temporär eine "INI-Secion" eingefügt
  TL.SaveToFile(TempFile);  // Datei Temporär abspeichern (ist dann sozusagen ne INI-File
  TL.Free;

  // ab hier behandelst die *.conf wie eine NORMALE INI-File
  PIni := Tinifile.Create(TempFile);
  with Pini do
  begin
    Edit1.Text:=ReadString('TEMP', 'MaxPlayerLevel', '0');
  end;
  PIni.Free;

  DeleteFile(TempFile); // Temporäre datei wieder löschen
end;


2. Schreiben des wertes aus (Hier Edit1) in die datei:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
procedure TForm1.Button2Click(Sender: TObject);
var
  ConfFile, TempFile: string;
  TL: TStringList;
begin
    ConfFile:=ExtractFilePath(ParamStr(0))+ 'mangosd.conf';  // angabe wo die *.conf file ist
  TempFile:=ExtractFilePath(ParamStr(0))+ 'mangosd.tmp';    // Temporäre datei (später benötigt)

  // Eine Temporäre datei erzeugen
  TL := TStringList.Create;
  TL.LoadFromFile(ConfFile);  // *.conf file in ne TStringList laden
  TL.Insert(0, '[TEMP]');  // An Position "0" der TStringlist wird Temporär eine "INI-Secion" eingefügt
  TL.SaveToFile(TempFile);  // Datei Temporär abspeichern (ist dann sozusagen ne INI-File
  TL.Free;

  // ab hier behandelst die *.conf wie eine NORMALE INI-File
  PIni := Tinifile.Create(TempFile);
  with Pini do
  begin
    WriteString('TEMP', 'MaxPlayerLevel', Edit1.Text);
  end;
  PIni.Free;

  // Hier wird der Temporäre eintrag >>[TEMP]<< wieder entfernt
  TL := TStringList.Create;
  TL.LoadFromFile(TempFile);
  if TL[0] = '[TEMP]' then TL.Delete(0);
  TL.SaveToFile(ConfFile);
  TL.Free;
  
  DeleteFile(TempFile); // Temporäre datei wieder löschen
end;


Sollte im großen und ganzen schön funzen so
Gibt sicher noch ne schnellere / sicherere methode, aber mir fällt da grd nichts ein :D

beim schreiben wird hier "NOCHMAL" die originale datei ausgelesen, das kannst du aber handhaben wie du möchtest!
(Temp datei erst beim beenden des Programmes entfernen, das bleibt dir überlassen)

EDIT:
Falls du das ganze im speicher editieren willst, schau dir noch das an:
www.delphi-forum.de/viewtopic.php?p=443091

---

grüße fuba
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Do 31.05.07 06:28 
zu meiner Antwort oben eine Berichtigung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9',#8]) then Key := #0; // Klammern vergessen
end;



Sorry


Chris

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
Novo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90

Win XP, Win 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Fr 01.06.07 22:59 
Und was schreibe ich in den Array, wenn ich nur eine 1 oder 0 zulassen will?



greez Novo