localdb.pas
来自「2009最新 传奇汉化0599代码 传奇汉化」· PAS 代码 · 共 1,924 行 · 第 1/5 页
PAS
1,924 行
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.SelPoint:=n18 -1;
MonItem.MaxPoint:=n1C;
MonItem.ItemName:=s2C;
MonItem.Count:=n20;
ItemList.Add(MonItem);
Inc(Result);
end;
end;
end;
LoadList.Free;
end;
end;
//00488178
function TFrmDB.LoadNpcs(): Integer;
var
NPC:TNormNpc;
i:Integer;
{$IFDEF UseTXT}
sFileName,s10,s18,s1C,s20,s24,s28,s2C,s30,s34,s38:String;
LoadList:TStringList;
{$ELSE}
nType:Integer;
boUse:Boolean;
ResourceString
sSQLString = 'SELECT * FROM TBL_NPC';
{$ENDIF}
begin
Result:= -1;
EnterCriticalSection(ProcessHumanCriticalSection);
try
{$IFDEF UseTXT}
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;
{$ELSE}
try
UseSQL();
Query.SQL.Clear;
Query.SQL.Add(sSQLString);
try
Query.Open;
except
Result:= -2;
end;
for i:=0 to Query.RecordCount -1 do begin
boUse := GetBoolean(Query,'FLD_ENABLED');
if boUse then begin
NPC:=nil;
nType := Query.FieldByName('FLD_TYPE').AsInteger;
case nType of
0: NPC:=TMerchant.Create;
1: NPC:=TGuildOfficial.Create;
2: NPC:=TCastleOfficial.Create;
end;
if NPC <> nil then begin
NPC.m_sMapName := Query.FieldByName('FLD_MAPNAME').AsString;
NPC.m_nCurrX := Query.FieldByName('FLD_X').AsInteger;
NPC.m_nCurrY := Query.FieldByName('FLD_Y').AsInteger;
NPC.m_sCharName := Query.FieldByName('FLD_NAME').AsString;
NPC.m_nFlag := Query.FieldByName('FLD_FLAG').AsInteger;
NPC.m_wAppr := Query.FieldByName('FLD_APPEARANCE').AsInteger;
UserEngine.QuestNPCList.Add(NPC);
end;
end;
Result := 1;
Query.Next;
end;
finally
Query.Close;
end;
{$ENDIF}
finally
LeaveCriticalSection(ProcessHumanCriticalSection);
end;
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)
else QuestDiaryList.Add(nil);
Inc(nC);
if nC >= 105 then break;
end;
end;
//00488EF0
function TFrmDB.LoadStartPoint(): Integer;
var
i:Integer;
StartPoint:pTStartPoint;
{$IFDEF UseTXT}
sFileName,sLineText,sMapName,sX,sY:String;
LoadList:TStringList;
{$ELSE}
sMap:String;
ResourceString
sSQLString = 'SELECT * FROM TBL_STARTPOINT';
{$ENDIF}
begin
Result:= -1;
EnterCriticalSection(ProcessHumanCriticalSection);
try
{$IFDEF UseTXT}
sFileName:=g_Config.sEnvirDir + 'StartPoint.txt';
if FileExists(sFileName) then begin
g_StartPoint.Lock;
try
for I := 0 to g_StartPoint.Count - 1 do begin
Dispose(pTStartPoint(g_StartPoint.Items[I]));
end;
g_StartPoint.Clear;
// g_StartPointList.Lock;
// g_StartPointList.Clear;
LoadList:=TStringList.Create;
LoadList.LoadFromFile(sFileName);
for i:=0 to LoadList.Count -1 do begin
sLineText:=Trim(LoadList.Strings[i]);
if (sLineText <> '') and (sLineText[1] <> ';') then begin
sLineText:=GetValidStr3(sLineText, sMapName, [' ', #9]);
sLineText:=GetValidStr3(sLineText, sX, [' ', #9]);
sLineText:=GetValidStr3(sLineText, sY, [' ', #9]);
if (sMapName <> '') and (sX <> '') and (sY <> '')then begin
New(StartPoint);
StartPoint.sMapName:=sMapName;
StartPoint.nX:=Str_ToInt(sX,0);
StartPoint.nY:=Str_ToInt(sY,0);
StartPoint.Envir:=g_MapManager.FindMap(sMapName);
StartPoint.dwWhisperTick:=GetTickCount();
g_StartPoint.Add(StartPoint);
// g_StartPointList.AddObject(sMapName,TObject(MakeLong(Str_ToInt(sX,0),Str_ToInt(sY,0))));
Result:=1;
end;
end;
end;
LoadList.Free;
finally
g_StartPoint.UnLock;
// g_StartPointList.UnLock;
end;
end;
{$ELSE}
UseSQL();
Query.SQL.Clear;
Query.SQL.Add(sSQLString);
try
Query.Open;
except
Result:= -2;
end;
try
g_StartPoint.Lock;
for I := 0 to g_StartPoint.Count - 1 do begin
Dispose(pTStartPoint(g_StartPoint.Items[I]));
end;
g_StartPoint.Clear;
for i:=0 to Query.RecordCount -1 do begin
sMap := Query.FieldByName('FLD_MAPNAME').AsString;
if (sMap <> '') then begin
New(StartPoint);
StartPoint.sMapName := sMap;
StartPoint.nX := Query.FieldByName('FLD_X').AsInteger;
StartPoint.nY := Query.FieldByName('FLD_Y').AsInteger;
StartPoint.Envir := g_MapManager.FindMap(sMap);
StartPoint.btJob := 99;
StartPoint.dwWhisperTick := GetTickCount();
g_StartPoint.Add(StartPoint);
Result:=1;
end;
Query.Next;
end;
finally
g_StartPoint.UnLock;
end;
Query.Close;
{$ENDIF}
finally
LeaveCriticalSection(ProcessHumanCriticalSection);
end;
end;
//00489240
function TFrmDB.LoadUnbindList(): Integer;
var
sFileName,tStr,sData,s20:String;
LoadList:TStringList;
i:Integer;
n10:Integer;
begin
Result:=0;
sFileName:=g_Config.sEnvirDir + 'UnbindList.txt';
if FileExists(sFileName) then begin
LoadList:=TStringList.Create;
LoadList.LoadFromFile(sFileName);
for i:=0 to LoadList.Count -1 do begin
tStr:=LoadList.Strings[i];
if (tStr <> '') and (tStr[1] <> ';') then begin
tStr:=GetValidStr3(tStr, sData, [' ', #9]);
tStr:=GetValidStrCap(tStr, s20, [' ', #9]);
if (s20 <> '') and (s20[1] = '"') then
ArrestStringEx(s20,'"','"',s20);
n10:=Str_ToInt(sData,0);
if n10 > 0 then g_UnbindList.AddObject(s20,TObject(n10))
else begin
Result:=-i;
break;
end;
end;
end;
LoadList.Free;
end;
end;
function TFrmDB.LoadNpcScript(NPC: TNormNpc; sPatch,
sScritpName: String): Integer; //0048C4D8
begin
if sPatch = '' then sPatch:=sNpc_def;
Result:=LoadScriptFile(NPC,sPatch,sScritpName,False);
end;
function TFrmDB.LoadScriptFile(NPC: TNormNpc; sPatch, sScritpName: String;
boFlag: Boolean): Integer; //0048B684
var
nQuestIdx,I,n1C,n20,n24,nItemType,nPriceRate: Integer;
n6C,n70:Integer;
sScritpFileName,s30,s34,s38,s3C,s40,s44,s48,s4C,s50:String;
LoadList:TStringList;
DefineList:TList;
s54,s58,s5C,sLabel:String;
DefineInfo:pTDefineInfo;
bo8D:Boolean;
Script:pTScript;
SayingRecord:pTSayingRecord;
SayingProcedure:pTSayingProcedure;
QuestConditionInfo:pTQuestConditionInfo;
QuestActionInfo:pTQuestActionInfo;
Goods:pTGoods;
function LoadCallScript(sFileName,sLabel:String;List:TStringList):Boolean; //00489BD4
var
I: Integer;
LoadStrList:TStringList;
bo1D:Boolean;
s18:String;
begin
Result:=False;
if FileExists(sFileName) then begin
LoadStrList:=TStringList.Create;
LoadStrList.LoadFromFile(sFileName);
DeCodeStringList(LoadStrList);
sLabel:='[' + sLabel + ']';
bo1D:=False;
for I := 0 to LoadStrList.Count - 1 do begin
s18:=Trim(LoadStrList.Strings[i]);
if s18 <> '' then begin
if not bo1D then begin
if (s18[1] = '[') and (CompareText(s18,sLabel) = 0) then begin
bo1D:=True;
List.Add(s18);
end;
end else begin //00489CBF
if s18[1] <> '{' then begin
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?