home *** CD-ROM | disk | FTP | other *** search
/ Speelhal Klassiekers - Hits des Salles de Jeux / Arcade.bin / games / Xonix32 / SRC / HISCORES.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-05  |  2.5 KB  |  99 lines

  1.  
  2. //===========================
  3. // HiScores.cpp
  4. // by SA VanNess
  5. // 05 Jun 97
  6. // for the Win32 platform
  7. //===========================
  8. // High score table
  9. // Class implementation
  10. //===========================
  11. // Copyright (C) 1997  SA VanNess
  12. // <savanness@pipeline.com>
  13. //
  14. // For copyright information, see the file gnu_license.txt included
  15. // with this source code distribution.
  16. //
  17. // This program is free software; you can redistribute it and/or modify
  18. // it under the terms of the GNU General Public License as published by
  19. // the Free Software Foundation; either version 2 of the License, or
  20. // (at your option) any later version.
  21. //
  22. // This program is distributed in the hope that it will be useful,
  23. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. // GNU General Public License for more details.
  26. //
  27. // You should have received a copy of the GNU General Public License
  28. // along with this program; if not, write to the Free Software
  29. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30. //===========================
  31.  
  32. #include <afxwin.h>
  33. #include <afxcmn.h>
  34. #include <afxres.h>
  35.  
  36. #include "macros.h"
  37. #include "hiscores.h"
  38.  
  39. //-----------------
  40. BOOL CScoreList::Save()
  41. {
  42. int i,j;
  43. FILE* pf = fopen("hiscores.dat","wb");
  44. if (!pf) return FALSE;
  45.  
  46. for(i=0; i < 10; i++) m_iScoreArray[i] ^= 0x55555555;
  47. for(i=0; i < 10; i++) for(j=0; j < 16; j++) m_szNameArray[i][j] ^= 0x55;
  48. fwrite(m_iScoreArray,sizeof(UINT),10,pf);
  49. fwrite(m_szNameArray,16,10,pf);
  50. for(i=0; i < 10; i++) m_iScoreArray[i] ^= 0x55555555;
  51. for(i=0; i < 10; i++) for(j=0; j < 16; j++) m_szNameArray[i][j] ^= 0x55;
  52.  
  53. fclose(pf);
  54. return TRUE;
  55. }
  56.  
  57. //-----------------
  58. BOOL CScoreList::Load()
  59. {
  60. int i,j;
  61. FILE* pf = fopen("hiscores.dat","rb");
  62. if (!pf)
  63.    {
  64.    for(UINT i=0; i < 10; i++)
  65.       {
  66.       m_iScoreArray[i] = 0;
  67.       strcpy(m_szNameArray[i],"...empty...");
  68.       }
  69.    return FALSE;
  70.    }
  71.  
  72. fread(m_iScoreArray,sizeof(UINT),10,pf);
  73. fread(m_szNameArray,16,10,pf);
  74. for(i=0; i < 10; i++) m_iScoreArray[i] ^= 0x55555555;
  75. for(i=0; i < 10; i++) for(j=0; j < 16; j++) m_szNameArray[i][j] ^= 0x55;
  76.  
  77. fclose(pf);
  78. return TRUE;
  79. }
  80.  
  81. //-----------------
  82. void CScoreList::Insert(UINT iSlot, char* pszName, UINT iScore)
  83. {
  84. UINT j=0;
  85.  
  86. j = 9;
  87. while(j > iSlot)
  88.    {
  89.    m_iScoreArray[j] = m_iScoreArray[j-1];
  90.    strcpy(m_szNameArray[j],m_szNameArray[j-1]);
  91.    j--;
  92.    }
  93. m_iScoreArray[j] = iScore;
  94. strcpy(m_szNameArray[j],pszName);
  95.  
  96. return;
  97. }
  98.  
  99.