localdb.pas

来自「2009最新 传奇汉化0599代码 传奇汉化」· PAS 代码 · 共 1,924 行 · 第 1/5 页

PAS
1,924
字号
  sSQLString = 'SELECT * FROM TBL_MAGIC ORDER BY FLD_ID';
begin
  Result:= -1;
  EnterCriticalSection(ProcessHumanCriticalSection);
  try
  try
    UserEngine.SwitchMagicList();
    {
    for I := 0 to UserEngine.MagicList.Count - 1 do begin
      Dispose(pTMagic(UserEngine.MagicList.Items[I]));
    end;
    UserEngine.MagicList.Clear;
    }

    UseSQL();
    Query.SQL.Clear;
    Query.SQL.Add(sSQLString);
    try
      Query.Open;
    except
      Result:= -2;
    end;
    for i:=0 to Query.RecordCount -1 do begin
      New(Magic);
      Magic.wMagicId      := Query.FieldByName('FLD_ID').AsInteger;
      Magic.wMimicID      := Query.FieldByName('FLD_MIMICID').AsInteger;
      Magic.sMagicName    := Trim(Query.FieldByName('FLD_NAME').AsString);
      Magic.btEffectType  := Query.FieldByName('FLD_EFFECTTYPE').AsInteger;
      Magic.btEffect      := Query.FieldByName('FLD_EFFECT').AsInteger;
      Magic.wSpell        := Query.FieldByName('FLD_SPELL').AsInteger;
      Magic.wPower        := Query.FieldByName('FLD_POWER').AsInteger;
      Magic.wMaxPower     := Query.FieldByName('FLD_MAXPOWER').AsInteger;
      Magic.btJob         := Query.FieldByName('FLD_JOB').AsInteger;
      Magic.TrainLevel[0] := Query.FieldByName('FLD_NEEDL1').AsInteger;
      Magic.TrainLevel[1] := Query.FieldByName('FLD_NEEDL2').AsInteger;
      Magic.TrainLevel[2] := Query.FieldByName('FLD_NEEDL3').AsInteger;
      Magic.TrainLevel[3] := Magic.TrainLevel[2]; //Query.FieldByName('FLD_NEEDL3').AsInteger;
      Magic.MaxTrain[0]   := Query.FieldByName('FLD_L1TRAIN').AsInteger;
      Magic.MaxTrain[1]   := Query.FieldByName('FLD_L2TRAIN').AsInteger;
      Magic.MaxTrain[2]   := Query.FieldByName('FLD_L3TRAIN').AsInteger;
      Magic.MaxTrain[3]   := Magic.MaxTrain[2];
      Magic.btTrainLv     := MaxSkillLevel;
      Magic.dwDelayTime   := Query.FieldByName('FLD_DELAY').AsInteger;
      Magic.btDefSpell    := Query.FieldByName('FLD_DEFSPELL').AsInteger;
      Magic.btDefPower    := Query.FieldByName('FLD_DEFPOWER').AsInteger;
      Magic.btDefMaxPower := Query.FieldByName('FLD_DEFMAXPOWER').AsInteger;
      Magic.sDescr        := Trim(Query.FieldByName('FLD_DESCR').AsString);
      if Magic.wMagicId > 0 then begin
        UserEngine.m_MagicList.Add(Magic);
      end else begin
        Dispose(Magic);
      end;
      Result := 1;
      Query.Next;
    end;
  finally
    Query.Close;
  end;
  finally
    LeaveCriticalSection(ProcessHumanCriticalSection);
  end;
end;

function TFrmDB.LoadMakeItem(): Integer; //00488CDC
var
  I,n14:Integer;
  s18,s20,s24:String;
  LoadList:TStringList;
  sFileName:String;
  List28:TStringList;
begin
  Result:= -1;
  sFileName:=g_Config.sEnvirDir + 'MakeItem.txt';
  if FileExists(sFileName) then begin
    LoadList:=TStringList.Create;
    LoadList.LoadFromFile(sFileName);
    List28:=nil;
    s24:='';
    for I := 0 to LoadList.Count - 1 do begin
      s18:=Trim(LoadList.Strings[I]);
      if (s18 <> '') and (s18[1] <> ';') then begin
        if s18[1] = '[' then begin
          if List28 <> nil then
            g_MakeItemList.AddObject(s24,List28);
          List28:=TStringList.Create;
          ArrestStringEx(s18,'[',']',s24);
        end else begin
          if List28 <> nil then begin
            s18:=GetValidStr3(s18,s20,[' ',#9]);
            n14:=Str_ToInt(Trim(s18),1);
            List28.AddObject(s20,TObject(n14));
          end;
        end;
      end;
    end;    // for
    if List28 <> nil then
      g_MakeItemList.AddObject(s24,List28);
    LoadList.Free;
    Result:=1;
  end;
end;


function TFrmDB.LoadMapInfo: Integer;
  function LoadMapQuest(sName:String):TMerchant;
  var
    QuestNPC:TMerchant;
  begin
    QuestNPC:=TMerchant.Create;
    QuestNPC.m_sMapName:='0';
    QuestNPC.m_nCurrX:=0;
    QuestNPC.m_nCurrY:=0;
    QuestNPC.m_sCharName:=sName;
    QuestNPC.m_nFlag:=0;
    QuestNPC.m_wAppr:=0;
    QuestNPC.m_sFilePath:='MapQuest_def\';
    QuestNPC.m_boIsHide:=True;
    QuestNPC.m_boIsQuest:=False;
    UserEngine.QuestNPCList.Add(QuestNPC);

    Result:=QuestNPC;
  end;

{$IFDEF UseTXT}
  procedure LoadSubMapInfo(LoadList:TStringList;sFileName:String);
  var
    I: Integer;
    sFilePatchName,sFileDir:String;
    LoadMapList:TStringList;
  begin
    sFileDir:=g_Config.sEnvirDir + 'MapInfo\';
    if not DirectoryExists(sFileDir) then begin
      CreateDir(sFileDir);
    end;
      
    sFilePatchName:=sFileDir + sFileName;
    if FileExists(sFilePatchName) then begin
      LoadMapList:=TStringList.Create;
      LoadMapList.LoadFromFile(sFilePatchName);
      for I := 0 to LoadMapList.Count - 1 do begin
        LoadList.Add(LoadMapList.Strings[I]);
      end;
      LoadMapList.Free;
    end;
  end;
{$ENDIF}

var
{$IFDEF UseTXT}
  sFileName:String;

  LoadList:TStringList;
  sLineText:String;

  sData,sMapNo,sMapNameLine,sMapFileName,sDMapNO,sServerIndex:String;
  nSMapX,nSMapY,nDMapX,nDMapY:Integer;

  sMapInfoFile:String;
{$ELSE}
  nIdx: Integer;
{$ENDIF}
  sCaption: String;
  i:Integer;
  sFlag,s34,s38,sMapName,sMapDesc,sReConnectMap:String;
  nServerIndex:Integer;
  MapFlag:TMapFlag;
  QuestNPC:TMerchant;
{$IFNDEF UseTXT}
ResourceString
  sSQLString = 'SELECT * FROM TBL_MAPINFO';
{$ENDIF}
begin
  sCaption := FrmMain.Caption;
  Result:= -1;
  try
    EnterCriticalSection(ProcessHumanCriticalSection);
  {$IFDEF UseTXT}
    sFileName:=g_Config.sEnvirDir + 'MapInfo.txt';
    if FileExists(sFileName) then begin
      LoadList:=TStringList.Create;
      LoadList.LoadFromFile(sFileName);
      if LoadList.Count < 0 then begin
        LoadList.Free;
        exit;
      end;
      I:=0;
      while (True) do begin
        if I >= LoadList.Count then break;
        if CompareLStr('loadmapinfo',LoadList.Strings[I],Length('loadmapinfo')) then begin
          sMapInfoFile:=GetValidStr3(LoadList.Strings[I], sLineText, [' ', #9]);
          LoadList.Delete(I);
          if sMapInfoFile <> '' then begin
            LoadSubMapInfo(LoadList,sMapInfoFile);
          end;
        end;
        Inc(I);
      end;
      Result:=1;

      for i:=0 to LoadList.Count -1 do begin
        sLineText:=LoadList.Strings[i];
        if (sLineText <> '') and (sLineText[1] = '[') then begin
          sMapName:='';
          MapFlag.boSAFE:=False;
          sLineText:=ArrestStringEx(sLineText,'[',']',sMapNameLine);
          sMapDesc:=GetValidStrCap(sMapNameLine,sMapFileName,[' ', ',', #9]);
          sMapFileName:=GetValidStr3(sMapFileName,sMapName,['|']);
          if sMapFileName = '' then sMapFileName:=sMapName;
            
          if (sMapDesc <> '') and (sMapDesc[1] = '"') then
              ArrestStringEx(sMapDesc,'"','"',sMapDesc);
          sServerIndex:=Trim(GetValidStr3(sMapDesc,sMapDesc,[' ', ',', #9]));
          nServerIndex:=Str_ToInt(sServerIndex,0);
          if sMapName = '' then Continue;


          FillChar(MapFlag,SizeOf(TMapFlag),#0);
          MapFlag.nL:=1;
          QuestNPC:=nil;
          MapFlag.nNEEDSETONFlag:= -1;
          MapFlag.nNeedONOFF:= -1;
          MapFlag.nMUSICID:=-1;
          MapFlag.nGuildTerritory:=-1; // Sergiu

          FrmMain.Caption:=sCaption + '[Processing Map: '+sMapName+' ('+inttostr(I+1)+'/'+inttostr(LoadList.Count)+')';

          sFlag := sLineText;
    {$ELSE}
      try
      UseSQL();
      Query.SQL.Clear;
      Query.SQL.Add(sSQLString);
      MiniMapList.Clear;
      BigMapList.Clear;
      try
        Query.Open;
      except
        Result:= -2;
      end;
      for i:=0 to Query.RecordCount -1 do begin
        sMapName      := Trim(Query.FieldByName('FLD_MAPFILENAME').AsString);
        sMapDesc      := Trim(Query.FieldByName('FLD_MAPNAME').AsString);
        sFlag         := Trim(Query.FieldByName('FLD_FLAGS').AsString);
        nServerIndex  := Query.FieldByName('FLD_SERVERINDEX').AsInteger;
        
        if sMapName = '' then begin
          Query.Next;
          Continue;
        end;
        FrmMain.Caption:=sCaption + '[Processing Map: '+sMapName+' ('+inttostr(I+1)+'/'+inttostr(Query.RecordCount)+')';
  //      FrmMain.MemoLog.Lines.Add(' -> Adding Map: '+sMapName+' ('+inttostr(I+1)+'/'+inttostr(Query.RecordCount)+')');
        nIdx          := Query.FieldByName('FLD_MINIMAP').AsInteger;
        if nIdx > 0 then
          MiniMapList.AddObject(sMapName,TObject(nIdx));

     nIdx          := Query.FieldByName('FLD_BIGMAP').AsInteger;
      if nIdx > 0 then
        BigMapList.AddObject(sMapName,TObject(nIdx));

  
    {$ENDIF}

      FillChar(MapFlag,SizeOf(TMapFlag),#0);
      MapFlag.nL:=1;
      QuestNPC:=nil;
      MapFlag.boSAFE:=False;
      MapFlag.nNEEDSETONFlag:= -1;
      MapFlag.nNeedONOFF:= -1;
      MapFlag.nMUSICID:=-1;
      MapFlag.nGuildTerritory:=-1;

      while (True) do begin
        if sFlag = '' then break;
        sFlag:=GetValidStr3(sFlag,s34,[' ', ',', #9]);
        if s34 = '' then break;

        if CompareText(s34,'SAFE') = 0 then begin
          MapFlag.boSAFE:=True;
          Continue;
        end;
        if CompareText(s34,'DARK') = 0 then begin
          MapFlag.boDarkness:=True;
          Continue;
        end;
        if CompareText(s34,'FIGHT') = 0 then begin
          MapFlag.boFightZone:=True;
          Continue;
        end;
        if CompareText(s34,'FIGHT3') = 0 then begin
          MapFlag.boFight3Zone:=True;
          Continue;
        end;
        if CompareText(s34,'DAY') = 0 then begin
          MapFlag.boDayLight:=True;
          Continue;
        end;
        if CompareText(s34,'QUIZ') = 0 then begin
          MapFlag.boQUIZ:=True;
          Continue;
        end;
        if CompareLStr(s34,'NORECONNECT',length('NORECONNECT')) then begin
          MapFlag.boNORECONNECT:=True;
          ArrestStringEx(s34,'(',')',sReConnectMap);
          MapFlag.sNoReConnectMap:=sReConnectMap;
          if MapFlag.sNoReConnectMap = '' then Result:= -11;
          Continue;
        end;
        if CompareLStr(s34,'CHECKQUEST',length('CHECKQUEST')) then begin
          ArrestStringEx(s34,'(',')',s38);
          QuestNPC:=LoadMapQuest(s38);
          Continue;
        end;
        if CompareLStr(s34,'NEEDSET_ON',length('NEEDSET_ON')) then begin
          MapFlag.nNeedONOFF:=1;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nNEEDSETONFlag:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'NEEDSET_OFF',length('NEEDSET_OFF')) then begin
          MapFlag.nNeedONOFF:=0;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nNEEDSETONFlag:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'MUSIC',length('MUSIC')) then begin
          MapFlag.boMUSIC:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nMUSICID:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'EXPRATE',length('EXPRATE')) then begin
          MapFlag.boEXPRATE:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nEXPRATE:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKWINLEVEL',length('PKWINLEVEL')) then begin
          MapFlag.boPKWINLEVEL:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKWINLEVEL:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKWINEXP',length('PKWINEXP')) then begin
          MapFlag.boPKWINEXP:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKWINEXP:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKLOSTLEVEL',length('PKLOSTLEVEL')) then begin
          MapFlag.boPKLOSTLEVEL:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKLOSTLEVEL:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'PKLOSTEXP',length('PKLOSTEXP')) then begin
          MapFlag.boPKLOSTEXP:=True;
          ArrestStringEx(s34,'(',')',s38);
          MapFlag.nPKLOSTEXP:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECHP',length('DECHP')) then begin
          MapFlag.boDECHP:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nDECHPPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nDECHPTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'INCHP',length('INCHP')) then begin
          MapFlag.boINCHP:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nINCHPPOINT:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nINCHPTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECGAMEGOLD',length('DECGAMEGOLD')) then begin
          MapFlag.boDECGAMEGOLD:=True;
          ArrestStringEx(s34,'(',')',s38);

          MapFlag.nDECGAMEGOLD:=Str_ToInt(GetValidStr3(s38,s38,['/']),-1);
          MapFlag.nDECGAMEGOLDTIME:=Str_ToInt(s38,-1);
          Continue;
        end;
        if CompareLStr(s34,'DECGAMEPOINT',length('DECGAMEPOINT')) then begin

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?