leong124

Double-O-Files.inc

Jan 20th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 17.10 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dutils>
  3.  
  4. #if defined _dof_included
  5.     #endinput
  6. #endif
  7. #define _dof_included
  8.  
  9. #if !defined isnull
  10.     #define isnull(%1) \
  11.         ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  12. #endif
  13.  
  14. #if !defined strcpy
  15.     #define strcpy(%0,%1,%2) \
  16.         strcat((%0[0] = '\0', %0), %1, %2)
  17. #endif
  18.  
  19. #define MAX_ENTRIES 60 // Eintraege zum lesen
  20. #define MAX_KEY_SIZE 18
  21. #define MAX_VALUE_SIZE 133
  22. #define MAX_FILE_SIZE 128
  23.  
  24. #define USER_FILE_PATH "Accounts/%s.dudb.sav"
  25.  
  26. //#define DOF_DEBUG
  27. //#define DUDB_CONVERT
  28. //#define DINI_CONVERT
  29.  
  30. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31.  
  32. static LoadedFile[MAX_FILE_SIZE+1];
  33. static LoadedEntries;
  34. static FileChanged=false;
  35. static Keys[MAX_ENTRIES][MAX_KEY_SIZE+1];
  36. static KeyHashes[MAX_ENTRIES];
  37. static Values[MAX_ENTRIES][MAX_VALUE_SIZE+1];
  38.  
  39. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  40.  
  41. /*
  42. native DOF_SetFile(file[]);
  43. native DOF_LoadFile();
  44. native DOF_SaveFile();
  45. native DOF_PrintFile(comment[]="");
  46. native DOF_GetString(file[],key[],bool:hashcmp=true);
  47. native DOF_GetStringEx(file[],key[],result[],len,bool:hashcmp=true);
  48. native DOF_GetFloat(file[],key[],bool:hashcmp=true);
  49. native DOF_GetInt(file[],key[],bool:hashcmp=true);
  50. native DOF_GetBool(file[],key[],bool:hashcmp=true);
  51. native DOF_SetString(file[],key[],value[],bool:hashcmp=true);
  52. native DOF_SetFloat(file[],key[],Float:value,bool:hashcmp=true);
  53. native DOF_SetInt(file[],key[],value,bool:hashcmp=true);
  54. native DOF_SetBool(file[],key[],bool:value,bool:hashcmp=true);
  55. native DOF_IsSet(file[],key[],bool:hashcmp=true);
  56. native DOF_Unset(file[],key[],bool:hashcmp=true);
  57. native DOF_FileExists(file[]);
  58. native DOF_RemoveFile(file[]);
  59. native DOF_CreateFile(file[],password[]="");
  60. native DOF_RenameFile(oldfile[],newfile[]);
  61. native DOF_RenameKey(file[],oldkey[],newkey[],bool:hashcmp=true);
  62. native DOF_CopyFile(filetocopy[],newfile[]);
  63. native DOF_CheckLogin(file[],password[]);
  64. native DOF_GetHashCols();
  65. native DOF_File(user[]);
  66. */
  67.  
  68. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  69.  
  70. DOF_Exit()//Bei OnGameModeExit:
  71. {
  72.     DOF_SaveFile();
  73. }
  74.  
  75. stock DOF_SetFile(file[])
  76. {
  77.     if(!isnull(file))
  78.         return strcpy(LoadedFile,file,sizeof(LoadedFile));
  79.     return 0;
  80. }
  81.  
  82. stock DOF_LoadFile()
  83. {
  84.     if(!isnull(LoadedFile))
  85.     {
  86.         LoadedEntries=0;
  87.         new File:f=fopen(LoadedFile,io_read),string[MAX_VALUE_SIZE+MAX_KEY_SIZE+5],pos,pos2;
  88.         while(fread(f,string,sizeof(string)) && LoadedEntries<MAX_ENTRIES)
  89.         {
  90.             StripNewLine(string);
  91.             if(!isnull(string) && string[0]!=';')//;This is a comment^^
  92.             {
  93.                 pos=0;
  94.                 while(string[pos]!='=' && string[pos])
  95.                 {
  96.                     if(pos<MAX_KEY_SIZE)
  97.                         Keys[LoadedEntries][pos]=string[pos];
  98.                     pos++;
  99.                 }
  100.                 if(pos<MAX_KEY_SIZE)
  101.                     Keys[LoadedEntries][pos]='\0';
  102.                 KeyHashes[LoadedEntries]=DOF_bernstein(Keys[LoadedEntries]);
  103.                
  104.                 pos++;
  105.                 pos2=pos;
  106.                 while(string[pos2] && (pos2-pos)<MAX_VALUE_SIZE)
  107.                 {
  108.                     Values[LoadedEntries][pos2-pos]=string[pos2];
  109.                     pos2++;
  110.                 }
  111.                 if((pos2-pos)<MAX_VALUE_SIZE)
  112.                     Values[LoadedEntries][pos2-pos]='\0';
  113.                 LoadedEntries++;
  114.             }
  115.         }
  116.         fclose(f);
  117.         return LoadedEntries;
  118.     }
  119.     return 0;
  120. }
  121.  
  122. stock DOF_SaveFile()
  123. {
  124.     if(!isnull(LoadedFile) && FileChanged)
  125.     {
  126.         #if defined DOF_DEBUG
  127.             //DOF_PrintFile();
  128.             printf("[DOF] Schreibe Datei ('%s') neu!",LoadedFile);
  129.         #endif
  130.         fremove(LoadedFile);
  131.         new File:f=fopen(LoadedFile,io_append),string[MAX_VALUE_SIZE+MAX_KEY_SIZE+5];
  132.         for(new i=0;i<LoadedEntries;i++)
  133.         {
  134.             format(string,sizeof(string),"%s=%s\r\n",Keys[i],Values[i]);
  135.             fwrite(f,string);
  136.         }
  137.         FileChanged=false;
  138.         return fclose(f);
  139.     }
  140.     return 0;
  141. }
  142.  
  143. stock DOF_PrintFile(comment[]="")
  144. {
  145.     if(!isnull(LoadedFile))
  146.     {
  147.         printf("[DOF] Geladene Datei: '%s'",LoadedFile);
  148.         for(new i=0;i<LoadedEntries;i++)
  149.             printf("%s=%s",Keys[i],Values[i]);
  150.         printf("(%d Eintraege)",LoadedEntries);
  151.         if(!isnull(comment))
  152.             printf("* Kommentar: %s",comment);
  153.         return 1;
  154.     }
  155.    
  156.     print("[DOF] Keine Datei geladen!");
  157.     return 0;
  158. }
  159.  
  160. stock DOF_GetString(file[],key[],bool:hashcmp=true)
  161. {
  162.     new result[MAX_VALUE_SIZE];
  163.     if(!isnull(file) && !isnull(key))
  164.     {
  165.         if(DOF_FileExists(file))
  166.         {
  167.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  168.             {
  169.                 if(FileChanged)
  170.                     DOF_SaveFile();
  171.                 #if defined DOF_DEBUG
  172.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  173.                 #endif
  174.                 DOF_SetFile(file);
  175.                 DOF_LoadFile();
  176.             }
  177.  
  178.             if(hashcmp)
  179.             {
  180.                 for(new i=0, h=DOF_bernstein(key);i<LoadedEntries;i++)
  181.                 {
  182.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],key,true))
  183.                     {
  184.                         strcpy(result,Values[i],sizeof(result));
  185.                         return result;
  186.                     }
  187.                 }
  188.             }
  189.             else
  190.             {
  191.                 for(new i=0;i<LoadedEntries;i++)
  192.                 {
  193.                     if(!strcmpex(Keys[i],key,true))
  194.                     {
  195.                         strcpy(result,Values[i],sizeof(result));
  196.                         return result;
  197.                     }
  198.                 }
  199.             }
  200.         }
  201.     }
  202.     return result;
  203. }
  204.  
  205. stock DOF_GetStringEx(file[],key[],result[],len,bool:hashcmp=true)
  206. {
  207.     if(!isnull(file) && !isnull(key))
  208.     {
  209.         if(DOF_FileExists(file))
  210.         {
  211.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  212.             {
  213.                 if(FileChanged)
  214.                     DOF_SaveFile();
  215.                 #if defined DOF_DEBUG
  216.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  217.                 #endif
  218.                 DOF_SetFile(file);
  219.                 DOF_LoadFile();
  220.             }
  221.  
  222.             if(hashcmp)
  223.             {
  224.                 for(new i=0, h=DOF_bernstein(key);i<LoadedEntries;i++)
  225.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],key,true))
  226.                         return strcpy(result,Values[i],len);
  227.             }
  228.             else
  229.             {
  230.                 for(new i=0;i<LoadedEntries;i++)
  231.                     if(!strcmpex(Keys[i],key,true))
  232.                         return strcpy(result,Values[i],len);
  233.             }
  234.         }
  235.     }
  236.     return 0;
  237. }
  238.  
  239. stock Float:DOF_GetFloat(file[],key[],bool:hashcmp=true)
  240.     return floatstr(DOF_GetString(file,key,hashcmp));
  241.    
  242. stock DOF_GetInt(file[],key[],bool:hashcmp=true)
  243.     return strval(DOF_GetString(file,key,hashcmp));
  244.    
  245. stock bool:DOF_GetBool(file[],key[],bool:hashcmp=true)
  246. {
  247.     if(strval(DOF_GetString(file,key,hashcmp)))
  248.         return (bool:1);
  249.     return (bool:0);
  250. }
  251.  
  252. stock DOF_SetString(file[],key[],value[],bool:hashcmp=true)
  253. {
  254.     if(!isnull(file) && !isnull(key))
  255.     {
  256.         if(DOF_FileExists(file))
  257.         {
  258.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  259.             {
  260.                 if(FileChanged)
  261.                     DOF_SaveFile();
  262.                 #if defined DOF_DEBUG
  263.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  264.                 #endif
  265.                 DOF_SetFile(file);
  266.                 DOF_LoadFile();
  267.             }
  268.  
  269.             FileChanged=true;
  270.             if(hashcmp)
  271.             {
  272.                 for(new i=0, h=DOF_bernstein(key);i<LoadedEntries;i++)
  273.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],key,true))
  274.                         return strcpy(Values[i],value,MAX_VALUE_SIZE);
  275.             }
  276.             else
  277.             {
  278.                 for(new i=0;i<LoadedEntries;i++)
  279.                     if(!strcmpex(Keys[i],key,true))
  280.                         return strcpy(Values[i],value,MAX_VALUE_SIZE);
  281.             }
  282.  
  283.             //Key existiert nicht:
  284.             if(LoadedEntries<MAX_ENTRIES)
  285.             {
  286.                 strcpy(Keys[LoadedEntries],key,MAX_KEY_SIZE);
  287.                 KeyHashes[LoadedEntries]=DOF_bernstein(Keys[LoadedEntries]);
  288.                 strcpy(Values[LoadedEntries],value,MAX_VALUE_SIZE);
  289.                 LoadedEntries++;
  290.                 return 1;
  291.             }
  292.         }
  293.     }
  294.     return 0;
  295. }
  296.  
  297. stock DOF_IsSet(file[],key[],bool:hashcmp=true)
  298. {
  299.     if(!isnull(file) && !isnull(key))
  300.     {
  301.         if(DOF_FileExists(file))
  302.         {
  303.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  304.             {
  305.                 if(FileChanged)
  306.                     DOF_SaveFile();
  307.                 #if defined DOF_DEBUG
  308.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  309.                 #endif
  310.                 DOF_SetFile(file);
  311.                 DOF_LoadFile();
  312.             }
  313.  
  314.             if(hashcmp)
  315.             {
  316.                 for(new i=0, h=DOF_bernstein(key);i<LoadedEntries;i++)
  317.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],key,true))
  318.                         return 1;
  319.             }
  320.             else
  321.             {
  322.                 for(new i=0;i<LoadedEntries;i++)
  323.                     if(!strcmpex(Keys[i],key,true))
  324.                         return 1;
  325.             }
  326.         }
  327.     }
  328.     return 0;
  329. }
  330.  
  331. stock DOF_Unset(file[],key[],bool:hashcmp=true)
  332. {
  333.     if(!isnull(file) && !isnull(key))
  334.     {
  335.         if(DOF_FileExists(file))
  336.         {
  337.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  338.             {
  339.                 if(FileChanged)
  340.                     DOF_SaveFile();
  341.                 #if defined DOF_DEBUG
  342.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  343.                 #endif
  344.                 DOF_SetFile(file);
  345.                 DOF_LoadFile();
  346.             }
  347.  
  348.             if(hashcmp)
  349.             {
  350.                 for(new i=0, h=DOF_bernstein(key);i<LoadedEntries;i++)
  351.                 {
  352.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],key,true))
  353.                     {
  354.                         FileChanged=true;
  355.                         LoadedEntries--;
  356.                         Keys[i]=Keys[LoadedEntries];
  357.                         KeyHashes[i]=KeyHashes[LoadedEntries];
  358.                         Values[i]=Values[LoadedEntries];
  359.                         return 1;
  360.                     }
  361.                 }
  362.             }
  363.             else
  364.             {
  365.                 for(new i=0;i<LoadedEntries;i++)
  366.                 {
  367.                     if(!strcmpex(Keys[i],key,true))
  368.                     {
  369.                         FileChanged=true;
  370.                         LoadedEntries--;
  371.                         Keys[i]=Keys[LoadedEntries];
  372.                         KeyHashes[i]=KeyHashes[LoadedEntries];
  373.                         Values[i]=Values[LoadedEntries];
  374.                         return 1;
  375.                     }
  376.                 }
  377.             }
  378.         }
  379.     }
  380.     return 0;
  381. }
  382.  
  383. stock DOF_SetFloat(file[],key[],Float:value,bool:hashcmp=true)
  384. {
  385.     new fvalue[MAX_VALUE_SIZE];
  386.     format(fvalue,sizeof(fvalue),"%.8f",value);
  387.     return DOF_SetString(file,key,fvalue,hashcmp);
  388. }
  389.  
  390. stock DOF_SetInt(file[],key[],value,bool:hashcmp=true)
  391. {
  392.     new ivalue[MAX_VALUE_SIZE];
  393.     format(ivalue,sizeof(ivalue),"%d",value);
  394.     return DOF_SetString(file,key,ivalue,hashcmp);
  395. }
  396.  
  397. stock DOF_SetBool(file[],key[],bool:value,bool:hashcmp=true)
  398. {
  399.     if(value)
  400.         return DOF_SetString(file,key,"1",hashcmp);
  401.     return DOF_SetString(file,key,"0",hashcmp);
  402. }
  403.  
  404. stock DOF_FileExists(file[])
  405.     return fexist(file);
  406.    
  407. stock DOF_RemoveFile(file[])
  408. {
  409.     if(!isnull(file))
  410.     {
  411.         if(!isnull(LoadedFile) && !strcmpex(file,LoadedFile,false))//Gespeicherte Datei loschen, falls die gespeicherte Datei die ist, welche geloscht werden soll.
  412.         {
  413.             LoadedFile[0]='\0';
  414.             LoadedEntries=0;
  415.             FileChanged=false;//added by hk_shade
  416.         }
  417.         return fremove(file);
  418.     }
  419.     return 0;
  420. }
  421.  
  422. stock DOF_CreateFile(file[],password[]="")
  423. {
  424.     if(!isnull(file))
  425.     {
  426.         if(!DOF_FileExists(file))
  427.         {
  428.             DOF_SaveFile();
  429.             #if defined DOF_DEBUG
  430.                 printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  431.             #endif
  432.             new File:f=fopen(file,io_append);
  433.             fclose(f);
  434.             LoadedEntries=0;
  435.             DOF_SetFile(file);
  436.             if(!isnull(password))
  437.                 DOF_SetInt(file,"password_hash",num_hash(password));
  438.             FileChanged=true;//added by hk_shade
  439.             return DOF_SaveFile();
  440.         }
  441.     }
  442.     return 0;
  443. }
  444.  
  445. stock DOF_RenameFile(oldfile[],newfile[])
  446. {
  447.     if(!isnull(oldfile) && !isnull(newfile))
  448.     {
  449.         if(DOF_FileExists(oldfile) && !DOF_FileExists(newfile))
  450.         {
  451.             if(FileChanged)
  452.                 DOF_SaveFile();//Derzeitige Datei speichern
  453.             DOF_SetFile(oldfile);
  454.             DOF_LoadFile();
  455.             FileChanged=true;//added by hk_shade
  456.             fremove(oldfile);
  457.             DOF_SetFile(newfile);
  458.             return DOF_SaveFile();
  459.         }
  460.     }
  461.     return 0;
  462. }
  463.  
  464. stock DOF_RenameKey(file[],oldkey[],newkey[],bool:hashcmp=true)
  465. {
  466.     if(!isnull(file) && !isnull(oldkey) && !isnull(newkey))
  467.     {
  468.         if(DOF_FileExists(file))
  469.         {
  470.             if(isnull(LoadedFile) || strcmpex(file,LoadedFile,false))//Neue Datei laden.
  471.             {
  472.                 if(FileChanged)
  473.                     DOF_SaveFile();
  474.                 #if defined DOF_DEBUG
  475.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  476.                 #endif
  477.                 DOF_SetFile(file);
  478.                 DOF_LoadFile();
  479.             }
  480.  
  481.             if(hashcmp)
  482.             {
  483.                 for(new i=0, h=DOF_bernstein(oldkey);i<LoadedEntries;i++)
  484.                 {
  485.                     if(h==KeyHashes[i] && !strcmpex(Keys[i],oldkey,true))
  486.                     {
  487.                         FileChanged=true;
  488.                         strcpy(Keys[i],newkey,MAX_KEY_SIZE);
  489.                         KeyHashes[i]=DOF_bernstein(Keys[i]);
  490.                         return 1;
  491.                     }
  492.                 }
  493.             }
  494.             else
  495.             {
  496.                 for(new i=0;i<LoadedEntries;i++)
  497.                 {
  498.                     if(!strcmpex(Keys[i],oldkey,true))
  499.                     {
  500.                         FileChanged=true;
  501.                         strcpy(Keys[i],newkey,MAX_KEY_SIZE);
  502.                         KeyHashes[i]=DOF_bernstein(Keys[i]);
  503.                         return 1;
  504.                     }
  505.                 }
  506.             }
  507.         }
  508.     }
  509.     return 0;
  510. }
  511.  
  512. stock DOF_CopyFile(filetocopy[],newfile[])
  513. {
  514.     if(!isnull(filetocopy) && !isnull(newfile))
  515.     {
  516.         if(DOF_FileExists(filetocopy) && !DOF_FileExists(newfile))
  517.         {
  518.             if(FileChanged)
  519.                 DOF_SaveFile();//Derzeitige Datei speichern
  520.             DOF_SetFile(filetocopy);
  521.             DOF_LoadFile();
  522.             DOF_SetFile(newfile);
  523.             FileChanged=true;//added by hk_shade
  524.             return DOF_SaveFile();
  525.         }
  526.     }
  527.     return 0;
  528. }
  529.  
  530. stock DOF_CheckLogin(file[],password[])
  531. {
  532.     if(!isnull(file) && !isnull(password))
  533.         if(num_hash(password)==DOF_GetInt(file,"password_hash"))
  534.             return 1;
  535.     return 0;
  536. }
  537.  
  538. stock DOF_GetHashCols()
  539. {
  540.     new c;
  541.     for(new i=0;i<LoadedEntries;i++)
  542.     {
  543.         for(new j=(i+1);j<LoadedEntries;j++)
  544.         {
  545.             if(KeyHashes[i]==KeyHashes[j] && strcmpex(Keys[i],Keys[j],true))
  546.             {
  547.                 printf("[DOF] Hash-Kollision: '%s' (%d) mit '%s' (%d)",Keys[i],KeyHashes[i],Keys[j],KeyHashes[j]);
  548.                 c++;
  549.             }
  550.         }
  551.     }
  552.     return c;
  553. }
  554.  
  555. stock DOF_File(user[])
  556. {
  557.     new newfile[MAX_FILE_SIZE];
  558.     format(newfile,sizeof(newfile),USER_FILE_PATH,DOF_udb_encode(user));
  559.     return newfile;
  560. }
  561.  
  562. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  563. //DUDB (DracoBlue)
  564.  
  565. stock DOF_udb_encode(nickname[]) {
  566.     new tmp[255];
  567.     set(tmp,nickname);
  568.     tmp=strreplace("_","_00",tmp);
  569.     tmp=strreplace(";","_01",tmp);
  570.     tmp=strreplace("!","_02",tmp);
  571.     tmp=strreplace("/","_03",tmp);
  572.     tmp=strreplace("\\","_04",tmp);
  573.     tmp=strreplace("[","_05",tmp);
  574.     tmp=strreplace("]","_06",tmp);
  575.     tmp=strreplace("?","_07",tmp);
  576.     tmp=strreplace(".","_08",tmp);
  577.     tmp=strreplace("*","_09",tmp);
  578.     tmp=strreplace("<","_10",tmp);
  579.     tmp=strreplace(">","_11",tmp);
  580.     tmp=strreplace("{","_12",tmp);
  581.     tmp=strreplace("}","_13",tmp);
  582.     tmp=strreplace(" ","_14",tmp);
  583.     tmp=strreplace("\"","_15",tmp);
  584.     tmp=strreplace(":","_16",tmp);
  585.     tmp=strreplace("|","_17",tmp);
  586.     tmp=strreplace("=","_18",tmp);
  587.     return tmp;
  588. }
  589.  
  590. stock DOF_udb_decode(nickname[]) {
  591.     new tmp[255];
  592.     set(tmp,nickname);
  593.     tmp=strreplace("_01",";",tmp);
  594.     tmp=strreplace("_02","!",tmp);
  595.     tmp=strreplace("_03","/",tmp);
  596.     tmp=strreplace("_04","\\",tmp);
  597.     tmp=strreplace("_05","[",tmp);
  598.     tmp=strreplace("_06","]",tmp);
  599.     tmp=strreplace("_07","?",tmp);
  600.     tmp=strreplace("_08",".",tmp);
  601.     tmp=strreplace("_09","*",tmp);
  602.     tmp=strreplace("_10","<",tmp);
  603.     tmp=strreplace("_11",">",tmp);
  604.     tmp=strreplace("_12","{",tmp);
  605.     tmp=strreplace("_13","}",tmp);
  606.     tmp=strreplace("_14"," ",tmp);
  607.     tmp=strreplace("_15","\"",tmp);
  608.     tmp=strreplace("_16",":",tmp);
  609.     tmp=strreplace("_17","|",tmp);
  610.     tmp=strreplace("_18","=",tmp);
  611.     tmp=strreplace("_00","_",tmp);
  612.     return tmp;
  613. }
  614.  
  615. //YSI_misc.own (Y_Less)
  616.  
  617. stock DOF_bernstein(string[])
  618. {
  619.     new
  620.         h = -1,
  621.         i,
  622.         j;
  623.     while ((j = string[i++]))
  624.     {
  625.         h = h * 33 + j;
  626.     }
  627.     return h;
  628. }
  629.  
  630. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  631.  
  632. #if defined DUDB_CONVERT
  633.  
  634.     #define dUser(%0).(             DOF_GetString(DOF_File(%0),
  635.     #define dUserSet(%0).(          DOF_SetString(DOF_File(%0),
  636.     #define dUserINT(%0).(          DOF_GetInt(DOF_File(%0),
  637.     #define dUserSetINT(%0).(       DOF_SetInt(DOF_File(%0),
  638.     #define dUserFLOAT(%0).(        DOF_GetFloat(DOF_File(%0),
  639.     #define dUserSetFLOAT(%0).(     DOF_SetFloat(DOF_File(%0),
  640.     #define udb_Create(%0,%1)       DOF_CreateFile(DOF_File(%0),%1)
  641.     #define udb_RenameUser(%0,%1)   DOF_RenameFile(DOF_File(%0),DOF_File(%1))
  642.     #define udb_Exists(%0)          DOF_FileExists(DOF_File(%0))
  643.     #define udb_Remove(%0)          DOF_RemoveFile(DOF_File(%0))
  644.     #define udb_CheckLogin(%0,%1)   DOF_CheckLogin(DOF_File(%0),%1)
  645.     #define udb_hash                num_hash
  646.     #define udb_encode              DOF_udb_encode
  647.     #define udb_decode              DOF_udb_decode
  648.    
  649.     #if !defined _dudb_included
  650.         #define _dudb_included
  651.     #endif
  652. #endif
  653.  
  654. #if defined DINI_CONVERT
  655.  
  656.     #define dini_Exists             DOF_FileExists
  657.     #define dini_Remove             DOF_RemoveFile
  658.     #define dini_Create             DOF_CreateFile
  659.     #define dini_Set                DOF_SetString
  660.     #define dini_Get                DOF_GetString
  661.     #define dini_IntSet             DOF_SetInt
  662.     #define dini_Int                DOF_GetInt
  663.     #define dini_BoolSet            DOF_SetBool
  664.     #define dini_Bool               DOF_GetBool
  665.     #define dini_FloatSet           DOF_SetFloat
  666.     #define dini_Float              DOF_GetFloat
  667.     #define dini_Unset              DOF_Unset
  668.     #define dini_Isset              DOF_IsSet
  669.    
  670.     #if !defined _dini_included
  671.         #define _dini_included
  672.     #endif
  673. #endif
Advertisement
Add Comment
Please, Sign In to add comment