Advertisement
Guest User

EMPIRE

a guest
May 29th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "empire_text_convert.h"
  3.  
  4. namespace
  5. {
  6. struct STextConvertTable
  7. {
  8. char acUpper[26];
  9. char acLower[26];
  10. BYTE aacHan[5000][2];
  11. BYTE aacJaum[50][2];
  12. BYTE aacMoum[50][2];
  13. } g_aTextConvTable[3];
  14. }
  15.  
  16. bool LoadEmpireTextConvertTable(DWORD dwEmpireID, const char* c_szFileName)
  17. {
  18. if (dwEmpireID < 1 || dwEmpireID > 3)
  19. return false;
  20.  
  21. FILE * fp = fopen(c_szFileName, "rb");
  22.  
  23. if (!fp)
  24. return false;
  25.  
  26. DWORD dwEngCount = 26;
  27. DWORD dwHanCount = (0xC8 - 0xB0+1) * (0xFE - 0xA1+1);
  28. DWORD dwHanSize = dwHanCount * 2;
  29.  
  30. STextConvertTable& rkTextConvTable=g_aTextConvTable[dwEmpireID-1];
  31.  
  32. fread(rkTextConvTable.acUpper, 1, dwEngCount, fp);
  33. fread(rkTextConvTable.acLower, 1, dwEngCount, fp);
  34. fread(rkTextConvTable.aacHan, 1, dwHanSize, fp);
  35.  
  36. fread(rkTextConvTable.aacJaum, 1, 60, fp);
  37. fread(rkTextConvTable.aacMoum, 1, 42, fp);
  38.  
  39. fclose(fp);
  40.  
  41. return true;
  42. }
  43.  
  44. #ifdef ENABLE_NEWSTUFF
  45. #include "config.h"
  46. #endif
  47. void ConvertEmpireText(DWORD dwEmpireID, char* szText, size_t len, int iPct)
  48. {
  49. #ifdef ENABLE_NEWSTUFF
  50. if(g_bGlobalShoutEnable || g_bDisableEmpireLanguageCheck)
  51. return;
  52. #endif
  53. if (dwEmpireID < 1 || dwEmpireID > 3 || len == 0)
  54. return;
  55.  
  56. const STextConvertTable& rkTextConvTable = g_aTextConvTable[dwEmpireID - 1];
  57.  
  58. for (BYTE* pbText = reinterpret_cast<BYTE*>(szText) ; len > 0 && *pbText != '\0' ; --len, ++pbText)
  59. {
  60. if (number(1,100) > iPct)
  61. {
  62. if (*pbText & 0x80)
  63. {
  64. static char s_cChinaTable[][3] = {"¡ò","££","£¤","¡ù","¡ð" };
  65. int n = number(0, 4);
  66. pbText[0] = s_cChinaTable[n][0];
  67. pbText[1] = s_cChinaTable[n][1];
  68.  
  69. ++pbText;
  70. --len;
  71. }
  72. else
  73. {
  74. if (*pbText >= 'a' && *pbText <= 'z')
  75. {
  76. *pbText = rkTextConvTable.acLower[*pbText - 'a'];
  77. }
  78. else if (*pbText >= 'A' && *pbText <= 'Z')
  79. {
  80. *pbText = rkTextConvTable.acUpper[*pbText - 'A'];
  81. }
  82. }
  83. }
  84. else
  85. {
  86. if (*pbText & 0x80)
  87. {
  88. ++pbText;
  89. --len;
  90. }
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement