Browse Source

PAL_swprintf accepts number of chars rather than bytes.

LouYihua 7 years ago
parent
commit
28e3b9498b
4 changed files with 7 additions and 7 deletions
  1. 2 2
      battle.c
  2. 2 2
      fight.c
  3. 2 2
      script.c
  4. 1 1
      text.c

+ 2 - 2
battle.c

@@ -748,7 +748,7 @@ PAL_BattleWon(
          PAL_CreateBox(PAL_XY(offsetX+82, 32), 7, propertyLength+8, 1, FALSE);
 
          WCHAR buffer[256] = L"";
-		 PAL_swprintf(buffer, sizeof(buffer), L"%ls%ls%ls", PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_GetWord(STATUS_LABEL_LEVEL), PAL_GetWord(BATTLEWIN_LEVELUP_LABEL));
+		 PAL_swprintf(buffer, sizeof(buffer) / sizeof(WCHAR), L"%ls%ls%ls", PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_GetWord(STATUS_LABEL_LEVEL), PAL_GetWord(BATTLEWIN_LEVELUP_LABEL));
          PAL_DrawText(buffer, PAL_XY(110, 10), 0, FALSE, FALSE, FALSE);
 
          for (j = 0; j < 8; j++)
@@ -883,7 +883,7 @@ PAL_BattleWon(
    if (gpGlobals->g.PlayerRoles.statname[w] != OrigPlayerRoles.statname[w]) \
    {                                                        \
       WCHAR buffer[256] = L""; \
-      PAL_swprintf(buffer, sizeof(buffer), L"%ls%ls%ls", PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_GetWord(label), PAL_GetWord(BATTLEWIN_LEVELUP_LABEL)); \
+      PAL_swprintf(buffer, sizeof(buffer) / sizeof(WCHAR), L"%ls%ls%ls", PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_GetWord(label), PAL_GetWord(BATTLEWIN_LEVELUP_LABEL)); \
       PAL_CreateSingleLineBox(PAL_XY(offsetX+78, 60), maxNameWidth+maxPropertyWidth+PAL_TextWidth(PAL_GetWord(BATTLEWIN_LEVELUP_LABEL))/32+4, FALSE);    \
       PAL_DrawText(buffer, PAL_XY(offsetX+90, 70),  0, FALSE, FALSE, FALSE); \
       PAL_DrawNumber(gpGlobals->g.PlayerRoles.statname[w] - OrigPlayerRoles.statname[w], 5, PAL_XY(183+(maxNameWidth+maxPropertyWidth-3)*8, 74), kNumColorYellow, kNumAlignRight); \

+ 2 - 2
fight.c

@@ -4832,7 +4832,7 @@ PAL_BattleStealFromEnemy(
 
          if (c > 0)
          {
-			 PAL_swprintf(s, sizeof(s), L"%ls %d %ls", PAL_GetWord(34), c, PAL_GetWord(10));
+			 PAL_swprintf(s, sizeof(s) / sizeof(WCHAR), L"%ls %d %ls", PAL_GetWord(34), c, PAL_GetWord(10));
          }
       }
       else
@@ -4843,7 +4843,7 @@ PAL_BattleStealFromEnemy(
          g_Battle.rgEnemy[wTarget].e.nStealItem--;
          PAL_AddItemToInventory(g_Battle.rgEnemy[wTarget].e.wStealItem, 1);
 
-         PAL_swprintf(s, sizeof(s), L"%ls%ls", PAL_GetWord(34), g_Battle.rgEnemy[wTarget].e.wStealItem);
+         PAL_swprintf(s, sizeof(s) / sizeof(WCHAR), L"%ls%ls", PAL_GetWord(34), g_Battle.rgEnemy[wTarget].e.wStealItem);
 	  }
 
       if (s[0] != '\0')

+ 2 - 2
script.c

@@ -562,7 +562,7 @@ PAL_AdditionalCredits(
    for (i = 0; i < 12; i++)
    {
       WCHAR buffer[48];
-	  PAL_swprintf(buffer, sizeof(buffer), rgszStrings[i], gConfig.pszMsgFile ? g_rcCredits[i] : rgszcps[i][gConfig.uCodePage]);
+	  PAL_swprintf(buffer, sizeof(buffer) / sizeof(WCHAR), rgszStrings[i], gConfig.pszMsgFile ? g_rcCredits[i] : rgszcps[i][gConfig.uCodePage]);
 	  PAL_DrawText(buffer, PAL_XY(0, 2 + i * 16), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
    }
 
@@ -1438,7 +1438,7 @@ PAL_InterpretInstruction(
          PAL_AddItemToInventory(gpGlobals->g.lprgStore[0].rgwItems[i], 1);
 
          PAL_StartDialog(kDialogCenterWindow, 0, 0, FALSE);
-         PAL_swprintf(s, sizeof(s), L"%ls%ls", PAL_GetWord(42), PAL_GetWord(gpGlobals->g.lprgStore[0].rgwItems[i]));
+         PAL_swprintf(s, sizeof(s) / sizeof(WCHAR), L"%ls%ls", PAL_GetWord(42), PAL_GetWord(gpGlobals->g.lprgStore[0].rgwItems[i]));
          PAL_ShowDialogText(s);
       }
       else

+ 1 - 1
text.c

@@ -1798,7 +1798,7 @@ PAL_MultiByteToWideChar(
   Parameters:
 
     [IN]  buffer - Storage location for output.
-	[IN]  count - Size of the output buffer, including the termination null character.
+	[IN]  count - Length of the output buffer in characters including the termination null one.
 	[IN]  format - Format-control string.
 	[IN]  ... - Optional arguments.