Internationalization updates: disposed of wXXXX() string calls; using text manipulation calls from strlib where needed (from zap); reasonably cranked UNICODE buffers; separated readable English strings from sprintf() format strings

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2171 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2006-01-13 03:49:11 +00:00
parent 08443a64f7
commit 4d61775397
43 changed files with 398 additions and 301 deletions
+11 -12
View File
@@ -72,7 +72,7 @@ static BOOLEAN getLineWithinWidth(TEXT *pText,
LOCDATA CommData;
int cur_comm;
UNICODE shared_phrase_buf[256];
UNICODE shared_phrase_buf[2048];
volatile BOOLEAN summary = FALSE;
typedef struct response_entry
@@ -1564,12 +1564,14 @@ DoCommunication (PENCOUNTER_STATE pES)
if (temp == NULL)
continue;
// fprintf (stderr, "%s\n", temp);
while (wstrlen (temp) > (unsigned int) SUMMARY_CHARS
while (utf8StringCount (temp) > (unsigned int) SUMMARY_CHARS
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
int space_index = SUMMARY_CHARS;
UNICODE *pend = skipUTF8Chars (temp, SUMMARY_CHARS);
int space_index = pend - temp;
// find last space before it goes over the max chars per line
for (i = SUMMARY_CHARS - 1; i > 0; i--)
for (i = space_index; i > 0; i--)
{
if (temp[i] == ' ')
{
@@ -1577,12 +1579,9 @@ DoCommunication (PENCOUNTER_STATE pES)
break;
}
}
for (i = 0; i < space_index; i++, temp++)
{
buffer[i] = *temp;
}
buffer[i] = '\0';
temp++;
strncpy (buffer, temp, space_index);
buffer[space_index] = '\0';
temp += space_index + 1;
t.pStr = buffer;
LockMutex (GraphicsLock);
font_DrawText (&t);
@@ -1593,7 +1592,7 @@ DoCommunication (PENCOUNTER_STATE pES)
{
t.baseline.x = SIS_SCREEN_WIDTH >> 1;
t.align = ALIGN_CENTER;
t.pStr = "_MORE_";
t.pStr = STR_MIDDLE_DOT "MORE" STR_MIDDLE_DOT;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x17, 0x00), 0x01));
LockMutex (GraphicsLock);
font_DrawText (&t);
@@ -1627,7 +1626,7 @@ DoCommunication (PENCOUNTER_STATE pES)
t.baseline.x = SIS_SCREEN_WIDTH >> 1;
t.align = ALIGN_CENTER;
t.pStr = "_MORE_";
t.pStr = STR_MIDDLE_DOT "MORE" STR_MIDDLE_DOT;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x17, 0x00), 0x01));
LockMutex (GraphicsLock);
font_DrawText (&t);
+1 -1
View File
@@ -1497,7 +1497,7 @@ yack0_respond (void)
{
case 0:
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+1 -1
View File
@@ -297,7 +297,7 @@ DiscussConquer (RESPONSE_REF R)
if (PHRASE_ENABLED (conquer_because_1))
{
#if 0
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+1 -1
View File
@@ -339,7 +339,7 @@ RealizeMistake (RESPONSE_REF R)
SET_GAME_STATE (SHOFIXTI_STACK2, 3);
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+1 -1
View File
@@ -435,7 +435,7 @@ NeutralSupox (RESPONSE_REF R)
break;
case 2:
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+1 -1
View File
@@ -545,7 +545,7 @@ NeutralUtwig (RESPONSE_REF R)
{
case 0:
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+2 -2
View File
@@ -367,7 +367,7 @@ YehatHome (RESPONSE_REF R)
Response (give_info, YehatHome);
if (!GET_GAME_STATE (NO_YEHAT_ALLY_HOME))
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
@@ -494,7 +494,7 @@ YehatSpace (RESPONSE_REF R)
{
case 0:
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+1 -1
View File
@@ -403,7 +403,7 @@ AquaintZoqFot (RESPONSE_REF R)
if (PHRASE_ENABLED (we_are_vindicator0))
{
UNICODE buf[80];
UNICODE buf[ALLIANCE_NAME_BUFSIZE];
GetAllianceName (buf, name_1);
construct_response (
+25 -12
View File
@@ -28,7 +28,7 @@ int NPCNumberPhrase (int number, UNICODE **ptrack);
void
NPCPhrase_cb (int index, TFB_TrackCB cb)
{
UNICODE *pStr, numbuf[100];
UNICODE *pStr, numbuf[400];
void *pClip, *pTimeStamp;
switch (index)
@@ -52,7 +52,7 @@ NPCPhrase_cb (int index, TFB_TrackCB cb)
adx = dx >= 0 ? dx : -dx;
dy = 9812 - LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
ady = dy >= 0 ? dy : -dy;
wsprintf (numbuf,
sprintf (numbuf,
"%+04d.%01u,%+04d.%01u",
(SIZE)(dy / 10), (COUNT)(ady % 10),
(SIZE)(dx / 10), (COUNT)(adx % 10));
@@ -86,9 +86,9 @@ NPCPhrase_cb (int index, TFB_TrackCB cb)
i = GET_GAME_STATE (NEW_ALLIANCE_NAME);
S = SetAbsStringTableIndex (CommData.ConversationPhrases, (index - 1) + i);
wstrcpy (numbuf, (UNICODE *)GetStringAddress (S));
strcpy (numbuf, (UNICODE *)GetStringAddress (S));
if (i == 3)
wstrcat (numbuf, GLOBAL_SIS (CommanderName));
strcat (numbuf, GLOBAL_SIS (CommanderName));
}
pStr = numbuf;
pClip = 0;
@@ -121,7 +121,7 @@ NPCNumberPhrase (int number, UNICODE **ptrack)
int queued = 0;
int toplevel = 0;
UNICODE *TrackNames[MAX_NUMBER_TRACKS];
UNICODE numbuf[32];
UNICODE numbuf[60];
if (!speech)
return 0;
@@ -224,17 +224,20 @@ GetAllianceName (UNICODE *buf, RESPONSE_REF name_1)
i = GET_GAME_STATE (NEW_ALLIANCE_NAME);
S = SetAbsStringTableIndex (CommData.ConversationPhrases, (name_1 - 1) + i);
wstrcpy (buf, (UNICODE *)GetStringAddress (S));
// XXX: this should someday be changed so that the function takes
// the buffer size as an argument
strcpy (buf, (UNICODE *)GetStringAddress (S));
if (i == 3)
{
wstrcat (buf, GLOBAL_SIS (CommanderName));
wstrcat (buf, (UNICODE *)GetStringAddress (SetRelStringTableIndex (S, 1)));
strcat (buf, GLOBAL_SIS (CommanderName));
strcat (buf, (UNICODE *)GetStringAddress (SetRelStringTableIndex (S, 1)));
}
}
void
construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...)
{
UNICODE *buf_start = buf;
UNICODE *name;
va_list vlist;
@@ -247,9 +250,9 @@ construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...)
S = SetAbsStringTableIndex (CommData.ConversationPhrases, R - 1);
wstrcpy (buf, (UNICODE *)GetStringAddress (S));
strcpy (buf, (UNICODE *)GetStringAddress (S));
len = wstrlen (buf);
len = strlen (buf);
buf += len;
@@ -257,8 +260,8 @@ construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...)
if (name)
{
len = wstrlen (name);
wstrncpy (buf, name, len);
len = strlen (name);
strncpy (buf, name, len);
buf += len;
/*
@@ -274,6 +277,16 @@ construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...)
va_end (vlist);
*buf = '\0';
// XXX: this should someday be changed so that the function takes
// the buffer size as an argument
if ((buf_start == shared_phrase_buf) &&
(buf - shared_phrase_buf > sizeof (shared_phrase_buf)))
{
fprintf (stderr, "Error: shared_phrase_buf size exceeded,"
" please increase!\n");
abort ();
}
}
LOCDATAPTR
+2 -1
View File
@@ -26,7 +26,7 @@
extern LOCDATA CommData;
extern int cur_comm;
extern UNICODE shared_phrase_buf[256];
extern UNICODE shared_phrase_buf[2048];
#define PLAYER_SAID(r,i) ((r)==(i))
#define PHRASE_ENABLED(p) \
@@ -63,6 +63,7 @@ extern void DoNPCPhrase (UNICODE *pStr);
extern void NPCPhrase_cb (int index, TFB_TrackCB cb);
#define NPCPhrase(index) NPCPhrase_cb ((index), NULL)
#define ALLIANCE_NAME_BUFSIZE 256
extern void GetAllianceName (UNICODE *buf, RESPONSE_REF name_1);
extern void construct_response (UNICODE *buf, int R /* promoted from
+4 -11
View File
@@ -79,24 +79,17 @@ Credits_MakeTextFrame (int w, int h, COLOR TransColor)
return f;
}
static void
CopyTextString (char *Buffer, COUNT BufSize, const char *Src)
{
strncpy (Buffer, Src, BufSize);
Buffer[BufSize - 1] = '\0';
}
static int
ParseTextLines (TEXT *Lines, int MaxLines, char *Buffer)
{
int i;
const char* pEnd = Buffer + strlen(Buffer);
const char* pEnd = Buffer + strlen (Buffer);
for (i = 0; i < MaxLines && Buffer < pEnd; ++i, ++Lines)
{
char* pTerm = strchr(Buffer, '\n');
char* pTerm = strchr (Buffer, '\n');
if (!pTerm)
pTerm = Buffer + strlen(Buffer);
pTerm = Buffer + strlen (Buffer);
*pTerm = '\0'; /* terminate string */
Lines->pStr = Buffer;
Lines->CharCount = ~0;
@@ -162,7 +155,7 @@ Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir,
return 0;
pStr += scaned;
CopyTextString (buf, sizeof (buf), pStr);
utf8StringCopy (buf, sizeof (buf), pStr);
rows = ParseTextLines (TextLines, MAX_TEXT_LINES, buf);
if (rows == 0)
return 0;
+6 -5
View File
@@ -246,7 +246,7 @@ InitEncounter (void)
}
else
{
UNICODE buf[40];
UNICODE buf[256];
t.pStr = GAME_STRING (ENCOUNTER_STRING_BASE + 2);
t.CharCount = (COUNT)~0;
@@ -452,7 +452,7 @@ UninitEncounter (void)
STAMP ship_s;
const UNICODE *str1 = NULL;
const UNICODE *str2 = NULL;
UNICODE buf[20];
UNICODE buf[80];
HSTARSHIP hStarShip;
SHIP_FRAGMENTPTR FragPtr;
COLOR fade_ship_cycle[] =
@@ -563,7 +563,8 @@ UninitEncounter (void)
GetStringContents (
FragPtr->ShipInfo.race_strings,
(STRINGPTR)buf, FALSE);
wstrupr (buf);
// XXX: this will not work with UTF-8 strings
strupr (buf);
t.baseline.x = scavenge_r.corner.x + 100;
t.baseline.y = scavenge_r.corner.y + 68;
@@ -601,7 +602,7 @@ UninitEncounter (void)
/* collect bounty ResUnits */
j = race_bounty[battle_counter - 1] >> 3;
RecycleAmount += j;
wsprintf (buf, "%u", RecycleAmount);
sprintf (buf, "%u", RecycleAmount);
t.baseline.x = r.corner.x + r.extent.width - 1;
t.baseline.y = r.corner.y + 14;
t.align = ALIGN_RIGHT;
@@ -680,7 +681,7 @@ UninitEncounter (void)
r.corner.x = scavenge_r.corner.x + 10;
r.extent.width = 132;
DrawFilledRectangle (&r);
wsprintf (buf, "%u RU", RecycleAmount);
sprintf (buf, "%u %s", RecycleAmount, "RU");
t.baseline.x = r.corner.x + (r.extent.width >> 1);
t.baseline.y = r.corner.y + 14;
t.align = ALIGN_CENTER;
+34 -27
View File
@@ -131,15 +131,18 @@ enum
static void
FeedbackSetting (BYTE which_setting)
{
UNICODE buf[64];
UNICODE buf[128];
const char *tmpstr;
buf[0] = '\0';
// pre-terminate buffer in case snprintf() overflows
buf[sizeof (buf) - 1] = '\0';
switch (which_setting)
{
case SOUND_ON_SETTING:
case SOUND_OFF_SETTING:
snprintf (buf, sizeof buf, "%s %s",
snprintf (buf, sizeof (buf) - 1, "%s %s",
GAME_STRING (OPTION_STRING_BASE + 0),
GLOBAL (glob_flags) & SOUND_DISABLED
? GAME_STRING (OPTION_STRING_BASE + 3) :
@@ -147,7 +150,7 @@ FeedbackSetting (BYTE which_setting)
break;
case MUSIC_ON_SETTING:
case MUSIC_OFF_SETTING:
snprintf (buf, sizeof buf, "%s %s",
snprintf (buf, sizeof (buf) - 1, "%s %s",
GAME_STRING (OPTION_STRING_BASE + 1),
GLOBAL (glob_flags) & MUSIC_DISABLED
? GAME_STRING (OPTION_STRING_BASE + 3) :
@@ -167,7 +170,7 @@ FeedbackSetting (BYTE which_setting)
}
else
tmpstr = "";
snprintf (buf, sizeof buf, "%s %s%s",
snprintf (buf, sizeof (buf) - 1, "%s %s%s",
GAME_STRING (OPTION_STRING_BASE + 2),
!(GLOBAL (glob_flags) & CYBORG_ENABLED)
? GAME_STRING (OPTION_STRING_BASE + 3) :
@@ -176,7 +179,8 @@ FeedbackSetting (BYTE which_setting)
break;
case CHANGE_CAPTAIN_SETTING:
case CHANGE_SHIP_SETTING:
wstrcpy (buf, GAME_STRING (NAMING_STRING_BASE + 0));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (NAMING_STRING_BASE + 0));
break;
}
@@ -188,15 +192,15 @@ FeedbackSetting (BYTE which_setting)
static void
FeedbackQuit (BYTE which_setting)
{
UNICODE buf[20];
UNICODE buf[80];
buf[0] = '\0';
switch (which_setting)
{
case NO_QUIT_MENU:
wsprintf (buf, "Don't Quit");
utf8StringCopy (buf, sizeof (buf), "Don't Quit");
break;
case YES_QUIT_MENU:
wsprintf (buf, "Quit Game");
utf8StringCopy (buf, sizeof (buf), "Quit Game");
break;
}
@@ -410,9 +414,9 @@ DoNaming (PMENU_STATE pMS)
tes.ChangeCallback = OnNameChange;
if (DoTextEntry (&tes))
wstrcpy (Setting, buf);
utf8StringCopy (Setting, sizeof (Setting), buf);
else
wstrcpy (buf, Setting);
utf8StringCopy (buf, sizeof (buf), Setting);
DrawDescriptionString (pMS, 0, DDSHS_NORMAL);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -627,7 +631,7 @@ DrawCargo (COUNT redraw_state)
else
{
TEXT t;
UNICODE buf[10];
UNICODE buf[40];
COLOR cargo_color[] =
{
BUILD_COLOR (MAKE_RGB15 (2, 14, 19), 0x00),
@@ -660,7 +664,7 @@ DrawCargo (COUNT redraw_state)
r.corner.y = t.baseline.y - r.extent.height + 1;
DrawFilledRectangle (&r);
SetContextForeGroundColor (cargo_color[i]);
wsprintf (buf, "%u", GLOBAL_SIS (ElementAmounts[i]));
sprintf (buf, "%u", GLOBAL_SIS (ElementAmounts[i]));
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += 12;
@@ -672,7 +676,7 @@ DrawCargo (COUNT redraw_state)
r.corner.y = t.baseline.y - r.extent.height + 1;
DrawFilledRectangle (&r);
SetContextForeGroundColor (cargo_color[i]);
wsprintf (buf, "%u", GLOBAL_SIS (TotalBioMass));
sprintf (buf, "%u", GLOBAL_SIS (TotalBioMass));
t.CharCount = (COUNT)~0;
font_DrawText (&t);
}
@@ -707,7 +711,7 @@ ShowSummary (SUMMARY_DESC *pSD)
QUEUE player_q;
CONTEXT OldContext;
SIS_STATE SaveSS;
unsigned char buf[80];
UNICODE buf[256];
SaveSS = GlobData.SIS_state;
player_q = GLOBAL (built_ship_q);
@@ -796,7 +800,7 @@ ShowSummary (SUMMARY_DESC *pSD)
SetContextClipRect (&OldRect);
SetContext (SpaceContext);
wsprintf (buf, "%lu", GLOBAL_SIS (ResUnits));
sprintf (buf, "%lu", GLOBAL_SIS (ResUnits));
t.baseline.y = 102;
r.extent.width = 76;
r.extent.height = SHIP_NAME_HEIGHT;
@@ -809,7 +813,7 @@ ShowSummary (SUMMARY_DESC *pSD)
t.CharCount = (COUNT)~0;
}
t.baseline.y = 126;
wsprintf (buf, "%u", MAKE_WORD (pSD->MCreditLo, pSD->MCreditHi));
sprintf (buf, "%u", MAKE_WORD (pSD->MCreditLo, pSD->MCreditHi));
r.extent.width = 30;
r.extent.height = SHIP_NAME_HEIGHT;
r.corner.x = t.baseline.x - (r.extent.width >> 1);
@@ -856,10 +860,12 @@ ShowSummary (SUMMARY_DESC *pSD)
buf[0] = '\0';
break;
case IN_HYPERSPACE:
wstrcpy (buf, GAME_STRING (NAVIGATION_STRING_BASE + 0));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (NAVIGATION_STRING_BASE + 0));
break;
case IN_QUASISPACE:
wstrcpy (buf, GAME_STRING (NAVIGATION_STRING_BASE + 1));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (NAVIGATION_STRING_BASE + 1));
break;
}
@@ -870,11 +876,12 @@ ShowSummary (SUMMARY_DESC *pSD)
t.align = ALIGN_CENTER;
t.baseline.x = SIS_SCREEN_WIDTH - 57 - 3 + (SIS_TITLE_WIDTH >> 1);
if (pSD->Activity == IN_STARBASE)
wstrcpy (buf, GAME_STRING (STARBASE_STRING_BASE));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (STARBASE_STRING_BASE));
else if (pSD->Activity == IN_PLANET_ORBIT)
wstrcpy (buf, GLOBAL_SIS (PlanetName));
utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName));
else
wsprintf (buf, "%03u.%01u : %03u.%01u",
sprintf (buf, "%03u.%01u : %03u.%01u",
r.corner.x / 10, r.corner.x % 10,
r.corner.y / 10, r.corner.y % 10);
t.CharCount = (COUNT)~0;
@@ -1063,8 +1070,8 @@ Restart:
RECT r;
TEXT t;
BYTE i, SHIFT;
UNICODE buf[80];
unsigned char buf2[15];
UNICODE buf[256];
UNICODE buf2[80];
LockMutex (GraphicsLock);
BatchGraphics ();
@@ -1128,9 +1135,9 @@ ChangeGameSelection:
t.baseline.x = r.corner.x + 3;
t.baseline.y = r.corner.y + 8;
wsprintf (buf, "%02i", NewState - SHIFT + i);
sprintf (buf, "%02i", NewState - SHIFT + i);
if (MAX_SAVED_GAMES > 99)
wsprintf (buf, "%03i", NewState - SHIFT + i);
sprintf (buf, "%03i", NewState - SHIFT + i);
font_DrawText (&t);
r.extent.width = 204 - SAFE_X;
@@ -1139,14 +1146,14 @@ ChangeGameSelection:
t.baseline.x = r.corner.x + 3;
if (((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index == 0)
wsprintf (buf, "Empty Slot");
utf8StringCopy (buf, sizeof (buf), "Empty Slot");
else
{
DateToString (buf2, sizeof buf2,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].month_index,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].day_index,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index);
wsprintf (buf, "Saved Game - Date: %s",buf2);
sprintf (buf, "%s %s", "Saved Game - Date:", buf2);
}
font_DrawText (&t);
}
+5 -2
View File
@@ -284,8 +284,11 @@ InitSIS (void)
GLOBAL_SIS (NumLanders) = 1;
wstrcpy (GLOBAL_SIS (ShipName), GAME_STRING (NAMING_STRING_BASE + 2));
wstrcpy (GLOBAL_SIS (CommanderName), GAME_STRING (NAMING_STRING_BASE + 3));
utf8StringCopy (GLOBAL_SIS (ShipName), sizeof (GLOBAL_SIS (ShipName)),
GAME_STRING (NAMING_STRING_BASE + 2));
utf8StringCopy (GLOBAL_SIS (CommanderName),
sizeof (GLOBAL_SIS (CommanderName)),
GAME_STRING (NAMING_STRING_BASE + 3));
ActivateStarShip (HUMAN_SHIP, 0);
CloneShipFragment (HUMAN_SHIP, &GLOBAL (built_ship_q), 0);
+11 -18
View File
@@ -86,13 +86,6 @@ DoFMV (const char *name, const char *loopname, BOOLEAN uninit)
return TRUE;
}
static void
CopyTextString (char *Buffer, COUNT BufSize, const char *Src)
{
strncpy (Buffer, Src, BufSize);
Buffer[BufSize - 1] = '\0';
}
static BOOLEAN
ParseColorString (const char *Src, COLOR* pColor)
{
@@ -141,13 +134,13 @@ static COUNT
ParseTextLines (TEXT *Lines, COUNT MaxLines, char* Buffer)
{
COUNT i;
const char* pEnd = Buffer + strlen(Buffer);
const char* pEnd = Buffer + strlen (Buffer);
for (i = 0; i < MaxLines && Buffer < pEnd; ++i, ++Lines)
{
char* pTerm = strchr(Buffer, '\n');
char* pTerm = strchr (Buffer, '\n');
if (!pTerm)
pTerm = Buffer + strlen(Buffer);
pTerm = Buffer + strlen (Buffer);
*pTerm = '\0'; /* terminate string */
Lines->pStr = Buffer;
Lines->CharCount = ~0;
@@ -320,10 +313,10 @@ DoPresentation (PVOID pIS)
continue;
if (1 != sscanf (pStr, "%15s", Opcode))
continue;
pStr += strlen(Opcode);
pStr += strlen (Opcode);
if (*pStr != '\0')
++pStr;
strupr(Opcode);
strupr (Opcode);
if (strcmp (Opcode, "DIMS") == 0)
{ /* set dimensions */
@@ -342,7 +335,7 @@ DoPresentation (PVOID pIS)
}
else if (strcmp (Opcode, "FONT") == 0)
{ /* set font */
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
if (pPIS->Font)
DestroyFont (ReleaseFont (pPIS->Font));
pPIS->Font = CaptureFont ((FONT_REF) LoadFontFile (pPIS->Buffer));
@@ -355,14 +348,14 @@ DoPresentation (PVOID pIS)
}
else if (strcmp (Opcode, "ANI") == 0)
{ /* set ani */
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
if (pPIS->Frame)
DestroyDrawable (ReleaseDrawable (pPIS->Frame));
pPIS->Frame = CaptureDrawable (LoadCelFile (pPIS->Buffer));
}
else if (strcmp (Opcode, "MUSIC") == 0)
{ /* set music */
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
if (pPIS->MusicRef)
{
StopMusic ();
@@ -434,7 +427,7 @@ DoPresentation (PVOID pIS)
COUNT i;
COORD y;
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
pPIS->LinesCount = ParseTextLines (pPIS->TextLines,
MAX_TEXT_LINES, pPIS->Buffer);
@@ -478,7 +471,7 @@ DoPresentation (PVOID pIS)
COUNT i;
COORD y;
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
pPIS->LinesCount = ParseTextLines (pPIS->TextLines,
MAX_TEXT_LINES, pPIS->Buffer);
@@ -674,7 +667,7 @@ DoPresentation (PVOID pIS)
{ /* call another script */
Present_UnbatchGraphics (pPIS, TRUE);
CopyTextString (pPIS->Buffer, sizeof(pPIS->Buffer), pStr);
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
ShowPresentationFile (pPIS->Buffer);
}
else if (strcmp (Opcode, "NOOP") == 0)
-2
View File
@@ -45,8 +45,6 @@ typedef SWORD SIZE;
typedef SIZE *PSIZE;
typedef unsigned char UNICODE;
#include "strtemp.h"
// XXX: this include should be removed in the future.
#define NULL_PTR 0L
-1
View File
@@ -40,7 +40,6 @@ typedef struct soundposition
#define GetSoundIndex GetStringTableIndex
#define SetAbsSoundIndex SetAbsStringTableIndex
#define SetRelSoundIndex SetRelStringTableIndex
#define GetSoundLength GetStringLength
#define GetSoundAddress GetStringAddress
#define GetSoundContents GetStringContents
+25 -23
View File
@@ -304,13 +304,14 @@ GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps)
{
int pos;
int num = 0;
while (*TimeStamps && (pos = wstrcspn (TimeStamps, ",\r\n")))
while (*TimeStamps && (pos = strcspn (TimeStamps, ",\r\n")))
{
UNICODE valStr[10];
UNICODE valStr[32];
uint32 val;
wstrncpy (valStr, TimeStamps, pos);
strncpy (valStr, TimeStamps, pos);
valStr[pos] = '\0';
val = wstrtoul(valStr,NULL,10);
val = strtoul (valStr, NULL, 10);
if (val)
{
*time_stamps = (sint32)val;
@@ -318,7 +319,7 @@ GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps)
time_stamps++;
}
TimeStamps += pos;
TimeStamps += strspn(TimeStamps, ",\r\n");
TimeStamps += strspn (TimeStamps, ",\r\n");
}
return (num);
}
@@ -339,13 +340,15 @@ SplitSubPages (UNICODE *text, sint32 *timestamp, int *num_pages)
else
split_text = (UNICODE **) HRealloc (split_text,
sizeof (UNICODE *) * (page + 1));
// XXX: this will only work when ASCII punctuation and spaces
// are used exclusively
if (!ispunct (text[pos - 1]) && !isspace (text[pos - 1]))
{
split_text[page] = HMalloc (sizeof (UNICODE) * (pos + ellips + 4));
if (ellips)
wstrcpy (split_text[page], "..");
wstrncpy (split_text[page] + ellips, text, pos);
wstrcpy (split_text[page] + ellips + pos, "...");
strcpy (split_text[page], "..");
strncpy (split_text[page] + ellips, text, pos);
strcpy (split_text[page] + ellips + pos, "...");
timestamp[page] = - pos * TEXT_SPEED;
if (timestamp[page] > -1000)
timestamp[page] = -1000;
@@ -358,8 +361,8 @@ SplitSubPages (UNICODE *text, sint32 *timestamp, int *num_pages)
{
split_text[page] = HMalloc (sizeof (UNICODE) * (pos + ellips + 1));
if (ellips)
wstrcpy (split_text[page], "..");
wstrncpy (split_text[page] + ellips, text, pos);
strcpy (split_text[page], "..");
strncpy (split_text[page] + ellips, text, pos);
*(split_text[page] + ellips + pos) = 0;
timestamp[page] = - pos * TEXT_SPEED;
if (timestamp[page] > -1000)
@@ -384,8 +387,8 @@ SplitSubPages (UNICODE *text, sint32 *timestamp, int *num_pages)
sizeof (UNICODE *) * (page + 1));
split_text[page] = HMalloc (sizeof (UNICODE) * (pos + ellips + 1));
if (ellips)
wstrcpy (split_text[page], "..");
wstrncpy (split_text[page] + ellips, text, pos);
strcpy (split_text[page], "..");
strncpy (split_text[page] + ellips, text, pos);
*(split_text[page] + ellips + pos) = 0;
timestamp[page] = - pos * TEXT_SPEED;
if (timestamp[page] > -1000)
@@ -464,19 +467,18 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
return;
}
slen = wstrlen (TrackText);
slen = strlen (TrackText);
if (tct)
{
int slen1;
slen1 = wstrlen ((UNICODE *)cur_text_chain->text);
int slen1 = strlen ((UNICODE *)cur_text_chain->text);
cur_text_chain->text = HRealloc (
(UNICODE *)cur_text_chain->text, slen1 + slen + 1);
wstrcpy (&((UNICODE *)cur_text_chain->text)[slen1], TrackText);
strcpy (&((UNICODE *)cur_text_chain->text)[slen1], TrackText);
}
else
{
begin_chain->text = HMalloc (slen + 1);
wstrcpy ((UNICODE *)begin_chain->text, TrackText);
strcpy ((UNICODE *)begin_chain->text, TrackText);
cur_text_chain = begin_chain;
begin_chain->tag_me = 1;
begin_chain->track_num = tct;
@@ -521,10 +523,10 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
return;
}
oTT = (UNICODE *)last_ts_chain->text;
slen1 = wstrlen (oTT);
slen2 = wstrlen (split_text[0]);
slen1 = strlen (oTT);
slen2 = strlen (split_text[0]);
last_ts_chain->text = HRealloc (oTT, slen1 + slen2 + 1);
wstrcpy (&((UNICODE *)last_ts_chain->text)[slen1], split_text[0]);
strcpy (&((UNICODE *)last_ts_chain->text)[slen1], split_text[0]);
HFree (split_text[0]);
for (page_counter = 1; page_counter < num_pages; page_counter++)
{
@@ -559,10 +561,10 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
UNICODE *oTT;
oTT = (UNICODE *)cur_text_chain->text;
slen1 = wstrlen (oTT);
slen2 = wstrlen (split_text[0]);
slen1 = strlen (oTT);
slen2 = strlen (split_text[0]);
cur_text_chain->text = HRealloc (oTT, slen1 + slen2 + 1);
wstrcpy (&((UNICODE *)cur_text_chain->text)[slen1], split_text[0]);
strcpy (&((UNICODE *)cur_text_chain->text)[slen1], split_text[0]);
HFree (split_text[0]);
}
else
+38
View File
@@ -18,6 +18,9 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "strlib.h"
// Resynchronise (skip everything starting with 0x10xxxxxx):
static inline void
@@ -230,6 +233,41 @@ utf8StringCountN(const unsigned char *start, const unsigned char *end) {
}
}
// Locates a wide char (ch) in a UTF-8 string (pStr)
// returns the char positions when found
// -1 when not found
int
utf8StringPos (const unsigned char *pStr, wchar_t ch)
{
int pos;
for (pos = 0; *pStr != '\0'; ++pos)
{
if (getCharFromString (&pStr) == ch)
return pos;
}
if (ch == '\0' && *pStr == '\0')
return pos;
return -1;
}
// Safe version of strcpy(), somewhat analogous to strncpy()
// except it guarantees a 0-term when size > 0
// when size == 0, returns NULL
unsigned char *
utf8StringCopy (unsigned char *dst, size_t size, const unsigned char *src)
{
if (size == 0)
return 0;
strncpy (dst, src, size);
dst[size - 1] = '\0';
return dst;
}
unsigned char *
skipUTF8Chars(const unsigned char *ptr, size_t num) {
wchar_t ch;
+3
View File
@@ -58,6 +58,9 @@ unsigned char *getLineFromString(const unsigned char *start,
size_t utf8StringCount(const unsigned char *start);
size_t utf8StringCountN(const unsigned char *start,
const unsigned char *end);
int utf8StringPos (const unsigned char *pStr, wchar_t ch);
unsigned char *utf8StringCopy (unsigned char *dst, size_t size,
const unsigned char *src);
unsigned char *skipUTF8Chars(const unsigned char *ptr, size_t num);
size_t getWideFromString(wchar_t *wstr, size_t maxcount,
const unsigned char *start);
+53 -23
View File
@@ -359,15 +359,15 @@ DrawTeamString (PMELEE_STATE pMS, COUNT HiLiteState)
lfText.baseline.x = r.corner.x + 1;
lfText.align = ALIGN_LEFT;
lfText.CharCount = wstrlen (lfText.pStr); // (COUNT)~0;
lfText.CharCount = strlen (lfText.pStr);
BatchGraphics ();
if (!(HiLiteState & DTSHS_EDIT))
{ // normal or selected state
TEXT rtText;
UNICODE buf[10];
UNICODE buf[30];
wsprintf (buf, "%d", pMS->star_bucks[pMS->side]);
sprintf (buf, "%d", pMS->star_bucks[pMS->side]);
rtText.pStr = buf;
rtText.align = ALIGN_RIGHT;
rtText.CharCount = (COUNT)~0;
@@ -813,7 +813,7 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState)
font_DrawText (&Text);
rtText.baseline.y = Text.baseline.y;
wsprintf (buf, "%d", GetTeamValue (&pMS->FileList[bot]));
sprintf (buf, "%d", GetTeamValue (&pMS->FileList[bot]));
rtText.CharCount = (COUNT)~0;
font_DrawText (&rtText);
}
@@ -855,7 +855,7 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState)
font_DrawText (&Text);
rtText.baseline.y = Text.baseline.y;
wsprintf (buf, "%d", GetTeamValue (&pMS->FileList[bot - top]));
sprintf (buf, "%d", GetTeamValue (&pMS->FileList[bot - top]));
rtText.CharCount = (COUNT)~0;
font_DrawText (&rtText);
}
@@ -1048,7 +1048,7 @@ GetNewList:
goto GetNewList;
}
if (pbuf && wstricmp (file, pbuf) == 0)
if (pbuf && stricmp (file, pbuf) == 0)
{
pMS->CurIndex = GetDirEntryTableIndex (pMS->TeamDE) + NUM_PREBUILT;
pbuf = 0;
@@ -1525,7 +1525,7 @@ BuildAndDrawShipList (PMELEE_STATE pMS)
RECT r;
TEXT t;
STAMP s;
UNICODE buf[10];
UNICODE buf[30];
side = !i;
@@ -1554,7 +1554,7 @@ BuildAndDrawShipList (PMELEE_STATE pMS)
MAKE_RGB15 (0xA, 0xA, 0x1F), 0x9));
font_DrawText (&t);
wsprintf (buf, "%d", pMS->star_bucks[i]);
sprintf (buf, "%d", pMS->star_bucks[i]);
t.baseline.x = 4;
t.baseline.y = 7;
t.align = ALIGN_LEFT;
@@ -1802,7 +1802,9 @@ DoMelee (PMELEE_STATE pMS)
static void
InitPreBuilt (PMELEE_STATE pMS)
{
wstrcpy (pMS->PreBuiltList[0].TeamName, GAME_STRING (MELEE_STRING_BASE + 4));
utf8StringCopy (pMS->PreBuiltList[0].TeamName,
sizeof (pMS->PreBuiltList[0].TeamName),
GAME_STRING (MELEE_STRING_BASE + 4));
pMS->PreBuiltList[0].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[0].ShipList[0][1] = MELEE_CHMMR;
pMS->PreBuiltList[0].ShipList[0][2] = MELEE_DRUUGE;
@@ -1818,7 +1820,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[0].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[0].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[1].TeamName, GAME_STRING (MELEE_STRING_BASE + 5));
utf8StringCopy (pMS->PreBuiltList[1].TeamName,
sizeof (pMS->PreBuiltList[1].TeamName),
GAME_STRING (MELEE_STRING_BASE + 5));
pMS->PreBuiltList[1].ShipList[0][0] = MELEE_ARILOU;
pMS->PreBuiltList[1].ShipList[0][1] = MELEE_CHENJESU;
pMS->PreBuiltList[1].ShipList[0][2] = MELEE_EARTHLING;
@@ -1834,7 +1838,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[1].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[1].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[2].TeamName, GAME_STRING (MELEE_STRING_BASE + 6));
utf8StringCopy (pMS->PreBuiltList[2].TeamName,
sizeof (pMS->PreBuiltList[2].TeamName),
GAME_STRING (MELEE_STRING_BASE + 6));
pMS->PreBuiltList[2].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[2].ShipList[0][1] = MELEE_CHMMR;
pMS->PreBuiltList[2].ShipList[0][2] = MELEE_DRUUGE;
@@ -1850,7 +1856,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[2].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[2].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[3].TeamName, GAME_STRING (MELEE_STRING_BASE + 7));
utf8StringCopy (pMS->PreBuiltList[3].TeamName,
sizeof (pMS->PreBuiltList[3].TeamName),
GAME_STRING (MELEE_STRING_BASE + 7));
pMS->PreBuiltList[3].ShipList[0][0] = MELEE_CHENJESU;
pMS->PreBuiltList[3].ShipList[0][1] = MELEE_CHENJESU;
pMS->PreBuiltList[3].ShipList[0][2] = MELEE_CHMMR;
@@ -1866,7 +1874,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[3].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[3].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[4].TeamName, GAME_STRING (MELEE_STRING_BASE + 8));
utf8StringCopy (pMS->PreBuiltList[4].TeamName,
sizeof (pMS->PreBuiltList[4].TeamName),
GAME_STRING (MELEE_STRING_BASE + 8));
pMS->PreBuiltList[4].ShipList[0][0] = MELEE_URQUAN;
pMS->PreBuiltList[4].ShipList[0][1] = MELEE_CHENJESU;
pMS->PreBuiltList[4].ShipList[0][2] = MELEE_MYCON;
@@ -1882,7 +1892,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[4].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[4].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[5].TeamName, "Ford's Fighters");
utf8StringCopy (pMS->PreBuiltList[5].TeamName,
sizeof (pMS->PreBuiltList[5].TeamName),
"Ford's Fighters");
pMS->PreBuiltList[5].ShipList[0][0] = MELEE_CHMMR;
pMS->PreBuiltList[5].ShipList[0][1] = MELEE_ZOQFOTPIK;
pMS->PreBuiltList[5].ShipList[0][2] = MELEE_MELNORME;
@@ -1898,7 +1910,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[5].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[5].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[6].TeamName, "Leyland's Lashers");
utf8StringCopy (pMS->PreBuiltList[6].TeamName,
sizeof (pMS->PreBuiltList[6].TeamName),
"Leyland's Lashers");
pMS->PreBuiltList[6].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[6].ShipList[0][1] = MELEE_EARTHLING;
pMS->PreBuiltList[6].ShipList[0][2] = MELEE_MYCON;
@@ -1914,7 +1928,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[6].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[6].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[7].TeamName, "The Gregorizers 200");
utf8StringCopy (pMS->PreBuiltList[7].TeamName,
sizeof (pMS->PreBuiltList[7].TeamName),
"The Gregorizers 200");
pMS->PreBuiltList[7].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[7].ShipList[0][1] = MELEE_CHMMR;
pMS->PreBuiltList[7].ShipList[0][2] = MELEE_DRUUGE;
@@ -1930,7 +1946,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[7].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[7].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[8].TeamName, "300 point Armada!");
utf8StringCopy (pMS->PreBuiltList[8].TeamName,
sizeof (pMS->PreBuiltList[8].TeamName),
"300 point Armada!");
pMS->PreBuiltList[8].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[8].ShipList[0][1] = MELEE_CHMMR;
pMS->PreBuiltList[8].ShipList[0][2] = MELEE_CHENJESU;
@@ -1946,7 +1964,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[8].ShipList[1][5] = MELEE_URQUAN;
pMS->PreBuiltList[8].ShipList[1][6] = MELEE_YEHAT;
wstrcpy (pMS->PreBuiltList[9].TeamName, "Little Dudes with Attitudes");
utf8StringCopy (pMS->PreBuiltList[9].TeamName,
sizeof (pMS->PreBuiltList[9].TeamName),
"Little Dudes with Attitudes");
pMS->PreBuiltList[9].ShipList[0][0] = MELEE_UMGAH;
pMS->PreBuiltList[9].ShipList[0][1] = MELEE_THRADDASH;
pMS->PreBuiltList[9].ShipList[0][2] = MELEE_SHOFIXTI;
@@ -1962,7 +1982,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[9].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[9].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[10].TeamName, "New Alliance Ships");
utf8StringCopy (pMS->PreBuiltList[10].TeamName,
sizeof (pMS->PreBuiltList[10].TeamName),
"New Alliance Ships");
pMS->PreBuiltList[10].ShipList[0][0] = MELEE_ARILOU;
pMS->PreBuiltList[10].ShipList[0][1] = MELEE_CHMMR;
pMS->PreBuiltList[10].ShipList[0][2] = MELEE_EARTHLING;
@@ -1978,7 +2000,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[10].ShipList[1][5] = MELEE_THRADDASH;
pMS->PreBuiltList[10].ShipList[1][6] = MELEE_SPATHI;
wstrcpy (pMS->PreBuiltList[11].TeamName, "Old Alliance Ships");
utf8StringCopy (pMS->PreBuiltList[11].TeamName,
sizeof (pMS->PreBuiltList[11].TeamName),
"Old Alliance Ships");
pMS->PreBuiltList[11].ShipList[0][0] = MELEE_ARILOU;
pMS->PreBuiltList[11].ShipList[0][1] = MELEE_CHENJESU;
pMS->PreBuiltList[11].ShipList[0][2] = MELEE_EARTHLING;
@@ -1994,7 +2018,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[11].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[11].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[12].TeamName, "Old Hierarchy Ships");
utf8StringCopy (pMS->PreBuiltList[12].TeamName,
sizeof (pMS->PreBuiltList[12].TeamName),
"Old Hierarchy Ships");
pMS->PreBuiltList[12].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[12].ShipList[0][1] = MELEE_ILWRATH;
pMS->PreBuiltList[12].ShipList[0][2] = MELEE_MYCON;
@@ -2010,7 +2036,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[12].ShipList[1][5] = (BYTE)~0;
pMS->PreBuiltList[12].ShipList[1][6] = (BYTE)~0;
wstrcpy (pMS->PreBuiltList[13].TeamName, "Star Control 1");
utf8StringCopy (pMS->PreBuiltList[13].TeamName,
sizeof (pMS->PreBuiltList[13].TeamName),
"Star Control 1");
pMS->PreBuiltList[13].ShipList[0][0] = MELEE_ANDROSYNTH;
pMS->PreBuiltList[13].ShipList[0][1] = MELEE_ARILOU;
pMS->PreBuiltList[13].ShipList[0][2] = MELEE_CHENJESU;
@@ -2026,7 +2054,9 @@ InitPreBuilt (PMELEE_STATE pMS)
pMS->PreBuiltList[13].ShipList[1][5] = MELEE_VUX;
pMS->PreBuiltList[13].ShipList[1][6] = MELEE_YEHAT;
wstrcpy (pMS->PreBuiltList[14].TeamName, "Star Control 2");
utf8StringCopy (pMS->PreBuiltList[14].TeamName,
sizeof (pMS->PreBuiltList[14].TeamName),
"Star Control 2");
pMS->PreBuiltList[14].ShipList[0][0] = MELEE_CHMMR;
pMS->PreBuiltList[14].ShipList[0][1] = MELEE_DRUUGE;
pMS->PreBuiltList[14].ShipList[0][2] = MELEE_KOHR_AH;
+8 -7
View File
@@ -138,7 +138,8 @@ DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
int num_items;
FONT OldFont;
TEXT t;
UNICODE buf[40];
UNICODE buf[256];
pos = beg_index + NewState;
num_items = 1 + end_index - beg_index;
r->corner.x -= 1;
@@ -161,7 +162,7 @@ DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08));
for (i = beg_index; i <= end_index; i++)
{
wsprintf (buf, menu_string[i]);
utf8StringCopy (buf, sizeof (buf), menu_string[i]);
if (hilite && pos == i)
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x08));
@@ -539,9 +540,9 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
if (s.frame && optWhichMenu == OPT_PC)
{
if (beg_index == PM_CREW)
sprintf (menu_string[PM_CREW], "crew(%d)", GLOBAL (CrewCost));
sprintf (menu_string[PM_CREW], "%s(%d)", "crew", GLOBAL (CrewCost));
if (beg_index == PM_FUEL)
sprintf (menu_string[PM_FUEL], "fuel(%d)", GLOBAL (FuelCost));
sprintf (menu_string[PM_FUEL], "%s(%d)", "fuel", GLOBAL (FuelCost));
if (beg_index == PM_SOUND_ON)
{
end_index = beg_index + 5;
@@ -607,7 +608,7 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
switch (beg_index + NewState)
{
TEXT t;
UNICODE buf[4];
UNICODE buf[20];
case PM_CREW:
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
@@ -615,7 +616,7 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (CrewCost));
sprintf (buf, "%u", GLOBAL (CrewCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
@@ -626,7 +627,7 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (FuelCost));
sprintf (buf, "%u", GLOBAL (FuelCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
+2 -2
View File
@@ -69,7 +69,7 @@ DrawModuleStrings (PMENU_STATE pMS, BYTE NewModule)
else if (pMS->CurFrame)
{
TEXT t;
UNICODE buf[10];
UNICODE buf[40];
s.frame = SetAbsFrameIndex (pMS->CurFrame, NewModule);
DrawStamp (&s);
@@ -78,7 +78,7 @@ DrawModuleStrings (PMENU_STATE pMS, BYTE NewModule)
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
sprintf (buf, "%u", GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
+2 -2
View File
@@ -212,7 +212,7 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
{
COUNT ships_left;
TEXT t;
UNICODE buf[10];
UNICODE buf[40];
STAMP s;
CONTEXT OldContext;
GETMELEE_STATE gmstate;
@@ -266,7 +266,7 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
SetContextForeGroundColor (PICK_BG_COLOR);
DrawFilledRectangle (&gmstate.flash_rect);
wsprintf (buf, "%d", cur_bucks);
sprintf (buf, "%d", cur_bucks);
t.baseline.y = 7;
t.align = ALIGN_RIGHT;
t.pStr = buf;
+3 -3
View File
@@ -218,15 +218,15 @@ ChangeSelection:
if (crew_level)
{
char buf[20];
char buf[80];
t.baseline.x = r.corner.x + (r.extent.width >> 1);
t.pStr = buf;
t.CharCount = (COUNT)~0;
if (crew_level >= max_crew)
wsprintf (buf, "%u", crew_level);
sprintf (buf, "%u", crew_level);
else
wsprintf (buf, "%u/%u", crew_level, max_crew);
sprintf (buf, "%u/%u", crew_level, max_crew);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02));
font_DrawText (&t);
}
+12 -12
View File
@@ -31,12 +31,12 @@ ShowRemainingCapacity (void)
RECT r;
TEXT rt;
CONTEXT OldContext;
UNICODE rt_amount_buf[10];
UNICODE rt_amount_buf[40];
OldContext = SetContext (StatusContext);
SetContextFont (TinyFont);
wsprintf (rt_amount_buf, "%u",
sprintf (rt_amount_buf, "%u",
GetSBayCapacity (NULL_PTR)
- GLOBAL_SIS (TotalElementMass));
rt.baseline.x = 59;
@@ -67,7 +67,7 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
TEXT rt;
RECT r;
CONTEXT OldContext;
UNICODE rt_amount_buf[10];
UNICODE rt_amount_buf[40];
LockMutex (GraphicsLock);
@@ -150,14 +150,14 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0x1F), 0x09));
rt.baseline.x = 32;
wsprintf (rt_amount_buf, "%u",
sprintf (rt_amount_buf, "%u",
GLOBAL (ElementWorth[OldElement]));
rt.CharCount = (COUNT)~0;
font_DrawText (&rt);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
rt.baseline.x = 58;
wsprintf (rt_amount_buf, "%u",
sprintf (rt_amount_buf, "%u",
GLOBAL_SIS (ElementAmounts[OldElement]));
rt.CharCount = (COUNT)~0;
font_DrawText (&rt);
@@ -180,7 +180,7 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
rt.baseline.x = 58;
wsprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
sprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
rt.CharCount = (COUNT)~0;
font_DrawText (&rt);
@@ -222,15 +222,15 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
rt.baseline.y = cy;
if (OldElement == NUM_ELEMENT_CATEGORIES)
wsprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
sprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
else
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0x1F), 0x09));
rt.baseline.x = 32;
wsprintf (rt_amount_buf, "%u", GLOBAL (ElementWorth[OldElement]));
sprintf (rt_amount_buf, "%u", GLOBAL (ElementWorth[OldElement]));
rt.CharCount = (COUNT)~0;
font_DrawText (&rt);
wsprintf (rt_amount_buf, "%u", GLOBAL_SIS (ElementAmounts[OldElement]));
sprintf (rt_amount_buf, "%u", GLOBAL_SIS (ElementAmounts[OldElement]));
}
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
@@ -252,15 +252,15 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
rt.baseline.y = cy;
if (NewElement == NUM_ELEMENT_CATEGORIES)
wsprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
sprintf (rt_amount_buf, "%u", GLOBAL_SIS (TotalBioMass));
else
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
rt.baseline.x = 32;
wsprintf (rt_amount_buf, "%u", GLOBAL (ElementWorth[NewElement]));
sprintf (rt_amount_buf, "%u", GLOBAL (ElementWorth[NewElement]));
rt.CharCount = (COUNT)~0;
font_DrawText (&rt);
wsprintf (rt_amount_buf, "%u", GLOBAL_SIS (ElementAmounts[NewElement]));
sprintf (rt_amount_buf, "%u", GLOBAL_SIS (ElementAmounts[NewElement]));
}
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0x1F, 0x1F), 0x0B));
+7 -18
View File
@@ -27,6 +27,7 @@
#include "state.h"
#include "sounds.h"
#include "util.h"
#include "strlib.h"
// If DEBUG_DEVICES is defined, the device list shown in the game will
@@ -34,18 +35,6 @@
// devices the player actually possesses.
//#define DEBUG_DEVICES
static COUNT
lpstrchr (const UNICODE *pStr, UNICODE ch)
{
COUNT skip_chars;
skip_chars = 0;
while (*pStr++ != ch)
++skip_chars;
return (skip_chars);
}
static void
DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice)
{
@@ -134,10 +123,10 @@ DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice)
t.baseline.y = cy;
t.pStr = GAME_STRING (pDeviceMap[OldDevice] +
DEVICE_STRING_BASE + 1);
t.CharCount = lpstrchr (t.pStr, ' ');
t.CharCount = utf8StringPos (t.pStr, ' ');
font_DrawText (&t);
t.baseline.y += 7;
t.pStr += t.CharCount + 1;
t.pStr = skipUTF8Chars (t.pStr, t.CharCount + 1);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
}
@@ -163,10 +152,10 @@ DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice)
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
t.baseline.y = cy;
t.pStr = GAME_STRING (pDeviceMap[OldDevice] + DEVICE_STRING_BASE + 1);
t.CharCount = lpstrchr (t.pStr, ' ');
t.CharCount = utf8StringPos (t.pStr, ' ');
font_DrawText (&t);
t.baseline.y += 7;
t.pStr += t.CharCount + 1;
t.pStr = skipUTF8Chars (t.pStr, t.CharCount + 1);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
}
@@ -181,10 +170,10 @@ DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice)
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0x1F, 0x1F), 0x0B));
t.baseline.y = cy;
t.pStr = GAME_STRING (pDeviceMap[NewDevice] + DEVICE_STRING_BASE + 1);
t.CharCount = lpstrchr (t.pStr, ' ');
t.CharCount = utf8StringPos (t.pStr, ' ');
font_DrawText (&t);
t.baseline.y += 7;
t.pStr += t.CharCount + 1;
t.pStr = skipUTF8Chars (t.pStr, t.CharCount + 1);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
}
+3 -1
View File
@@ -462,7 +462,9 @@ GenerateSOL (BYTE control)
break;
case GENERATE_NAME:
i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;
wstrcpy (GLOBAL_SIS (PlanetName), GAME_STRING (PLANET_NUMBER_BASE + i));
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + i));
SET_GAME_STATE (BATTLE_PLANET,
pSolarSysState->PlanetDesc[i].data_index);
break;
+3 -1
View File
@@ -77,7 +77,9 @@ GenerateSpathi (BYTE control)
if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0])
{
#ifdef NOTYET
wstrcpy (GLOBAL_SIS (PlanetName), "Spathiwa");
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
"Spathiwa");
#endif /* NOTYET */
pSolarSysState->MoonDesc[0].data_index = PELLUCID_WORLD;
+1 -1
View File
@@ -774,7 +774,7 @@ CheckObjectCollision (COUNT index)
] += NumRetrieved;
pPSD->NumFrames = NUM_TEXT_FRAMES;
wsprintf (pPSD->AmountBuf, "%u", NumRetrieved);
sprintf (pPSD->AmountBuf, "%u", NumRetrieved);
pStr = GAME_STRING (EType + ELEMENTS_STRING_BASE);
pPSD->MineralText[0].baseline.x =
+1 -1
View File
@@ -41,7 +41,7 @@ typedef struct
COUNT ElementAmounts[NUM_ELEMENT_CATEGORIES];
COUNT NumFrames;
UNICODE AmountBuf[10];
UNICODE AmountBuf[40];
TEXT MineralText[3];
COLOR ColorCycle[NUM_TEXT_FRAMES >> 1];
+1 -1
View File
@@ -486,7 +486,7 @@ FillOrbits (PSOLARSYS_STATE system,
{SUPERGIANT_ROCK_DIST, SUPERGIANT_GASG_DIST},
};
#ifdef DEBUG_ORBITS
UNICODE buf[40];
UNICODE buf[256];
char stype[] = {'D', 'G', 'S'};
char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
#endif /* DEBUG_ORBITS */
+6 -5
View File
@@ -459,10 +459,10 @@ DrawStarMap (COUNT race_update, PRECT pClipRect)
#ifdef NOTYET
{
UNICODE buf[40];
UNICODE buf[256];
GetClusterName (SDPtr, buf);
wprintf ("%s\n", buf);
printf ("%s\n", buf);
}
#endif /* NOTYET */
s.origin.x = UNIVERSE_TO_DISPX (SDPtr->star_pt.x);
@@ -613,7 +613,7 @@ DoMoveCursor (PMENU_STATE pMS)
#define MAX_ACCEL_DELAY (ONE_SECOND / 8)
#define STEP_ACCEL_DELAY (ONE_SECOND / 120)
STAMP s;
UNICODE buf[30];
UNICODE buf[256];
static UNICODE last_buf;
pMS->MenuRepeatDelay = (COUNT)pMS->CurState;
@@ -793,7 +793,8 @@ UpdateCursorInfo:
&& UNIVERSE_TO_DISPY (pt.y) == s.origin.y)
{
pMS->first_item = pt;
wstrcpy (buf, GAME_STRING (STAR_STRING_BASE + 132));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (STAR_STRING_BASE + 132));
}
}
@@ -824,7 +825,7 @@ UpdateCursorInfo:
last_buf = buf[0];
DrawSISMessage (buf);
}
wsprintf (buf, "%s %u.%u",
sprintf (buf, "%s %u.%u",
GAME_STRING (NAVIGATION_STRING_BASE + 4),
fuel_required / FUEL_TANK_SCALE,
(fuel_required % FUEL_TANK_SCALE) / 10);
+23 -17
View File
@@ -86,41 +86,43 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
{
BYTE ButtonState;
int end_page_len;
UNICODE last_c, end_page_buf[80];
UNICODE end_page_buf[200];
wchar_t last_c;
COUNT row_cells;
BOOLEAN Sleepy;
RECT r;
TEXT t;
wsprintf (end_page_buf, "%s\n", GAME_STRING (SCAN_STRING_BASE + NUM_SCAN_TYPES));
end_page_len = wstrlen (end_page_buf);
sprintf (end_page_buf, "%s\n", GAME_STRING (SCAN_STRING_BASE + NUM_SCAN_TYPES));
end_page_len = utf8StringCount (end_page_buf);
GetFrameRect (SetAbsFrameIndex (SpaceJunkFrame, 18), &r);
t.align = ALIGN_LEFT;
t.CharCount = 1;
t.pStr = pStr;
last_c = *pStr;
Sleepy = TRUE;
UnlockMutex (GraphicsLock);
FlushInput ();
// XXX: this is a pretty ugly goto
goto InitPageCell;
while (StrLen)
{
COUNT col_cells;
const UNICODE *pLastStr;
const UNICODE *pTempStr;
const UNICODE *pNextStr;
COUNT lf_pos;
pLastStr = t.pStr;
// scan for LFs in the remaining string
// trailing LF will be ignored
for (lf_pos = StrLen, pTempStr = t.pStr;
lf_pos && *pTempStr != '\n';
--lf_pos, ++pTempStr)
for (lf_pos = StrLen, pNextStr = t.pStr;
lf_pos && getCharFromString (&pNextStr) != '\n';
--lf_pos)
;
col_cells = 0;
@@ -138,12 +140,14 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
{
COUNT word_chars;
const UNICODE *pStr;
wchar_t c;
pStr = t.pStr;
while (isgraph (*pStr))
++pStr;
pNextStr = t.pStr;
while (isWideGraphChar (getCharFromString (&pNextStr)))
pStr = pNextStr;
word_chars = (COUNT)(pStr - t.pStr);
word_chars = utf8StringCountN (t.pStr, pStr);
if ((col_cells += word_chars) <= NUM_CELL_COLS)
{
DWORD TimeOut;
@@ -153,6 +157,9 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
TimeOut = GetTimeCounter ();
while (word_chars--)
{
pNextStr = t.pStr;
c = getCharFromString (&pNextStr);
if (!Sleepy || (GLOBAL (CurrentActivity) & CHECK_ABORT))
font_DrawText (&t);
else
@@ -164,17 +171,16 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
PlaySound (ReadOutSounds, NotPositional (), NULL,
GAME_SOUND_PRIORITY);
if (t.pStr[0] == ',')
if (c == ',')
TimeOut += ONE_SECOND / 4;
if (t.pStr[0] == '.' || t.pStr[0] == '!' ||
t.pStr[0] == '?')
if (c == '.' || c == '!' || c == '?')
TimeOut += ONE_SECOND / 2;
else
TimeOut += ONE_SECOND / 20;
if (word_chars == 0)
TimeOut += ONE_SECOND / 20;
TaskSwitch();
TaskSwitch ();
while (GetTimeCounter () < TimeOut)
{
if (ButtonState)
@@ -192,12 +198,12 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
TaskSwitch();
}
}
++t.pStr;
t.pStr = pNextStr;
t.baseline.x += r.extent.width + 1;
}
++col_cells;
last_c = *t.pStr++;
last_c = getCharFromString (&t.pStr);
t.baseline.x += r.extent.width + 1;
}
} while (col_cells <= NUM_CELL_COLS && last_c != '\n' && StrLen);
+3 -3
View File
@@ -99,7 +99,7 @@ MatchSupportShip (PMENU_STATE pMS)
static void
DeltaSupportCrew (SIZE crew_delta)
{
UNICODE buf[10];
UNICODE buf[40];
HSTARSHIP hTemplate;
SHIP_FRAGMENTPTR StarShipPtr, TemplatePtr;
@@ -122,9 +122,9 @@ DeltaSupportCrew (SIZE crew_delta)
{
if (StarShipPtr->ShipInfo.crew_level >=
TemplatePtr->RaceDescPtr->ship_info.crew_level)
wsprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level);
sprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level);
else
wsprintf (buf, "%u/%u",
sprintf (buf, "%u/%u",
StarShipPtr->ShipInfo.crew_level,
TemplatePtr->RaceDescPtr->ship_info.crew_level);
+41 -26
View File
@@ -139,38 +139,45 @@ PrintCoarseScanPC (void)
{
if (pSolarSysState->pOrbitalDesc->pPrevDesc ==
&pSolarSysState->SunDesc[0])
wstrcpy (buf, GLOBAL_SIS (PlanetName));
utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName));
else
{
switch (pSolarSysState->pOrbitalDesc->pPrevDesc
- pSolarSysState->PlanetDesc)
{
case 2: /* EARTH */
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 9));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 9));
break;
case 4: /* JUPITER */
switch (pSolarSysState->pOrbitalDesc
- pSolarSysState->MoonDesc)
{
case 0:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 10));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 10));
break;
case 1:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 11));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 11));
break;
case 2:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 12));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 12));
break;
case 3:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 13));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 13));
break;
}
break;
case 5:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 14));
case 5: /* SATURN */
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 14));
break;
case 7:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 15));
case 7: /* NEPTUNE */
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 15));
break;
}
}
@@ -220,9 +227,9 @@ PrintCoarseScanPC (void)
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, "Atmo: ", LEFT_SIDE_BASELINE_X_PC);
if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)
sprintf (buf, "Super Thick");
utf8StringCopy (buf, sizeof (buf), "Super Thick");
else if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0)
sprintf (buf, "Vacuum");
utf8StringCopy (buf, sizeof (buf), "Vacuum");
else
{
val = (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity * 100
@@ -251,7 +258,7 @@ PrintCoarseScanPC (void)
t.pStr = "None";
else
{
sprintf (buf, "Class %u",
sprintf (buf, "%s %u", "Class",
pSolarSysState->SysInfo.PlanetInfo.Weather + 1);
t.pStr = buf;
}
@@ -267,7 +274,7 @@ PrintCoarseScanPC (void)
t.pStr = "None";
else
{
sprintf (buf, "Class %u",
sprintf (buf, "%s %u", "Class",
pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1);
t.pStr = buf;
}
@@ -352,38 +359,45 @@ PrintCoarseScan3DO (void)
if (CurStarDescPtr->Index == SOL_DEFINED)
{
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])
wstrcpy (buf, GLOBAL_SIS (PlanetName));
utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName));
else
{
switch (pSolarSysState->pOrbitalDesc->pPrevDesc
- pSolarSysState->PlanetDesc)
{
case 2: /* EARTH */
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 9));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 9));
break;
case 4: /* JUPITER */
switch (pSolarSysState->pOrbitalDesc
- pSolarSysState->MoonDesc)
{
case 0:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 10));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 10));
break;
case 1:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 11));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 11));
break;
case 2:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 12));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 12));
break;
case 3:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 13));
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 13));
break;
}
break;
case 5:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 14));
case 5: /* SATURN */
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 14));
break;
case 7:
wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 15));
case 7: /* NEPTUNE */
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (PLANET_NUMBER_BASE + 15));
break;
}
}
@@ -915,6 +929,7 @@ DoScan (PMENU_STATE pMS)
{
DWORD TimeIn, WaitTime;
BOOLEAN select, cancel;
select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = PulsedInputState.key[KEY_MENU_CANCEL];
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
@@ -948,7 +963,7 @@ DoScan (PMENU_STATE pMS)
if (pMS->CurState == DISPATCH_SHUTTLE)
{
COUNT fuel_required;
UNICODE buf[20];
UNICODE buf[100];
if ((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)
|| (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity ==
@@ -974,7 +989,7 @@ DoScan (PMENU_STATE pMS)
return (TRUE);
}
wsprintf (buf, "%s%1.1f",
sprintf (buf, "%s%1.1f",
GAME_STRING (NAVIGATION_STRING_BASE + 5),
(float) fuel_required / FUEL_TANK_SCALE);
LockMutex (GraphicsLock);
+2 -1
View File
@@ -1625,7 +1625,8 @@ GenerateRandomIP (BYTE control)
case GENERATE_NAME:
{
i = pSolarSysState->pBaseDesc - pSolarSysState->PlanetDesc;
wsprintf (GLOBAL_SIS (PlanetName), "%s",
utf8StringCopy (GLOBAL_SIS (PlanetName),
sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + (9 + 7) + i));
SET_GAME_STATE (BATTLE_PLANET,
pSolarSysState->PlanetDesc[i].data_index);
+1 -1
View File
@@ -97,7 +97,7 @@ DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f)
t.align = ALIGN_RIGHT;
t.valign = VALIGN_BOTTOM;
t.CharCount = (COUNT)~0;
wsprintf (buf, "v%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
sprintf (buf, "v%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
SetContextForeGroundColor (WHITE_COLOR);
font_DrawText (&t);
+2 -2
View File
@@ -234,7 +234,7 @@ InitShipStatus (STARSHIPPTR StarShipPtr, PRECT pClipRect)
GetStringLength (locString),y);
{
UNICODE buf[3];
UNICODE buf[30];
TEXT Text;
FONT OldFont;
@@ -242,7 +242,7 @@ InitShipStatus (STARSHIPPTR StarShipPtr, PRECT pClipRect)
if (!(GLOBAL (CurrentActivity) & IN_BATTLE))
{
wsprintf (buf, "%d", SIPtr->ship_cost);
sprintf (buf, "%d", SIPtr->ship_cost);
Text.pStr = buf;
Text.CharCount = (COUNT)~0;
}
+6 -6
View File
@@ -231,7 +231,7 @@ DrawRaceStrings (BYTE NewRaceItem)
TEXT t;
HSTARSHIP hStarShip;
STARSHIPPTR StarShipPtr;
UNICODE buf[10];
UNICODE buf[30];
COUNT ShipCost[] =
{
RACE_SHIP_COST
@@ -255,7 +255,7 @@ DrawRaceStrings (BYTE NewRaceItem)
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", ShipCost[NewRaceItem]);
sprintf (buf, "%u", ShipCost[NewRaceItem]);
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (
0x00, 0x1F, 0x00), 0x02));
@@ -287,7 +287,7 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect)
{
RECT r;
TEXT t;
UNICODE buf[20];
UNICODE buf[80];
HSTARSHIP hTemplate;
SHIP_FRAGMENTPTR TemplatePtr;
@@ -297,11 +297,11 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect)
&GLOBAL (avail_race_q), hTemplate);
if (StarShipPtr->ShipInfo.crew_level >=
TemplatePtr->RaceDescPtr->ship_info.crew_level)
wsprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level);
sprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level);
else if (StarShipPtr->ShipInfo.crew_level == 0)
wsprintf (buf, "SCRAP");
utf8StringCopy (buf, sizeof (buf), "SCRAP");
else
wsprintf (buf, "%u/%u",
sprintf (buf, "%u/%u",
StarShipPtr->ShipInfo.crew_level,
TemplatePtr->RaceDescPtr->ship_info.crew_level);
UnlockStarShip (&GLOBAL (avail_race_q), hTemplate);
+40 -40
View File
@@ -144,9 +144,9 @@ SetContextClipRect (&r);
void
DrawHyperCoords (POINT universe)
{
UNICODE buf[20];
UNICODE buf[100];
wsprintf (buf, "%03u.%01u : %03u.%01u",
sprintf (buf, "%03u.%01u : %03u.%01u",
universe.x / 10, universe.x % 10,
universe.y / 10, universe.y % 10);
@@ -156,7 +156,7 @@ DrawHyperCoords (POINT universe)
void
DrawSISMessage (UNICODE *pStr)
{
UNICODE buf[40];
UNICODE buf[256];
CONTEXT OldContext;
OldContext = SetContext (OffScreenContext);
@@ -196,7 +196,8 @@ SetContextClipRect (&r);
GetClusterName (CurStarDescPtr, buf);
break;
case IN_HYPERSPACE:
wstrcpy (buf, GAME_STRING (NAVIGATION_STRING_BASE
utf8StringCopy (buf, sizeof (buf),
GAME_STRING (NAVIGATION_STRING_BASE
+ (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1 ? 0 : 1)));
break;
}
@@ -240,7 +241,7 @@ DrawStatusMessage (UNICODE *pStr)
{
RECT r;
TEXT t;
UNICODE buf[20];
UNICODE buf[128];
CONTEXT OldContext;
OldContext = SetContext (StatusContext);
@@ -262,17 +263,16 @@ DrawStatusMessage (UNICODE *pStr)
if (pMenuState == 0
&& CommData.ConversationPhrases /* Melnorme shenanigans */
&& cur_comm == MELNORME_CONVERSATION)
wsprintf (buf, "%u Cr", MAKE_WORD (
sprintf (buf, "%u %s", MAKE_WORD (
GET_GAME_STATE (MELNORME_CREDIT0),
GET_GAME_STATE (MELNORME_CREDIT1)
));
), "Cr");
else if (GET_GAME_STATE (CHMMR_BOMB_STATE) < 2)
wsprintf (buf, "%lu RU", GLOBAL_SIS (ResUnits));
sprintf (buf, "%lu %s", GLOBAL_SIS (ResUnits), "RU");
else
if (optWhichMenu == OPT_PC)
wstrcpy (buf, "UNLIMITED RU");
else
wstrcpy (buf, STR_INFINITY_SIGN " RU");
sprintf (buf, "%s %s",
(optWhichMenu == OPT_PC) ? "UNLIMITED" : STR_INFINITY_SIGN,
"RU");
pStr = buf;
}
else if (pStr == 0)
@@ -341,7 +341,7 @@ DrawFlagshipName (BOOLEAN InStatusArea)
COLOR OldColor;
CONTEXT OldContext;
FRAME OldFontEffect;
UNICODE buf[60];
UNICODE buf[250];
if (InStatusArea)
{
@@ -366,8 +366,10 @@ DrawFlagshipName (BOOLEAN InStatusArea)
r.extent.height = SHIP_NAME_HEIGHT;
t.pStr = buf;
wsprintf (buf, "%s %s", GAME_STRING (NAMING_STRING_BASE + 1), GLOBAL_SIS (ShipName));
wstrupr (buf);
sprintf (buf, "%s %s", GAME_STRING (NAMING_STRING_BASE + 1),
GLOBAL_SIS (ShipName));
// XXX: this will not work with UTF-8 strings
strupr (buf);
}
OldFontEffect = SetContextFontEffect (NULL);
OldColor = SetContextForeGroundColor (BLACK_COLOR);
@@ -400,7 +402,7 @@ DrawFlagshipStats (void)
COLOR OldColor;
FRAME OldFontEffect;
CONTEXT OldContext;
UNICODE buf[60];
UNICODE buf[128];
SIZE leading;
BYTE i;
BYTE energy_regeneration, energy_wait, turn_wait;
@@ -474,32 +476,32 @@ DrawFlagshipStats (void)
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 4));
wsprintf (buf, "nose:");
utf8StringCopy (buf, sizeof (buf), "nose:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "spread:");
utf8StringCopy (buf, sizeof (buf), "spread:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "side:");
utf8StringCopy (buf, sizeof (buf), "side:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "tail:");
utf8StringCopy (buf, sizeof (buf), "tail:");
font_DrawText (&t);
t.baseline.x += 5;
t.baseline.y = r.corner.y + leading + 3;
t.align = ALIGN_LEFT;
wsprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[15])));
sprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[15])));
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[14])));
sprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[14])));
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[13])));
sprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[13])));
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[0])));
sprintf (buf, "%-7.7s", describeWeapon (GLOBAL_SIS (ModuleSlots[0])));
font_DrawText (&t);
t.baseline.x = r.extent.width - 25;
@@ -508,38 +510,38 @@ DrawFlagshipStats (void)
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 5));
wsprintf (buf, "maximum velocity:");
utf8StringCopy (buf, sizeof (buf), "maximum velocity:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "turning rate:");
utf8StringCopy (buf, sizeof (buf), "turning rate:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "combat energy:");
utf8StringCopy (buf, sizeof (buf), "combat energy:");
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "maximum fuel:");
utf8StringCopy (buf, sizeof (buf), "maximum fuel:");
font_DrawText (&t);
t.baseline.x = r.extent.width - 2;
t.baseline.y = r.corner.y + leading + 3;
wsprintf (buf, "%4u", max_thrust * 4);
sprintf (buf, "%4u", max_thrust * 4);
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "%4u", 1 + TURN_WAIT - turn_wait);
sprintf (buf, "%4u", 1 + TURN_WAIT - turn_wait);
font_DrawText (&t);
t.baseline.y += leading;
{
unsigned int energy_per_10_sec =
(((100 * ONE_SECOND * energy_regeneration) /
((1 + energy_wait) * BATTLE_FRAME_RATE)) + 5) / 10;
wsprintf (buf, "%2u.%1u",
sprintf (buf, "%2u.%1u",
energy_per_10_sec / 10,
energy_per_10_sec % 10);
}
font_DrawText (&t);
t.baseline.y += leading;
wsprintf (buf, "%4lu", (fuel / FUEL_TANK_SCALE));
sprintf (buf, "%4lu", (fuel / FUEL_TANK_SCALE));
font_DrawText (&t);
SetContextFontEffect (OldFontEffect);
@@ -688,13 +690,11 @@ DrawPC_SIS (void)
{
TEXT t;
RECT r;
UNICODE buf[10];
GetGaugeRect (&r, FALSE);
t.baseline.x = STATUS_WIDTH >> 1;
t.baseline.y = r.corner.y - 1;
t.align = ALIGN_CENTER;
t.pStr = buf;
t.CharCount = (COUNT)~0;
SetContextFont (TinyFont);
SetContextForeGroundColor (BLACK_COLOR);
@@ -705,7 +705,7 @@ DrawPC_SIS (void)
DrawFilledRectangle (&r);
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 1));
wsprintf (buf, "FUEL");
t.pStr = "FUEL";
font_DrawText (&t);
r.corner.y += 79;
@@ -713,7 +713,7 @@ DrawPC_SIS (void)
DrawFilledRectangle (&r);
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 2));
wsprintf (buf, "CREW");
t.pStr = "CREW";
font_DrawText (&t);
SetContextFontEffect (NULL);
@@ -725,7 +725,7 @@ DrawPC_SIS (void)
DrawFilledRectangle (&r);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x02, 0x04, 0x1E), 0x38));
t.baseline.y = r.corner.y + 6;
wsprintf (buf, "CAPTAIN");
t.pStr = "CAPTAIN";
font_DrawText (&t);
}
@@ -735,7 +735,7 @@ DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta)
STAMP s;
RECT r;
TEXT t;
UNICODE buf[12];
UNICODE buf[60];
CONTEXT OldContext;
if (crew_delta == 0 && fuel_delta == 0 && resunit_delta == 0)
@@ -865,7 +865,7 @@ DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta)
GLOBAL_SIS (CrewEnlisted) = CrewCapacity;
}
wsprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted));
sprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted));
GetGaugeRect (&r, TRUE);
t.baseline.y = r.corner.y + r.extent.height;
t.CharCount = (COUNT)~0;
@@ -901,7 +901,7 @@ DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta)
);
if (new_coarse_fuel != old_coarse_fuel)
{
wsprintf (buf, "%u", new_coarse_fuel);
sprintf (buf, "%u", new_coarse_fuel);
GetGaugeRect (&r, FALSE);
t.baseline.y = r.corner.y + r.extent.height;
t.CharCount = (COUNT)~0;
+2 -2
View File
@@ -119,7 +119,7 @@ DrawBattleCrewAmount (STARSHIPPTR StarShipPtr, BOOLEAN CountPlayer)
#define MAX_CREW_DIGITS 3
RECT r;
TEXT t;
UNICODE buf[10];
UNICODE buf[40];
t.baseline.x = BATTLE_CREW_X + 2;
if (optWhichMenu == OPT_PC)
@@ -136,7 +136,7 @@ DrawBattleCrewAmount (STARSHIPPTR StarShipPtr, BOOLEAN CountPlayer)
r.extent.width = 6 * MAX_CREW_DIGITS + 6;
r.extent.height = 5;
wsprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted) + (CountPlayer ? 1 : 0));
sprintf (buf, "%u", GLOBAL_SIS (CrewEnlisted) + (CountPlayer ? 1 : 0));
SetContextFont (StarConFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08));
+1 -1
View File
@@ -609,7 +609,7 @@ dumpSystemCallback (const STAR_DESC *star, const SOLARSYS_STATE *system,
void
dumpSystem (FILE *out, const STAR_DESC *star, const SOLARSYS_STATE *system)
{
UNICODE name[40];
UNICODE name[256];
UNICODE buf[40];
GetClusterName ((STAR_DESCPTR) star, name);