diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 1324bd5d8..7cab1f2d0 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -789,7 +789,7 @@ ShowSummary (SUMMARY_DESC *pSD) QUEUE player_q; CONTEXT OldContext; SIS_STATE SaveSS; - UNICODE buf[80]; + unsigned char buf[80]; SaveSS = GlobData.SIS_state; player_q = GLOBAL (built_ship_q); @@ -810,7 +810,8 @@ ShowSummary (SUMMARY_DESC *pSD) MAX_BUILT_SHIPS, sizeof (SHIP_FRAGMENT)); for (i = 0; i < pSD->NumShips; ++i) CloneShipFragment (pSD->ShipList[i], &GLOBAL (built_ship_q), 0); - DateToString (buf, pSD->month_index, pSD->day_index, pSD->year_index), + DateToString (buf, sizeof buf, + pSD->month_index, pSD->day_index, pSD->year_index), ClearSISRect (DRAW_SIS_DISPLAY); DrawStatusMessage (buf); UninitQueue (&GLOBAL (built_ship_q)); @@ -1146,7 +1147,8 @@ Restart: RECT r; TEXT t; BYTE i, SHIFT; - UNICODE buf[80],buf2[15]; + UNICODE buf[80]; + unsigned char buf2[15]; LockMutex (GraphicsLock); BatchGraphics (); @@ -1224,7 +1226,7 @@ ChangeGameSelection: wsprintf (buf, "Empty Slot"); else { - DateToString (buf2, + 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); diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 62bc6d804..493504ad5 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -225,28 +225,12 @@ SetContextClipRect (NULL_PTR); } void -DateToString (UNICODE *buf, BYTE month_index, BYTE day_index, COUNT - year_index) +DateToString (unsigned char *buf, size_t bufLen, + BYTE month_index, BYTE day_index, COUNT year_index) { - COUNT i; - - wstrcpy (buf, GAME_STRING (MONTHS_STRING_BASE + month_index - 1)); - buf[3] = ' '; - i = day_index; - buf[5] = (UNICODE)((i % 10) + '0'); - i /= 10; - buf[4] = (UNICODE)((i % 10) + '0'); - buf[6] = '_'; - - i = year_index; - buf[10] = (UNICODE)((i % 10) + '0'); - i /= 10; - buf[9] = (UNICODE)((i % 10) + '0'); - i /= 10; - buf[8] = (UNICODE)((i % 10) + '0'); - i /= 10; - buf[7] = (UNICODE)((i % 10) + '0'); - buf[11] = '\0'; + snprintf (buf, bufLen, "%s %02d_%04d", + GAME_STRING (MONTHS_STRING_BASE + month_index - 1), + day_index, year_index); } void @@ -291,7 +275,7 @@ DrawStatusMessage (UNICODE *pStr) } else if (pStr == 0) { - DateToString (buf, + DateToString (buf, sizeof buf, GLOBAL (GameClock.month_index), GLOBAL (GameClock.day_index), GLOBAL (GameClock.year_index)); diff --git a/sc2/src/sc2code/sis.h b/sc2/src/sc2code/sis.h index d3bcbf249..40578925c 100644 --- a/sc2/src/sc2code/sis.h +++ b/sc2/src/sc2code/sis.h @@ -256,8 +256,8 @@ extern void DrawHyperCoords (POINT puniverse); extern void DrawSISTitle (UNICODE *pStr); extern void DrawSISMessage (UNICODE *pStr); extern void DrawGameDate (void); -extern void DateToString (UNICODE *buf, BYTE month_index, BYTE day_index, - COUNT year_index); +extern void DateToString (unsigned char *buf, size_t bufLen, + BYTE month_index, BYTE day_index, COUNT year_index); extern void DrawStatusMessage (UNICODE *pStr); extern void DrawLanders (void); extern void DrawStorageBays (BOOLEAN Refresh);