Advertisement
Guest User

Double-O-Seven

a guest
Sep 17th, 2010
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.89 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 128 // Eintraege zum lesen
  20. #define MAX_KEY_SIZE 64
  21. #define MAX_VALUE_SIZE 256
  22. #define MAX_FILE_SIZE 64
  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))
  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) || strcmp(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] && !strcmp(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(!strcmp(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) || strcmp(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] && !strcmp(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(!strcmp(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) || strcmp(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] && !strcmp(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(!strcmp(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) || strcmp(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] && !strcmp(Keys[i],key,true))
  318.                         return 1;
  319.             }
  320.             else
  321.             {
  322.                 for(new i=0;i<LoadedEntries;i++)
  323.                     if(!strcmp(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) || strcmp(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] && !strcmp(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(!strcmp(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) && !strcmp(file,LoadedFile,false))//Gespeicherte Datei löschen, falls die gespeicherte Datei die ist, welche gelöscht werden soll.
  412.         {
  413.             LoadedFile[0]='\0';
  414.             LoadedEntries=0;
  415.         }
  416.         return fremove(file);
  417.     }
  418.     return 0;
  419. }
  420.  
  421. stock DOF_CreateFile(file[],password[]="")
  422. {
  423.     if(!isnull(file))
  424.     {
  425.         if(!DOF_FileExists(file))
  426.         {
  427.             DOF_SaveFile();
  428.             #if defined DOF_DEBUG
  429.                 printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  430.             #endif
  431.             new File:f=fopen(file,io_append);
  432.             fclose(f);
  433.             DOF_SetFile(file);
  434.             LoadedEntries=0;
  435.             if(!isnull(password))
  436.                 DOF_SetInt(file,"password_hash",num_hash(password));
  437.             return DOF_SaveFile();
  438.         }
  439.     }
  440.     return 0;
  441. }
  442.  
  443. stock DOF_RenameFile(oldfile[],newfile[])
  444. {
  445.     if(!isnull(oldfile) && !isnull(newfile))
  446.     {
  447.         if(DOF_FileExists(oldfile) && !DOF_FileExists(newfile))
  448.         {
  449.             if(FileChanged)
  450.                 DOF_SaveFile();//Derzeitige Datei speichern
  451.             DOF_SetFile(oldfile);
  452.             DOF_LoadFile();
  453.             fremove(oldfile);
  454.             DOF_SetFile(newfile);
  455.             return DOF_SaveFile();
  456.         }
  457.     }
  458.     return 0;
  459. }
  460.  
  461. stock DOF_RenameKey(file[],oldkey[],newkey[],bool:hashcmp=true)
  462. {
  463.     if(!isnull(file) && !isnull(oldkey) && !isnull(newkey))
  464.     {
  465.         if(DOF_FileExists(file))
  466.         {
  467.             if(isnull(LoadedFile) || strcmp(file,LoadedFile,false))//Neue Datei laden.
  468.             {
  469.                 if(FileChanged)
  470.                     DOF_SaveFile();
  471.                 #if defined DOF_DEBUG
  472.                     printf("[DOF] Alte Datei ('%s') gespeichert, lade neue ('%s')!",LoadedFile,file);
  473.                 #endif
  474.                 DOF_SetFile(file);
  475.                 DOF_LoadFile();
  476.             }
  477.  
  478.             if(hashcmp)
  479.             {
  480.                 for(new i=0, h=DOF_bernstein(oldkey);i<LoadedEntries;i++)
  481.                 {
  482.                     if(h==KeyHashes[i] && !strcmp(Keys[i],oldkey,true))
  483.                     {
  484.                         FileChanged=true;
  485.                         strcpy(Keys[i],newkey,MAX_KEY_SIZE);
  486.                         KeyHashes[i]=DOF_bernstein(Keys[i]);
  487.                         return 1;
  488.                     }
  489.                 }
  490.             }
  491.             else
  492.             {
  493.                 for(new i=0;i<LoadedEntries;i++)
  494.                 {
  495.                     if(!strcmp(Keys[i],oldkey,true))
  496.                     {
  497.                         FileChanged=true;
  498.                         strcpy(Keys[i],newkey,MAX_KEY_SIZE);
  499.                         KeyHashes[i]=DOF_bernstein(Keys[i]);
  500.                         return 1;
  501.                     }
  502.                 }
  503.             }
  504.         }
  505.     }
  506.     return 0;
  507. }
  508.  
  509. stock DOF_CopyFile(filetocopy[],newfile[])
  510. {
  511.     if(!isnull(filetocopy) && !isnull(newfile))
  512.     {
  513.         if(DOF_FileExists(filetocopy) && !DOF_FileExists(newfile))
  514.         {
  515.             if(FileChanged)
  516.                 DOF_SaveFile();//Derzeitige Datei speichern
  517.             DOF_SetFile(filetocopy);
  518.             DOF_LoadFile();
  519.             DOF_SetFile(newfile);
  520.             return DOF_SaveFile();
  521.         }
  522.     }
  523.     return 0;
  524. }
  525.  
  526. stock DOF_CheckLogin(file[],password[])
  527. {
  528.     if(!isnull(file) && !isnull(password))
  529.         if(num_hash(password)==DOF_GetInt(file,"password_hash"))
  530.             return 1;
  531.     return 0;
  532. }
  533.  
  534. stock DOF_GetHashCols()
  535. {
  536.     new c;
  537.     for(new i=0;i<LoadedEntries;i++)
  538.     {
  539.         for(new j=(i+1);j<LoadedEntries;j++)
  540.         {
  541.             if(KeyHashes[i]==KeyHashes[j] && strcmp(Keys[i],Keys[j],true))
  542.             {
  543.                 printf("[DOF] Hash-Kollision: '%s' (%d) mit '%s' (%d)",Keys[i],KeyHashes[i],Keys[j],KeyHashes[j]);
  544.                 c++;
  545.             }
  546.         }
  547.     }
  548.     return c;
  549. }
  550.  
  551. stock DOF_File(user[])
  552. {
  553.     new newfile[MAX_FILE_SIZE];
  554.     format(newfile,sizeof(newfile),USER_FILE_PATH,DOF_udb_encode(user));
  555.     return newfile;
  556. }
  557.  
  558. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  559. //DUDB (DracoBlue)
  560.  
  561. stock DOF_udb_encode(nickname[]) {
  562.     new tmp[255];
  563.     set(tmp,nickname);
  564.     tmp=strreplace("_","_00",tmp);
  565.     tmp=strreplace(";","_01",tmp);
  566.     tmp=strreplace("!","_02",tmp);
  567.     tmp=strreplace("/","_03",tmp);
  568.     tmp=strreplace("\\","_04",tmp);
  569.     tmp=strreplace("[","_05",tmp);
  570.     tmp=strreplace("]","_06",tmp);
  571.     tmp=strreplace("?","_07",tmp);
  572.     tmp=strreplace(".","_08",tmp);
  573.     tmp=strreplace("*","_09",tmp);
  574.     tmp=strreplace("<","_10",tmp);
  575.     tmp=strreplace(">","_11",tmp);
  576.     tmp=strreplace("{","_12",tmp);
  577.     tmp=strreplace("}","_13",tmp);
  578.     tmp=strreplace(" ","_14",tmp);
  579.     tmp=strreplace("\"","_15",tmp);
  580.     tmp=strreplace(":","_16",tmp);
  581.     tmp=strreplace("|","_17",tmp);
  582.     tmp=strreplace("=","_18",tmp);
  583.     return tmp;
  584. }
  585.  
  586. stock DOF_udb_decode(nickname[]) {
  587.     new tmp[255];
  588.     set(tmp,nickname);
  589.     tmp=strreplace("_01",";",tmp);
  590.     tmp=strreplace("_02","!",tmp);
  591.     tmp=strreplace("_03","/",tmp);
  592.     tmp=strreplace("_04","\\",tmp);
  593.     tmp=strreplace("_05","[",tmp);
  594.     tmp=strreplace("_06","]",tmp);
  595.     tmp=strreplace("_07","?",tmp);
  596.     tmp=strreplace("_08",".",tmp);
  597.     tmp=strreplace("_09","*",tmp);
  598.     tmp=strreplace("_10","<",tmp);
  599.     tmp=strreplace("_11",">",tmp);
  600.     tmp=strreplace("_12","{",tmp);
  601.     tmp=strreplace("_13","}",tmp);
  602.     tmp=strreplace("_14"," ",tmp);
  603.     tmp=strreplace("_15","\"",tmp);
  604.     tmp=strreplace("_16",":",tmp);
  605.     tmp=strreplace("_17","|",tmp);
  606.     tmp=strreplace("_18","=",tmp);
  607.     tmp=strreplace("_00","_",tmp);
  608.     return tmp;
  609. }
  610.  
  611. //YSI_misc.own (Y_Less)
  612.  
  613. stock DOF_bernstein(string[])
  614. {
  615.     new
  616.         h = -1,
  617.         i,
  618.         j;
  619.     while ((j = string[i++]))
  620.     {
  621.         h = h * 33 + j;
  622.     }
  623.     return h;
  624. }
  625.  
  626. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  627.  
  628. #if defined DUDB_CONVERT
  629.  
  630.     #define dUser(%0).(             DOF_GetString(DOF_File(%0),
  631.     #define dUserSet(%0).(          DOF_SetString(DOF_File(%0),
  632.     #define dUserINT(%0).(          DOF_GetInt(DOF_File(%0),
  633.     #define dUserSetINT(%0).(       DOF_SetInt(DOF_File(%0),
  634.     #define dUserFLOAT(%0).(        DOF_GetFloat(DOF_File(%0),
  635.     #define dUserSetFLOAT(%0).(     DOF_SetFloat(DOF_File(%0),
  636.     #define udb_Create(%0,%1)       DOF_CreateFile(DOF_File(%0),%1)
  637.     #define udb_RenameUser(%0,%1)   DOF_RenameFile(DOF_File(%0),DOF_File(%1))
  638.     #define udb_Exists(%0)          DOF_FileExists(DOF_File(%0))
  639.     #define udb_Remove(%0)          DOF_RemoveFile(DOF_File(%0))
  640.     #define udb_CheckLogin(%0,%1)   DOF_CheckLogin(DOF_File(%0),%1)
  641.     #define udb_hash                num_hash
  642.     #define udb_encode              DOF_udb_encode
  643.     #define udb_decode              DOF_udb_decode
  644.    
  645.     #if !defined _dudb_included
  646.         #define _dudb_included
  647.     #endif
  648. #endif
  649.  
  650. #if defined DINI_CONVERT
  651.  
  652.     #define dini_Exists             DOF_FileExists
  653.     #define dini_Remove             DOF_RemoveFile
  654.     #define dini_Create             DOF_CreateFile
  655.     #define dini_Set                DOF_SetString
  656.     #define dini_Get                DOF_GetString
  657.     #define dini_IntSet             DOF_SetInt
  658.     #define dini_Int                DOF_GetInt
  659.     #define dini_BoolSet            DOF_SetBool
  660.     #define dini_Bool               DOF_GetBool
  661.     #define dini_FloatSet           DOF_SetFloat
  662.     #define dini_Float              DOF_GetFloat
  663.     #define dini_Unset              DOF_Unset
  664.     #define dini_Isset              DOF_IsSet
  665.    
  666.     #if !defined _dini_included
  667.         #define _dini_included
  668.     #endif
  669. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement