diff --git a/sc2/src/sc2code/libs/graphics/font.c b/sc2/src/sc2code/libs/graphics/font.c index 7151f0c23..281dc4da3 100644 --- a/sc2/src/sc2code/libs/graphics/font.c +++ b/sc2/src/sc2code/libs/graphics/font.c @@ -138,7 +138,8 @@ TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta) { COORD top_y, bot_y; SIZE width; - UNICODE next_ch, *pStr; + UNICODE next_ch; + const UNICODE *pStr; if (pdelta == 0) { @@ -164,7 +165,8 @@ TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta) if ((next_ch = *pStr++) == '\0') num_chars = 0; next_ch -= FIRST_CHAR; - if (ch < MAX_CHARS && GetFrameWidth (&FontPtr->CharDesc[ch])) + if (ch < (UNICODE) MAX_CHARS && + GetFrameWidth (&FontPtr->CharDesc[ch])) { COORD y; @@ -177,7 +179,7 @@ TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta) width += GetFrameWidth (&FontPtr->CharDesc[ch]); #if 0 - if (num_chars && next_ch < MAX_CHARS + if (num_chars && next_ch < (UNICODE) MAX_CHARS && !(FontPtr->KernTab[ch] & (FontPtr->KernTab[next_ch] >> 2))) width -= FontPtr->KernAmount; @@ -227,7 +229,8 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) if ((FontPtr = _CurFontPtr) != 0) { COUNT num_chars; - UNICODE next_ch, *pStr; + UNICODE next_ch; + const UNICODE *pStr; TEXTPTR TextPtr; PRIMITIVE locPrim; TFB_Palette color; @@ -260,7 +263,8 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) num_chars = 0; next_ch -= FIRST_CHAR; locPrim.Object.Stamp.frame = &FontPtr->CharDesc[ch]; - if (ch < MAX_CHARS && GetFrameWidth (locPrim.Object.Stamp.frame)) + if (ch < (UNICODE) MAX_CHARS && + GetFrameWidth (locPrim.Object.Stamp.frame)) { RECT r; @@ -289,7 +293,7 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) locPrim.Object.Stamp.origin.x += GetFrameWidth (locPrim.Object.Stamp.frame); #if 0 - if (num_chars && next_ch < MAX_CHARS + if (num_chars && next_ch < (UNICODE) MAX_CHARS && !(FontPtr->KernTab[ch] & (FontPtr->KernTab[next_ch] >> 2))) locPrim.Object.Stamp.origin.x -= FontPtr->KernAmount; diff --git a/sc2/src/sc2code/libs/reslib.h b/sc2/src/sc2code/libs/reslib.h index df537fe62..b4ccbe1ac 100644 --- a/sc2/src/sc2code/libs/reslib.h +++ b/sc2/src/sc2code/libs/reslib.h @@ -69,8 +69,7 @@ extern BOOLEAN DeleteResFile (uio_DirHandle *dir, const char *filename); extern MEM_HANDLE InitResourceSystem (const char *resfile, COUNT resindex_type, BOOLEAN (*FileErrorFunc) (const char *filename)); extern BOOLEAN UninitResourceSystem (void); -extern BOOLEAN InstallResTypeVectors ( - COUNT res_type, +extern BOOLEAN InstallResTypeVectors (COUNT res_type, MEM_HANDLE (*load_func) (uio_Stream *fp, DWORD len), BOOLEAN (*free_func) (MEM_HANDLE handle)); extern MEM_HANDLE res_GetResource (RESOURCE res); @@ -78,15 +77,13 @@ extern MEM_HANDLE res_DetachResource (RESOURCE res); extern BOOLEAN FreeResource (RESOURCE res); extern COUNT CountResourceTypes (void); -extern MEM_HANDLE OpenResourceIndexFile (PVOID - resfile); -extern MEM_HANDLE OpenResourceIndexInstance (DWORD - res); +extern MEM_HANDLE OpenResourceIndexFile (const char *resfile); +extern MEM_HANDLE OpenResourceIndexInstance (DWORD res); extern MEM_HANDLE SetResourceIndex (MEM_HANDLE hRH); extern BOOLEAN CloseResourceIndex (MEM_HANDLE hRH); -extern MEM_HANDLE GetResourceData (uio_Stream *fp, DWORD - length, MEM_FLAGS mem_flags); +extern MEM_HANDLE GetResourceData (uio_Stream *fp, DWORD length, + MEM_FLAGS mem_flags); #define RESOURCE_PRIORITY DEFAULT_MEM_PRIORITY #define RESOURCE_DATAPTR PBYTE diff --git a/sc2/src/sc2code/libs/resource/resinit.c b/sc2/src/sc2code/libs/resource/resinit.c index a97285f37..dc1a82f36 100644 --- a/sc2/src/sc2code/libs/resource/resinit.c +++ b/sc2/src/sc2code/libs/resource/resinit.c @@ -87,7 +87,9 @@ MEM_HANDLE _GetResFileData (uio_Stream *res_fp, DWORD flen) { UWORD lo_word, hi_word; - DWORD res_offs, remainder; + DWORD res_offs; + DWORD remainder = 0; + // Initialisation is to keep the compiler quiet. MEM_SIZE HeaderSize; INDEX_HEADER h; INDEX_HEADERPTR ResHeaderPtr; @@ -249,18 +251,20 @@ UninitResourceSystem (void) } MEM_HANDLE -OpenResourceIndexFile (PVOID resfile) +OpenResourceIndexFile (const char *resfile) { uio_Stream *res_fp; char fullname[256]; strcpy (fullname, resfile); - if ((res_fp = res_OpenResFile (contentDir, fullname, "rb")) == 0) + res_fp = res_OpenResFile (contentDir, fullname, "rb"); + if (res_fp == 0) { - sprintf (fullname, "%s.pkg", (char *) resfile); - if ((res_fp = res_OpenResFile (contentDir, fullname, "rb")) == 0) + sprintf (fullname, "%s.pkg", resfile); + res_fp = res_OpenResFile (contentDir, fullname, "rb"); + if (res_fp == 0) { - sprintf (fullname, "%s.ndx", (char *) resfile); + sprintf (fullname, "%s.ndx", resfile); res_fp = res_OpenResFile (contentDir, fullname, "rb"); } } diff --git a/sc2/src/sc2code/libs/uio/debug.c b/sc2/src/sc2code/libs/uio/debug.c index 852ef27b3..0618af5ef 100644 --- a/sc2/src/sc2code/libs/uio/debug.c +++ b/sc2/src/sc2code/libs/uio/debug.c @@ -555,7 +555,7 @@ err: uio_releaseStdioAccess(handles[i]); } uio_free(handles); - uio_free(newArgs); + uio_free((void *) newArgs); uio_closeDir(tempDir); return errCode; diff --git a/sc2/src/sc2code/libs/video/video.h b/sc2/src/sc2code/libs/video/video.h index db3e830da..fbb910dfb 100644 --- a/sc2/src/sc2code/libs/video/video.h +++ b/sc2/src/sc2code/libs/video/video.h @@ -51,4 +51,6 @@ typedef struct tfb_videoclip } TFB_VideoClip; +extern VIDEO_REF _init_video_file(const char *pStr); + #endif // _UQM_VIDEO_H diff --git a/sc2/src/sc2code/libs/video/vidplayer.c b/sc2/src/sc2code/libs/video/vidplayer.c index de5ce8948..4f614ad90 100644 --- a/sc2/src/sc2code/libs/video/vidplayer.c +++ b/sc2/src/sc2code/libs/video/vidplayer.c @@ -105,8 +105,8 @@ TFB_FadeClearScreen (void) // audio-synced video playback task // the frame rate and timing is dictated by the audio -int -as_video_play_task (void* data) +static int +as_video_play_task (void *data) { Task task = (Task) data; volatile TFB_VideoClip* vid; @@ -218,8 +218,8 @@ as_video_play_task (void* data) // audio-independent video playback task // the frame rate and timing is dictated by the video decoder -int -video_play_task (void* data) +static int +video_play_task (void *data) { Task task = (Task) data; TFB_VideoClip* vid; @@ -397,7 +397,7 @@ TFB_VideoPlaying (VIDEO_REF VidRef) return vid->playing; } -BOOLEAN +static BOOLEAN TFB_DoVideoInput (PVOID pIS) { VIDEO_INPUT_STATE* pVIS = (VIDEO_INPUT_STATE*) pIS; @@ -528,6 +528,6 @@ vp_QueueBuffer (TFB_SoundSample* sample, audio_Object buffer) //TFB_VideoClip* vid = sample->data; TFB_TagBuffer (sample, buffer, - (void*) SoundDecoder_GetFrame (sample->decoder)); + (void *) SoundDecoder_GetFrame (sample->decoder)); } diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 22cc7502d..bd2a93292 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -22,6 +22,7 @@ #include "colors.h" #include "controls.h" #include "file.h" +#include "fmv.h" #include "gamestr.h" #include "globdata.h" #include "intel.h" diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index a43034699..8982a0874 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -33,7 +33,7 @@ //#define DEBUG_DEVICES static COUNT -lpstrchr (UNICODE *pStr, UNICODE ch) +lpstrchr (const UNICODE *pStr, UNICODE ch) { COUNT skip_chars; @@ -131,7 +131,8 @@ DrawDevices (PMENU_STATE pMS, BYTE OldDevice, BYTE NewDevice) if (OldDevice != NewDevice) { t.baseline.y = cy; - t.pStr = GAME_STRING (pDeviceMap[OldDevice] + DEVICE_STRING_BASE + 1); + t.pStr = GAME_STRING (pDeviceMap[OldDevice] + + DEVICE_STRING_BASE + 1); t.CharCount = lpstrchr (t.pStr, ' '); font_DrawText (&t); t.baseline.y += 7; diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 8bce97cca..a7b746e87 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -19,6 +19,7 @@ #include "colors.h" #include "controls.h" #include "encount.h" +#include "gameopt.h" #include "gamestr.h" #include "globdata.h" #include "options.h" @@ -57,8 +58,8 @@ void RepairBackRect (PRECT pRect); static BOOLEAN transition_pending; -int -flash_cursor_func(void *data) +static int +flash_cursor_func (void *data) { BYTE c, val; POINT universe; diff --git a/sc2/src/sc2code/planets/report.c b/sc2/src/sc2code/planets/report.c index 25b10f109..43764e416 100644 --- a/sc2/src/sc2code/planets/report.c +++ b/sc2/src/sc2code/planets/report.c @@ -110,8 +110,8 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen) while (StrLen) { COUNT col_cells; - UNICODE *pLastStr; - UNICODE *pTempStr; + const UNICODE *pLastStr; + const UNICODE *pTempStr; COUNT lf_pos; pLastStr = t.pStr; @@ -137,7 +137,7 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen) do { COUNT word_chars; - UNICODE *pStr; + const UNICODE *pStr; pStr = t.pStr; while (isgraph (*pStr)) @@ -166,7 +166,8 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen) if (t.pStr[0] == ',') TimeOut += ONE_SECOND / 4; - if (t.pStr[0] == '.' || t.pStr[0] == '!' || t.pStr[0] == '?') + if (t.pStr[0] == '.' || t.pStr[0] == '!' || + t.pStr[0] == '?') TimeOut += ONE_SECOND / 2; else TimeOut += ONE_SECOND / 20; diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 6f7baeca2..a6b24fe5a 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -104,16 +104,18 @@ EraseCoarseScan (void) } static void -PrintScanTitlePC (TEXT *t, RECT *r, char *txt, int xpos) +PrintScanTitlePC (TEXT *t, RECT *r, const char *txt, int xpos) { t->baseline.x = xpos; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); - wsprintf (t->pStr, txt); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + t->pStr = txt; t->CharCount = (COUNT)~0; font_DrawText (t); TextRect (t, r, NULL_PTR); t->baseline.x += r->extent.width; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xF, 0x00, 0x19), 0x3B)); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0xF, 0x00, 0x19), 0x3B)); } static void @@ -184,7 +186,8 @@ PrintCoarseScanPC (void) t.pStr = buf; t.CharCount = (COUNT)~0; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); SetContextFont (MicroFont); font_DrawText (&t); SetContextFont (TinyFont); @@ -198,7 +201,6 @@ PrintCoarseScanPC (void) t.align = ALIGN_LEFT; LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Orbit: ", LEFT_SIDE_BASELINE_X_PC); temp = (SIZE)((pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist * 100L + (EARTH_RADIUS >> 1)) / EARTH_RADIUS); @@ -206,13 +208,13 @@ PrintCoarseScanPC (void) wsprintf (buf, "%u.%u a.u.", temp / 100, (temp / 10) % 10); else wsprintf (buf, "%u.%02u a.u.", temp / 100, temp % 100); + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Atmo: ", LEFT_SIDE_BASELINE_X_PC); if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE) wsprintf (buf, "Super Thick"); @@ -227,39 +229,48 @@ PrintCoarseScanPC (void) else wsprintf (buf, "%u.%02u atm", temp / 100, temp % 100); } + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Temp: ", LEFT_SIDE_BASELINE_X_PC); - wsprintf (buf, "%d^ c", pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature); + wsprintf (buf, "%d^ c", + pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature); + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Weather: ", LEFT_SIDE_BASELINE_X_PC); if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0) - wsprintf (buf, "None"); + t.pStr = "None"; else - wsprintf (buf, "Class %u", pSolarSysState->SysInfo.PlanetInfo.Weather + 1); + { + wsprintf (buf, "Class %u", + pSolarSysState->SysInfo.PlanetInfo.Weather + 1); + t.pStr = buf; + } t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Tectonics: ", LEFT_SIDE_BASELINE_X_PC); - if (PLANSIZE (pSolarSysState->SysInfo.PlanetInfo.PlanDataPtr->Type) == GAS_GIANT) - wsprintf (buf, "None"); + if (PLANSIZE (pSolarSysState->SysInfo.PlanetInfo.PlanDataPtr->Type) == + GAS_GIANT) + t.pStr = "None"; else - wsprintf (buf, "Class %u", pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1); + { + wsprintf (buf, "Class %u", + pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1); + t.pStr = buf; + } t.CharCount = (COUNT)~0; font_DrawText (&t); UnlockMutex (GraphicsLock); @@ -267,43 +278,44 @@ PrintCoarseScanPC (void) t.baseline.y = SCAN_BASELINE_Y_PC; LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Mass: ", RIGHT_SIDE_BASELINE_X_PC); { DWORD tr; tr = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius; - if ((tr = (tr * tr * tr / 100L + tr = (tr * tr * tr / 100L * (DWORD)pSolarSysState->SysInfo.PlanetInfo.PlanetDensity - + (DWORD)((100L * 100L) >> 1)) - / (DWORD)(100L * 100L)) == 0) + + (DWORD)((100L * 100L) >> 1)) / (DWORD)(100L * 100L); + if (tr == 0) tr = 1; if (tr >= 10 * 100) wsprintf (buf, "%lu.%lu e.s.", tr / 100, (tr / 10) % 10); else wsprintf (buf, "%lu.%02lu e.s.", tr / 100, tr % 100); } + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Radius: ", RIGHT_SIDE_BASELINE_X_PC); - if ((temp = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius) >= 10 * 100) + temp = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius; + if (temp >= 10 * 100) wsprintf (buf, "%u.%u e.s.", temp / 100, (temp / 10) % 10); else wsprintf (buf, "%u.%02u e.s.", temp / 100, temp % 100); + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Gravity: ", RIGHT_SIDE_BASELINE_X_PC); - if ((temp = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity) >= 10 * 100) + temp = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity; + if (temp >= 10 * 100) wsprintf (buf, "%u.%u g.", temp / 100, (temp / 10) % 10); else { @@ -311,17 +323,18 @@ PrintCoarseScanPC (void) temp = 1; wsprintf (buf, "%u.%02u g.", temp / 100, temp % 100); } + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Day: ", RIGHT_SIDE_BASELINE_X_PC); if (pSolarSysState->SysInfo.PlanetInfo.RotationPeriod < 240 * 10) { - temp = (SIZE)(pSolarSysState->SysInfo.PlanetInfo.RotationPeriod * 10 / 24); + temp = (SIZE)(pSolarSysState->SysInfo.PlanetInfo.RotationPeriod * + 10 / 24); wsprintf (buf, "%u.%02u days", temp / 100, temp % 100); } else @@ -330,16 +343,17 @@ PrintCoarseScanPC (void) + (24 >> 1)) / 24); wsprintf (buf, "%u.%u days", temp / 10, temp % 10); } + t.pStr = buf; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += SCAN_LEADING_PC; UnlockMutex (GraphicsLock); LockMutex (GraphicsLock); - t.pStr = buf; PrintScanTitlePC (&t, &r, "Tilt: ", RIGHT_SIDE_BASELINE_X_PC); if ((temp = pSolarSysState->SysInfo.PlanetInfo.AxialTilt) < 0) temp = -temp; + t.pStr = buf; wsprintf (buf, "%u^", temp); t.CharCount = (COUNT)~0; font_DrawText (&t); diff --git a/sc2/src/sc2code/units.h b/sc2/src/sc2code/units.h index 65b0e0657..576f4d13d 100644 --- a/sc2/src/sc2code/units.h +++ b/sc2/src/sc2code/units.h @@ -95,17 +95,17 @@ extern int ScreenHeight; static inline COORD logxToUniverse (long lx) { - return (lx * ((MAX_X_UNIVERSE + 1) >> 4)) * 10 - / ((long) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH); + return (COORD) ((lx * ((MAX_X_UNIVERSE + 1) >> 4)) * 10 + / ((long) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH)); } #define LOGX_TO_UNIVERSE(lx) \ logxToUniverse (lx) static inline COORD logyToUniverse (long ly) { - return MAX_Y_UNIVERSE - + return (COORD) (MAX_Y_UNIVERSE - (COORD)(((long) (ly) * ((MAX_Y_UNIVERSE + 1) >> 4)) - / ((long) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT)); + / ((long) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT))); } #define LOGY_TO_UNIVERSE(ly) \ logyToUniverse (ly)