📄 localdb.~pas
字号:
Result:=0;
sFileName:=g_Config.sEnvirDir + 'MiniMap.txt';
if FileExists(sFileName) then begin
MiniMapList.Clear;
tMapList:=TStringList.Create;
tMapList.LoadFromFile(sFileName);
for i:=0 to tMapList.Count -1 do begin
tStr:=tMapList.Strings[i];
if (tStr <> '') and (tStr[1] <> ';') then begin
tStr:=GetValidStr3(tStr, sMapNO, [' ', #9]);
tStr:=GetValidStr3(tStr, sMapIdx, [' ', #9]);
nIdx:=Str_ToInt(sMapIdx,0);
if nIdx > 0 then
MiniMapList.AddObject(sMapNO,TObject(nIdx));
end;
end;
tMapList.Free;
end;
end;
//004867F4
function TFrmDB.LoadMonGen(): Integer;
procedure LoadMapGen(MonGenList:TStringList;sFileName:String);
var
I: Integer;
sFilePatchName:String;
sFileDir:String;
LoadList:TStringList;
begin
sFileDir:=g_Config.sEnvirDir + 'MonGen\';
if not DirectoryExists(sFileDir) then begin
CreateDir(sFileDir);
end;
sFilePatchName:=sFileDir + sFileName;
if FileExists(sFilePatchName) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(sFilePatchName);
for I := 0 to LoadList.Count - 1 do begin
MonGenList.Add(LoadList.Strings[I]);
end;
LoadList.Free;
end;
end;
var
sFileName,sLineText,sData:String;
MonGenInfo:pTMonGenInfo;
LoadList:TStringList;
sMapGenFile:String;
i:Integer;
begin
Result:=0;
sFileName:=g_Config.sEnvirDir + 'MonGen.txt';
if FileExists(sFileName) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(sFileName);
I:=0;
while (True) do begin
if I >= LoadList.Count then break;
if CompareLStr('loadgen',LoadList.Strings[I],Length('loadgen')) then begin
sMapGenFile:=GetValidStr3(LoadList.Strings[I], sLineText, [' ', #9]);
LoadList.Delete(I);
if sMapGenFile <> '' then begin
LoadMapGen(LoadList,sMapGenFile);
end;
end;
Inc(I);
end;
for i:=0 to LoadList.Count -1 do begin
sLineText:=LoadList.Strings[i];
if (sLineText <> '') and (sLineText[1] <> ';') then begin
New(MonGenInfo);
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.sMapName:=sData;
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.nX:=Str_ToInt(sData,0);
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.nY:=Str_ToInt(sData,0);
sLineText:=GetValidStrCap(sLineText, sData, [' ', #9]);
if (sData <> '') and (sData[1] = '"') then
ArrestStringEx(sData,'"','"',sData);
MonGenInfo.sMonName:=sData;
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.nRange:=Str_ToInt(sData,0);
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.nCount:=Str_ToInt(sData,0);
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.dwZenTime:=Str_ToInt(sData, -1) * 60 * 1000;
sLineText:=GetValidStr3(sLineText, sData, [' ', #9]);
MonGenInfo.nMissionGenRate:=Str_ToInt(sData,0); //集中座标刷新机率 1 -100
if (MonGenInfo.sMapName <> '') and
(MonGenInfo.sMonName <> '') and
(MonGenInfo.dwZenTime <> 0) and
(g_MapManager.GetMapInfo(nServerIndex,MonGenInfo.sMapName) <> nil) then begin
MonGenInfo.CertList:=TList.Create;
MonGenInfo.Envir:=g_MapManager.FindMap(MonGenInfo.sMapName);
if MonGenInfo.Envir <> nil then begin
UserEngine.m_MonGenList.Add(MonGenInfo);
end else begin
Dispose(MonGenInfo);
end;
end;
//tMonGenInfo.nRace:=UserEngine.GetMonRace(tMonGenInfo.sMonName);
end;//00486B5B
end;//00486B67
//00486B67
New(MonGenInfo);
MonGenInfo.sMapName:='';
MonGenInfo.sMonName:='';
MonGenInfo.CertList:=TList.Create;
MonGenInfo.Envir:=nil;
UserEngine.m_MonGenList.Add(MonGenInfo);
LoadList.Free;
Result:=1;
end;
end;
//00485E04
function TFrmDB.LoadMonsterDB():Integer;
var
i:Integer;
Monster:pTMonInfo;
ResourceString
sSQLString = 'select * from Monster';
begin
Result:=0;
EnterCriticalSection(ProcessHumanCriticalSection);
try
for I := 0 to UserEngine.MonsterList.Count - 1 do begin
Dispose(pTMonInfo(UserEngine.MonsterList.Items[I]));
end;
UserEngine.MonsterList.Clear;
Query.SQL.Clear;
Query.SQL.Add(sSQLString);
try
Query.Open;
finally
Result:= -1;
end;
for i:=0 to Query.RecordCount -1 do begin
New(Monster);
Monster.ItemList := TList.Create;
Monster.sName := Trim(Query.FieldByName('NAME').AsString);
Monster.btRace := Query.FieldByName('Race').AsInteger;
Monster.btRaceImg := Query.FieldByName('RaceImg').AsInteger;
Monster.wAppr := Query.FieldByName('Appr').AsInteger;
Monster.wLevel := Query.FieldByName('Lvl').AsInteger;
Monster.btLifeAttrib := Query.FieldByName('Undead').AsInteger;
Monster.wCoolEye := Query.FieldByName('CoolEye').AsInteger;
Monster.dwExp := Query.FieldByName('Exp').AsInteger;
//城门或城墙的状态跟HP值有关,如果HP异常,将导致城墙显示不了
if Monster.btRace in [110,111] then begin //如果为城墙或城门由HP不加倍
Monster.wHP := Query.FieldByName('HP').AsInteger;
end else begin
Monster.wHP := ROUND(Query.FieldByName('HP').AsInteger * (g_Config.nMonsterPowerRate / 10));
end;
Monster.wMP := ROUND(Query.FieldByName('MP').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wAC := ROUND(Query.FieldByName('AC').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wMAC := ROUND(Query.FieldByName('MAC').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wDC := ROUND(Query.FieldByName('DC').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wMaxDC := ROUND(Query.FieldByName('DCMAX').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wMC := ROUND(Query.FieldByName('MC').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wSC := ROUND(Query.FieldByName('SC').AsInteger * (g_Config.nMonsterPowerRate / 10));
Monster.wSpeed := Query.FieldByName('SPEED').AsInteger;
Monster.wHitPoint := Query.FieldByName('HIT').AsInteger;
Monster.wWalkSpeed := _MAX(200,Query.FieldByName('WALK_SPD').AsInteger);
Monster.wWalkStep := _MAX(1,Query.FieldByName('WalkStep').AsInteger);
Monster.wWalkWait := Query.FieldByName('WalkWait').AsInteger;
Monster.wAttackSpeed := Query.FieldByName('ATTACK_SPD').AsInteger;
if Monster.wWalkSpeed < 200 then Monster.wWalkSpeed:= 200;
if Monster.wAttackSpeed < 200 then Monster.wAttackSpeed:= 200;
Monster.ItemList:=nil;
LoadMonitems(Monster.sName,Monster.ItemList);
UserEngine.MonsterList.Add(Monster);
Result := 1;
Query.Next;
end;
Query.Close;
finally
LeaveCriticalSection(ProcessHumanCriticalSection);
end;
end;
function TFrmDB.LoadMonitems(MonName:String;var ItemList:TList):Integer;//00485ABC
var
I: Integer;
s24:String;
LoadList:TStringList;
MonItem:pTMonItem;
s28,s2C,s30:String;
n18,n1C,n20:Integer;
begin
Result:=0;
s24:=g_Config.sEnvirDir + 'MonItems\' + MonName + '.txt';
if FileExists(s24) then begin
if ItemList <> nil then begin
for I := 0 to Itemlist.Count - 1 do begin
DisPose(pTMonItem(ItemList.Items[I]));
end;
ItemList.Clear;
end; //00485B81
LoadList:=TStringList.Create;
LoadList.LoadFromFile(s24);
for I := 0 to LoadList.Count - 1 do begin
s28:=LoadList.Strings[I];
if (s28 <> '') and (s28[1] <> ';') then begin
s28:=GetValidStr3(s28,s30,[' ','/',#9]);
n18:=Str_ToInt(s30,-1);
s28:=GetValidStr3(s28,s30,[' ','/',#9]);
n1C:=Str_ToInt(s30,-1);
s28:=GetValidStr3(s28,s30,[' ',#9]);
if s30 <> '' then begin
if s30[1] = '"' then
ArrestStringEx(s30,'"','"',s30);
end;
s2C:=s30;
s28:=GetValidStr3(s28,s30,[' ',#9]);
n20:=Str_ToInt(s30,1);
if (n18 > 0) and (n1C > 0) and (s2C <> '') then begin
if ItemList = nil then ItemList:=TList.Create;
New(MonItem);
MonItem.n00:=n18 -1;
MonItem.n04:=n1C;
MonItem.sMonName:=s2C;
MonItem.n18:=n20;
ItemList.Add(MonItem);
Inc(Result);
end;
end;
end;
LoadList.Free;
end;
end;
//00488178
function TFrmDB.LoadNpcs(): Integer;
var
sFileName,s10,s18,s1C,s20,s24,s28,s2C,s30,s34,s38:String;
LoadList:TStringList;
NPC:TNormNpc;
i:Integer;
begin
sFileName:=g_Config.sEnvirDir + 'Npcs.txt';
if FileExists(sFileName) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(sFileName);
for i:=0 to LoadList.Count -1 do begin
s18:=Trim(LoadList.Strings[i]);
if (s18 <> '') and (s18[1] <> ';') then begin
s18:=GetValidStrCap(s18, s20, [' ', #9]);
if (s20 <> '') and (s20[1] = '"') then
ArrestStringEx(s20,'"','"',s20);
s18:=GetValidStr3(s18, s24, [' ', #9]);
s18:=GetValidStr3(s18, s28, [' ', #9]);
s18:=GetValidStr3(s18, s2C, [' ', #9]);
s18:=GetValidStr3(s18, s30, [' ', #9]);
s18:=GetValidStr3(s18, s34, [' ', #9]);
s18:=GetValidStr3(s18, s38, [' ', #9]);
if (s20 <> '') and (s28 <> '') and (s38 <> '') then begin
NPC:=nil;
case Str_ToInt(s24,0) of
0: NPC:=TMerchant.Create;
1: NPC:=TGuildOfficial.Create;
2: NPC:=TCastleOfficial.Create;
end;
if NPC <> nil then begin
NPC.m_sMapName:=s28;
NPC.m_nCurrX:=Str_ToInt(s2C,0);
NPC.m_nCurrY:=Str_ToInt(s30,0);
NPC.m_sCharName:=s20;
NPC.m_nFlag:=Str_ToInt(s34,0);
NPC.m_wAppr:=Str_ToInt(s38,0);
UserEngine.QuestNPCList.Add(NPC); //0048847D
end;
end;
end;
end;
LoadList.Free;
end;
Result:= 1;
end;
//00489840
function TFrmDB.LoadQuestDiary(): Integer;
function sub_48978C(nIndex:Integer):String;
begin
if nIndex >= 1000 then begin
Result:=IntToStr(nIndex);
exit;
end;
if nIndex >= 100 then begin
Result:=IntToStr(nIndex) + '0';
exit;
end;
Result:=IntToStr(nIndex) + '00';
end;
var
i,ii:Integer;
QDDinfoList:TList;
QDDinfo:pTQDDinfo;
s14,s18,s1C,s20:String;
bo2D:Boolean;
nC:Integer;
LoadList:TStringList;
begin
Result:=1;
for i:=0 to QuestDiaryList.Count -1 do begin
QDDinfoList:=QuestDiaryList.Items[i];
for ii:=0 to QDDinfoList.Count -1 do begin
QDDinfo:=QDDinfoList.Items[ii];
QDDinfo.sList.Free;
Dispose(QDDinfo);
end;
QDDinfoList.Free;
end;
QuestDiaryList.Clear;
bo2D:=False;
nC:=1;
while (True) do begin
QDDinfoList:=nil;
s14:='QuestDiary\' + sub_48978C(nC) + '.txt';
if FileExists(s14) then begin
s18:='';
QDDinfo:=nil;
LoadList:=TStringList.Create;
LoadList.LoadFromFile(s14);
for i:=0 to LoadList.Count -1 do begin
s1C:=LoadList.Strings[i];
if (s1C <> '') and (s1C[1] <> ';') then begin
if (s1C[1] = '[') and (length(s1C) > 2) then begin
if s18 = '' then begin
ArrestStringEx(s1C,'[',']',s18);
QDDinfoList:=TList.Create;
New(QDDinfo);
QDDinfo.n00:=nC;
QDDinfo.s04:=s18;
QDDinfo.sList:=TStringList.Create;
QDDinfoList.Add(QDDinfo);
bo2D:=True;
end else begin
if s1C[1] <> '@' then begin
s1C:=GetValidStr3(s1C,s20,[' ',#9]);
ArrestStringEx(s20,'[',']',s20);
New(QDDinfo);
QDDinfo.n00:=Str_ToInt(s20,0);
QDDinfo.s04:=s1C;
QDDinfo.sList:=TStringList.Create;
QDDinfoList.Add(QDDinfo);
bo2D:=True;
end else bo2D:=False;
end;
end else begin //00489AFD
if bo2D then QDDinfo.sList.Add(s1C);
end;
end;//00489B11
end;
LoadList.Free;
end;//00489B25
if QDDinfoList <> nil then QuestDiaryList.Add(QDDinfoList)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -