diff --git a/sc2/src/msvc++/UrQuanMasters.dsp b/sc2/src/msvc++/UrQuanMasters.dsp index fe3dadae7..99e27e6b0 100644 --- a/sc2/src/msvc++/UrQuanMasters.dsp +++ b/sc2/src/msvc++/UrQuanMasters.dsp @@ -151,6 +151,10 @@ SOURCE=..\sc2code\libs\file\temp.c # Begin Group "graphics" # PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\prim.h +# End Source File # Begin Group "sdl" # PROP Default_Filter "" @@ -3350,6 +3354,10 @@ SOURCE=..\sc2code\gameopt.c # End Source File # Begin Source File +SOURCE=..\sc2code\gameopt.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\gamestr.h # End Source File # Begin Source File @@ -3434,6 +3442,10 @@ SOURCE=..\sc2code\load.c # End Source File # Begin Source File +SOURCE=..\sc2code\load.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\loadship.c # End Source File # Begin Source File @@ -3442,6 +3454,10 @@ SOURCE=..\sc2code\master.c # End Source File # Begin Source File +SOURCE=..\sc2code\master.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\melee.c # End Source File # Begin Source File @@ -3478,6 +3494,10 @@ SOURCE=..\sc2code\pickmele.c # End Source File # Begin Source File +SOURCE=..\sc2code\pickmele.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\pickship.c # End Source File # Begin Source File @@ -3490,6 +3510,10 @@ SOURCE=..\sc2code\process.c # End Source File # Begin Source File +SOURCE=..\sc2code\process.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\races.h # End Source File # Begin Source File @@ -3506,6 +3530,10 @@ SOURCE=..\sc2code\restart.c # End Source File # Begin Source File +SOURCE=..\sc2code\restart.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\restypes.h # End Source File # Begin Source File @@ -3514,6 +3542,10 @@ SOURCE=..\sc2code\save.c # End Source File # Begin Source File +SOURCE=..\sc2code\save.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\settings.c # End Source File # Begin Source File @@ -3582,6 +3614,10 @@ SOURCE=..\sc2code\starcon.c # End Source File # Begin Source File +SOURCE=..\sc2code\starcon.h +# End Source File +# Begin Source File + SOURCE=..\sc2code\starmap.c # End Source File # Begin Source File diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index 31fc84826..8bb0cfc6b 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -223,8 +223,6 @@ BOOLEAN Battle (void) { SIZE num_ships; - extern SIZE InitShips (void); - void UninitShips (void); LockMutex (GraphicsLock); diff --git a/sc2/src/sc2code/cleanup.c b/sc2/src/sc2code/cleanup.c index 2b427baca..18354d144 100644 --- a/sc2/src/sc2code/cleanup.c +++ b/sc2/src/sc2code/cleanup.c @@ -17,9 +17,11 @@ */ #include "battle.h" +#include "master.h" #include "nameref.h" #include "reslib.h" #include "gamestr.h" +#include "init.h" #include "setup.h" #include "sounds.h" #include "libs/sndlib.h" @@ -33,23 +35,18 @@ void FreeLanderData (void); void FreeIPData (void); -void FreeMasterShipList (void); - -void UninitSpace (void); - void FreeHyperData (void); //End Added by Chris static void UninitContexts (void); static void UninitKernel (BOOLEAN ships); +static void UninitGameKernel (void); void FreeKernel (void) { - extern void UninitPlayerInput (void); - UninitKernel (TRUE); UninitContexts (); @@ -100,9 +97,10 @@ UninitKernel (BOOLEAN ships) ActivityFrame = 0; } -void +static void UninitGameKernel (void) { + // XXX: this function is never called. Why not? (BUG?) if (ActivityFrame) { FreeSC2Data (); @@ -115,3 +113,4 @@ UninitGameKernel (void) } } + diff --git a/sc2/src/sc2code/clock.c b/sc2/src/sc2code/clock.c index 618014d98..dd759027d 100644 --- a/sc2/src/sc2code/clock.c +++ b/sc2/src/sc2code/clock.c @@ -32,9 +32,11 @@ #define IsLeapYear(yi) (!((yi) & 3) && (((yi) % 100) || ((yi) % 400))) +static int clock_task_func(void* data); + static Mutex clock_mutex; -int clock_task_func(void* data) +static int clock_task_func(void* data) { BOOLEAN LastPilot; DWORD LastTime; diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index b1da72730..bacaad116 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -25,6 +25,7 @@ #include "endian_uqm.h" #include "gamestr.h" #include "options.h" +#include "oscill.h" #include "resinst.h" #include "settings.h" #include "setup.h" @@ -40,12 +41,12 @@ #include -void InitOscilloscope (int x, int y, int width, int height, FRAME_DESC *f); -void SetSliderImage (void *f); -void InitSlider (int x, int y, int width, int height, - int bwidth, int bheight, void *f); -void Oscilloscope (int grab_data); -void Slider (void); +static void init_xform_control (void); +static void uninit_xform_control (void); +static void xform_complete (void); +static void xform_PLUT_step (SIZE TDelta); +static void FlushPLUTXForms (void); +static int ambient_anim_task (void *data); #define MAX_RESPONSES 8 @@ -120,7 +121,7 @@ enum static int subtitle_state = DONE_SUBTITLE; static Mutex subtitle_mutex; -static volatile UNICODE *last_subtitle; +static const UNICODE * volatile last_subtitle; static TFB_Image *subtitle_cache; /* _count_lines - mostly stolen from add_text, just sees how many lines @@ -129,7 +130,8 @@ static TFB_Image *subtitle_cache; static int _count_lines (PTEXT pText) { COUNT maxchars = (COUNT)~0; - UNICODE ch, *pStr; + UNICODE ch; + const UNICODE *pStr; SIZE text_width; int num = 0; @@ -186,7 +188,8 @@ add_text (int status, PTEXT pTextIn) TEXT locText; PTEXT pText; SIZE leading; - UNICODE ch, *pStr; + UNICODE ch; + const UNICODE *pStr; SIZE text_width; int num_lines = 0; static COORD last_baseline; @@ -496,7 +499,7 @@ static struct { Mutex XFormLock; } XFormControl; -void +static void init_xform_control (void) { XFormControl.XFormCurrent = XFormControl.XFormInsertPoint = 0; @@ -504,13 +507,13 @@ init_xform_control (void) XFormControl.XFormLock = CreateMutex ("Transform Lock", SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO); } -void +static void uninit_xform_control (void) { DestroyMutex (XFormControl.XFormLock); } -void +static void xform_complete (void) { LockMutex (XFormControl.XFormLock); @@ -557,7 +560,7 @@ static volatile BOOLEAN SummaryChange; static volatile BOOLEAN ClearSubtitle; /* Only one thread should ever be allowed to be calling this at any time */ -void +static void xform_PLUT_step (SIZE TDelta) { XFORM_CONTROL *control; @@ -640,7 +643,7 @@ xform_PLUT_step (SIZE TDelta) * writes are atomic anyway, and Flush is the only routine that writes * XFormFlush. */ -void +static void FlushPLUTXForms (void) { while (XFormControl.XFormsPending) @@ -859,7 +862,8 @@ UpdateSpeechGraphics (BOOLEAN Initialize) SetContext (OldContext); } -int ambient_anim_task(void* data) +static int +ambient_anim_task (void *data) { SIZE TalkAlarm; FRAME TalkFrame; @@ -1725,7 +1729,7 @@ DoCommunication (PENCOUNTER_STATE pES) while (wstrlen (temp) > (unsigned int) SUMMARY_CHARS && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { - int space_index; + int space_index = SUMMARY_CHARS; // find last space before it goes over the max chars per line for (i = SUMMARY_CHARS - 1; i > 0; i--) { diff --git a/sc2/src/sc2code/dummy.c b/sc2/src/sc2code/dummy.c index 58fbb287a..8494cdb25 100644 --- a/sc2/src/sc2code/dummy.c +++ b/sc2/src/sc2code/dummy.c @@ -21,6 +21,7 @@ * much. */ +#include "dummy.h" #include "coderes.h" #include "races.h" @@ -381,16 +382,3 @@ CreatePixmapRegion (FRAME Frame, PPOINT lpOrg, SIZE width, SIZE height) } -void -SetPrimNextLink (PPRIMITIVE pPrim, COUNT Link) -{ - SetPrimLinks (pPrim, END_OF_LIST, Link); -} - - -COUNT -GetPrimNextLink (PPRIMITIVE pPrim) -{ - return (GetSuccLink (GetPrimLinks (pPrim))); -} - diff --git a/sc2/src/sc2code/dummy.h b/sc2/src/sc2code/dummy.h index a1c2efb39..6124b57c9 100644 --- a/sc2/src/sc2code/dummy.h +++ b/sc2/src/sc2code/dummy.h @@ -17,12 +17,14 @@ #ifndef _DUMMY_H #define _DUMMY_H +#include "libs/compiler.h" #include "libs/gfxlib.h" -//extern MEM_HANDLE LoadVidInstance (DWORD res); +extern MEM_HANDLE LoadVidInstance (DWORD res); +extern MEM_HANDLE LoadCodeResFile (PSTR pStr); -//extern DRAWABLE CreatePixmapRegion (FRAME Frame, PPOINT pOrg, SIZE width, -// SIZE height); +extern DRAWABLE CreatePixmapRegion (FRAME Frame, PPOINT lpOrg, SIZE width, + SIZE height); extern void SetPrimNextLink (PPRIMITIVE pPrim, COUNT Link); extern COUNT GetPrimNextLink (PPRIMITIVE pPrim); diff --git a/sc2/src/sc2code/encount.c b/sc2/src/sc2code/encount.c index e951d8062..9b66e4276 100644 --- a/sc2/src/sc2code/encount.c +++ b/sc2/src/sc2code/encount.c @@ -22,6 +22,7 @@ #include "build.h" #include "colors.h" #include "controls.h" +#include "gameopt.h" #include "gamestr.h" #include "globdata.h" #include "init.h" @@ -31,12 +32,15 @@ #include "settings.h" #include "setup.h" #include "sounds.h" -#include "state.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" #include "libs/inplib.h" +static void DrawFadeText (const UNICODE *str1, const UNICODE *str2, + BOOLEAN fade_in, PRECT pRect); + + static BOOLEAN DoSelectAction (PMENU_STATE pMS) { @@ -348,8 +352,8 @@ InitEncounter (void) } static void -DrawFadeText (UNICODE *str1, UNICODE *str2, BOOLEAN fade_in, PRECT - pRect) +DrawFadeText (const UNICODE *str1, const UNICODE *str2, BOOLEAN fade_in, + PRECT pRect) { SIZE i; DWORD TimeIn; @@ -408,7 +412,8 @@ DrawFadeText (UNICODE *str1, UNICODE *str2, BOOLEAN fade_in, PRECT SleepThreadUntil (TimeIn + (ONE_SECOND / 20)); TimeIn = GetTimeCounter (); } - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), + 0x08)); font_DrawText (&t1); font_DrawText (&t2); } @@ -440,12 +445,14 @@ UninitEncounter (void) BOOLEAN Sleepy; DWORD Time; SIZE VictoryState; - COUNT RecycleAmount; + COUNT RecycleAmount = 0; SIZE i; RECT r, scavenge_r; TEXT t; STAMP ship_s; - UNICODE *str1, *str2, buf[20]; + const UNICODE *str1 = NULL; + const UNICODE *str2 = NULL; + UNICODE buf[20]; HSTARSHIP hStarShip; SHIP_FRAGMENTPTR FragPtr; COLOR fade_ship_cycle[] = @@ -461,7 +468,9 @@ UninitEncounter (void) BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), }; -#define NUM_SHIP_FADES (sizeof (fade_ship_cycle) / sizeof (fade_ship_cycle[0])) +#define NUM_SHIP_FADES (sizeof (fade_ship_cycle) / \ + sizeof (fade_ship_cycle[0])) + COUNT race_bounty[] = { RACE_SHIP_COST @@ -476,12 +485,11 @@ UninitEncounter (void) ) ? 0 : 1; hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q)); - FragPtr = (SHIP_FRAGMENTPTR)LockStarShip (&GLOBAL (npc_built_ship_q), hStarShip); + FragPtr = (SHIP_FRAGMENTPTR)LockStarShip (&GLOBAL (npc_built_ship_q), + hStarShip); battle_counter = GET_RACE_ID (FragPtr) + 1; - if (GetStarShipFromIndex ( - &GLOBAL (avail_race_q), - (COUNT)(battle_counter - 1) - ) == 0) + if (GetStarShipFromIndex (&GLOBAL (avail_race_q), + (COUNT)(battle_counter - 1)) == 0) { VictoryState = -1; InitSISContexts (); @@ -508,9 +516,7 @@ UninitEncounter (void) DrawSISMessage (NULL_PTR); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) - DrawHyperCoords ( - GLOBAL (ShipStamp.origin) - ); + DrawHyperCoords (GLOBAL (ShipStamp.origin)); else if (HIWORD (GLOBAL (ShipStamp.frame)) == 0) DrawHyperCoords (CurStarDescPtr->star_pt); else @@ -525,7 +531,8 @@ UninitEncounter (void) ReinitQueue (&race_q[(NUM_SIDES - 1) - i]); - for (hStarShip = GetHeadLink (pQueue); hStarShip; hStarShip = hNextShip) + for (hStarShip = GetHeadLink (pQueue); hStarShip; + hStarShip = hNextShip) { FragPtr = (SHIP_FRAGMENTPTR)LockStarShip (pQueue, hStarShip); hNextShip = _GetSuccLink (FragPtr); @@ -549,14 +556,16 @@ UninitEncounter (void) ship_s.origin.x = scavenge_r.corner.x + 32; ship_s.origin.y = scavenge_r.corner.y + 56; - ship_s.frame = IncFrameIndex (FragPtr->ShipInfo.icons); + ship_s.frame = IncFrameIndex ( + FragPtr->ShipInfo.icons); DrawStamp (&ship_s); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F)); SetContextFont (TinyFont); GetStringContents ( - FragPtr->ShipInfo.race_strings, (STRINGPTR)buf, FALSE - ); + FragPtr->ShipInfo.race_strings, + (STRINGPTR)buf, FALSE); wstrupr (buf); t.baseline.x = scavenge_r.corner.x + 100; @@ -566,19 +575,19 @@ UninitEncounter (void) t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += 6; - t.pStr = GAME_STRING (ENCOUNTER_STRING_BASE + 3); + t.pStr = GAME_STRING ( + ENCOUNTER_STRING_BASE + 3); t.CharCount = (COUNT)~0; font_DrawText (&t); ship_s.frame = FragPtr->ShipInfo.icons; SetContextFont (MicroFont); - DrawFadeText ( - str1 = GAME_STRING (ENCOUNTER_STRING_BASE + 4), - str2 = GAME_STRING (ENCOUNTER_STRING_BASE + 5), - TRUE, - &scavenge_r - ); + str1 = GAME_STRING ( + ENCOUNTER_STRING_BASE + 4); + str2 = GAME_STRING ( + ENCOUNTER_STRING_BASE + 5), + DrawFadeText (str1, str2, TRUE, &scavenge_r); } r.corner.y = scavenge_r.corner.y + 9; @@ -587,11 +596,12 @@ UninitEncounter (void) SetContextForeGroundColor (BLACK_COLOR); r.extent.width = 34; - r.corner.x = scavenge_r.corner.x + scavenge_r.extent.width + r.corner.x = scavenge_r.corner.x + + scavenge_r.extent.width - (10 + r.extent.width); DrawFilledRectangle (&r); - /* collect bounty ResUnits */ + /* collect bounty ResUnits */ j = race_bounty[battle_counter - 1] >> 3; RecycleAmount += j; wsprintf (buf, "%u", RecycleAmount); @@ -600,9 +610,8 @@ UninitEncounter (void) t.align = ALIGN_RIGHT; t.pStr = buf; t.CharCount = (COUNT)~0; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x18), 0x50) - ); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0x00, 0x00, 0x18), 0x50)); font_DrawText (&t); DeltaSISGauges (0, 0, j); @@ -681,16 +690,12 @@ UninitEncounter (void) t.pStr = buf; t.CharCount = (COUNT)~0; SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x18), 0x50) - ); + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x18), 0x50)); font_DrawText (&t); - DrawFadeText ( - str1 = GAME_STRING (ENCOUNTER_STRING_BASE + 6), - str2 = GAME_STRING (ENCOUNTER_STRING_BASE + 7), - TRUE, - &scavenge_r - ); + str1 = GAME_STRING (ENCOUNTER_STRING_BASE + 6); + str2 = GAME_STRING (ENCOUNTER_STRING_BASE + 7); + DrawFadeText (str1, str2, TRUE, &scavenge_r); Time = GetTimeCounter () + ONE_SECOND * 2; UnlockMutex (GraphicsLock); while (!(AnyButtonPress (TRUE)) diff --git a/sc2/src/sc2code/fmv.c b/sc2/src/sc2code/fmv.c index 7e8e3bb17..d9ad5bd11 100644 --- a/sc2/src/sc2code/fmv.c +++ b/sc2/src/sc2code/fmv.c @@ -21,6 +21,7 @@ #include "controls.h" #include "hyper.h" #include "options.h" +#include "master.h" #include "resinst.h" #include "settings.h" #include "setup.h" @@ -29,16 +30,10 @@ #include "libs/inplib.h" -//Added by Chris - -BOOLEAN InitGameKernel (void); -void LoadMasterShipList (void); - -//End Added by Chris - void DoShipSpin (COUNT index, MUSIC_REF hMusic) { +#ifdef WANT_SHIP_SPINS char buf[30]; BYTE clut_buf[1]; RECT old_r, r; @@ -72,6 +67,7 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) clut_buf[0] = FadeAllToColor; SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); FlushColorXForms (); +#endif /* WANT_SHIP_SPINS */ } void diff --git a/sc2/src/sc2code/fmv.h b/sc2/src/sc2code/fmv.h index 44dfec0ea..b206af05a 100644 --- a/sc2/src/sc2code/fmv.h +++ b/sc2/src/sc2code/fmv.h @@ -17,13 +17,20 @@ #ifndef _FMV_H #define _FMV_H +#include "libs/compiler.h" + + extern void Logo (void); extern void Introduction (void); extern void Victory (void); -#ifdef WANT_SHIP_SPINS +#include "libs/sndlib.h" extern void DoShipSpin (COUNT index, MUSIC_REF hMusic); -#endif + +extern BOOLEAN DoFMV (const char *name, const char *loopname, + BOOLEAN uninit); +extern BOOLEAN ShowPresentation (const char *name); + #endif /* _FMV_H */ diff --git a/sc2/src/sc2code/gameev.h b/sc2/src/sc2code/gameev.h index 92a7c911f..d7bb9b0e2 100644 --- a/sc2/src/sc2code/gameev.h +++ b/sc2/src/sc2code/gameev.h @@ -18,6 +18,7 @@ #define _GAMEEV_H #include "libs/compiler.h" +#include "libs/gfxlib.h" enum @@ -52,6 +53,8 @@ typedef enum extern void AddInitialGameEvents (void); extern void EventHandler (BYTE selector); +extern void SetRaceDest (BYTE which_race, COORD x, COORD y, BYTE days_left, + BYTE func_index); #endif /* _GAMEEV_H */ diff --git a/sc2/src/sc2code/gameinp.c b/sc2/src/sc2code/gameinp.c index a06db39ec..5cc011b02 100644 --- a/sc2/src/sc2code/gameinp.c +++ b/sc2/src/sc2code/gameinp.c @@ -21,6 +21,7 @@ #include "planets/planets.h" #include "settings.h" #include "sounds.h" +#include "libs/inplib.h" #include "libs/timelib.h" #include "libs/threadlib.h" diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 07d0a104b..17cde1d43 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -16,14 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "gameopt.h" + #include "build.h" #include "colors.h" #include "commglue.h" #include "controls.h" #include "encount.h" #include "gamestr.h" -#include "options.h" #include "inplib.h" +#include "load.h" +#include "options.h" +#include "save.h" #include "settings.h" #include "setup.h" #include "sounds.h" @@ -34,12 +38,6 @@ #include -//Added by Chris - -void SaveProblem (void); - -//End Added by Chris - #define MAX_SAVED_GAMES 50 #define SUMMARY_X_OFFS 14 #define SUMMARY_SIDE_OFFS 7 @@ -977,9 +975,6 @@ LoadGameDescriptions (SUMMARY_DESC *pSD) for (i = 0; i < MAX_SAVED_GAMES; ++i, ++pSD) { - extern BOOLEAN LoadGame (COUNT which_game, - SUMMARY_DESC *summary_desc); - if (!LoadGame (i, pSD)) pSD->year_index = 0; } @@ -1059,9 +1054,6 @@ Restart: if (pMS->delta_item == SAVE_GAME) { STAMP MsgStamp; - extern BOOLEAN SaveGame (COUNT - which_game, SUMMARY_DESC - *summary_desc); ConfirmSaveLoad (&MsgStamp); if (SaveGame ((COUNT)pMS->CurState, pSD)) @@ -1099,8 +1091,6 @@ Restart: } else { - extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc); - ConfirmSaveLoad (0); if (LoadGame ((COUNT)pMS->CurState, NULL_PTR)) GLOBAL (CurrentActivity) |= CHECK_LOAD; @@ -1405,7 +1395,9 @@ DoGameOptions (PMENU_STATE pMS) case SAVE_GAME: case LOAD_GAME: pMS->CurFrame = (FRAME)FadeMusic (0, ONE_SECOND >> 1); - return (PickGame (pMS)); + // XXX: what is going on here? A DWORD is cast + // to a FRAME. + return PickGame (pMS); case QUIT_GAME: pMS->Initialized = FALSE; pMS->CurState = NO_QUIT_MENU; diff --git a/sc2/src/sc2code/gameopt.h b/sc2/src/sc2code/gameopt.h new file mode 100644 index 000000000..0d7b7e8cd --- /dev/null +++ b/sc2/src/sc2code/gameopt.h @@ -0,0 +1,26 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _GAMEOPT_H +#define _GAMEOPT_H + +#include "compiler.h" +#include "libs/gfxlib.h" + +extern void ConfirmSaveLoad (STAMP *MsgStamp); +extern BOOLEAN GameOptions (void); + +#endif /* _GAMEOPT_H */ + diff --git a/sc2/src/sc2code/globdata.c b/sc2/src/sc2code/globdata.c index 3df74691c..7e02c1cc1 100644 --- a/sc2/src/sc2code/globdata.c +++ b/sc2/src/sc2code/globdata.c @@ -20,6 +20,7 @@ #include "coderes.h" #include "encount.h" +#include "master.h" #include "setup.h" #include "resinst.h" #include "build.h" @@ -28,11 +29,8 @@ #include -//Added by Chris -void InitGlobData (void); - -//End Added by Chris +static void CreateRadar (void); CONTEXT RadarContext; FRAME PlayFrame; @@ -42,7 +40,7 @@ GLOBDATA GlobData; extern FRAME flagship_status, misc_data; BOOLEAN initedSIS = 0; -void +static void CreateRadar (void) { if (RadarContext == 0) @@ -135,11 +133,9 @@ InitSIS (void) { SHIP_FRAGMENTPTR FragPtr; EXTENDED_SHIP_FRAGMENTPTR ExtFragPtr; - extern HSTARSHIP FindMasterShip (DWORD ship_ref); FragPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + &GLOBAL (avail_race_q), hStarShip); if (i < num_ships - 1) { HSTARSHIP hMasterShip; @@ -147,7 +143,8 @@ InitSIS (void) hMasterShip = FindMasterShip (ship_ref); MasterShipPtr = LockStarShip (&master_q, hMasterShip); - FragPtr->ShipInfo = ((SHIP_FRAGMENTPTR)MasterShipPtr)->ShipInfo; + FragPtr->ShipInfo = + ((SHIP_FRAGMENTPTR)MasterShipPtr)->ShipInfo; UnlockStarShip (&master_q, hMasterShip); } else @@ -177,9 +174,7 @@ InitSIS (void) ExtFragPtr->ShipInfo.days_left = 0; FragPtr->RaceDescPtr = (RACE_DESCPTR)&ExtFragPtr->ShipInfo; - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } } } @@ -322,3 +317,23 @@ UninitSIS (void) initedSIS = FALSE; } +void +InitGlobData (void) +{ + COUNT i; + + i = GLOBAL (glob_flags); + memset ((PBYTE)&GlobData, 0, sizeof (GlobData)); + GLOBAL (glob_flags) = (BYTE)i; + + GLOBAL (DisplayArray) = DisplayArray; + // The clock semaphore was initially initialized as '1' + // but it is always cleared before set, so it toggled between + // 2 and 1, which doesn't actually do anything. + + GLOBAL (GameClock.clock_sem) = + CreateSemaphore(0, "Clock", SYNC_CLASS_TOPLEVEL); +} + + + diff --git a/sc2/src/sc2code/globdata.h b/sc2/src/sc2code/globdata.h index 2037033fd..9960dc5b3 100644 --- a/sc2/src/sc2code/globdata.h +++ b/sc2/src/sc2code/globdata.h @@ -972,6 +972,8 @@ extern void RetrieveStarMap (void); extern void FreeSC2Data (void); extern BOOLEAN LoadSC2Data (void); +void InitGlobData (void); + #endif /* _GLOBDATA_H */ diff --git a/sc2/src/sc2code/gravwell.c b/sc2/src/sc2code/gravwell.c index 4c8fbd2d3..686ac5980 100644 --- a/sc2/src/sc2code/gravwell.c +++ b/sc2/src/sc2code/gravwell.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "element.h" #include "resinst.h" #include "setup.h" diff --git a/sc2/src/sc2code/grpinfo.c b/sc2/src/sc2code/grpinfo.c index fe43d3f24..714846768 100644 --- a/sc2/src/sc2code/grpinfo.c +++ b/sc2/src/sc2code/grpinfo.c @@ -137,7 +137,8 @@ BuildGroups (void) // XXX: BUG: i is redefined in the line below, so the assignment // to i a few lines ago is useless. - // EncounterPercent is never used in practice. - SvdB + // EncounterPercent is never used in practice. + // BestIndex may be used uninitialised. - SvdB if ((i = HomeWorld[Index]) && CurStarDescPtr->Index == (BYTE)i) { BestIndex = Index; diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index 0d2cf39b1..ab74dd54c 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "hyper.h" + #include "build.h" #include "collide.h" #include "colors.h" @@ -37,6 +39,9 @@ void WaitForNoInput (SIZE Duration); //End Added by Chris +static void LoadHyperData (void); + + #define XOFFS ((RADAR_SCAN_WIDTH + (UNIT_SCREEN_WIDTH << 2)) >> 1) #define YOFFS ((RADAR_SCAN_HEIGHT + (UNIT_SCREEN_HEIGHT << 2)) >> 1) @@ -279,7 +284,7 @@ FreeHyperData (void) hypercmaps[1] = 0; } -void +static void LoadHyperData (void) { if (hyperstars[0] == 0) diff --git a/sc2/src/sc2code/init.c b/sc2/src/sc2code/init.c index d61e764c9..162a26337 100644 --- a/sc2/src/sc2code/init.c +++ b/sc2/src/sc2code/init.c @@ -27,10 +27,11 @@ #include "units.h" -FRAME stars_in_space, - asteroid[NUM_VIEWS], - blast[NUM_VIEWS], - explosion[NUM_VIEWS]; +FRAME stars_in_space; +FRAME asteroid[NUM_VIEWS]; +FRAME blast[NUM_VIEWS]; +FRAME explosion[NUM_VIEWS]; + BOOLEAN load_animation (PFRAME pixarray, DWORD big_res, DWORD med_res, DWORD @@ -261,21 +262,3 @@ UninitShips (void) } } -void -InitGlobData (void) -{ - COUNT i; - - i = GLOBAL (glob_flags); - memset ((PBYTE)&GlobData, 0, sizeof (GlobData)); - GLOBAL (glob_flags) = (BYTE)i; - - GLOBAL (DisplayArray) = DisplayArray; - // The clock semaphore was initially initialized as '1' - // but it is always cleared before set, so it toggled between - // 2 and 1, which doesn't actually do anything. - - GLOBAL (GameClock.clock_sem) = - CreateSemaphore(0, "Clock", SYNC_CLASS_TOPLEVEL); -} - diff --git a/sc2/src/sc2code/init.h b/sc2/src/sc2code/init.h index de64cf75d..927e5b9a4 100644 --- a/sc2/src/sc2code/init.h +++ b/sc2/src/sc2code/init.h @@ -24,6 +24,11 @@ extern FRAME stars_in_space; +extern BOOLEAN InitSpace (void); +extern void UninitSpace (void); + +extern SIZE InitShips (void); +extern void UninitShips (void); #endif /* _INIT_H */ diff --git a/sc2/src/sc2code/intel.c b/sc2/src/sc2code/intel.c index a43379003..8e963dde1 100644 --- a/sc2/src/sc2code/intel.c +++ b/sc2/src/sc2code/intel.c @@ -22,6 +22,8 @@ #include "globdata.h" #include "setup.h" +#include + SIZE cur_player; @@ -29,8 +31,9 @@ BATTLE_INPUT_STATE computer_intelligence (void) { BATTLE_INPUT_STATE InputState; + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) - return (0); + return 0; if (CyborgDescPtr) { @@ -51,8 +54,15 @@ computer_intelligence (void) InputState = BATTLE_WEAPON; /* pick a random ship */ break; } + default: + // Should not happen. Satisfying compiler. + fprintf (stderr, "Warning: Unexpected state in " + "computer_intelligence()."); + InputState = 0; + break; } } - return (InputState); + return InputState; } + diff --git a/sc2/src/sc2code/intro.c b/sc2/src/sc2code/intro.c index f99a1fab4..ecb37a184 100644 --- a/sc2/src/sc2code/intro.c +++ b/sc2/src/sc2code/intro.c @@ -21,9 +21,10 @@ #include "settings.h" #include "setup.h" #include "sounds.h" +#include "fmv.h" #include "libs/graphics/gfx_common.h" #include "libs/sound/sound.h" -#include "libs/vidlib.h" +//#include "libs/vidlib.h" #include "libs/inplib.h" #include @@ -59,8 +60,12 @@ typedef struct } PRESENTATION_INPUT_STATE, *PPRESENTATION_INPUT_STATE; + +static BOOLEAN DoPresentation (PVOID pIS); + + BOOLEAN -DoFMV (char *name, char *loopname, BOOLEAN uninit) +DoFMV (const char *name, const char *loopname, BOOLEAN uninit) { VIDEO_REF VidRef; @@ -90,8 +95,7 @@ ParseColorString (const char *Src, COLOR* pColor) return FALSE; *pColor = BUILD_COLOR (MAKE_RGB15 ( - (clr >> 19) & 0x1f, (clr >> 11) & 0x1f, (clr >> 3) & 0x1f), - 0); + (clr >> 19) & 0x1f, (clr >> 11) & 0x1f, (clr >> 3) & 0x1f), 0); return TRUE; } @@ -102,8 +106,7 @@ DoFadeScreen (PRESENTATION_INPUT_STATE* pPIS, const char *Src, BYTE FadeType) int msecs; if (1 == sscanf (Src, "%d", &msecs)) { - pPIS->TimeOut = XFormColorMap ( - (COLORMAPPTR) xform_buf, + pPIS->TimeOut = XFormColorMap ((COLORMAPPTR) xform_buf, (SIZE)(msecs * ONE_SECOND / 1000)) + ONE_SECOND / 10; pPIS->TimeOutOnSkip = FALSE; } @@ -171,7 +174,7 @@ Present_UnbatchGraphics (PRESENTATION_INPUT_STATE* pPIS, BOOLEAN bYield) } } -BOOLEAN +static BOOLEAN DoPresentation (PVOID pIS) { PRESENTATION_INPUT_STATE* pPIS = (PRESENTATION_INPUT_STATE*) pIS; @@ -504,7 +507,7 @@ DoPresentation (PVOID pIS) } BOOLEAN -ShowPresentation (char *name) +ShowPresentation (const char *name) { CONTEXT OldContext; FONT OldFont; @@ -513,8 +516,7 @@ ShowPresentation (char *name) RECT r = {{0, 0}, {SCREEN_WIDTH, SCREEN_HEIGHT}}; pis.SlideShow = CaptureStringTable ( - LoadStringTableFile (contentDir, name) - ); + LoadStringTableFile (contentDir, name)); if (!pis.SlideShow) return FALSE; pis.SlideShow = SetAbsStringTableIndex (pis.SlideShow, 0); diff --git a/sc2/src/sc2code/libs/gfxlib.h b/sc2/src/sc2code/libs/gfxlib.h index d0f73c455..060d1c185 100644 --- a/sc2/src/sc2code/libs/gfxlib.h +++ b/sc2/src/sc2code/libs/gfxlib.h @@ -102,7 +102,7 @@ typedef enum typedef struct text { POINT baseline; - UNICODE *pStr; + const UNICODE *pStr; TEXT_ALIGN align; TEXT_VALIGN valign; COUNT CharCount; @@ -115,61 +115,7 @@ typedef STRING_TABLE COLORMAP_REF; typedef STRING COLORMAP; typedef STRINGPTR COLORMAPPTR; -enum gfx_object -{ - POINT_PRIM = 0, - STAMP_PRIM, - STAMPFILL_PRIM, - LINE_PRIM, - TEXT_PRIM, - RECT_PRIM, - RECTFILL_PRIM, - - NUM_PRIMS -}; -typedef BYTE GRAPHICS_PRIM; - -typedef union -{ - POINT Point; - STAMP Stamp; - LINE Line; - TEXT Text; - RECT Rect; -} PRIM_DESC; -typedef PRIM_DESC *PPRIM_DESC; - -typedef DWORD PRIM_LINKS; - -typedef struct -{ - PRIM_LINKS Links; - DWORD TypeAndColor; - PRIM_DESC Object; -} PRIMITIVE; -typedef PRIMITIVE *PPRIMITIVE; - -#define END_OF_LIST ((COUNT)0xFFFF) - -#define PRIM_COLOR_SHIFT 8 -#define PRIM_COLOR_MASK ((DWORD)~0L << PRIM_COLOR_SHIFT) -#define PRIM_TYPE_MASK (~PRIM_COLOR_MASK) - -#define GetPredLink(l) LOWORD(l) -#define GetSuccLink(l) HIWORD(l) -#define MakeLinks MAKE_DWORD -#define SetPrimLinks(pPrim,p,s) ((pPrim)->Links = MakeLinks (p, s)) -#define GetPrimLinks(pPrim) ((pPrim)->Links) -#define SetPrimType(pPrim,t) \ - ((pPrim)->TypeAndColor = ((pPrim)->TypeAndColor & PRIM_COLOR_MASK) \ - | ((t) & PRIM_TYPE_MASK)) -#define GetPrimType(pPrim) \ - ((GRAPHICS_PRIM)LOBYTE ((pPrim)->TypeAndColor)) -#define SetPrimColor(pPrim,c) \ - ((pPrim)->TypeAndColor = ((pPrim)->TypeAndColor & PRIM_TYPE_MASK) \ - | ((c) << PRIM_COLOR_SHIFT)) -#define GetPrimColor(pPrim) \ - ((COLOR)((pPrim)->TypeAndColor >> PRIM_COLOR_SHIFT)) +#include "graphics/prim.h" typedef BYTE BATCH_FLAGS; diff --git a/sc2/src/sc2code/libs/graphics/filegfx.c b/sc2/src/sc2code/libs/graphics/filegfx.c index 19df71d7d..5b8911bcf 100644 --- a/sc2/src/sc2code/libs/graphics/filegfx.c +++ b/sc2/src/sc2code/libs/graphics/filegfx.c @@ -18,8 +18,8 @@ #include "gfxintrn.h" #include "options.h" +#include "libs/reslib.h" -extern char *_cur_resfile_name; DWORD LoadCelFile (PVOID pStr) diff --git a/sc2/src/sc2code/libs/graphics/gfx_common.h b/sc2/src/sc2code/libs/graphics/gfx_common.h index 41ae57fe4..e8c03a7dd 100644 --- a/sc2/src/sc2code/libs/graphics/gfx_common.h +++ b/sc2/src/sc2code/libs/graphics/gfx_common.h @@ -77,8 +77,6 @@ extern int ScreenWidthActual; extern int ScreenHeightActual; extern int GraphicsDriver; -int Starcon2Main (void *); - #include "cmap.h" #endif diff --git a/sc2/src/sc2code/libs/graphics/prim.h b/sc2/src/sc2code/libs/graphics/prim.h new file mode 100644 index 000000000..2b82b7557 --- /dev/null +++ b/sc2/src/sc2code/libs/graphics/prim.h @@ -0,0 +1,91 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _PRIM_H +#define _PRIM_H + +enum gfx_object +{ + POINT_PRIM = 0, + STAMP_PRIM, + STAMPFILL_PRIM, + LINE_PRIM, + TEXT_PRIM, + RECT_PRIM, + RECTFILL_PRIM, + + NUM_PRIMS +}; +typedef BYTE GRAPHICS_PRIM; + +typedef union +{ + POINT Point; + STAMP Stamp; + LINE Line; + TEXT Text; + RECT Rect; +} PRIM_DESC; +typedef PRIM_DESC *PPRIM_DESC; + +typedef DWORD PRIM_LINKS; + +typedef struct +{ + PRIM_LINKS Links; + DWORD TypeAndColor; + PRIM_DESC Object; +} PRIMITIVE; +typedef PRIMITIVE *PPRIMITIVE; + +#define END_OF_LIST ((COUNT)0xFFFF) + +#define PRIM_COLOR_SHIFT 8 +#define PRIM_COLOR_MASK ((DWORD)~0L << PRIM_COLOR_SHIFT) +#define PRIM_TYPE_MASK (~PRIM_COLOR_MASK) + +#define GetPredLink(l) LOWORD(l) +#define GetSuccLink(l) HIWORD(l) +#define MakeLinks MAKE_DWORD +#define SetPrimLinks(pPrim,p,s) ((pPrim)->Links = MakeLinks (p, s)) +#define GetPrimLinks(pPrim) ((pPrim)->Links) +#define SetPrimType(pPrim,t) \ + ((pPrim)->TypeAndColor = ((pPrim)->TypeAndColor & PRIM_COLOR_MASK) \ + | ((t) & PRIM_TYPE_MASK)) +#define GetPrimType(pPrim) \ + ((GRAPHICS_PRIM)LOBYTE ((pPrim)->TypeAndColor)) +#define SetPrimColor(pPrim,c) \ + ((pPrim)->TypeAndColor = ((pPrim)->TypeAndColor & PRIM_TYPE_MASK) \ + | ((c) << PRIM_COLOR_SHIFT)) +#define GetPrimColor(pPrim) \ + ((COLOR)((pPrim)->TypeAndColor >> PRIM_COLOR_SHIFT)) + +static inline void +SetPrimNextLink (PPRIMITIVE pPrim, COUNT Link) +{ + SetPrimLinks (pPrim, END_OF_LIST, Link); +} + + +static inline COUNT +GetPrimNextLink (PPRIMITIVE pPrim) +{ + return GetSuccLink (GetPrimLinks (pPrim)); +} + + +#endif /* PRIM_H */ + + diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c index b14577c1c..9a8253bbe 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c @@ -23,12 +23,14 @@ #endif #include +#include "options.h" #include "port.h" #include "sdl_common.h" -#include "primitives.h" #include "sdluio.h" #include "libs/file.h" -#include "options.h" +#include "libs/reslib.h" +#include "primitives.h" + typedef struct anidata { @@ -39,8 +41,6 @@ typedef struct anidata } AniData; -extern char *_cur_resfile_name; - static void process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct) { diff --git a/sc2/src/sc2code/libs/reslib.h b/sc2/src/sc2code/libs/reslib.h index 39099022a..df537fe62 100644 --- a/sc2/src/sc2code/libs/reslib.h +++ b/sc2/src/sc2code/libs/reslib.h @@ -51,6 +51,8 @@ typedef COUNT RES_PACKAGE; ((RESOURCE)(i) << TYPE_BITS) | \ ((RESOURCE)(t))) +const char *_cur_resfile_name; + extern uio_Stream *res_OpenResFile (uio_DirHandle *dir, const char *filename, const char *mode); extern int ReadResFile (PVOID lpBuf, COUNT size, COUNT count, uio_Stream *fp); @@ -64,8 +66,8 @@ extern long LengthResFile (uio_Stream *fp); extern BOOLEAN res_CloseResFile (uio_Stream *fp); extern BOOLEAN DeleteResFile (uio_DirHandle *dir, const char *filename); -extern MEM_HANDLE InitResourceSystem (PVOID resfile, COUNT resindex_type, - BOOLEAN (*FileErrorFunc) (PVOID 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, diff --git a/sc2/src/sc2code/libs/resource/getres.c b/sc2/src/sc2code/libs/resource/getres.c index 4dd40046a..17b579403 100644 --- a/sc2/src/sc2code/libs/resource/getres.c +++ b/sc2/src/sc2code/libs/resource/getres.c @@ -20,7 +20,8 @@ #include "port.h" #include "options.h" -char *_cur_resfile_name; + +const char *_cur_resfile_name; static BOOLEAN ValidResource (INDEX_HEADERPTR ResHeaderPtr, RESOURCE res) diff --git a/sc2/src/sc2code/libs/resource/resinit.c b/sc2/src/sc2code/libs/resource/resinit.c index 7fcebeaf9..a97285f37 100644 --- a/sc2/src/sc2code/libs/resource/resinit.c +++ b/sc2/src/sc2code/libs/resource/resinit.c @@ -215,8 +215,8 @@ _GetResFileData (uio_Stream *res_fp, DWORD flen) } MEM_HANDLE -InitResourceSystem (PVOID resfile, COUNT resindex_type, BOOLEAN - (*FileErrorFunc) (PVOID filename)) +InitResourceSystem (const char *resfile, COUNT resindex_type, BOOLEAN + (*FileErrorFunc) (const char *filename)) { MEM_HANDLE h; diff --git a/sc2/src/sc2code/libs/resource/resintrn.h b/sc2/src/sc2code/libs/resource/resintrn.h index 4403d8fa4..e9ab5572e 100644 --- a/sc2/src/sc2code/libs/resource/resintrn.h +++ b/sc2/src/sc2code/libs/resource/resintrn.h @@ -74,7 +74,6 @@ extern MEM_HANDLE _GetResFileData (uio_Stream *res_fp, DWORD flen); extern void _set_current_index_header (INDEX_HEADERPTR ResHeaderPtr); extern INDEX_HEADERPTR _get_current_index_header (void); -extern char *_cur_resfile_name; #endif /* _RESINTRN_H */ diff --git a/sc2/src/sc2code/libs/sound/fileinst.c b/sc2/src/sc2code/libs/sound/fileinst.c index 2f0e86ba3..567a3f796 100644 --- a/sc2/src/sc2code/libs/sound/fileinst.c +++ b/sc2/src/sc2code/libs/sound/fileinst.c @@ -18,8 +18,8 @@ #include "sndintrn.h" #include "options.h" +#include "reslib.h" -extern char *_cur_resfile_name; SOUND_REF LoadSoundFile (PVOID pStr) diff --git a/sc2/src/sc2code/libs/sound/music.c b/sc2/src/sc2code/libs/sound/music.c index 634d929f9..4b58f1f50 100644 --- a/sc2/src/sc2code/libs/sound/music.c +++ b/sc2/src/sc2code/libs/sound/music.c @@ -14,9 +14,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "sound.h" -#include "options.h" #include "file.h" +#include "options.h" +#include "sound.h" +#include "libs/reslib.h" + static MUSIC_REF curMusicRef; @@ -110,7 +112,6 @@ MEM_HANDLE _GetMusicData (uio_Stream *fp, DWORD length) { MEM_HANDLE h; - extern char *_cur_resfile_name; h = 0; if (_cur_resfile_name && (h = AllocMusicData (sizeof (void *)))) diff --git a/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.c b/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.c index 08f9ea075..675caace9 100644 --- a/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.c +++ b/sc2/src/sc2code/libs/sound/openal/audiodrv_openal.c @@ -19,7 +19,10 @@ #ifdef HAVE_OPENAL + #include "audiodrv_openal.h" +#include "libs/tasklib.h" + ALCcontext *alcContext = NULL; ALCdevice *alcDevice = NULL; diff --git a/sc2/src/sc2code/libs/sound/sfx.c b/sc2/src/sc2code/libs/sound/sfx.c index 8d54868fa..0f8ce73fd 100644 --- a/sc2/src/sc2code/libs/sound/sfx.c +++ b/sc2/src/sc2code/libs/sound/sfx.c @@ -14,13 +14,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "options.h" +#include "sound.h" +#include "libs/reslib.h" + #ifdef WIN32 #include #endif #include -#include "sound.h" -#include "options.h" static void CheckFinishedChannels (void); @@ -179,7 +181,6 @@ _GetSoundBankData (uio_Stream *fp, DWORD length) { char *s1, *s2; - extern char *_cur_resfile_name; if (_cur_resfile_name == 0 || (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0) diff --git a/sc2/src/sc2code/libs/sound/sound.c b/sc2/src/sc2code/libs/sound/sound.c index e309b38c0..f772d9eb7 100644 --- a/sc2/src/sc2code/libs/sound/sound.c +++ b/sc2/src/sc2code/libs/sound/sound.c @@ -174,7 +174,7 @@ fade_task (void *data) FadeTask = 0; FinishTask (task); - return (1); + return 1; } DWORD @@ -192,7 +192,8 @@ FadeMusic (BYTE end_vol, SIZE TimeInterval) TaskSwitch (); } - if ((TTotal = TimeInterval) <= 0) + TTotal = TimeInterval; + if (TTotal <= 0) TTotal = 1; /* prevent divide by zero and negative fade */ volume_end = end_vol; @@ -207,5 +208,7 @@ FadeMusic (BYTE end_vol, SIZE TimeInterval) TimeOut = GetTimeCounter (); } - return (TimeOut); + return TimeOut; } + + diff --git a/sc2/src/sc2code/libs/strings/getstr.c b/sc2/src/sc2code/libs/strings/getstr.c index 8446d06cb..bbb62f63f 100644 --- a/sc2/src/sc2code/libs/strings/getstr.c +++ b/sc2/src/sc2code/libs/strings/getstr.c @@ -16,14 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "options.h" #include "strintrn.h" #include "libs/graphics/gfx_common.h" -#include "options.h" +#include "libs/reslib.h" #ifdef WIN32 #include #endif #include + static void dword_convert (PDWORD dword_array, COUNT num_dwords) { @@ -46,7 +48,6 @@ _GetStringData (uio_Stream *fp, DWORD length) { char *s; - extern char *_cur_resfile_name; if (_cur_resfile_name && (s = strrchr (_cur_resfile_name, '.')) && stricmp (s, ".txt") == 0) diff --git a/sc2/src/sc2code/libs/strings/sfileins.c b/sc2/src/sc2code/libs/strings/sfileins.c index b193cd63c..a6a0c6585 100644 --- a/sc2/src/sc2code/libs/strings/sfileins.c +++ b/sc2/src/sc2code/libs/strings/sfileins.c @@ -19,11 +19,11 @@ #include "port.h" #include "strintrn.h" #include "uio.h" +#include "libs/reslib.h" -extern char *_cur_resfile_name; STRING_TABLE -LoadStringTableFile (uio_DirHandle *dir, char *fileName) +LoadStringTableFile (uio_DirHandle *dir, const char *fileName) { uio_Stream *fp; diff --git a/sc2/src/sc2code/libs/strlib.h b/sc2/src/sc2code/libs/strlib.h index 93f60394a..8a297df05 100644 --- a/sc2/src/sc2code/libs/strlib.h +++ b/sc2/src/sc2code/libs/strlib.h @@ -30,7 +30,7 @@ typedef PBYTE STRINGPTR; extern BOOLEAN InstallStringTableResType (COUNT string_type); extern STRING_TABLE LoadStringTableInstance (DWORD res); extern STRING_TABLE LoadStringTableFile (uio_DirHandle *dir, - char *fileName); + const char *fileName); extern BOOLEAN DestroyStringTable (STRING_TABLE StringTable); extern STRING CaptureStringTable (STRING_TABLE StringTable); extern STRING_TABLE ReleaseStringTable (STRING String); diff --git a/sc2/src/sc2code/libs/video/vfileins.c b/sc2/src/sc2code/libs/video/vfileins.c index 7c3843437..6e249f764 100644 --- a/sc2/src/sc2code/libs/video/vfileins.c +++ b/sc2/src/sc2code/libs/video/vfileins.c @@ -17,13 +17,12 @@ */ #include "vidlib.h" +#include "video.h" VIDEO_REF -LoadVideoFile (PVOID pStr) +LoadVideoFile (const char *pStr) { - extern VIDEO_REF _init_video_file (PVOID pStr); - - return (_init_video_file (pStr)); + return _init_video_file (pStr); } diff --git a/sc2/src/sc2code/libs/video/video.c b/sc2/src/sc2code/libs/video/video.c index 73c9d7e8f..15a76a568 100644 --- a/sc2/src/sc2code/libs/video/video.c +++ b/sc2/src/sc2code/libs/video/video.c @@ -14,8 +14,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "setup.h" #include "video.h" + +#include "setup.h" #include "vidplayer.h" #include "libs/inplib.h" @@ -72,7 +73,7 @@ VidPlaying () } VIDEO_TYPE -VidPlay (VIDEO_REF VidRef, char *loopname, BOOLEAN uninit) +VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit) // uninit was used to uninit the game kernel // before spawning duck exe { @@ -118,12 +119,12 @@ VidDoInput (void) } VIDEO_REF -_init_video_file(PVOID pStr) +_init_video_file(const char *pStr) { TFB_VideoClip* vid; TFB_VideoDecoder* dec; - dec = VideoDecoder_Load (contentDir, (const char*)pStr); + dec = VideoDecoder_Load (contentDir, pStr); if (!dec) return NULL_VIDEO_REF; diff --git a/sc2/src/sc2code/libs/vidlib.h b/sc2/src/sc2code/libs/vidlib.h index f3b1b214b..8404d3238 100644 --- a/sc2/src/sc2code/libs/vidlib.h +++ b/sc2/src/sc2code/libs/vidlib.h @@ -38,17 +38,12 @@ extern void UninitVideo (void); extern BYTE SetVideoMode (BYTE new_mode); extern BYTE GetVideoMode (void); -extern VIDEO_REF LoadVideoFile (PVOID pStr); +extern VIDEO_REF LoadVideoFile (const char *pStr); extern BOOLEAN DestroyVideo (VIDEO_REF VideoRef); -extern VIDEO_TYPE VidPlay (VIDEO_REF VidRef, char *loopname, BOOLEAN - uninit); +extern VIDEO_TYPE VidPlay (VIDEO_REF VidRef, const char *loopname, + BOOLEAN uninit); extern void VidStop (void); extern VIDEO_REF VidPlaying (void); extern void VidDoInput (void); -extern BOOLEAN DoFMV (char *name, char *loopname, BOOLEAN uninit); -extern BOOLEAN ShowPresentation(char *name); - - - #endif /* _VIDLIB_H */ diff --git a/sc2/src/sc2code/load.c b/sc2/src/sc2code/load.c index 68cdb048c..34c055cf3 100644 --- a/sc2/src/sc2code/load.c +++ b/sc2/src/sc2code/load.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "load.h" + #include "build.h" #include "declib.h" #include "encount.h" @@ -32,6 +34,8 @@ ACTIVITY NextActivity; +static BOOLEAN LoadSummary (uio_Stream *in_fp); + static void LoadShipQueue (DECODE_REF fh, PQUEUE pQueue, BOOLEAN MakeQ) { @@ -68,8 +72,7 @@ LoadShipQueue (DECODE_REF fh, PQUEUE pQueue, BOOLEAN MakeQ) Ptr = ((PBYTE)&FragPtr->ShipInfo) - Offset; cread ((PBYTE)Ptr, - ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, - 1, fh); + ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, 1, fh); if (Offset == 0) { EXTENDED_SHIP_FRAGMENTPTR ExtFragPtr; @@ -83,9 +86,10 @@ LoadShipQueue (DECODE_REF fh, PQUEUE pQueue, BOOLEAN MakeQ) } } -BOOLEAN +static BOOLEAN LoadSummary (uio_Stream *in_fp) { + // XXX: This function seems to be unused. SUMMARY_DESC S; return (ReadResFile (&S, sizeof (S), 1, in_fp) == sizeof (S)); @@ -118,7 +122,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) { memcpy (summary_desc, buf, sizeof (*summary_desc)); res_CloseResFile (in_fp); - return (TRUE); + return TRUE; } GlobData.SIS_state = summary_desc->SS; @@ -126,7 +130,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) if ((fh = copen (in_fp, FILE_STREAM, STREAM_READ)) == 0) { res_CloseResFile (in_fp); - return (FALSE); + return FALSE; } ReinitQueue (&GLOBAL (GameClock.event_q)); @@ -216,8 +220,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) hStarShip = GetStarShipFromIndex ( &GLOBAL (avail_race_q), - EncounterPtr->SD.ShipList[i].var1 - ); + EncounterPtr->SD.ShipList[i].var1); TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( &GLOBAL (avail_race_q), hStarShip ); @@ -227,9 +230,7 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) TemplatePtr->ShipInfo.icons; EncounterPtr->SD.ShipList[i].melee_icon = TemplatePtr->ShipInfo.melee_icon; - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } UnlockEncounter (hEncounter); @@ -309,10 +310,10 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) GLOBAL (DisplayArray) = DisplayArray; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } diff --git a/sc2/src/sc2code/load.h b/sc2/src/sc2code/load.h new file mode 100644 index 000000000..120b15361 --- /dev/null +++ b/sc2/src/sc2code/load.h @@ -0,0 +1,27 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LOAD_H +#define _LOAD_H + +#include "sis.h" +#include "libs/compiler.h" + +extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc); + + +#endif /* _LOAD_H */ + diff --git a/sc2/src/sc2code/master.c b/sc2/src/sc2code/master.c index e21deee02..8f7f16df9 100644 --- a/sc2/src/sc2code/master.c +++ b/sc2/src/sc2code/master.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "master.h" + #include "build.h" #include "resinst.h" #include "displist.h" diff --git a/sc2/src/sc2code/master.h b/sc2/src/sc2code/master.h new file mode 100644 index 000000000..a43a0f80c --- /dev/null +++ b/sc2/src/sc2code/master.h @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MASTER_H +#define _MASTER_H + +#include "races.h" +#include "libs/compiler.h" + + +extern void LoadMasterShipList (void); +extern void FreeMasterShipList (void); +extern HSTARSHIP FindMasterShip (DWORD ship_ref); + +#endif /* _MASTER_H */ + diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 65b2c432c..22cc7502d 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -23,11 +23,13 @@ #include "controls.h" #include "file.h" #include "gamestr.h" +#include "globdata.h" #include "intel.h" #include "nameref.h" #include "options.h" #include "races.h" #include "resinst.h" +#include "save.h" #include "settings.h" #include "setup.h" #include "sounds.h" @@ -47,18 +49,11 @@ void ConfirmSaveLoad (STAMP *MsgStamp); -void SaveProblem (void); - -void DoShipSpin (COUNT index, MUSIC_REF hMusic); - -BOOLEAN InitSpace (void); - -void UninitSpace (void); - -void InitGlobData (void); - //End Added by Chris + +static int flash_selection_func (void *data); + enum { CONTROLS_TOP, @@ -233,6 +228,10 @@ DrawControls (COUNT which_side, BOOLEAN HiLite) case AWESOME_RATING: which_icon = 3; break; + default: + // Should not happen. Satisfying compiler. + which_icon = 0; + break; } } @@ -542,7 +541,8 @@ Select (BYTE opt) } } -int flash_selection_func(void* data) +static int +flash_selection_func (void *data) { DWORD TimeIn; Task task = (Task) data; @@ -572,7 +572,7 @@ int flash_selection_func(void* data) FinishTask (task); - return(0); + return 0; } static void @@ -993,6 +993,7 @@ DoLoadTeam (PMELEE_STATE pMS) return (TRUE); } +// XXX: TODO: to be merged with DoTextEntry in gameopt.c static UWORD DoTextEntry (PMELEE_STATE pMS) { @@ -1006,6 +1007,11 @@ DoTextEntry (PMELEE_STATE pMS) pBaseStr = pMS->TeamImage[pMS->side].TeamName; max_chars = MAX_TEAM_CHARS; } + else + { + // Should not happen. Satisfying compiler. + return 0; + } ch = GetCharacter (); diff --git a/sc2/src/sc2code/melee.h b/sc2/src/sc2code/melee.h index ff3c7dba5..14b267041 100644 --- a/sc2/src/sc2code/melee.h +++ b/sc2/src/sc2code/melee.h @@ -102,5 +102,8 @@ typedef MELEE_STATE *PMELEE_STATE; extern PMELEE_STATE volatile pMeleeState; +extern void Melee (void); + + #endif /* _MELEE_H */ diff --git a/sc2/src/sc2code/menu.c b/sc2/src/sc2code/menu.c index f3d9fcdef..5763be77c 100644 --- a/sc2/src/sc2code/menu.c +++ b/sc2/src/sc2code/menu.c @@ -27,6 +27,15 @@ extern Task flash_task; extern RECT flash_rect; +static BYTE GetEndMenuState (BYTE BaseState); +static BYTE GetBeginMenuState (BYTE BaseState); +static BYTE FixMenuState (BYTE BadState); +static BYTE NextMenuState (BYTE BaseState, BYTE CurState); +static BYTE PreviousMenuState (BYTE BaseState, BYTE CurState); +static BOOLEAN GetAlternateMenu (BYTE *BaseState, BYTE *CurState); +static BYTE ConvertAlternateMenu (BYTE BaseState, BYTE NewState); + + /* Draw the blue background for PC Menu Text */ static void DrawPCMenuFrame (RECT *r) @@ -170,7 +179,7 @@ DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r) } /* Determine the last text item to display */ -BYTE +static BYTE GetEndMenuState (BYTE BaseState) { switch (BaseState) @@ -214,14 +223,14 @@ GetEndMenuState (BYTE BaseState) return BaseState; } -BYTE +static BYTE GetBeginMenuState (BYTE BaseState) { return BaseState; } /* Correct Menu State for cases where the Menu shouldn't move */ -BYTE +static BYTE FixMenuState (BYTE BadState) { switch (BadState) @@ -244,7 +253,7 @@ FixMenuState (BYTE BadState) } /* Choose the next menu to hilight in the 'forward' direction */ -BYTE +static BYTE NextMenuState (BYTE BaseState, BYTE CurState) { BYTE NextState; @@ -315,7 +324,7 @@ PreviousMenuState (BYTE BaseState, BYTE CurState) /* When using PC hierarchy, convert 3do->PC */ -BOOLEAN +static BOOLEAN GetAlternateMenu (BYTE *BaseState, BYTE *CurState) { BYTE AdjBase = *BaseState; @@ -403,7 +412,7 @@ GetAlternateMenu (BYTE *BaseState, BYTE *CurState) } /* When using PC hierarchy, convert PC->3DO */ -BYTE +static BYTE ConvertAlternateMenu (BYTE BaseState, BYTE NewState) { switch (BaseState + NewState) diff --git a/sc2/src/sc2code/oscill.c b/sc2/src/sc2code/oscill.c index 6e50a1ae9..5b5c51b0c 100644 --- a/sc2/src/sc2code/oscill.c +++ b/sc2/src/sc2code/oscill.c @@ -16,11 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "oscill.h" + #include "sis.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" #include "libs/sound/trackplayer.h" + static FRAMEPTR scope_frame; static int scope_init = 0; static TFB_Image *scope_bg = NULL; @@ -28,17 +31,19 @@ static TFB_Image *scope_surf = NULL; static UBYTE scope_data[RADAR_WIDTH - 2]; void -InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f) +InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME f) { scope_frame = f; if (!scope_init) { TFB_Canvas scope_bg_canvas, scope_surf_canvas; - scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1); + scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, + scope_frame->image->Palette, -1); scope_bg = TFB_DrawImage_New (scope_bg_canvas); - scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1); + scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, + scope_frame->image->Palette, -1); scope_surf = TFB_DrawImage_New (scope_surf_canvas); - TFB_DrawImage_Image (f->image, 0, 0, 0, NULL, scope_bg); + TFB_DrawImage_Image (scope_frame->image, 0, 0, 0, NULL, scope_bg); scope_init = 1; } /* remove compiler warnings */ @@ -49,6 +54,7 @@ InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f) void UninitOscilloscope (void) { + // XXX: Is never called (BUG?) if (scope_bg) { TFB_DrawImage_Delete (scope_bg); @@ -79,7 +85,8 @@ Oscilloscope (DWORD grab_data) g = scope_surf->Palette[238].g; b = scope_surf->Palette[238].b; for (i = 0; i < RADAR_WIDTH - 3; ++i) - TFB_DrawImage_Line (i + 1, scope_data[i], i + 2, scope_data[i + 1], r, g, b, scope_surf); + TFB_DrawImage_Line (i + 1, scope_data[i], i + 2, + scope_data[i + 1], r, g, b, scope_surf); } TFB_DrawImage_Image (scope_surf, 0, 0, 0, NULL, scope_frame->image); @@ -134,7 +141,8 @@ Slider (void) if (sliderDisabled) return; - if ((offs = GetSoundInfo (sliderSpace)) != last_offs ||sliderChanged) + offs = GetSoundInfo (sliderSpace); + if (offs != last_offs || sliderChanged) { sliderChanged = FALSE; last_offs = offs; @@ -145,3 +153,4 @@ Slider (void) UnbatchGraphics (); } } + diff --git a/sc2/src/sc2code/oscill.h b/sc2/src/sc2code/oscill.h index 3d844fede..e25073ba2 100644 --- a/sc2/src/sc2code/oscill.h +++ b/sc2/src/sc2code/oscill.h @@ -14,4 +14,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _OSCILL_H +#define _OSCILL_H + +#include "libs/compiler.h" +#include "libs/gfxlib.h" + extern BOOLEAN sliderDisabled; + +extern void InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, + FRAME f); +extern void Oscilloscope (DWORD grab_data); +extern void UninitOscilloscope (void); + +extern void InitSlider (int x, int y, int width, int height, + int bwidth, int bheight, FRAME f); +extern void SetSliderImage (FRAME f); +void Slider (void); + +#endif /* _OSCILL_H */ + diff --git a/sc2/src/sc2code/outfit.c b/sc2/src/sc2code/outfit.c index 83c0b6bb3..d794d908e 100644 --- a/sc2/src/sc2code/outfit.c +++ b/sc2/src/sc2code/outfit.c @@ -19,13 +19,13 @@ #include "options.h" #include "colors.h" #include "controls.h" +#include "gameopt.h" #include "gamestr.h" #include "resinst.h" #include "settings.h" #include "setup.h" #include "sis.h" #include "sounds.h" -#include "state.h" #include "libs/graphics/gfx_common.h" @@ -38,6 +38,7 @@ enum OUTFIT_DOFUEL }; + static void DrawModuleStrings (PMENU_STATE pMS, BYTE NewModule) { @@ -167,8 +168,6 @@ DisplayLanders (PMENU_STATE pMS) static BOOLEAN DoInstallModule (PMENU_STATE pMS) { - extern void DrawFlagshipStats (void); - BYTE NewState, new_slot_piece, old_slot_piece; SIZE FirstItem, LastItem; BOOLEAN select, cancel, motion; @@ -520,8 +519,9 @@ InitFlash: return (TRUE); } -void -ChangeFuelQuantity () + +static void +ChangeFuelQuantity (void) { RECT r; @@ -591,8 +591,6 @@ DoOutfit (PMENU_STATE pMS) { COUNT num_frames; STAMP s; - extern void DrawFlagshipName (BOOLEAN InStatusArea); - extern void DrawFlagshipStats (void); pMS->CurFrame = CaptureDrawable ( LoadGraphic (MODULES_PMAP_ANIM)); diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index 2cebc7152..ace716aad 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "pickmele.h" + #include "build.h" #include "controls.h" #include "intel.h" @@ -66,27 +68,37 @@ DoGetMelee (GETMELEE_STATE *gms) if (PlayerInput[which_player] == ComputerInput) { - /* TODO: Make this a frame-by-frame thing. This code is currently copied - * from intel.c's computer_intelligence */ + /* TODO: Make this a frame-by-frame thing. This code is currently + * copied from intel.c's computer_intelligence */ SleepThread (ONE_SECOND >> 1); left = right = up = down = FALSE; select = TRUE; } else if (which_player == 0) { - left = PulsedInputState.key[KEY_P1_LEFT] || PulsedInputState.key[KEY_MENU_LEFT]; - right = PulsedInputState.key[KEY_P1_RIGHT] || PulsedInputState.key[KEY_MENU_RIGHT]; - up = PulsedInputState.key[KEY_P1_THRUST] || PulsedInputState.key[KEY_MENU_UP]; - down = PulsedInputState.key[KEY_P1_DOWN] || PulsedInputState.key[KEY_MENU_DOWN]; - select = PulsedInputState.key[KEY_P1_WEAPON] || PulsedInputState.key[KEY_MENU_SELECT]; + left = PulsedInputState.key[KEY_P1_LEFT] || + PulsedInputState.key[KEY_MENU_LEFT]; + right = PulsedInputState.key[KEY_P1_RIGHT] || + PulsedInputState.key[KEY_MENU_RIGHT]; + up = PulsedInputState.key[KEY_P1_THRUST] || + PulsedInputState.key[KEY_MENU_UP]; + down = PulsedInputState.key[KEY_P1_DOWN] || + PulsedInputState.key[KEY_MENU_DOWN]; + select = PulsedInputState.key[KEY_P1_WEAPON] || + PulsedInputState.key[KEY_MENU_SELECT]; } else { - left = PulsedInputState.key[KEY_P2_LEFT] || PulsedInputState.key[KEY_MENU_LEFT]; - right = PulsedInputState.key[KEY_P2_RIGHT] || PulsedInputState.key[KEY_MENU_RIGHT]; - up = PulsedInputState.key[KEY_P2_THRUST] || PulsedInputState.key[KEY_MENU_UP]; - down = PulsedInputState.key[KEY_P2_DOWN] || PulsedInputState.key[KEY_MENU_DOWN]; - select = PulsedInputState.key[KEY_P2_WEAPON] || PulsedInputState.key[KEY_MENU_SELECT]; + left = PulsedInputState.key[KEY_P2_LEFT] || + PulsedInputState.key[KEY_MENU_LEFT]; + right = PulsedInputState.key[KEY_P2_RIGHT] || + PulsedInputState.key[KEY_MENU_RIGHT]; + up = PulsedInputState.key[KEY_P2_THRUST] || + PulsedInputState.key[KEY_MENU_UP]; + down = PulsedInputState.key[KEY_P2_DOWN] || + PulsedInputState.key[KEY_MENU_DOWN]; + select = PulsedInputState.key[KEY_P2_WEAPON] || + PulsedInputState.key[KEY_MENU_SELECT]; } if (GLOBAL (CurrentActivity) & CHECK_ABORT) @@ -347,7 +359,8 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player) StarShipPtr->captains_name_index = 0; UnlockStarShip (&race_q[which_player], gmstate.hBattleShip); - PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1), 0, NotPositional (), NULL, 0); + PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1), 0, + NotPositional (), NULL, 0); WaitForSoundEnd (0); } diff --git a/sc2/src/sc2code/pickmele.h b/sc2/src/sc2code/pickmele.h new file mode 100644 index 000000000..0528ad64c --- /dev/null +++ b/sc2/src/sc2code/pickmele.h @@ -0,0 +1,28 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _PICKMELE_H +#define _PICKMELE_H + +#include "races.h" +#include "libs/compiler.h" + +HSTARSHIP GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, + COUNT which_player); + + +#endif /* _PICKMELE_H */ + diff --git a/sc2/src/sc2code/pickship.c b/sc2/src/sc2code/pickship.c index bfe610b9c..5981757b0 100644 --- a/sc2/src/sc2code/pickship.c +++ b/sc2/src/sc2code/pickship.c @@ -19,6 +19,7 @@ #include "build.h" #include "colors.h" #include "controls.h" +#include "pickmele.h" #include "races.h" #include "resinst.h" #include "setup.h" @@ -159,7 +160,11 @@ ChangeSelection: DrawFilledRectangle (&r); if (hBattleShip == 0) + { crew_level = 0; + max_crew = 0; + // Satisfy compiler. + } else { SetContextFont (TinyFont); @@ -290,9 +295,6 @@ GetEncounterStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player) hBattleShip = GetHeadLink (&race_q[which_player]); else if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) { - extern HSTARSHIP GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, - COUNT which_player); - hBattleShip = GetMeleeStarShip (LastStarShipPtr, which_player); } else diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index fb4d4983b..a43034699 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -195,7 +195,6 @@ DeviceFailed (BYTE which_device) { BYTE val; extern ACTIVITY NextActivity; - extern void SaveFlagshipState (void); switch (which_device) { diff --git a/sc2/src/sc2code/planets/oval.c b/sc2/src/sc2code/planets/oval.c index bc0d4e8de..9cff9087c 100644 --- a/sc2/src/sc2code/planets/oval.c +++ b/sc2/src/sc2code/planets/oval.c @@ -17,7 +17,6 @@ */ #include "units.h" -#include "dummy.h" #include "libs/gfxlib.h" #include "graphics/context.h" #include "graphics/drawable.h" diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 5f353e83a..0390ee699 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "dummy.h" #include "nameref.h" #include "resinst.h" #include "setup.h" diff --git a/sc2/src/sc2code/planets/report.c b/sc2/src/sc2code/planets/report.c index 62ade76bc..25b10f109 100644 --- a/sc2/src/sc2code/planets/report.c +++ b/sc2/src/sc2code/planets/report.c @@ -18,7 +18,6 @@ #include "colors.h" #include "controls.h" -#include "dummy.h" #include "gamestr.h" #include "options.h" #include "setup.h" diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 3ca5ccbb1..6f7baeca2 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -18,7 +18,6 @@ #include "build.h" #include "controls.h" -#include "dummy.h" #include "encount.h" #include "gamestr.h" #include "lifeform.h" @@ -759,7 +758,6 @@ PickPlanetSide (PMENU_STATE pMS) { HSTARSHIP hStarShip; extern ACTIVITY NextActivity; - extern void SaveFlagshipState (void); if (pMenuState->flash_task) { diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 27bc00817..2822aec64 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -349,11 +349,7 @@ FreeSolarSys (void) pSolarSysState->MenuState.flash_task = 0; LockMutex (GraphicsLock); if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) - { - extern void SaveFlagshipState (void); - SaveFlagshipState (); - } UnlockMutex (GraphicsLock); } } diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index bd714d421..e74b7596e 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "process.h" + #include "build.h" #include "collide.h" #include "options.h" @@ -873,12 +875,12 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x, UnlockElement (hPostElement); } while ((hPostElement = hNextElement) != 0); - scroll_x = scroll_y = 0; - delta.x = delta.y = 0; /* because these are - * newly added elements - * that are already in - * adjusted coordinates - */ + scroll_x = 0; + scroll_y = 0; + delta.x = 0; + delta.y = 0; + /* because these are newly added elements that are + * already in adjusted coordinates */ state_flags = ElementPtr->state_flags; } diff --git a/sc2/src/sc2code/process.h b/sc2/src/sc2code/process.h new file mode 100644 index 000000000..0d424cbef --- /dev/null +++ b/sc2/src/sc2code/process.h @@ -0,0 +1,26 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _PROCESS_H +#define _PROCESS_H + +#include "libs/compiler.h" +#include "libs/gfxlib.h" + +extern void InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI); + +#endif /* _PROCESS_H */ + diff --git a/sc2/src/sc2code/races.h b/sc2/src/sc2code/races.h index dee8fbf08..3029a9279 100644 --- a/sc2/src/sc2code/races.h +++ b/sc2/src/sc2code/races.h @@ -521,7 +521,6 @@ enum #define SOL_Y 1450 extern BOOLEAN InitKernel (void); -extern void UninitKernel (BOOLEAN ships); extern void DrawCaptainsWindow (STARSHIPPTR StarShipPtr); diff --git a/sc2/src/sc2code/restart.c b/sc2/src/sc2code/restart.c index 6331cb7d8..79b86c0cc 100644 --- a/sc2/src/sc2code/restart.c +++ b/sc2/src/sc2code/restart.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "restart.h" + #include "colors.h" #include "controls.h" #include "credits.h" @@ -23,6 +25,7 @@ #include "fmv.h" #include "globdata.h" #include "intel.h" +#include "melee.h" #include "resinst.h" #include "settings.h" #include "setup.h" @@ -36,8 +39,6 @@ //Added by Chris -void Melee (void); - void FreeHyperData (void); void FreeIPData (void); @@ -46,8 +47,6 @@ void FreeSC2Data (void); void FreeLanderData (void); -BOOLEAN InitGameKernel (void); - //End Added by Chris enum diff --git a/sc2/src/sc2code/restart.h b/sc2/src/sc2code/restart.h new file mode 100644 index 000000000..0d4de735b --- /dev/null +++ b/sc2/src/sc2code/restart.h @@ -0,0 +1,26 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _RESTART_H +#define _RESTART_H + +#include "libs/compiler.h" + + +extern BOOLEAN StartGame (void); + +#endif /* _RESTART_H */ + diff --git a/sc2/src/sc2code/save.c b/sc2/src/sc2code/save.c index 02ce35378..59f8f578d 100644 --- a/sc2/src/sc2code/save.c +++ b/sc2/src/sc2code/save.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "save.h" + #include "build.h" #include "declib.h" #include "controls.h" @@ -66,8 +68,7 @@ SaveShipQueue (DECODE_REF fh, PQUEUE pQueue) cwrite ((PBYTE)&Index, sizeof (Index), 1, fh); Ptr = ((PBYTE)&FragPtr->ShipInfo) - Offset; - cwrite ((PBYTE)Ptr, - ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, + cwrite ((PBYTE)Ptr, ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, 1, fh); if (Offset == 0) { @@ -193,7 +194,8 @@ SaveProblemMessage (STAMP *MsgStamp) BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F), TRUE, BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x0F)); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x14, 0x14, 0x14), 0x0F)); for (i = 0; i < MAX_MSG_LINES; ++i) { @@ -224,8 +226,9 @@ SaveProblem (void) { TaskSwitch (); UpdateInputState (); - } while (!(PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_SPECIAL] || - (GLOBAL (CurrentActivity) & CHECK_ABORT))); + } while (!(PulsedInputState.key[KEY_MENU_SELECT] || + PulsedInputState.key[KEY_MENU_SPECIAL] || + (GLOBAL (CurrentActivity) & CHECK_ABORT))); LockMutex (GraphicsLock); BatchGraphics (); @@ -250,7 +253,8 @@ SaveGame (COUNT which_game, SUMMARY_DESC *summary_desc) made_room = FALSE; RetrySave: h = mem_request (10 * 1024); - if ((out_fp = mem_lock (h)) == 0 + out_fp = mem_lock (h); + if (out_fp == 0 || (fh = copen (out_fp, MEMORY_STREAM, STREAM_WRITE)) == 0) { if (success) @@ -276,15 +280,18 @@ RetrySave: POINT pt; STAR_DESC SD; char buf[256], file[PATH_MAX]; - extern void SaveFlagshipState (void); success = TRUE; if (CurStarDescPtr) SD = *CurStarDescPtr; else { - SD.star_pt.x = SD.star_pt.y = 0; - SD.Type = SD.Index = SD.Prefix = SD.Postfix = 0; + SD.star_pt.x = 0; + SD.star_pt.y = 0; + SD.Type = 0; + SD.Index = 0; + SD.Prefix = 0; + SD.Postfix = 0; } frame = GLOBAL (ShipStamp.frame); @@ -412,9 +419,9 @@ RetrySave: PrepareSummary (summary_desc); success = (BOOLEAN)(WriteResFile ( - summary_desc, sizeof (*summary_desc), 1, out_fp - ) != 0); - if (success && WriteResFile (mem_lock (h), (COUNT)flen, 1, out_fp) == 0) + summary_desc, sizeof (*summary_desc), 1, out_fp) != 0); + if (success && WriteResFile (mem_lock (h), (COUNT)flen, 1, + out_fp) == 0) success = FALSE; mem_unlock (h); @@ -438,3 +445,4 @@ RetrySave: return (success); } + diff --git a/sc2/src/sc2code/save.h b/sc2/src/sc2code/save.h new file mode 100644 index 000000000..3c9924f12 --- /dev/null +++ b/sc2/src/sc2code/save.h @@ -0,0 +1,27 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _SAVE_H +#define _SAVE_H + +#include "sis.h" +#include "libs/compiler.h" + +extern void SaveProblem (void); +extern BOOLEAN SaveGame (COUNT which_game, SUMMARY_DESC *summary_desc); + +#endif /* _SAVE_H */ + diff --git a/sc2/src/sc2code/setup.c b/sc2/src/sc2code/setup.c index 4f1b31627..1a78f2374 100644 --- a/sc2/src/sc2code/setup.c +++ b/sc2/src/sc2code/setup.c @@ -39,8 +39,6 @@ //Added by Chris -BOOLEAN InitSpace (void); - extern BOOLEAN InitVideo (BOOLEAN UseCDROM); //End Added by Chris diff --git a/sc2/src/sc2code/setup.h b/sc2/src/sc2code/setup.h index 77aaa6ad2..b1493eb9d 100644 --- a/sc2/src/sc2code/setup.h +++ b/sc2/src/sc2code/setup.h @@ -52,9 +52,11 @@ extern BYTE PlayerControl[]; extern SIZE cur_player; extern BOOLEAN InitContexts (void); +extern void UninitPlayerInput (void); +extern BOOLEAN InitGameKernel (void); -int initIO (void); -void uninitIO (void); +extern int initIO (void); +extern void uninitIO (void); extern void SetPlayerInput (void); diff --git a/sc2/src/sc2code/setupmenu.c b/sc2/src/sc2code/setupmenu.c index a277e7730..fe143ce31 100644 --- a/sc2/src/sc2code/setupmenu.c +++ b/sc2/src/sc2code/setupmenu.c @@ -39,19 +39,21 @@ typedef struct setup_menu_state { typedef SETUP_MENU_STATE *PSETUP_MENU_STATE; typedef struct { - char *optname; - char *tooltip[3]; + const char *optname; + const char *tooltip[3]; } OPTION; typedef struct { - char *category; + const char *category; int numopts; - OPTION * options; + OPTION *options; int selected; } MENU_CATEGORY; +static BOOLEAN DoSetupMenu (PSETUP_MENU_STATE pInputState); + static OPTION scaler_opts[] = { - { "None", + { "None", { "No scaling.", "Simulates the original 320x240 display.", "Fastest, though least attractive, option.", @@ -163,9 +165,9 @@ static OPTION subtitles_opts[] = { //static char *title_str = "Ur-Quan Masters Setup"; //static char *subtitle_str = "Graphics Options"; -static char *title_str = "Use arrows and fire to select options"; -static char *subtitle_str = "Press cancel when done"; -static char **tooltip; +static const char *title_str = "Use arrows and fire to select options"; +static const char *subtitle_str = "Press cancel when done"; +static const char **tooltip; #define NUM_OPTS 6 static MENU_CATEGORY cmdline_opts[] = { @@ -336,7 +338,7 @@ DrawMenu (PSETUP_MENU_STATE pInputState) SetContextForeGroundColor (oldtext); } -BOOLEAN +static BOOLEAN DoSetupMenu (PSETUP_MENU_STATE pInputState) { if (!pInputState->initialized) diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 57982f1e1..4028129e0 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -20,6 +20,7 @@ #include "colors.h" #include "controls.h" #include "fmv.h" +#include "gameopt.h" #include "gamestr.h" #include "melee.h" #include "options.h" @@ -70,7 +71,8 @@ enum SHIPYARD_EXIT }; -int hangar_anim_func (void* data) +static int +hangar_anim_func (void *data) { DWORD TimeIn; STAMP s; @@ -112,7 +114,7 @@ int hangar_anim_func (void* data) } FinishTask (task); - return(0); + return 0; } #ifdef WANT_SHIP_SPINS @@ -158,18 +160,15 @@ GetAvailableRaceCount (void) SHIP_FRAGMENTPTR StarShipPtr; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + &GLOBAL (avail_race_q), hStarShip); if (StarShipPtr->ShipInfo.ship_flags & GOOD_GUY) ++Index; hNextShip = _GetSuccLink (StarShipPtr); - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } - return (Index); + return Index; } static HSTARSHIP @@ -182,24 +181,19 @@ GetAvailableRaceFromIndex (BYTE Index) { SHIP_FRAGMENTPTR StarShipPtr; - StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip (&GLOBAL (avail_race_q), + hStarShip); if ((StarShipPtr->ShipInfo.ship_flags & GOOD_GUY) && Index-- == 0) { - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); - return (hStarShip); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); + return hStarShip; } hNextShip = _GetSuccLink (StarShipPtr); - UnlockStarShip ( - &GLOBAL (avail_race_q), hStarShip - ); + UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); } - return (0); + return 0; } static void @@ -221,12 +215,14 @@ DrawRaceStrings (BYTE NewRaceItem) r.extent.height = 11; BatchGraphics (); ClearSISRect (CLEAR_SIS_RADAR); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); DrawFilledRectangle (&r); r.corner = s.origin; r.extent.width = RADAR_WIDTH; r.extent.height = RADAR_HEIGHT; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); DrawFilledRectangle (&r); if (NewRaceItem != (BYTE)~0) { @@ -240,8 +236,10 @@ DrawRaceStrings (BYTE NewRaceItem) }; hStarShip = GetAvailableRaceFromIndex (NewRaceItem); - NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q), hStarShip); - s.frame = SetAbsFrameIndex (pMenuState->ModuleFrame, 3 + NewRaceItem); + NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q), + hStarShip); + s.frame = SetAbsFrameIndex (pMenuState->ModuleFrame, + 3 + NewRaceItem); DrawStamp (&s); StarShipPtr = LockStarShip (&GLOBAL (avail_race_q), hStarShip); s.frame = StarShipPtr->RaceDescPtr->ship_info.melee_icon; @@ -257,7 +255,8 @@ DrawRaceStrings (BYTE NewRaceItem) t.pStr = buf; wsprintf (buf, "%u", ShipCost[NewRaceItem]); SetContextFont (TinyFont); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02)); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 ( + 0x00, 0x1F, 0x00), 0x02)); font_DrawText (&t); } UnbatchGraphics (); @@ -290,13 +289,10 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect) HSTARSHIP hTemplate; SHIP_FRAGMENTPTR TemplatePtr; - hTemplate = GetStarShipFromIndex ( - &GLOBAL (avail_race_q), - GET_RACE_ID (StarShipPtr) - ); + hTemplate = GetStarShipFromIndex (&GLOBAL (avail_race_q), + GET_RACE_ID (StarShipPtr)); TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); + &GLOBAL (avail_race_q), hTemplate); if (StarShipPtr->ShipInfo.crew_level >= TemplatePtr->RaceDescPtr->ship_info.crew_level) wsprintf (buf, "%u", StarShipPtr->ShipInfo.crew_level); @@ -306,9 +302,7 @@ ShowShipCrew (SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect) wsprintf (buf, "%u/%u", StarShipPtr->ShipInfo.crew_level, TemplatePtr->RaceDescPtr->ship_info.crew_level); - UnlockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); + UnlockStarShip (&GLOBAL (avail_race_q), hTemplate); r = *pRect; t.baseline.x = r.corner.x + (r.extent.width >> 1); @@ -391,33 +385,21 @@ ShowCombatShip (COUNT which_window, SHIP_FRAGMENTPTR YankedStarShipPtr) ); if (GET_GROUP_LOC (StarShipPtr) > which_window) { - UnlockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); break; } hNextShip = _GetSuccLink (StarShipPtr); - UnlockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); hStarShip = hNextShip; } - InsertQueue (&GLOBAL (built_ship_q), - hTailShip, hStarShip); + InsertQueue (&GLOBAL (built_ship_q), hTailShip, hStarShip); hStarShip = hTailShip; StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + &GLOBAL (built_ship_q), hStarShip); SET_GROUP_LOC (StarShipPtr, which_window); - UnlockStarShip ( - &GLOBAL (built_ship_q), - hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); } for (i = 0; i < num_ships; ++i) @@ -501,8 +483,10 @@ ShowCombatShip (COUNT which_window, SHIP_FRAGMENTPTR YankedStarShipPtr) { RECT ClipRect; - ClipRect.corner.x = SIS_ORG_X + pship_win_info->finished_s.x; - ClipRect.corner.y = SIS_ORG_Y + pship_win_info->finished_s.y; + ClipRect.corner.x = SIS_ORG_X + + pship_win_info->finished_s.x; + ClipRect.corner.y = SIS_ORG_Y + + pship_win_info->finished_s.y; ClipRect.extent.width = SHIP_WIN_WIDTH; ClipRect.extent.height = SHIP_WIN_HEIGHT; SetContextClipRect (&ClipRect); @@ -546,8 +530,7 @@ CrewTransaction (SIZE crew_delta) crew_bought = (SIZE)MAKE_WORD ( GET_GAME_STATE (CREW_PURCHASED0), - GET_GAME_STATE (CREW_PURCHASED1) - ) + crew_delta; + GET_GAME_STATE (CREW_PURCHASED1)) + crew_delta; if (crew_bought < 0) { if (crew_delta < 0) @@ -579,9 +562,7 @@ CrewTransaction (SIZE crew_delta) LockMutex (GraphicsLock); } } - if (!(ActivateStarShip ( - SHOFIXTI_SHIP, CHECK_ALLIANCE - ) & GOOD_GUY)) + if (!(ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) & GOOD_GUY)) { SET_GAME_STATE (CREW_PURCHASED0, LOBYTE (crew_bought)); SET_GAME_STATE (CREW_PURCHASED1, HIBYTE (crew_bought)); @@ -615,7 +596,7 @@ DoModifyShips (PMENU_STATE pMS) if (GLOBAL (CurrentActivity) & CHECK_ABORT) { pMS->InputFunc = DoShipyard; - return (TRUE); + return TRUE; } if (!pMS->Initialized) @@ -631,7 +612,8 @@ DoModifyShips (PMENU_STATE pMS) } else { - SBYTE dx = 0, dy = 0; + SBYTE dx = 0; + SBYTE dy = 0; BYTE NewState; if (!(pMS->delta_item & MODIFY_CREW_FLAG)) @@ -677,10 +659,9 @@ DoModifyShips (PMENU_STATE pMS) NewState = (BYTE)(pMS->CurState - NewState + dx); } -#ifdef WANT_SHIP_SPINS - if (select || cancel || special -#else if (select || cancel +#ifdef WANT_SHIP_SPINS + || special #endif || NewState != pMS->CurState || ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy))) @@ -689,25 +670,21 @@ DoModifyShips (PMENU_STATE pMS) hStarShip; hStarShip = hNextShip) { StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); + &GLOBAL (built_ship_q), hStarShip); if (GET_GROUP_LOC (StarShipPtr) == pMS->CurState) { - UnlockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); break; } hNextShip = _GetSuccLink (StarShipPtr); - UnlockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); } if ((pMS->delta_item & MODIFY_CREW_FLAG) && (hStarShip)) { - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } else { @@ -724,8 +701,7 @@ DoModifyShips (PMENU_STATE pMS) if ((hSpinShip = hStarShip) || (HINIBBLE (pMS->CurState) == 0 && (hSpinShip = GetAvailableRaceFromIndex ( - LOBYTE (pMS->delta_item) - )))) + LOBYTE (pMS->delta_item))))) { SetFlashRect (NULL_PTR, (FRAME)0); SpinStarShip (hSpinShip); @@ -754,7 +730,7 @@ DoModifyShips (PMENU_STATE pMS) { pMS->delta_item = MODIFY_CREW_FLAG; DrawRaceStrings (0); - return (TRUE); + return TRUE; } else if (cancel) { @@ -767,16 +743,16 @@ DoModifyShips (PMENU_STATE pMS) } else if (select) { - Index = GetIndexFromStarShip ( - &GLOBAL (avail_race_q), - GetAvailableRaceFromIndex (LOBYTE (pMS->delta_item)) - ); + Index = GetIndexFromStarShip (&GLOBAL (avail_race_q), + GetAvailableRaceFromIndex ( + LOBYTE (pMS->delta_item))); if (GLOBAL_SIS (ResUnits) >= (DWORD)ShipCost[Index] && CloneShipFragment (Index, &GLOBAL (built_ship_q), 1)) { - ShowCombatShip ((COUNT)pMS->CurState, (SHIP_FRAGMENTPTR)0); + ShowCombatShip ((COUNT)pMS->CurState, + (SHIP_FRAGMENTPTR) 0); //Reset flash rectangle LockMutex (GraphicsLock); SetFlashRect ((PRECT)~0L, (FRAME)0); @@ -795,9 +771,10 @@ DoModifyShips (PMENU_STATE pMS) SetFlashRect (&r, (FRAME)0); UnlockMutex (GraphicsLock); } - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); - return (TRUE); + return TRUE; } else { @@ -820,13 +797,13 @@ DoModifyShips (PMENU_STATE pMS) pMS->delta_item = NewState | MODIFY_CREW_FLAG; } - return (TRUE); + return TRUE; } LockMutex (GraphicsLock); goto ChangeFlashRect; } else if (select || cancel) - { + { if ((pMS->delta_item & MODIFY_CREW_FLAG) && hStarShip != 0 && StarShipPtr->ShipInfo.crew_level == 0) @@ -860,7 +837,8 @@ DoModifyShips (PMENU_STATE pMS) GetGaugeRect (&r, TRUE); SetFlashRect (&r, (FRAME)0); SetContext (SpaceContext); - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } else { @@ -871,7 +849,8 @@ DoModifyShips (PMENU_STATE pMS) r.extent.height = 5; SetContext (SpaceContext); SetFlashRect (&r, (FRAME)0); - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); } } else if (pMS->delta_item & MODIFY_CREW_FLAG) @@ -880,10 +859,10 @@ DoModifyShips (PMENU_STATE pMS) if (hStarShip) StarShipPtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); + &GLOBAL (built_ship_q), hStarShip); - SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL); + SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, + MENU_SOUND_SELECT | MENU_SOUND_CANCEL); crew_delta = 0; if (dy < 0) { @@ -910,24 +889,22 @@ DoModifyShips (PMENU_STATE pMS) hTemplate = GetStarShipFromIndex ( &GLOBAL (avail_race_q), - GET_RACE_ID (StarShipPtr) - ); + GET_RACE_ID (StarShipPtr)); TemplatePtr = (SHIP_FRAGMENTPTR)LockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); - if (GLOBAL_SIS (ResUnits) >= (DWORD)GLOBAL (CrewCost) + &GLOBAL (avail_race_q), hTemplate); + if (GLOBAL_SIS (ResUnits) >= + (DWORD)GLOBAL (CrewCost) && StarShipPtr->ShipInfo.crew_level < StarShipPtr->ShipInfo.max_crew && StarShipPtr->ShipInfo.crew_level < - TemplatePtr->RaceDescPtr->ship_info.crew_level) + TemplatePtr->RaceDescPtr->ship_info. + crew_level) { if (StarShipPtr->ShipInfo.crew_level > 0) DeltaSISGauges (0, 0, -GLOBAL (CrewCost)); else - DeltaSISGauges (0, 0, - -(COUNT)ShipCost[ - GET_RACE_ID (StarShipPtr) - ]); + DeltaSISGauges (0, 0, -(COUNT)ShipCost[ + GET_RACE_ID (StarShipPtr) ]); ++StarShipPtr->ShipInfo.crew_level; crew_delta = 1; ShowShipCrew (StarShipPtr, &pMS->flash_rect0); @@ -939,17 +916,15 @@ DoModifyShips (PMENU_STATE pMS) SetContext (SpaceContext); SetFlashRect (&r, (FRAME)0); } - UnlockStarShip ( - &GLOBAL (avail_race_q), hTemplate - ); + UnlockStarShip (&GLOBAL (avail_race_q), + hTemplate); } } else if (dy > 0) { crew_bought = (SIZE)MAKE_WORD ( GET_GAME_STATE (CREW_PURCHASED0), - GET_GAME_STATE (CREW_PURCHASED1) - ); + GET_GAME_STATE (CREW_PURCHASED1)); if (hStarShip == 0) { if (GetCrewCount ()) @@ -978,10 +953,8 @@ DoModifyShips (PMENU_STATE pMS) - (crew_bought == CREW_EXPENSE_THRESHOLD ? 2 : 0)); else - DeltaSISGauges (0, 0, - (COUNT)ShipCost[ - GET_RACE_ID (StarShipPtr) - ]); + DeltaSISGauges (0, 0, (COUNT)ShipCost[ + GET_RACE_ID (StarShipPtr)]); crew_delta = -1; --StarShipPtr->ShipInfo.crew_level; } @@ -998,9 +971,7 @@ DoModifyShips (PMENU_STATE pMS) if (hStarShip) { - UnlockStarShip ( - &GLOBAL (built_ship_q), hStarShip - ); + UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); // clear out the bought ship index // so that flash rects work correctly @@ -1019,7 +990,7 @@ DoModifyShips (PMENU_STATE pMS) SetFlashRect ((PRECT)~0L, (FRAME)0); UnlockMutex (GraphicsLock); - return (TRUE); + return TRUE; } else { @@ -1048,7 +1019,7 @@ ChangeFlashRect: } } - return (TRUE); + return TRUE; } static void @@ -1068,7 +1039,8 @@ DrawBluePrint (PMENU_STATE pMS) s.origin.x = s.origin.y = 0; s.frame = DecFrameIndex (pMS->ModuleFrame); - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x16), 0x01)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0x00, 0x00, 0x16), 0x01)); DrawFilledStamp (&s); for (num_frames = 0; num_frames < NUM_DRIVE_SLOTS; ++num_frames) @@ -1091,7 +1063,8 @@ DrawBluePrint (PMENU_STATE pMS) DrawShipPiece (pMS, which_piece, num_frames, TRUE); } - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0x1F), 0x09)); + SetContextForeGroundColor (BUILD_COLOR ( + MAKE_RGB15 (0xA, 0xA, 0x1F), 0x09)); for (num_frames = 0; num_frames < NUM_MODULE_SLOTS; ++num_frames) { BYTE which_piece; @@ -1154,7 +1127,8 @@ DrawBluePrint (PMENU_STATE pMS) r.corner.x += r.extent.width + 1; DrawPoint (&r.corner); r.corner.x -= r.extent.width; - SetContextForeGroundColor (SetContextBackGroundColor (BLACK_COLOR)); + SetContextForeGroundColor ( + SetContextBackGroundColor (BLACK_COLOR)); DrawFilledRectangle (&r); m = FuelVolume < FUEL_VOLUME_PER_ROW ? (COUNT)FuelVolume : FUEL_VOLUME_PER_ROW; @@ -1171,7 +1145,7 @@ DrawBluePrint (PMENU_STATE pMS) UnlockMutex (GraphicsLock); } -void +static void BeginHangarAnim (PMENU_STATE pMS) { #ifdef WANT_HANGAR_ANIMATION @@ -1192,7 +1166,7 @@ BeginHangarAnim (PMENU_STATE pMS) #endif } -void +static void EndHangarAnim (PMENU_STATE pMS) { if (pMS->flash_task) @@ -1221,9 +1195,7 @@ DoShipyard (PMENU_STATE pMS) STAMP s; RECT r, old_r; - s.frame = CaptureDrawable ( - LoadGraphic (SHIPYARD_PMAP_ANIM) - ); + s.frame = CaptureDrawable (LoadGraphic (SHIPYARD_PMAP_ANIM)); pMS->CurString = CaptureColorMap (LoadColorMapFile ( contentDir, "lbm/dockpani.ct")); @@ -1297,7 +1269,7 @@ ExitShipyard: pMS->CurString = 0; UnlockMutex (GraphicsLock); - return (FALSE); + return FALSE; } else if (select) { @@ -1321,5 +1293,6 @@ ExitShipyard: else DoMenuChooser (pMS, PM_CREW); - return (TRUE); + return TRUE; } + diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 11a6357fa..f6b973491 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -705,7 +705,8 @@ GetGaugeRect (PRECT pRect, BOOLEAN IsCrewRect) pRect->corner.y = IsCrewRect ? 117 : 38; } -void DrawPC_SIS (void) +static void +DrawPC_SIS (void) { TEXT t; RECT r; @@ -1200,10 +1201,11 @@ static FRAME flash_frame; static FRAME flash_screen_frame = 0; static int flash_changed; Mutex flash_mutex = 0; -void arith_frame_blit (FRAME srcFrame, RECT *rsrc, FRAME dstFrame, - RECT *rdst, int num,int denom); +void arith_frame_blit (FRAME srcFrame, RECT *rsrc, FRAME dstFrame, + RECT *rdst, int num, int denom); -int flash_rect_func(void *data) +static int +flash_rect_func (void *data) { #define NORMAL_STRENGTH 4 #define NORMAL_F_STRENGTH 0 @@ -1211,7 +1213,8 @@ int flash_rect_func(void *data) DWORD TimeIn, WaitTime; SIZE strength, fstrength, incr; RECT cached_rect, framesize_rect; - FRAME cached_frame, cached_screen_frame = 0; + FRAME cached_frame = 0; + FRAME cached_screen_frame = 0; Task task = (Task)data; int cached[CACHE_SIZE]; STAMP cached_stamp[CACHE_SIZE]; diff --git a/sc2/src/sc2code/sis.h b/sc2/src/sc2code/sis.h index f6200d9cb..db62f7ba5 100644 --- a/sc2/src/sc2code/sis.h +++ b/sc2/src/sc2code/sis.h @@ -260,6 +260,8 @@ extern void DrawStatusMessage (UNICODE *pStr); extern void DrawLanders (void); extern void DrawStorageBays (BOOLEAN Refresh); extern void GetGaugeRect (PRECT pRect, BOOLEAN IsCrewRect); +extern void DrawFlagshipStats (void); +extern void SaveFlagshipState (void); extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta); diff --git a/sc2/src/sc2code/starbase.c b/sc2/src/sc2code/starbase.c index 878b5847d..588c27936 100644 --- a/sc2/src/sc2code/starbase.c +++ b/sc2/src/sc2code/starbase.c @@ -76,7 +76,7 @@ void DrawShipPiece (PMENU_STATE pMS, COUNT which_piece, COUNT which_slot, BOOLEAN DrawBluePrint) { - COLOR OldColor; + COLOR OldColor = 0; // Initialisation is to keep the compiler silent. RECT r; STAMP Side, Top; SBYTE RepairSlot; @@ -251,7 +251,8 @@ DrawShipPiece (PMENU_STATE pMS, COUNT which_piece, COUNT which_slot, } } -int rotate_starbase(void* data) +static int +rotate_starbase(void *data) { DWORD TimeIn; STAMP s; @@ -528,7 +529,7 @@ ExitStarBase: // XXX: Doesn't really belong in this file. COUNT -WrapText (UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width) +WrapText (const UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width) { COUNT num_lines; diff --git a/sc2/src/sc2code/starbase.h b/sc2/src/sc2code/starbase.h index 04199cedc..ad77c23f3 100644 --- a/sc2/src/sc2code/starbase.h +++ b/sc2/src/sc2code/starbase.h @@ -66,7 +66,7 @@ extern BOOLEAN DoShipyard (PMENU_STATE pMS); extern void DrawShipPiece (PMENU_STATE pMS, COUNT which_piece, COUNT which_slot, BOOLEAN DrawBluePrint); -extern COUNT WrapText (UNICODE *pStr, COUNT len, TEXT *tarray, SIZE +extern COUNT WrapText (const UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width); // XXX: Doesn't really belong in this file. diff --git a/sc2/src/sc2code/starcon.c b/sc2/src/sc2code/starcon.c index 27d1db53d..9be88b141 100644 --- a/sc2/src/sc2code/starcon.c +++ b/sc2/src/sc2code/starcon.c @@ -24,7 +24,9 @@ #include "types.h" #include "globdata.h" #include "resinst.h" +#include "restart.h" #include "setup.h" +#include "starcon.h" #include "libs/tasklib.h" @@ -32,7 +34,8 @@ // A seperate thread is always inside this function when the player // is in hyperspace. This thread awakens every BATTLE_FRAME_RATE seconds. // It then changes the appearant portal size when necessary. -int arilou_gate_task(void* data) +static int +arilou_gate_task(void *data) { BYTE counter; DWORD TimeIn; @@ -75,7 +78,8 @@ int arilou_gate_task(void* data) /* TODO: Remove these declarations once threading is gone. */ extern int snddriver, soundflags; -int Starcon2Main(void *threadArg) +int +Starcon2Main (void *threadArg) { #if DEBUG_PSYTRON || CREATE_JOURNAL { @@ -117,8 +121,6 @@ while (--ac > 0) if (LoadKernel (0,0)) { - extern BOOLEAN StartGame (void); - fprintf (stderr, "We've loaded the Kernel\n"); Logo (); diff --git a/sc2/src/sc2code/starcon.h b/sc2/src/sc2code/starcon.h new file mode 100644 index 000000000..a5eb2f910 --- /dev/null +++ b/sc2/src/sc2code/starcon.h @@ -0,0 +1,23 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _STARCON_H +#define _STARCON_H + +extern int Starcon2Main(void *threadArg); + +#endif /* _STARCON_H */ + diff --git a/sc2/src/sc2code/state.h b/sc2/src/sc2code/state.h index 311c3c806..02974d0fe 100644 --- a/sc2/src/sc2code/state.h +++ b/sc2/src/sc2code/state.h @@ -32,8 +32,6 @@ extern BOOLEAN GetGroupInfo (DWORD offset, BYTE which_group); extern DWORD PutGroupInfo (DWORD offset, BYTE which_group); extern void BuildGroups (void); -extern BOOLEAN GameOptions (void); - #define MAX_DESC_CHARS 60 typedef UNICODE GAME_DESC[MAX_DESC_CHARS + 1]; diff --git a/sc2/src/sc2code/status.c b/sc2/src/sc2code/status.c index e818cacfe..072853e93 100644 --- a/sc2/src/sc2code/status.c +++ b/sc2/src/sc2code/status.c @@ -427,7 +427,8 @@ PostProcessStatus (PELEMENT ShipPtr) else { SetContextForeGroundColor (BLACK_COLOR); - if ((i -= 5) <= 14) + i -= 5; + if (i <= 14) { COLOR flash_tab1[] = { @@ -494,6 +495,10 @@ PostProcessStatus (PELEMENT ShipPtr) r.extent.width = 2; c = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x50, 0x5), 0x28); break; + default: + // Should not happen. + c = 0; // Keeping compiler quiet. + break; } DrawFilledRectangle (&r); r.corner.x += i + r.extent.width; diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index c9c0872d3..b4b186450 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -39,6 +39,7 @@ #include "uqmversion.h" #include "comm.h" #include "setup.h" +#include "starcon.h" #if defined(GFXMODULE_SDL) @@ -83,7 +84,7 @@ static int preParseOptions(int argc, char *argv[], struct options_struct *options); static int parseOptions(int argc, char *argv[], struct options_struct *options); -static void usage (FILE *out); +static void usage (FILE *out, const struct options_struct *defaultOptions); static int parseIntOption (const char *str, int *result, const char *optName); static int parseFloatOption (const char *str, float *f, @@ -92,6 +93,7 @@ static int parseVolume (const char *str, float *vol, const char *optName); static int InvalidArgument(const char *supplied, const char *opt_name); static int Check_PC_3DO_opt (const char *value, DWORD mask, const char *opt, int *result); +static const char *PC_3DO_optString (DWORD optMask); /* TODO: Remove these global variables once threading is gone. */ int snddriver, soundflags; @@ -153,7 +155,7 @@ main (int argc, char *argv[]) if (options.runMode == runMode_usage) { - usage (stdout); + usage (stdout, &options); return EXIT_SUCCESS; } @@ -651,7 +653,7 @@ parseFloatOption (const char *str, float *f, const char *optName) } static void -usage (FILE *out) +usage (FILE *out, const struct options_struct *defaultOptions) { fprintf (out, "Options:\n"); fprintf (out, " -r, --res=WIDTHxHEIGHT (default 640x480, bigger " @@ -677,7 +679,7 @@ usage (FILE *out) fprintf (out, " -u, --nosubtitles\n"); fprintf (out, " -l, --logfile=FILE (sends console output to logfile " "FILE)\n"); - fprintf (out, " --addon (using a specific addon; " + fprintf (out, " --addon ADDON (using a specific addon; " "may be specified multiple times)\n"); fprintf (out, " --sound=DRIVER (openal, mixsdl, none; default " "mixsdl)\n"); @@ -685,15 +687,20 @@ usage (FILE *out) "currently only for openal)\n"); fprintf (out, "The following options can take either '3do' or 'pc' " "as an option:\n"); - fprintf (out, " -m, --music : Music version (default 3do)\n"); - fprintf (out, " -i, --intro : Intro/ending version (default 3do)\n"); + fprintf (out, " -m, --music : Music version (default %s)\n", + PC_3DO_optString(defaultOptions->whichMusic)); + fprintf (out, " -i, --intro : Intro/ending version (default %s)\n", + PC_3DO_optString(defaultOptions->whichIntro)); fprintf (out, " --cscan : coarse-scan display, pc=text, " - "3do=hieroglyphs (default 3do)\n"); + "3do=hieroglyphs (default %s)\n", + PC_3DO_optString(defaultOptions->whichCoarseScan)); fprintf (out, " --menu : menu type, pc=text, 3do=graphical " - "(default 3do)\n"); - fprintf (out, " --font : font types and colors (default pc)\n"); + "(default %s)\n", PC_3DO_optString(defaultOptions->whichMenu)); + fprintf (out, " --font : font types and colors (default %s)\n", + PC_3DO_optString(defaultOptions->whichFonts)); fprintf (out, " --scroll : ff/frev during comm. pc=per-page, " - "3do=smooth (default pc)\n"); + "3do=smooth (default %s)\n", + PC_3DO_optString(defaultOptions->smoothScroll)); } static int @@ -729,4 +736,21 @@ Check_PC_3DO_opt (const char *value, DWORD mask, const char *optName, return -1; } +static const char * +PC_3DO_optString(DWORD optMask) { + if (optMask & OPT_3DO) + { + if (optMask & OPT_PC) + return "both"; + return "3do"; + } + else + { + if (optMask & OPT_PC) + return "pc"; + return "none"; + } +} + +