From 4f837c0c70b3c5613999365e0b74ea98f5faf73f Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sat, 2 Dec 2006 12:50:28 +0000 Subject: [PATCH] Patches by Christian Ohm: 034 - Reorganized src-warcam.c 036 - Cleanup includes and function declarations git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@884 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/ivis_common/piefunc.h | 22 +- lib/ivis_common/piemode.h | 2 +- lib/ivis_common/rendmode.h | 17 +- src/action.c | 38 +- src/action.h | 2 + src/advvis.c | 79 +-- src/ai.c | 26 +- src/clparse.c | 1 - src/cluster.h | 3 + src/cmddroid.h | 1 + src/cmddroiddef.h | 2 + src/component.h | 3 + src/design.h | 2 + src/droiddef.h | 6 + src/edit3d.h | 2 + src/frontend.c | 96 +-- src/frontend.h | 1 + src/hci.c | 1330 ++++++++++++++++-------------------- src/hci.h | 8 +- src/ingameop.c | 25 +- src/ingameop.h | 1 - src/init.c | 135 ++-- src/init.h | 4 + src/intdisplay.h | 2 + src/intelmap.c | 1 - src/intorder.c | 21 +- src/keyedit.c | 3 +- src/main.c | 65 +- src/mission.c | 6 +- src/multiint.c | 4 - src/multilimit.c | 2 - src/multimenu.c | 4 +- src/scriptfuncs.c | 1 - src/structuredef.h | 4 + src/transporter.c | 2 - src/warcam.c | 890 +++++++++++------------- src/winmain.h | 2 + src/wrappers.c | 1 - 38 files changed, 1198 insertions(+), 1616 deletions(-) diff --git a/lib/ivis_common/piefunc.h b/lib/ivis_common/piefunc.h index 1c9f9c079..0a0581bed 100644 --- a/lib/ivis_common/piefunc.h +++ b/lib/ivis_common/piefunc.h @@ -10,30 +10,10 @@ #ifndef _piefunc_h #define _piefunc_h -/***************************************************************************/ - #include "lib/framework/frame.h" +#include "lib/ivis_common/piedef.h" - - -/***************************************************************************/ -/* - * Global Definitions - */ -/***************************************************************************/ - -/***************************************************************************/ -/* - * Global Variables - */ -/***************************************************************************/ - -/***************************************************************************/ -/* - * Global ProtoTypes - */ -/***************************************************************************/ extern void pie_DownLoadBufferToScreen(void *srcData, UDWORD destX, UDWORD destY,UDWORD srcWidth,UDWORD srcHeight,UDWORD srcStride); extern void pie_RectFilter(SDWORD x0, SDWORD y0, SDWORD x1, SDWORD y1, UDWORD colour); diff --git a/lib/ivis_common/piemode.h b/lib/ivis_common/piemode.h index 8b6060a49..2b3319ad4 100644 --- a/lib/ivis_common/piemode.h +++ b/lib/ivis_common/piemode.h @@ -36,7 +36,7 @@ typedef enum CLEAR_MODE */ /***************************************************************************/ -extern int32 _iVPRIM_DIVTABLE[]; +extern Sint32 _iVPRIM_DIVTABLE[]; /***************************************************************************/ /* diff --git a/lib/ivis_common/rendmode.h b/lib/ivis_common/rendmode.h index 4b6c36ec3..dad2d663f 100644 --- a/lib/ivis_common/rendmode.h +++ b/lib/ivis_common/rendmode.h @@ -9,21 +9,14 @@ //************************************************************************* //patch -#define iV_RenderBegin pie_LocalRenderBegin -#define iV_RenderEnd pie_LocalRenderEnd -#define iV_Line pie_Line -#define iV_Box pie_Box +#define iV_Line pie_Line +#define iV_Box pie_Box #define iV_BoxFill pie_BoxFillIndex -#define iV_TransBoxFill pie_TransBoxFill -#define iV_UniTransBoxFill pie_UniTransBoxFill +#define iV_TransBoxFill pie_TransBoxFill #define iV_DrawImage pie_ImageFileID #define iV_DrawImageRect pie_ImageFileIDTile #define iV_DrawTransImage pie_ImageFileID #define iV_DrawTransImageRect pie_ImageFileIDTile -#define iV_DrawStretchImage pie_ImageFileIDStretch -#define iV_UploadDisplayBuffer pie_UploadDisplayBuffer -#define iV_DownloadDisplayBuffer pie_DownloadDisplayBuffer -#define iV_ScaleBitmapRGB pie_ScaleBitmapRGB //************************************************************************* @@ -47,7 +40,7 @@ #define PIE_NO_CULL 0x00002000 //#define PIE_TEXANIM 0x00004000 // PIE_TEX must be set also #define PIE_PSXTEX 0x00008000 // - use playstation texture allocation method -#define PIE_BSPFRESH 0x00010000 // Freshly created by the BSP +#define PIE_BSPFRESH 0x00010000 // Freshly created by the BSP #define PIE_NOHALFPSXTEX 0x00020000 #define PIE_ALPHA 0x00040000 @@ -90,7 +83,7 @@ extern char* (*iV_ScreenDumpToDisk)(void); extern void (*iV_ppBitmap)(iBitmap *bmp, int x, int y, int w, int h, int ow); extern void (*iV_ppBitmapTrans)(iBitmap *bmp, int x, int y, int w, int h, int ow); extern void (*iV_SetTransFilter)(UDWORD rgb,UDWORD tablenumber); -extern void (*iV_UniBitmapDepth)(int texPage, int u, int v, int srcWidth, int srcHeight, +extern void (*iV_UniBitmapDepth)(int texPage, int u, int v, int srcWidth, int srcHeight, int x, int y, int destWidth, int destHeight, unsigned char brightness, int depth); extern void (*iV_SetTransImds)(BOOL trans); diff --git a/src/action.c b/src/action.c index a74ecad21..0f8ab6e53 100644 --- a/src/action.c +++ b/src/action.c @@ -7,32 +7,24 @@ #include #include "lib/framework/frame.h" -#include "lib/framework/trig.h" - -#include "objects.h" -#include "action.h" -#include "map.h" -#include "combat.h" -#include "geometry.h" #include "lib/gamelib/gtime.h" -#include "lib/ivis_common/ivisdef.h" -#include "visibility.h" -#include "projectile.h" -#include "order.h" -#include "hci.h" -#include "transporter.h" -#include "console.h" -#include "research.h" -#include "drive.h" -#include "mission.h" -#include "audio_id.h" -#include "multiplay.h" -#include "formation.h" -#include "intdisplay.h" -#include "fpath.h" #include "lib/script/script.h" -#include "scripttabs.h" + +#include "action.h" +#include "audio_id.h" +#include "combat.h" +#include "formation.h" +#include "geometry.h" +#include "hci.h" +#include "intdisplay.h" +#include "mission.h" +#include "multiplay.h" +#include "projectile.h" +#include "research.h" #include "scriptcb.h" +#include "scripttabs.h" +#include "transporter.h" +#include "visibility.h" /* attack run distance */ #define VTOL_ATTACK_LENGTH 1000 diff --git a/src/action.h b/src/action.h index c5a84ef82..92a2a44a1 100644 --- a/src/action.h +++ b/src/action.h @@ -7,6 +7,8 @@ #ifndef _action_h #define _action_h +#include "droiddef.h" + // What a droid is currently doing // Not necessarily the same as it's order as the AI may get a droid to do // something else whilst carrying out an order diff --git a/src/advvis.c b/src/advvis.c index 877439011..178f3bc97 100644 --- a/src/advvis.c +++ b/src/advvis.c @@ -3,16 +3,12 @@ /* Makes smooth transitions for terrain visibility */ #include "lib/framework/frame.h" -#include "objects.h" -#include "base.h" -#include "map.h" #include "lib/gamelib/gtime.h" -#include "display3d.h" + #include "advvis.h" +#include "display3d.h" #include "hci.h" -#include "lib/ivis_common/piestate.h" -#include "component.h" -#include "geometry.h" +#include "map.h" /* This uses oodles of memory and so can only be done on the PC */ @@ -20,18 +16,11 @@ #define FADE_IN_TIME (GAME_TICKS_PER_SEC/10) #define START_DIVIDE (8) -UDWORD avConsidered; -UDWORD avCalculated; -UDWORD avIgnored; +static UDWORD avConsidered; +static UDWORD avCalculated; +static UDWORD avIgnored; -// ------------------------------------------------------------------------------------ -BOOL bRevealActive = FALSE; -// ------------------------------------------------------------------------------------ -void avInformOfChange(SDWORD x, SDWORD y); -void avUpdateTiles( void ); -void processAVTile(UDWORD x, UDWORD y ); -UDWORD avGetObjLightLevel(BASE_OBJECT *psObj,UDWORD origLevel); -void avGetStats(UDWORD *considered, UDWORD *ignored, UDWORD *calculated); +static BOOL bRevealActive = FALSE; // ------------------------------------------------------------------------------------ @@ -73,6 +62,34 @@ SDWORD lowerX,upperX,lowerY,upperY; } } + +// ------------------------------------------------------------------------------------ +static void processAVTile(UDWORD x, UDWORD y) +{ + FRACT time; + MAPTILE *psTile; + UDWORD newLevel; + + psTile = mapTile(x, y); + if (psTile->level == UBYTE_MAX OR psTile->bMaxed) + { + return; + } + + time = (MAKEFRACT(frameTime) / GAME_TICKS_PER_SEC); + newLevel = MAKEINT(psTile->level + (time * FADE_IN_TIME)); + if (newLevel >= psTile->illumination) + { + psTile->level = psTile->illumination; + psTile->bMaxed = TRUE; + } + else + { + psTile->level = (UBYTE)newLevel; + } +} + + // ------------------------------------------------------------------------------------ void avUpdateTiles( void ) { @@ -125,32 +142,6 @@ UDWORD i,j; } -// ------------------------------------------------------------------------------------ -void processAVTile(UDWORD x, UDWORD y ) -{ -FRACT time; -MAPTILE *psTile; -UDWORD newLevel; - - psTile = mapTile(x,y); - if(psTile->level == UBYTE_MAX OR psTile->bMaxed) - { - return; - } - - time = (MAKEFRACT(frameTime)/GAME_TICKS_PER_SEC); - newLevel = MAKEINT(psTile->level + (time*FADE_IN_TIME)); - if(newLevel >= psTile->illumination) - { - psTile->level = psTile->illumination; - psTile->bMaxed = TRUE; - } - else - { - psTile->level =(UBYTE)newLevel; - } -} - // ------------------------------------------------------------------------------------ UDWORD avGetObjLightLevel(BASE_OBJECT *psObj,UDWORD origLevel) { diff --git a/src/ai.c b/src/ai.c index 89c08d8e4..5be2b0d49 100644 --- a/src/ai.c +++ b/src/ai.c @@ -5,27 +5,17 @@ * */ -/* Droid attack printf's */ #include "lib/framework/frame.h" -#include "objects.h" -#include "map.h" -#include "findpath.h" -#include "visibility.h" -#include "lib/gamelib/gtime.h" -#include "combat.h" -#include "hci.h" -#include "player.h" -#include "power.h" -#include "geometry.h" -#include "order.h" -#include "action.h" -#include "mapgrid.h" -#include "drive.h" -#include "projectile.h" -#include "cmddroid.h" -#include "group.h" +#include "action.h" +#include "cmddroid.h" +#include "combat.h" +#include "drive.h" +#include "map.h" +#include "mapgrid.h" #include "multiplay.h" +#include "player.h" +#include "projectile.h" // alliances UBYTE alliances[MAX_PLAYERS][MAX_PLAYERS]; diff --git a/src/clparse.c b/src/clparse.c index 609209c1b..bf8c9fb75 100644 --- a/src/clparse.c +++ b/src/clparse.c @@ -34,7 +34,6 @@ extern BOOL NETsetupTCPIP(void ** addr, char * machine); -extern char SaveGamePath[]; extern char datadir[MAX_PATH]; extern char * global_mods[MAX_MODS]; extern char * campaign_mods[MAX_MODS]; diff --git a/src/cluster.h b/src/cluster.h index d0fe29a27..a7d96009b 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -7,6 +7,9 @@ #ifndef _cluster_h #define _cluster_h +#include "droiddef.h" +#include "structuredef.h" + // maximum number of clusters in a game #define CLUSTER_MAX UBYTE_MAX diff --git a/src/cmddroid.h b/src/cmddroid.h index 621904457..e146c9f9e 100644 --- a/src/cmddroid.h +++ b/src/cmddroid.h @@ -8,6 +8,7 @@ #define _cmddroid_h #include "cmddroiddef.h" +#include "droiddef.h" // The number of available command droids for each player //extern SWORD numCommandDroids[MAX_PLAYERS]; diff --git a/src/cmddroiddef.h b/src/cmddroiddef.h index 8239c097c..aaf7d24ff 100644 --- a/src/cmddroiddef.h +++ b/src/cmddroiddef.h @@ -7,6 +7,8 @@ #ifndef _cmddroiddef_h #define _cmddroiddef_h +#include "statsdef.h" + // the maximum number of command droids per side #define MAX_CMDDROIDS 5 diff --git a/src/component.h b/src/component.h index ad18fd513..13babeff0 100644 --- a/src/component.h +++ b/src/component.h @@ -1,6 +1,9 @@ #ifndef _component_h #define _component_h +#include "droiddef.h" +#include "structuredef.h" + /* Header file for component.c Pumpkin Studios, EIDOS Interactive. diff --git a/src/design.h b/src/design.h index bdbfc4034..338e04ff7 100644 --- a/src/design.h +++ b/src/design.h @@ -1,6 +1,8 @@ #ifndef _design_h #define _design_h +#include "lib/widget/widgbase.h" + /* Design screen ID's */ #define IDDES_FORM 5000 // The base form for the design screen #define IDDES_STATSFORM 5001 // The design screen stats form diff --git a/src/droiddef.h b/src/droiddef.h index b75218a2f..134c57f4d 100644 --- a/src/droiddef.h +++ b/src/droiddef.h @@ -9,6 +9,12 @@ #include "lib/gamelib/animobj.h" #include "lib/sound/audio.h" +#include "base.h" +#include "deliverance.h" +#include "movedef.h" +#include "statsdef.h" +#include "weapons.h" + /* The number of components in the asParts / asBits arrays */ #define DROID_MAXCOMP (COMP_NUMCOMPONENTS - 1)//(COMP_NUMCOMPONENTS - 2) diff --git a/src/edit3d.h b/src/edit3d.h index 6d9c83bc5..b25cd40a7 100644 --- a/src/edit3d.h +++ b/src/edit3d.h @@ -1,6 +1,8 @@ #ifndef _edit3d_h #define _edit3d_h +#include "map.h" + #define TILE_RAISE 1 #define TILE_LOWER -1 #define MAX_TILE_HEIGHT 255 diff --git a/src/frontend.c b/src/frontend.c index d65e514d6..77f41c038 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -16,98 +16,42 @@ #include "lib/framework/frame.h" #include "lib/framework/frameresource.h" #include "lib/framework/strres.h" -#include "winmain.h" -#include "objects.h" -#include "display.h" -#include "lib/widget/widget.h" -/* Includes direct access to render library */ -#include "lib/ivis_common/ivisdef.h" -#include "lib/ivis_common/piestate.h" - -#include "keyedit.h" -#include "lib/ivis_common/piefunc.h" -#include "warzoneconfig.h" - -// FIXME Direct iVis implementation include! #include "lib/ivis_common/rendmode.h" - -#include "display3d.h" -#include "intdisplay.h" -#include "lib/sound/audio.h" // for sound. -#include "audio_id.h" // for sound.. - -#include "lib/sound/cdaudio.h" +#include "lib/netplay/netplay.h" #include "lib/sound/mixer.h" -#include "configuration.h" - - -#include "design.h" // for intadddesign -#include "hci.h" // for intShowPower -#include "text.h" // to get at string resources. -#include "frontend.h" -#include "console.h" -#include "wrappers.h" -#include "component.h" -#include "loadsave.h" -#include "csnap.h" -//#include "wrappers.h" // for bUsingKeyboard. -#include "frend.h" -#include "game.h" -#include "init.h" -#include "difficulty.h" -#include "ingameop.h" - +#include "lib/widget/widget.h" #include "advvis.h" -#include "seqdisp.h" -#include "multiplay.h" +#include "component.h" +#include "difficulty.h" +#include "display.h" +#include "frend.h" +#include "frontend.h" +#include "hci.h" +#include "ingameop.h" +#include "init.h" +#include "intdisplay.h" +#include "keyedit.h" +#include "loadsave.h" #include "multiint.h" #include "multilimit.h" -#include "multistat.h" -#include "lib/netplay/netplay.h" +#include "multiplay.h" +#include "seqdisp.h" +#include "text.h" +#include "warzoneconfig.h" +#include "winmain.h" +#include "wrappers.h" -extern BOOL bSubtitles; - -extern void intUpdateOptionText(struct _widget *psWidget, struct _w_context *psContext); -extern void set_active_data_directory(int); - -extern CURSORSNAP InterfaceSnap; -extern void ProcessCursorSnap(void); - -int StartWithGame = 1; // New game starts in Cam 1. - -char OnString[]={"On "}; -char OffString[]={"Off"}; - - -char strFog[MAX_STR_LENGTH]; -char strTrans[MAX_STR_LENGTH]; +static int StartWithGame = 1; // New game starts in Cam 1. tMode titleMode; // the global case - - -// //////////////////////////////////////////////////////////////////////////// -// Local Definitions -// iPalette titlePalette; int FEFont; -//int FEBigFont; char pLevelName[MAX_LEVEL_NAME_SIZE+1]; //256]; // vital! the wrf file to use. BOOL bForceEditorLoaded = FALSE; BOOL bUsingKeyboard = FALSE; // to disable mouse pointer when using keys. BOOL bUsingSlider = FALSE; -// //////////////////////////////////////////////////////////////////////////// -// extern Definitions - -//extern W_SCREEN *psWScreen; //The widget screen - -extern char SaveGamePath[]; - -extern BOOL firstcall; -extern IMAGEFILE *FrontImages; - - // //////////////////////////////////////////////////////////////////////////// // Function Definitions diff --git a/src/frontend.h b/src/frontend.h index f559236f9..4fe29f663 100644 --- a/src/frontend.h +++ b/src/frontend.h @@ -42,6 +42,7 @@ extern tMode titleMode; // the global case #define MAX_LEVEL_NAME_SIZE (256) +extern int FEFont; extern char pLevelName[MAX_LEVEL_NAME_SIZE+1]; //256]; // vital! the wrf file to use. diff --git a/src/hci.c b/src/hci.c index fd90f5828..f17ff02fa 100644 --- a/src/hci.c +++ b/src/hci.c @@ -3,89 +3,51 @@ * * Functions for the in game interface. * - * */ -#include -#include #include #include "lib/framework/frame.h" #include "lib/framework/strres.h" -#include "lib/widget/widget.h" - -#include "objects.h" -#include "loop.h" -#include "edit2d.h" -#include "map.h" -/* Includes direct access to render library */ -#include "lib/ivis_common/piedef.h" -#include "lib/ivis_common/piestate.h" -// FIXME Direct iVis implementation include! -#include "lib/ivis_common/rendmode.h" +#include "lib/gamelib/gtime.h" // FIXME Direct iVis implementation include! #include "lib/ivis_opengl/screen.h" +#include "lib/script/script.h" -#include "display3d.h" -#include "edit3d.h" -#include "disp2d.h" -#include "structure.h" -#include "research.h" -#include "function.h" -#include "lib/gamelib/gtime.h" -#include "hci.h" -#include "stats.h" -#include "game.h" -#include "power.h" -#include "lib/sound/audio.h" -#include "audio_id.h" -#include "lib/widget/widgint.h" -#include "lib/widget/bar.h" -#include "lib/widget/form.h" -#include "lib/widget/label.h" -#include "lib/widget/button.h" -#include "lib/widget/editbox.h" -#include "lib/widget/slider.h" -#include "lib/framework/fractions.h" -#include "order.h" #include "action.h" -#include "intimage.h" -#include "intdisplay.h" +#include "audio_id.h" +#include "console.h" #include "design.h" +#include "display.h" +#include "display3d.h" +#include "drive.h" +#include "edit3d.h" +#include "effects.h" +#include "game.h" +#include "hci.h" +#include "ingameop.h" +#include "intdisplay.h" #include "intelmap.h" #include "intorder.h" -#include "radar.h" +#include "keymap.h" +#include "loadsave.h" +#include "loop.h" #include "mapdisplay.h" -#include "objects.h" -#include "display.h" -#include "text.h" -#include "deliverance.h" -#include "winmain.h" #include "mission.h" -#include "csnap.h" // cursor snapping -#include "ingameop.h" // ingame options screen. +#include "multimenu.h" +#include "multiplay.h" +#include "radar.h" +#include "research.h" +#include "scriptcb.h" +#include "scriptextern.h" +#include "scripttabs.h" +#include "seqdisp.h" +#include "text.h" #include "transporter.h" #include "warcam.h" -#include "lib/script/script.h" -#include "scripttabs.h" -#include "scriptextern.h" -#include "scriptcb.h" -#include "console.h" -#include "loadsave.h" +#include "winmain.h" #include "wrappers.h" -#include "seqdisp.h" -#include "multiplay.h" -#include "multistat.h" -#include "multimenu.h" -#include "cdspan.h" - -#include "drive.h" -#include "levels.h" -#include "frontend.h" -#include "effects.h" -#include "keymap.h" - #define MAX_INTERFACE_SNAPS 64 #define MAX_RADAR_SNAPS 1 @@ -135,11 +97,9 @@ BUTSTATE ReticuleEnabled[NUMRETBUTS] = { // Reticule button enable states. }; - - // Set the x,y members of a button widget initialiser given a reticule button index. // -void SetReticuleButPos(UWORD ButId,W_BUTINIT *sButInit) +static void SetReticuleButPos(UWORD ButId, W_BUTINIT *sButInit) { ASSERT( ButId < NUMRETBUTS,"SetReticuleButPos : Bad button index" ); @@ -148,9 +108,6 @@ void SetReticuleButPos(UWORD ButId,W_BUTINIT *sButInit) } - -CURSORSNAP InterfaceSnap; - static BOOL ClosingObject = FALSE; static BOOL ClosingStats = FALSE; static UDWORD keyButtonMapping = 0; @@ -163,21 +120,12 @@ BOOL ClosingTransDroids = FALSE; BOOL ReticuleUp = FALSE; BOOL Refreshing = FALSE; +CURSORSNAP InterfaceSnap; char *DisplayBuffer; UDWORD displayBufferSize; -//hides the power bar from the display - NB static function now -static void intHidePowerBar(void); - -void setKeyButtonMapping( UDWORD val ); - -static void orderObjectInterface(void); -static void orderFactories(void); -static void orderResearch(void); -static void orderDroids(void); - /***************************************************************************************/ /* Widget ID numbers */ @@ -422,7 +370,7 @@ static UWORD objNumTabs; static UWORD objMajor, objMinor; /* The current map width and height in the new map edit boxes */ -//static UDWORD newMapWidth, newMapHeight; +static UDWORD newMapWidth, newMapHeight; /* Store a list of stats pointers from the main structure stats */ static STRUCTURE_STATS **apsStructStatsList; @@ -502,30 +450,6 @@ static BOOL bReopenBuildMenu = FALSE; /***************************************************************************************/ /* Function Prototypes */ - -/* Add the options widgets to the widget screen */ -BOOL intAddOptions(void); -/* Remove the options widgets from the widget screen */ -static void intRemoveOptions(void); -/* Process return codes from the Options screen */ -static void intProcessOptions(UDWORD id); -/* Process return codes from the object placement stats screen */ -static void intProcessEditStats(UDWORD id); - -#ifdef EDIT_OPTIONS -/* Add the edit widgets to the widget screen */ -static BOOL intAddEdit(void); -/* Remove the edit widgets from the widget screen */ -static void intRemoveEdit(void); -/* Process return codes from the edit screen */ -static void intProcessEdit(UDWORD id); -#endif - - -/* The int AddObject function is only called by : - * intAddBuild, intAddManufacture and intAddResearch - */ -static BOOL intAddObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected, BOOL bForceStats); static BOOL intUpdateObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats); /* Remove the object widgets from the widget screen */ void intRemoveObject(void); @@ -975,7 +899,7 @@ BOOL intIsRefreshing(void) // see if a delivery point is selected -FLAG_POSITION *intFindSelectedDelivPoint(void) +static FLAG_POSITION *intFindSelectedDelivPoint(void) { FLAG_POSITION *psFlagPos; @@ -993,7 +917,7 @@ FLAG_POSITION *intFindSelectedDelivPoint(void) // Refresh widgets once per game cycle if pending flag is set. // -void intDoScreenRefresh(void) +static void intDoScreenRefresh(void) { UWORD objMajor=0, objMinor=0, statMajor=0, statMinor=0; FLAG_POSITION *psFlag; @@ -1130,6 +1054,204 @@ void intDoScreenRefresh(void) IntRefreshPending = FALSE; } + +//hides the power bar from the display +static void intHidePowerBar(void) +{ + //only hides the power bar if the player has requested no power bar + if (!powerBarUp) + { + if (widgGetFromID(psWScreen, IDPOW_POWERBAR_T)) + { + widgHide(psWScreen, IDPOW_POWERBAR_T); + } + } +} + + +/* Remove the options widgets from the widget screen */ +static void intRemoveOptions(void) +{ +// widgEndScreen(psWScreen); + widgDelete(psWScreen, IDOPT_FORM); +// widgStartScreen(psWScreen); +} + + +#ifdef EDIT_OPTIONS +/* Add the edit widgets to the widget screen */ +static BOOL intAddEdit(void) +{ + W_FORMINIT sFormInit; + W_LABINIT sLabInit; + W_BUTINIT sButInit; + +// widgEndScreen(psWScreen); + + memset(&sFormInit, 0, sizeof(W_FORMINIT)); + memset(&sLabInit, 0, sizeof(W_LABINIT)); + memset(&sButInit, 0, sizeof(W_BUTINIT)); + + /* Add the edit form */ + sFormInit.formID = 0; + sFormInit.id = IDED_FORM; + sFormInit.style = WFORM_PLAIN; + sFormInit.x = ED_X; + sFormInit.y = ED_Y; + sFormInit.width = ED_WIDTH; + sFormInit.height = ED_HEIGHT; + if (!widgAddForm(psWScreen, &sFormInit)) + { + return FALSE; + } + + /* Add the Option screen label */ + sLabInit.formID = IDED_FORM; + sLabInit.id = IDED_LABEL; + sLabInit.style = WLAB_PLAIN; + sLabInit.x = ED_GAP; + sLabInit.y = ED_GAP; + sLabInit.width = ED_WIDTH; + sLabInit.height = ED_BUTHEIGHT; + sLabInit.pText = "Edit"; + sLabInit.FontID = WFont; + if (!widgAddLabel(psWScreen, &sLabInit)) + { + return FALSE; + } + + /* Add the close box */ + sButInit.formID = IDED_FORM; + sButInit.id = IDED_CLOSE; + sButInit.style = WBUT_PLAIN; + sButInit.x = ED_WIDTH - ED_GAP - CLOSE_SIZE; + sButInit.y = ED_GAP; + sButInit.width = CLOSE_SIZE; + sButInit.height = CLOSE_SIZE; + sButInit.FontID = WFont; + sButInit.pText = pCloseText; + sButInit.pTip = strresGetString(psStringRes, STR_MISC_CLOSE); + if (!widgAddButton(psWScreen, &sButInit)) + { + return FALSE; + } + return TRUE; +} + + +/* Remove the edit widgets from the widget screen */ +static void intRemoveEdit(void) +{ +// widgEndScreen(psWScreen); + widgDelete(psWScreen, IDED_FORM); +// widgStartScreen(psWScreen); +} + + +/* Get and validate the new map size from the options screen */ +static void intGetMapSize(void) +{ + SDWORD editWidth, editHeight; + STRING aText[WIDG_MAXSTR]; + UDWORD i, tmp, bitCount; + BOOL widthChanged = FALSE, heightChanged = FALSE; + STRING *pStr = widgGetString(psWScreen, IDOPT_MAPWIDTH); + + if (isdigit(*pStr)) + { + // There is a number in the string + sscanf(pStr, "%d", &editWidth); + } + else + { + // No number in the string, restore the old value + editWidth = newMapWidth; + widthChanged = TRUE; + } + + // Get the new height + pStr = widgGetString(psWScreen, IDOPT_MAPHEIGHT); + if (isdigit(*pStr)) + { + // There is a number in the string + sscanf(pStr, "%d", &editHeight); + } + else + { + // No number in the string, restore the old value + editHeight = newMapHeight; + heightChanged = TRUE; + } + + // now validate the sizes + if (editWidth <= 0 || editWidth > MAP_MAXWIDTH) + { + editWidth = newMapWidth; + widthChanged = TRUE; + } + else + { + // Check it is a power of 2 + bitCount = 0; + tmp = editWidth; + for (i = 0; i < 32; i++) + { + if (tmp & 1) + { + bitCount ++; + } + tmp = tmp >> 1; + } + if (bitCount != 1) + { + editWidth = newMapWidth; + widthChanged = TRUE; + } + } + if (editHeight <= 0 || editHeight > MAP_MAXHEIGHT) + { + editHeight = newMapHeight; + heightChanged = TRUE; + } + else + { + // Check it is a power of 2 + bitCount = 0; + tmp = editHeight; + for (i = 0; i < 32; i++) + { + if (tmp & 1) + { + bitCount ++; + } + tmp = tmp >> 1; + } + if (bitCount != 1) + { + editHeight = newMapHeight; + heightChanged = TRUE; + } + } + + // Store the new size + newMapWidth = editWidth; + newMapHeight = editHeight; + + // Syncronise the edit boxes if necessary + if (widthChanged) + { + sprintf(aText, "%d", newMapWidth); + widgSetString(psWScreen, IDOPT_MAPWIDTH, aText); + } + if (heightChanged) + { + sprintf(aText, "%d", newMapHeight); + widgSetString(psWScreen, IDOPT_MAPHEIGHT, aText); + } +} +#endif + + /* Reset the widget screen to just the reticule */ void intResetScreen(BOOL NoAnim) { @@ -1314,7 +1436,7 @@ void intResetScreen(BOOL NoAnim) // calulate the center world coords for a structure stat given // top left tile coords -void intCalcStructCenter(STRUCTURE_STATS *psStats, UDWORD tilex,UDWORD tiley, UDWORD *pcx, UDWORD *pcy) +static void intCalcStructCenter(STRUCTURE_STATS *psStats, UDWORD tilex, UDWORD tiley, UDWORD *pcx, UDWORD *pcy) { SDWORD width, height; @@ -1328,7 +1450,7 @@ void intCalcStructCenter(STRUCTURE_STATS *psStats, UDWORD tilex,UDWORD tiley, UD // Returns TRUE if the widget specified by id should filter input. // -BOOL AllowWidgetIntercept(UDWORD id) +static BOOL AllowWidgetIntercept(UDWORD id) { switch(id) { case IDPOW_POWERBAR_T: @@ -1342,6 +1464,214 @@ BOOL AllowWidgetIntercept(UDWORD id) } +/* Process return codes from the Options screen */ +static void intProcessOptions(UDWORD id) +{ + UDWORD i; + DROID_TEMPLATE *psTempl; + + if (id >= IDOPT_PLAYERSTART && id <= IDOPT_PLAYEREND) + { + widgSetButtonState(psWScreen, IDOPT_PLAYERSTART + selectedPlayer, 0); + selectedPlayer = id - IDOPT_PLAYERSTART; + widgSetButtonState(psWScreen, IDOPT_PLAYERSTART + selectedPlayer, WBUT_LOCK); + } + else + { + switch (id) + { +#ifdef EDIT_OPTIONS + case IDOPT_MAPLOAD: +#ifdef DISP2D + if (ed2dLoadMapFile()) +#endif + { + /* Managed to load so quit the option screen */ + intRemoveOptions(); + intMode = INT_NORMAL; + } + break; + case IDOPT_MAPSAVE: +#ifdef DISP2D + if (ed2dSaveMapFile()) +#endif + { + /* Managed to save so quit the option screen */ + intRemoveOptions(); + intMode = INT_NORMAL; + } + break; + + case IDOPT_MAPNEW: + intGetMapSize(); + if (mapNew(newMapWidth, newMapHeight)) + { + /* Managed to create a new map so quit the option screen */ + intRemoveOptions(); + intMode = INT_NORMAL; + } + break; + case IDOPT_MAPWIDTH: + intGetMapSize(); + break; + case IDOPT_MAPHEIGHT: + intGetMapSize(); + break; + case IDOPT_EDIT: + if (!display3D) + { + intRemoveOptions(); + intAddEdit(); + intMode = INT_EDIT; + } + break; +#endif + /* The add object buttons */ + case IDOPT_DROID: + intRemoveOptions(); + i = 0; + psTempl = apsDroidTemplates[selectedPlayer]; + while ((psTempl != NULL) && (i < MAXTEMPLATES)) + { + apsTemplateList[i] = psTempl; + psTempl = psTempl->psNext; + i++; + } + ppsStatsList = (BASE_STATS**)apsTemplateList; + objMode = IOBJ_MANUFACTURE; + intAddStats(ppsStatsList, i, NULL, NULL); + intMode = INT_EDITSTAT; + editPosMode = IED_NOPOS; +// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); + break; + case IDOPT_STRUCT: + intRemoveOptions(); + for (i = 0; i < numStructureStats && i < MAXSTRUCTURES; i++) + { + apsStructStatsList[i] = asStructureStats + i; + } + ppsStatsList = (BASE_STATS**)apsStructStatsList; + objMode = IOBJ_BUILD; + intAddStats(ppsStatsList, i, NULL, NULL); + intMode = INT_EDITSTAT; + editPosMode = IED_NOPOS; +// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); + break; + case IDOPT_FEATURE: + intRemoveOptions(); + for (i = 0; i < numFeatureStats && i < MAXFEATURES; i++) + { + apsFeatureList[i] = asFeatureStats + i; + } + ppsStatsList = (BASE_STATS**)apsFeatureList; + intAddStats(ppsStatsList, i, NULL, NULL); + intMode = INT_EDITSTAT; + editPosMode = IED_NOPOS; +// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); + break; + /* Close window buttons */ + case IDOPT_CLOSE: + intRemoveOptions(); + intMode = INT_NORMAL; +// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); + break; + /* Ignore these */ + case IDOPT_FORM: + case IDOPT_LABEL: + case IDOPT_MAPFORM: + case IDOPT_MAPLABEL: + case IDOPT_PLAYERFORM: + case IDOPT_PLAYERLABEL: + break; + case IDOPT_SAVEGAME: + /* NO LONGER AVAILABLE HERE - 14/04/98 AB*/ +//#ifdef DEBUG // We need this so that Keith can save maps to import into the editor. PD 13/05/98. +// if (saveGame()) +// { +// intRemoveOptions(); +// intMode = INT_NORMAL; +// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); +// } +//#endif + break; + case IDOPT_LOADGAME: + /* NO LONGER AVAILABLE HERE - 14/04/98 AB + if (loadGame(NULL, FALSE, TRUE)) + { + intRemoveOptions(); + intMode = INT_NORMAL; + widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); + }*/ + break; + default: + ASSERT( FALSE, "intProcessOptions: Unknown return code" ); + break; + } + } +} + + +/* Process return codes from the object placement stats screen */ +static void intProcessEditStats(UDWORD id) +{ + if (id >= IDSTAT_START && id <= IDSTAT_END) + { + /* Clicked on a stat button - need to look for a location for it */ + psPositionStats = ppsStatsList[id - IDSTAT_START]; + /*if it is a structure - need to check there is enough power available + to build */ + if (psPositionStats->ref >= REF_STRUCTURE_START && + psPositionStats->ref < REF_STRUCTURE_START + REF_RANGE) + { + if (!checkPower(selectedPlayer, ((STRUCTURE_STATS*)psPositionStats)->powerToBuild, TRUE)) + { + return; + } + } + /*if it is a template - need to check there is enough power available + to build */ + if (psPositionStats->ref >= REF_TEMPLATE_START && + psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE) + { + if (!checkPower(selectedPlayer, ((DROID_TEMPLATE*)psPositionStats)->powerPoints, TRUE)) + { + return; + } + } + intStartStructPosition(psPositionStats, NULL); + editPosMode = IED_POS; + } + else if (id == IDSTAT_CLOSE) + { + intRemoveStats(); + intStopStructPosition(); + intMode = INT_NORMAL; + objMode = IOBJ_NONE; + } +} + + +#ifdef EDIT_OPTIONS +/* Process return codes from the edit screen */ +static void intProcessEdit(UDWORD id) +{ + switch (id) + { + case IDED_CLOSE: + intRemoveEdit(); + intMode = INT_NORMAL; + break; + case IDED_FORM: + case IDED_LABEL: + break; + default: + ASSERT( FALSE, "intProcessEdit: Unknown return code" ); + break; + } +} +#endif + + /* Run the widgets for the in game interface */ INT_RETVAL intRunWidgets(void) { @@ -1955,112 +2285,7 @@ INT_RETVAL intRunWidgets(void) } -/* Get and validate the new map size from the options screen */ -/*static void intGetMapSize(void) -{ - SDWORD editWidth, editHeight; - char *pStr; - char aText[WIDG_MAXSTR]; - UDWORD i, tmp, bitCount; - BOOL widthChanged=FALSE, heightChanged=FALSE; - - // Get the new width - pStr = widgGetString(psWScreen, IDOPT_MAPWIDTH); - if (isdigit(*pStr)) - { - // There is a number in the string - sscanf(pStr, "%d", &editWidth); - } - else - { - // No number in the string, restore the old value - editWidth = newMapWidth; - widthChanged = TRUE; - } - - // Get the new height - pStr = widgGetString(psWScreen, IDOPT_MAPHEIGHT); - if (isdigit(*pStr)) - { - // There is a number in the string - sscanf(pStr, "%d", &editHeight); - } - else - { - // No number in the string, restore the old value - editHeight = newMapHeight; - heightChanged = TRUE; - } - - // now validate the sizes - if (editWidth <= 0 || editWidth > MAP_MAXWIDTH) - { - editWidth = newMapWidth; - widthChanged = TRUE; - } - else - { - // Check it is a power of 2 - bitCount = 0; - tmp = editWidth; - for(i=0; i<32; i++) - { - if (tmp & 1) - { - bitCount ++; - } - tmp = tmp >> 1; - } - if (bitCount != 1) - { - editWidth = newMapWidth; - widthChanged = TRUE; - } - } - if (editHeight <= 0 || editHeight > MAP_MAXHEIGHT) - { - editHeight = newMapHeight; - heightChanged = TRUE; - } - else - { - // Check it is a power of 2 - bitCount = 0; - tmp = editHeight; - for(i=0; i<32; i++) - { - if (tmp & 1) - { - bitCount ++; - } - tmp = tmp >> 1; - } - if (bitCount != 1) - { - editHeight = newMapHeight; - heightChanged = TRUE; - } - } - - // Store the new size - newMapWidth = editWidth; - newMapHeight = editHeight; - - // Syncronise the edit boxes if necessary - if (widthChanged) - { - sprintf(aText, "%d", newMapWidth); - widgSetString(psWScreen, IDOPT_MAPWIDTH, aText); - } - if (heightChanged) - { - sprintf(aText, "%d", newMapHeight); - widgSetString(psWScreen, IDOPT_MAPHEIGHT, aText); - } -}*/ - - -void intIncrementPlayerNumber(void) +static void intIncrementPlayerNumber(void) { intResetScreen(FALSE); @@ -2074,7 +2299,7 @@ void intIncrementPlayerNumber(void) -void intAddEditDroids(void) +static void intAddEditDroids(void) { UDWORD i; DROID_TEMPLATE *psTempl; @@ -2095,7 +2320,7 @@ void intAddEditDroids(void) } -void intAddEditStructures(void) +static void intAddEditStructures(void) { UDWORD i; @@ -2111,218 +2336,6 @@ void intAddEditStructures(void) } - -/* Process return codes from the Options screen */ -static void intProcessOptions(UDWORD id) -{ - UDWORD i; - DROID_TEMPLATE *psTempl; - - if (id >= IDOPT_PLAYERSTART && - id <= IDOPT_PLAYEREND) - { - widgSetButtonState(psWScreen, IDOPT_PLAYERSTART + selectedPlayer, 0); - selectedPlayer = id - IDOPT_PLAYERSTART; - widgSetButtonState(psWScreen, IDOPT_PLAYERSTART + selectedPlayer, WBUT_LOCK); - } - else - { - switch (id) - { -#ifdef EDIT_OPTIONS - - case IDOPT_MAPLOAD: -#ifdef DISP2D - if (ed2dLoadMapFile()) -#endif - { - /* Managed to load so quit the option screen */ - intRemoveOptions(); - intMode = INT_NORMAL; - } - break; - case IDOPT_MAPSAVE: -#ifdef DISP2D - if (ed2dSaveMapFile()) -#endif - { - /* Managed to save so quit the option screen */ - intRemoveOptions(); - intMode = INT_NORMAL; - } - break; - - case IDOPT_MAPNEW: - intGetMapSize(); - if (mapNew(newMapWidth,newMapHeight)) - { - /* Managed to create a new map so quit the option screen */ - intRemoveOptions(); - intMode = INT_NORMAL; - } - break; - case IDOPT_MAPWIDTH: - intGetMapSize(); - break; - case IDOPT_MAPHEIGHT: - intGetMapSize(); - break; - case IDOPT_EDIT: - if (!display3D) - { - intRemoveOptions(); - intAddEdit(); - intMode = INT_EDIT; - } - break; -#endif - /* The add object buttons */ - case IDOPT_DROID: - intRemoveOptions(); - i=0; - psTempl = apsDroidTemplates[selectedPlayer]; - while ((psTempl != NULL) && (i < MAXTEMPLATES)) - { - apsTemplateList[i] = psTempl; - psTempl=psTempl->psNext; - i++; - } - ppsStatsList = (BASE_STATS **)apsTemplateList; - objMode = IOBJ_MANUFACTURE; - intAddStats(ppsStatsList, i, NULL, NULL); - intMode = INT_EDITSTAT; - editPosMode = IED_NOPOS; -// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); - break; - case IDOPT_STRUCT: - intRemoveOptions(); - for(i=0; i< numStructureStats && i= IDSTAT_START && id <= IDSTAT_END) - { - /* Clicked on a stat button - need to look for a location for it */ - psPositionStats = ppsStatsList[id - IDSTAT_START]; - /*if it is a structure - need to check there is enough power available - to build */ - if (psPositionStats->ref >= REF_STRUCTURE_START && - psPositionStats->ref < REF_STRUCTURE_START + REF_RANGE) - { - if (!checkPower(selectedPlayer, ((STRUCTURE_STATS *)psPositionStats)-> - powerToBuild, TRUE)) - { - return; - } - } - /*if it is a template - need to check there is enough power available - to build */ - if (psPositionStats->ref >= REF_TEMPLATE_START && - psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE) - { - if (!checkPower(selectedPlayer, ((DROID_TEMPLATE *)psPositionStats)-> - powerPoints, TRUE)) - { - return; - } - } - intStartStructPosition(psPositionStats,NULL); - editPosMode = IED_POS; - } - else if (id == IDSTAT_CLOSE) - { - intRemoveStats(); - intStopStructPosition(); - intMode = INT_NORMAL; - objMode = IOBJ_NONE; - } -} - - -#ifdef EDIT_OPTIONS -/* Process return codes from the edit screen */ -static void intProcessEdit(UDWORD id) -{ - switch (id) - { - case IDED_CLOSE: - intRemoveEdit(); - intMode = INT_NORMAL; - break; - case IDED_FORM: - case IDED_LABEL: - break; - default: - ASSERT( FALSE, "intProcessEdit: Unknown return code" ); - break; - } -} -#endif - /* Set the shadow for the PowerBar */ static void intRunPower(void) { @@ -3454,7 +3467,7 @@ void intDisplayWidgets(void) screen_RestartBackDrop(); // Download buffer in system memory to the display back buffer. - iV_DownloadDisplayBuffer(DisplayBuffer); + pie_DownloadDisplayBuffer(DisplayBuffer); // DISP_WIDTH, DISP_HEIGHT); /*Add the radar to the design screen - only if player has HQ*/ @@ -3637,7 +3650,7 @@ BOOL intBuildMode(void) // Just tell the interface the build placement was canceled. // currently only relevant on the Playstation. // -void intBuildCancel(void) +static void intBuildCancel(void) { // nasty crash ... 12-3-99 @@ -3663,6 +3676,132 @@ void intDemolishCancel(void) } } + +//reorder the research facilities so that first built is first in the list +static void orderResearch(void) +{ + BASE_OBJECT *psTemp; + UDWORD i, maxLoop = (UDWORD)(numObjects / 2); + + for (i = 0; i < maxLoop; i++) + { + psTemp = apsObjectList[i]; + apsObjectList[i] = apsObjectList[(numObjects - 1) - i]; + apsObjectList[(numObjects - 1) - i] = psTemp; + } +} + + +// reorder the commanders +static void orderDroids(void) +{ + SDWORD i, j; + BASE_OBJECT *psTemp; + + debug( LOG_NEVER, "orderUnit\n" ); + + // bubble sort on the ID - first built will always be first in the list + for (i = 0; i < MAX_OBJECTS; i++) + { + for(j = i + 1; j < MAX_OBJECTS; j++) + { + if (apsObjectList[i] != NULL && apsObjectList[j] != NULL && + apsObjectList[i]->id > apsObjectList[j]->id) + { + psTemp = apsObjectList[i]; + apsObjectList[i] = apsObjectList[j]; + apsObjectList[j] = psTemp; + } + } + } +} + + +/*puts the selected players factories in order - Standard factories 1-5, then +cyborg factories 1-5 and then Vtol factories 1-5*/ +static void orderFactories(void) +{ + STRUCTURE *psStruct, *psNext; + SDWORD entry = 0; + UDWORD inc = 0, type = FACTORY_FLAG, objectInc = 0; + + ASSERT( numObjects <= NUM_FACTORY_TYPES * MAX_FACTORY, "orderFactories : too many factories!" ); + + //copy the object list into the list to order + memcpy(apsListToOrder, apsObjectList, sizeof(BASE_OBJECT*) * ORDERED_LIST_SIZE); + + //go through the list of structures and extract them in order + while (entry < numObjects) + { + for (psStruct = (STRUCTURE*)apsListToOrder[objectInc]; psStruct != NULL; psStruct = psNext) + { + psNext = (STRUCTURE*)apsListToOrder[++objectInc]; + if ((SDWORD)objectInc >= numObjects) + { + psNext = NULL; + } + + ASSERT( StructIsFactory(psStruct), "orderFactories: structure is not a factory" ); + + if (((FACTORY*)psStruct->pFunctionality)->psAssemblyPoint->factoryInc == inc + AND ((FACTORY*)psStruct->pFunctionality)->psAssemblyPoint->factoryType == type) + { + apsObjectList[entry++] = (BASE_OBJECT*)psStruct; + //quick check that don't end up with more! + if (entry > numObjects) + { + ASSERT( FALSE, "orderFactories: too many objects!" ); + return; + } + break; + } + } + inc++; + if (inc > MAX_FACTORY) + { + inc = 0; + type++; + } + objectInc = 0; + } +} + + +/*order the objects in the bottom bar according to their type*/ +static void orderObjectInterface(void) +{ + + if (apsObjectList == NULL) + { + //no objects so nothing to order! + return; + } + + switch(apsObjectList[0]->type) + { + case OBJ_STRUCTURE: + //if (((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_FACTORY OR + // ((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_CYBORG_FACTORY OR + // ((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_VTOL_FACTORY) + if (StructIsFactory((STRUCTURE *)apsObjectList[0])) + { + orderFactories(); + } + else if (((STRUCTURE *)apsObjectList[0])->pStructureType->type == + REF_RESEARCH) + { + orderResearch(); + } + break; + case OBJ_DROID: + orderDroids(); + default: + //nothing to do as yet! + break; + } +} + + /* Tell the interface a factory has completed building ALL droids */ void intManufactureFinished(STRUCTURE *psBuilding) { @@ -3790,22 +3929,8 @@ UWORD numForms(UDWORD total, UDWORD perForm) } -// Add... -// Droid order button ( always ) -// Transporter button, ( if transporter available ) -// Re-enforcements button, ( if in off world map and re-enforcements available ) -// -// Currently only used on Playstation. -// -BOOL intAddReticuleExtras(void) -{ - - return TRUE; -} - - /* Add the reticule widgets to the widget screen */ -BOOL _intAddReticule(void) +BOOL intAddReticule(void) { if(ReticuleUp == FALSE) { W_FORMINIT sFormInit; @@ -3958,7 +4083,7 @@ BOOL _intAddReticule(void) } -BOOL intReticuleIsUp(void) +static BOOL intReticuleIsUp(void) { return ReticuleUp; } @@ -4043,14 +4168,16 @@ void intSetShadowPower(UDWORD quantity) /* Add the options widgets to the widget screen */ -BOOL _intAddOptions(void) +BOOL intAddOptions(void) { W_FORMINIT sFormInit; W_EDBINIT sEdInit; W_BUTINIT sButInit; W_LABINIT sLabInit; UDWORD player; -// char aText[WIDG_MAXSTR];//, aTip[WIDG_MAXSTR]; +#ifdef EDIT_OPTIONS + char aText[WIDG_MAXSTR]; +#endif // widgEndScreen(psWScreen); @@ -4331,88 +4458,6 @@ BOOL _intAddOptions(void) } -/* Remove the options widgets from the widget screen */ -static void intRemoveOptions(void) -{ -// widgEndScreen(psWScreen); - widgDelete(psWScreen, IDOPT_FORM); -// widgStartScreen(psWScreen); -} - - - -#ifdef EDIT_OPTIONS -/* Add the edit widgets to the widget screen */ -static BOOL intAddEdit(void) -{ - W_FORMINIT sFormInit; - W_LABINIT sLabInit; - W_BUTINIT sButInit; - -// widgEndScreen(psWScreen); - - memset(&sFormInit, 0, sizeof(W_FORMINIT)); - memset(&sLabInit, 0, sizeof(W_LABINIT)); - memset(&sButInit, 0, sizeof(W_BUTINIT)); - - /* Add the edit form */ - sFormInit.formID = 0; - sFormInit.id = IDED_FORM; - sFormInit.style = WFORM_PLAIN; - sFormInit.x = ED_X; - sFormInit.y = ED_Y; - sFormInit.width = ED_WIDTH; - sFormInit.height = ED_HEIGHT; - if (!widgAddForm(psWScreen, &sFormInit)) - { - return FALSE; - } - - /* Add the Option screen label */ - sLabInit.formID = IDED_FORM; - sLabInit.id = IDED_LABEL; - sLabInit.style = WLAB_PLAIN; - sLabInit.x = ED_GAP; - sLabInit.y = ED_GAP; - sLabInit.width = ED_WIDTH; - sLabInit.height = ED_BUTHEIGHT; - sLabInit.pText = "Edit"; - sLabInit.FontID = WFont; - if (!widgAddLabel(psWScreen, &sLabInit)) - { - return FALSE; - } - - /* Add the close box */ - sButInit.formID = IDED_FORM; - sButInit.id = IDED_CLOSE; - sButInit.style = WBUT_PLAIN; - sButInit.x = ED_WIDTH - ED_GAP - CLOSE_SIZE; - sButInit.y = ED_GAP; - sButInit.width = CLOSE_SIZE; - sButInit.height = CLOSE_SIZE; - sButInit.FontID = WFont; - sButInit.pText = pCloseText; - sButInit.pTip = strresGetString(psStringRes, STR_MISC_CLOSE); - if (!widgAddButton(psWScreen, &sButInit)) - { - return FALSE; - } - - return TRUE; -} - - -/* Remove the edit widgets from the widget screen */ -static void intRemoveEdit(void) -{ -// widgEndScreen(psWScreen); - widgDelete(psWScreen, IDED_FORM); -// widgStartScreen(psWScreen); -} -#endif - - /* Add the object screen widgets to the widget screen. * select is a pointer to a function that returns true when the object is * to be added to the screen. @@ -5170,7 +5215,7 @@ static BOOL _intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected, } -static BOOL _intUpdateObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats) +static BOOL intUpdateObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats) { _intAddObjectWindow(psObjects,psSelected,bForceStats); @@ -5497,7 +5542,7 @@ found: // Jump to here if an object is found /* Reset the stats button for an object */ -static void _intSetStats(UDWORD id, BASE_STATS *psStats) +static void intSetStats(UDWORD id, BASE_STATS *psStats) { W_FORMINIT sFormInit; W_BARINIT sBarInit; @@ -5638,7 +5683,7 @@ static void _intSetStats(UDWORD id, BASE_STATS *psStats) } -void intUpdateManufactureLimits(struct _widget *psWidget, struct _w_context *psContext) +static void intUpdateManufactureLimits(struct _widget *psWidget, struct _w_context *psContext) { W_LABEL *Label = (W_LABEL*)psWidget; UDWORD MaxDroids = getMaxDroids(selectedPlayer); @@ -5660,7 +5705,7 @@ void intUpdateManufactureLimits(struct _widget *psWidget, struct _w_context *psC /* Add the stats widgets to the widget screen */ /* If psSelected != NULL it specifies which stat should be hilited psOwner specifies which object is hilighted on the object bar for this stat*/ -static BOOL _intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, +static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, BASE_STATS *psSelected, BASE_OBJECT *psOwner) { W_FORMINIT sFormInit; @@ -6686,6 +6731,12 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats) } +static BOOL intAddObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats) +{ + return _intAddObject(psObjects, psSelected,bForceStats); +} + + /* Add the build widgets to the widget screen */ /* If psSelected != NULL it specifies which droid should be hilited */ static BOOL intAddBuild(DROID *psSelected) @@ -7129,19 +7180,6 @@ void intShowPowerBar(void) } } -//hides the power bar from the display -void intHidePowerBar(void) -{ - //only hides the power bar if the player has requested no power bar - if (!powerBarUp) - { - if (widgGetFromID(psWScreen,IDPOW_POWERBAR_T)) - { - widgHide(psWScreen, IDPOW_POWERBAR_T); - } - } -} - //hides the power bar from the display - regardless of what player requested! void forceHidePowerBar(void) { @@ -7343,7 +7381,7 @@ SDWORD intNumSelectedDroids(UDWORD droidType) } -void intShowReticuleButton(UDWORD id,BOOL Show) +static void intShowReticuleButton(UDWORD id, BOOL Show) { int i; @@ -7502,13 +7540,13 @@ BOOL intCheckReticuleButEnabled(UDWORD id) } -BOOL InterfaceIsUp(UWORD Type) { +static BOOL InterfaceIsUp(UWORD Type) { return ((intMode == INT_OBJECT || intMode == INT_STAT) && objMode == Type); } // Do any maintenance on the interface that's needed when a structure is destroyed. // -void intDestroyStructure(STRUCTURE *psStruct) +static void intDestroyStructure(STRUCTURE *psStruct) { if(psStruct == CurrentStruct) { intInitStructureCycle(); @@ -7518,7 +7556,7 @@ void intDestroyStructure(STRUCTURE *psStruct) // Do any maintenance on the interface that's needed when a droid is destroyed. // -void intDestroyDroid(DROID *psDroid) +static void intDestroyDroid(DROID *psDroid) { if(psDroid == CurrentDroid) { intInitDroidCycle(); @@ -7526,7 +7564,7 @@ void intDestroyDroid(DROID *psDroid) } -void intInitObjectCycle(void) +static void intInitObjectCycle(void) { intInitStructureCycle(); intInitDroidCycle(); @@ -7666,7 +7704,7 @@ enum { }; -UDWORD GetWeaponMajorClass(WEAPON_STATS *psWeapStats) +static UDWORD GetWeaponMajorClass(WEAPON_STATS *psWeapStats) { switch(psWeapStats->weaponSubClass) { case WSC_FLAME: @@ -7726,7 +7764,7 @@ UDWORD GetWeaponMajorClass(WEAPON_STATS *psWeapStats) // Used for selecting similar types of units. // -BOOL DroidTypesMatch(DROID *psDroid1,DROID *psDroid2) +static BOOL DroidTypesMatch(DROID *psDroid1, DROID *psDroid2) { UDWORD Type1 = psDroid1->droidType; UDWORD Type2 = psDroid2->droidType; @@ -7760,7 +7798,7 @@ BOOL DroidTypesMatch(DROID *psDroid1,DROID *psDroid2) // Select all droids of the same type with the same cluster id as // the specified droid, deselects all others. // -BOOL intSelectDroidsInDroidCluster(DROID *psCurDroid) +static BOOL intSelectDroidsInDroidCluster(DROID *psCurDroid) { DROID *psDroid; UWORD NumSelected = 0; @@ -8083,188 +8121,8 @@ void GotoPrevObject(void) #endif - - - - -/*order the objects in the bottom bar according to their type*/ -void orderObjectInterface(void) -{ - - if (apsObjectList == NULL) - { - //no objects so nothing to order! - return; - } - - switch(apsObjectList[0]->type) - { - case OBJ_STRUCTURE: - //if (((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_FACTORY OR - // ((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_CYBORG_FACTORY OR - // ((STRUCTURE *)apsObjectList[0])->pStructureType->type == REF_VTOL_FACTORY) - if (StructIsFactory((STRUCTURE *)apsObjectList[0])) - { - orderFactories(); - } - else if (((STRUCTURE *)apsObjectList[0])->pStructureType->type == - REF_RESEARCH) - { - orderResearch(); - } - break; - case OBJ_DROID: - orderDroids(); - default: - //nothing to do as yet! - break; - } -} - -/*puts the selected players factories in order - Standard factories 1-5, then -cyborg factories 1-5 and then Vtol factories 1-5*/ -void orderFactories(void) -{ - STRUCTURE *psStruct, *psNext; - SDWORD entry; - UDWORD inc, type, objectInc; - - ASSERT( numObjects <= NUM_FACTORY_TYPES * MAX_FACTORY, - "orderFactories : too many factories!" ); - - //copy the object list into the list to order - memcpy(apsListToOrder, apsObjectList, sizeof(BASE_OBJECT *) * ORDERED_LIST_SIZE); - - entry = objectInc = inc = 0; - type = FACTORY_FLAG; - //go through the list of structures and extract them in order - while(entry < numObjects) - { - for(psStruct = (STRUCTURE *)apsListToOrder[objectInc]; psStruct != NULL; - psStruct = psNext) - { - psNext = (STRUCTURE *)apsListToOrder[++objectInc]; - if ((SDWORD)objectInc >= numObjects) - { - psNext = NULL; - } - - ASSERT( StructIsFactory(psStruct), - "orderFactories: structure is not a factory" ); - - if (((FACTORY *)psStruct->pFunctionality)->psAssemblyPoint-> - factoryInc == inc AND - ((FACTORY *)psStruct->pFunctionality)->psAssemblyPoint-> - factoryType == type) - { - apsObjectList[entry++] = (BASE_OBJECT *)psStruct; - //quick check that don't end up with more! - if (entry > numObjects) - { - ASSERT( FALSE, "orderFactories: too many objects!" ); - return; - } - break; - } - } - inc++; - if (inc > MAX_FACTORY) - { - inc = 0; - type++; - } - objectInc = 0; - } -} - -//reorder the research facilities so that first built is first in the list -void orderResearch(void) -{ - BASE_OBJECT *psTemp; - UDWORD i, maxLoop; - - maxLoop = (UDWORD)(numObjects/2); - for (i=0; i < maxLoop; i++) - { - psTemp = apsObjectList[i]; - apsObjectList[i] = apsObjectList[(numObjects-1)-i]; - apsObjectList[(numObjects-1)-i] = psTemp; - } -} - - -// reorder the commanders -void orderDroids(void) -{ - SDWORD i,j; - BASE_OBJECT *psTemp; - - debug( LOG_NEVER, "orderUnit\n" ); - - // bubble sort on the ID - first built will always be first in the list - for(i=0; iid > apsObjectList[j]->id) - { - psTemp = apsObjectList[i]; - apsObjectList[i] = apsObjectList[j]; - apsObjectList[j] = psTemp; - } - } - } -} - - //access function for selected object in the interface BASE_OBJECT * getCurrentSelected(void) { return psObjSelected; } - - -// -// Stack friendly wrappers for those greedy interface initialisation functions. -// - -BOOL intAddOptions(void) -{ - return _intAddOptions(); -} - - -BOOL intAddReticule(void) -{ - return _intAddReticule(); -} - - -static BOOL intAddObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats) -{ - - return _intAddObject(psObjects, psSelected,bForceStats); -} - - -static BOOL intUpdateObject(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,BOOL bForceStats) -{ - - return _intUpdateObject(psObjects, psSelected,bForceStats); -} - - -static void intSetStats(UDWORD id, BASE_STATS *psStats) -{ - - _intSetStats(id, psStats); -} - - -static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, - BASE_STATS *psSelected, BASE_OBJECT *psOwner) -{ - - return _intAddStats(ppsStatsList, numStats, psSelected, psOwner); -} diff --git a/src/hci.h b/src/hci.h index b66db7762..3ecb74485 100644 --- a/src/hci.h +++ b/src/hci.h @@ -6,13 +6,12 @@ #ifndef _hci_h #define _hci_h +#include "lib/ivis_common/pieclip.h" #include "lib/widget/widget.h" -#include "message.h" #include "cdspan.h" -#include "lib/ivis_common/pieclip.h" - -//#include "intimage.h" +#include "csnap.h" +#include "message.h" // store the objects that are being used for the object bar #define MAX_OBJECTS 15//10 we need at least 15 for the 3 different types of factory @@ -306,6 +305,7 @@ as big as Pie View in Research Msg now*/ /* pointer to hold the imd to use for a new template in the design screen */ extern iIMDShape *pNewDesignIMD; +extern CURSORSNAP InterfaceSnap; extern char *DisplayBuffer; extern UDWORD displayBufferSize; diff --git a/src/ingameop.c b/src/ingameop.c index ba85869c6..cb7230a9f 100644 --- a/src/ingameop.c +++ b/src/ingameop.c @@ -9,40 +9,31 @@ #include "lib/framework/frame.h" #include "lib/framework/strres.h" #include "lib/widget/widget.h" +#include "lib/netplay/netplay.h" +#include "lib/ivis_common/piestate.h" // for getrendertype +#include "lib/ivis_common/rendmode.h" +#include "lib/sound/audio.h" // for sound. +#include "lib/sound/cdaudio.h" +#include "lib/sound/mixer.h" + #include "display3d.h" #include "intdisplay.h" #include "hci.h" // for wFont def.& intmode. #include "loop.h" #include "text.h" -#include "lib/ivis_common/piestate.h" // for getrendertype #include "resource.h" -//#include "display.h" // for gammaValue. #include "frontend.h" // for textdisplay function #include "loadsave.h" // for textdisplay function #include "console.h" // to add console message - #include "scriptextern.h" // for tutorial -#include "lib/ivis_common/rendmode.h" #include "keybind.h" - -#include "lib/sound/audio.h" // for sound. - -#include "lib/sound/cdaudio.h" -#include "lib/sound/mixer.h" #include "multiplay.h" - - #include "csnap.h" #include "ingameop.h" #include "mission.h" #include "transporter.h" -#include "lib/netplay/netplay.h" +#include "winmain.h" - -extern char SaveGamePath[]; - -//extern W_SCREEN *psWScreen; -extern CURSORSNAP InterfaceSnap; extern void addText(int FontID,UDWORD FormID,UDWORD id, UDWORD PosX, UDWORD PosY, char *txt, UDWORD attachID,BOOL *State); //status bools.(for hci.h) diff --git a/src/ingameop.h b/src/ingameop.h index 829b61ecc..ddd08fdeb 100644 --- a/src/ingameop.h +++ b/src/ingameop.h @@ -14,7 +14,6 @@ extern void intProcessInGameOptions (UDWORD); // status bools. extern BOOL ClosingInGameOp; extern BOOL InGameOpUp; -extern BOOL bSubtitles; // //////////////////////////////////////////////////////////////////////////// // defines diff --git a/src/init.c b/src/init.c index 90f65c948..9131bce43 100644 --- a/src/init.c +++ b/src/init.c @@ -12,98 +12,68 @@ #include "lib/framework/frameresource.h" #include "lib/framework/input.h" #include "lib/framework/strres.h" - -#include "init.h" -#include "mechanics.h" -#include "objects.h" -#include "display.h" -#include "ai.h" -#include "astar.h" -#include "disp2d.h" -#include "hci.h" -#include "lib/sound/audio.h" -#include "csnap.h" -#include "wrappers.h" -#include -#include "game.h" -#include "lib/gamelib/animobj.h" #include "lib/gamelib/ani.h" -#include "drive.h" -#include "bucket3d.h" -#include "message.h" -#include "data.h" -#include "raycast.h" -#include "text.h" -#include "console.h" - -#include "lib/ivis_common/piedef.h" -#include "lib/ivis_common/piestate.h" - -#include "configuration.h" #include "lib/ivis_common/piemode.h" -#include "lib/ivis_common/tex.h" - -#include "resource.h" +#include "lib/ivis_common/piestate.h" #include "lib/ivis_common/rendmode.h" -#include "lib/ivis_common/ivi.h" -#include "group.h" -#include "wrappers.h" -#include "display3d.h" - -#include "atmos.h" -#include "environ.h" -#include "warzoneconfig.h" -#include "multiplay.h" - +#include "lib/ivis_common/tex.h" +#include "lib/netplay/netplay.h" #include "lib/script/script.h" +#include "lib/sound/cdaudio.h" + +#include "advvis.h" +#include "astar.h" +#include "atmos.h" +#include "audio_id.h" +#include "cluster.h" +#include "cmddroid.h" +#include "component.h" +#include "configuration.h" +#include "console.h" +#include "data.h" +#include "display.h" +#include "display3d.h" +#include "drive.h" +#include "edit3d.h" +#include "effects.h" +#include "environ.h" +#include "formation.h" +#include "fpath.h" +#include "frend.h" +#include "frontend.h" +#include "game.h" +#include "gateway.h" +#include "hci.h" +#include "init.h" +#include "intdisplay.h" +#include "keymap.h" +#include "levels.h" +#include "lighting.h" +#include "loop.h" +#include "mapgrid.h" +#include "mechanics.h" +#include "miscimd.h" +#include "mission.h" +#include "modding.h" +#include "multigifts.h" +#include "multiplay.h" +#include "projectile.h" +#include "radar.h" +#include "raycast.h" +#include "resource.h" +#include "scriptextern.h" #include "scripttabs.h" #include "scriptvals.h" -#include "miscimd.h" -#include "keymap.h" -#include "edit3d.h" -#include "component.h" -#include "fpath.h" +#include "text.h" +#include "transporter.h" +#include "warzoneconfig.h" #include "winmain.h" +#include "wrappers.h" #ifdef ARROWS #include "arrow.h" #endif -#include "texture.h" - -#include "frend.h" - -#include "intimage.h" -#include "power.h" -#include "deliverance.h" -#include "radar.h" -#include "audio_id.h" -#include "intdisplay.h" -#include "formationdef.h" -#include "formation.h" - -#include "lib/sound/cdaudio.h" -#include "lib/sound/mixer.h" -#include "advvis.h" - -#include "mission.h" -#include "transporter.h" -#include "projectile.h" -#include "levels.h" -#include "loop.h" -#include "cmddroid.h" -#include "effects.h" -#include "scriptextern.h" -#include "mapgrid.h" -#include "cluster.h" -#include "gateway.h" -#include "lighting.h" - -#include "modding.h" - -#include "lib/netplay/netplay.h" -#include "multigifts.h" - extern char UserMusicPath[]; extern void statsInitVars(void); @@ -682,11 +652,6 @@ IMAGEFILE *FrontImages; BOOL DirectControl = FALSE; - -extern int FEFont; -//extern int FEBigFont; - - // Each module in the game should have a call from here to initialise // any globals and statics to there default values each time the game // or frontend restarts. diff --git a/src/init.h b/src/init.h index 154ae3f4b..919f3bad0 100644 --- a/src/init.h +++ b/src/init.h @@ -7,6 +7,8 @@ #ifndef _init_h #define _init_h +#include "lib/ivis_common/ivisdef.h" + // the size of the file loading buffer #define FILE_LOAD_BUFF_SIZE (1024*1024) @@ -58,5 +60,7 @@ extern BLOCK_HEAP *psMapHeap; // the block heap for the pre WRF data extern BLOCK_HEAP *psMissionHeap; +extern IMAGEFILE *FrontImages; + #endif diff --git a/src/intdisplay.h b/src/intdisplay.h index 9ab95f078..41d45664d 100644 --- a/src/intdisplay.h +++ b/src/intdisplay.h @@ -175,6 +175,8 @@ void intUpdateCommandFact(struct _widget *psWidget, struct _w_context *psContext void intUpdateProgressBar(struct _widget *psWidget, struct _w_context *psContext); +void intUpdateOptionText(struct _widget *psWidget, struct _w_context *psContext); + void intUpdateQuantity(struct _widget *psWidget, struct _w_context *psContext); //callback to display the factory number extern void intAddFactoryInc(struct _widget *psWidget, struct _w_context *psContext); diff --git a/src/intelmap.c b/src/intelmap.c index 25dd5b9a5..89550e4ca 100644 --- a/src/intelmap.c +++ b/src/intelmap.c @@ -46,7 +46,6 @@ #include "csnap.h" -extern CURSORSNAP InterfaceSnap; #define NO_VIDEO diff --git a/src/intorder.c b/src/intorder.c index b17eff9f2..0c410afed 100644 --- a/src/intorder.c +++ b/src/intorder.c @@ -428,7 +428,7 @@ BOOL intUpdateOrder(DROID *psDroid) // //changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99 //BOOL _intAddOrder(DROID *Droid) -BOOL _intAddOrder(BASE_OBJECT *psObj) +BOOL intAddOrder(BASE_OBJECT *psObj) { W_FORMINIT sFormInit; W_BUTINIT sButInit; @@ -854,7 +854,7 @@ void intRunOrder(void) // Process the droid order screen. // -void _intProcessOrder(UDWORD id) +void intProcessOrder(UDWORD id) { UWORD i; UWORD OrdIndex; @@ -1021,23 +1021,6 @@ BOOL intRefreshOrder(void) } -//changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99 -//BOOL intAddOrder(DROID *Droid) -BOOL intAddOrder(BASE_OBJECT *psObj) -{ - - //changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99 - //return _intAddOrder(Droid); - return _intAddOrder(psObj); -} - -void intProcessOrder(UDWORD id) -{ - - _intProcessOrder(id); -} - - // Remove the droids order screen with animation. // void intRemoveOrder(void) diff --git a/src/keyedit.c b/src/keyedit.c index 2ec456941..b5363a859 100644 --- a/src/keyedit.c +++ b/src/keyedit.c @@ -20,6 +20,7 @@ #include "text.h" #include "lib/ivis_common/textdraw.h" #include "hci.h" +#include "init.h" #include "loadsave.h" #include "keymap.h" #include "csnap.h" @@ -57,8 +58,6 @@ // //////////////////////////////////////////////////////////////////////////// // variables -extern IMAGEFILE *FrontImages; -extern CURSORSNAP InterfaceSnap; static KEY_MAPPING *selectedKeyMap; // //////////////////////////////////////////////////////////////////////////// diff --git a/src/main.c b/src/main.c index 4b3ddf566..23874ded1 100644 --- a/src/main.c +++ b/src/main.c @@ -2,52 +2,43 @@ * main.c * */ -#include "lib/framework/frame.h" -#include "lib/framework/configfile.h" + +#include +#include +#include /* For SHGetFolderPath */ #ifdef WIN32 # include #endif // WIN32 -#include -#include -#include - -#include "lib/widget/widget.h" -#include "lib/script/script.h" -#include "init.h" -#include "loop.h" -#include "objects.h" -#include "display.h" -#include "lib/ivis_common/piestate.h" +#include "lib/framework/frame.h" +#include "lib/framework/configfile.h" #include "lib/gamelib/gtime.h" +#include "lib/ivis_common/piestate.h" +#include "lib/ivis_common/rendmode.h" +#include "lib/ivis_opengl/screen.h" +#include "lib/netplay/netplay.h" +#include "lib/script/script.h" +#include "lib/widget/widget.h" + +#include "clparse.h" +#include "configuration.h" +#include "display.h" +#include "frontend.h" +#include "game.h" +#include "init.h" +#include "levels.h" +#include "lighting.h" +#include "loadsave.h" +#include "loop.h" +#include "modding.h" +#include "multiplay.h" +#include "research.h" +#include "seqdisp.h" +#include "warzoneconfig.h" #include "winmain.h" #include "wrappers.h" -#include "scripttabs.h" -#include "deliverance.h" -#include "frontend.h" -#include "seqdisp.h" -#include "lib/sound/audio.h" -#include "console.h" -#include "lib/ivis_common/rendmode.h" -#include "lib/ivis_common/piemode.h" -#include "levels.h" -#include "research.h" -#include "warzoneconfig.h" -#include "clparse.h" -#include "cdspan.h" -#include "configuration.h" -#include "multiplay.h" -#include "lib/netplay/netplay.h" -#include "loadsave.h" -#include "game.h" -#include "lighting.h" -#include "lib/sound/mixer.h" -// FIXME Direct iVis implementation include! -#include "lib/ivis_opengl/screen.h" - -#include "modding.h" #ifndef DEFAULT_DATADIR # define DEFAULT_DATADIR "/usr/share/warzone2100/" diff --git a/src/mission.c b/src/mission.c index b096513ae..a015af894 100644 --- a/src/mission.c +++ b/src/mission.c @@ -31,6 +31,7 @@ #include "frontend.h" // for displaytextoption. #include "csnap.h" // cursor snapping #include "intdisplay.h" +#include "winmain.h" #include "display.h" #include "loadsave.h" #include "lib/script/script.h" @@ -71,7 +72,6 @@ #include "texture.h" -extern CURSORSNAP InterfaceSnap; //DEFINES************** //#define IDTIMER_FORM 11000 // has to be in the header..boohoo //#define IDTIMER_DISPLAY 11001 @@ -150,10 +150,6 @@ extern CURSORSNAP InterfaceSnap; #define NOT_PLAYED_ACTIVATED 0x20 -//EXTERNALS************* - -extern char SaveGamePath[]; - MISSION mission; BOOL offWorldKeepLists; diff --git a/src/multiint.c b/src/multiint.c index aa97bf8a3..bbddea342 100644 --- a/src/multiint.c +++ b/src/multiint.c @@ -78,8 +78,6 @@ extern char MultiForcesPath[255]; extern char MultiCustomMapsPath[255]; extern char MultiPlayersPath[255]; -extern IMAGEFILE *FrontImages; -extern CURSORSNAP InterfaceSnap; extern BOOL bSendingMap; extern void intDisplayTemplateButton(struct _widget *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours); @@ -122,8 +120,6 @@ static UDWORD hideTime=0; #define DEFAULTSKIRMISHMAP "Sk-Rush" -extern int FEFont; - /// end of globals. // //////////////////////////////////////////////////////////////////////////// // Function protos diff --git a/src/multilimit.c b/src/multilimit.c index a03a2d3ca..99e191d24 100644 --- a/src/multilimit.c +++ b/src/multilimit.c @@ -38,8 +38,6 @@ // //////////////////////////////////////////////////////////////////////////// // externs -extern IMAGEFILE *FrontImages; -extern CURSORSNAP InterfaceSnap; extern void intDisplayPlainForm (struct _widget *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours); diff --git a/src/multimenu.c b/src/multimenu.c index ea46cf2e7..42a21c19c 100644 --- a/src/multimenu.c +++ b/src/multimenu.c @@ -21,6 +21,7 @@ #include "objmem.h" //for droid lists. #include "component.h" // for disaplycomponentobj. #include "hci.h" // for wFont def.& intmode. +#include "init.h" //#include "intfac.h" // for images. #include "power.h" #include "loadsave.h" // for drawbluebox @@ -47,9 +48,6 @@ W_SCREEN *psRScreen; // requester stuff. extern char MultiCustomMapsPath[255]; -extern CURSORSNAP InterfaceSnap; -//extern W_SCREEN *psWScreen; -extern IMAGEFILE *FrontImages; extern void displayMultiBut(struct _widget *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours); BOOL MultiMenuUp = FALSE; diff --git a/src/scriptfuncs.c b/src/scriptfuncs.c index afd965c75..0ea3098e4 100644 --- a/src/scriptfuncs.c +++ b/src/scriptfuncs.c @@ -1243,7 +1243,6 @@ BOOL scrApproxRoot(void) } // ----------------------------------------------------------------------------------------- -extern void intShowReticuleButton(UDWORD id,BOOL Show); // Add a reticule button to the interface BOOL scrAddReticuleButton(void) { diff --git a/src/structuredef.h b/src/structuredef.h index 4d29bfbb0..8ebbdd394 100644 --- a/src/structuredef.h +++ b/src/structuredef.h @@ -7,6 +7,10 @@ #ifndef _structuredef_h #define _structuredef_h +#include "lib/gamelib/animobj.h" +#include "statsdef.h" +#include "weapons.h" + #define NUM_FACTORY_MODULES 2 #define NUM_RESEARCH_MODULES 4 #define NUM_POWER_MODULES 4 diff --git a/src/transporter.c b/src/transporter.c index 65d048c6a..598381edd 100644 --- a/src/transporter.c +++ b/src/transporter.c @@ -40,8 +40,6 @@ #include "csnap.h" -extern CURSORSNAP InterfaceSnap; - //#define IDTRANS_FORM 9000 //The Transporter base form #define IDTRANS_TABFORM 9001 //The Transporter tabbed form #define IDTRANS_CLOSE 9002 //The close button icon diff --git a/src/warcam.c b/src/warcam.c index 46d61c8c8..4ae09bcd0 100644 --- a/src/warcam.c +++ b/src/warcam.c @@ -38,7 +38,6 @@ #endif - #define MODFRACT(value,mod) \ while((value) < 0) { (value) += (mod); } \ while((value) > (mod)) { (value) -= (mod); } @@ -77,43 +76,6 @@ SDWORD presAvAngle = 0;; #define MINCAMROTX -20 -/* Function Prototypes... */ -/* Firstly for tracking position */ -void updateCameraAcceleration ( UBYTE update ); -void updateCameraVelocity ( UBYTE update ); -void updateCameraPosition ( UBYTE update ); - -/* And now, rotation */ -void updateCameraRotationAcceleration( UBYTE update ); -void updateCameraRotationVelocity( UBYTE update ); -void updateCameraRotationPosition( UBYTE update ); - -void initWarCam ( void ); -BOOL processWarCam ( void ); -void setWarCamActive ( BOOL status ); -BASE_OBJECT *camFindTarget ( void ); -void camAllignWithTarget ( BASE_OBJECT *psTarget ); -BOOL camTrackCamera ( void ); -void camSwitchOff ( void ); -BOOL getWarCamStatus ( void ); -void camToggleInfo ( void ); -//void setUpRadarTarget ( SDWORD x, SDWORD y ); -void setUpRadarTarget ( SDWORD x, SDWORD y ); -void requestRadarTrack ( SDWORD x, SDWORD y ); -BOOL getRadarTrackingStatus ( void ); -void dispWarCamLogo ( void ); -UDWORD getPositionMagnitude ( void ); -UDWORD getRotationMagnitude ( void ); -void toggleRadarAllignment ( void ); -void camInformOfRotation ( iVector *rotation ); -void processLeaderSelection ( void ); -SDWORD getAverageTrackAngle ( BOOL bCheckOnScreen ); -SDWORD getGroupAverageTrackAngle ( UDWORD groupNumber, BOOL bCheckOnScreen ); -void getTrackingConcerns ( SDWORD *x,SDWORD *y, SDWORD *z ); -void getGroupTrackingConcerns ( SDWORD *x,SDWORD *y, SDWORD *z,UDWORD groupNumber, BOOL bOnScreen ); - -UDWORD getNumDroidsSelected ( void ); - /* These used to be #defines but they're variable now as it may be necessary to allow the player to customise tracking speed? Jim? */ @@ -177,6 +139,222 @@ static void CancelWarCam(void) } +/* Static function that switches off tracking - and might not be desirable? - Jim?*/ +static void camSwitchOff( void ) +{ + /* Restore the angles */ +// player.r.x = trackingCamera.oldView.r.x; + player.r.z = trackingCamera.oldView.r.z; + + /* And height */ + /* Is this desirable??? */ +// player.p.y = trackingCamera.oldView.p.y; + + /* Restore distance */ + setViewDistance(trackingCamera.oldDistance); +} + + +#define LEADER_LEFT 1 +#define LEADER_RIGHT 2 +#define LEADER_UP 3 +#define LEADER_DOWN 4 +#define LEADER_STATIC 5 + +static void processLeaderSelection( void ) +{ + DROID *psDroid; + DROID *psPresent; + DROID *psNew = NULL; + UDWORD leaderClass; + BOOL bSuccess; + UDWORD dif; + UDWORD bestSoFar; + + if (demoGetStatus()) + { + return; + } + + if (getWarCamStatus()) + { + /* Only do if we're tracking a droid */ + if (trackingCamera.target->type != OBJ_DROID) + { + return; + } + } + else + { + return; + } + + /* Don't do if we're driving?! */ + if (getDrivingStatus()) + { + return; + } + + psPresent = (DROID*)trackingCamera.target; + + if (keyPressed(KEY_LEFTARROW)) + { + leaderClass = LEADER_LEFT; + } + + else if (keyPressed(KEY_RIGHTARROW)) + { + leaderClass = LEADER_RIGHT; + } + + else if (keyPressed(KEY_UPARROW)) + { + leaderClass = LEADER_UP; + } + + else if (keyPressed(KEY_DOWNARROW)) + { + leaderClass = LEADER_DOWN; + } + else + { + leaderClass = LEADER_STATIC; + } + + bSuccess = FALSE; + bestSoFar = UDWORD_MAX; + + switch (leaderClass) + { + case LEADER_LEFT: + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is it even on the sscreen? */ + if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid != psPresent) + { + if (psDroid->sDisplay.screenX < psPresent->sDisplay.screenX) + { + dif = psPresent->sDisplay.screenX - psDroid->sDisplay.screenX; + if (dif < bestSoFar) + { + bestSoFar = dif; + bSuccess = TRUE; + psNew = psDroid; + } + } + } + } + break; + case LEADER_RIGHT: + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is it even on the sscreen? */ + if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid != psPresent) + { + if (psDroid->sDisplay.screenX > psPresent->sDisplay.screenX) + { + dif = psDroid->sDisplay.screenX - psPresent->sDisplay.screenX; + if (dif < bestSoFar) + { + bestSoFar = dif; + bSuccess = TRUE; + psNew = psDroid; + } + } + } + } + break; + case LEADER_UP: + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is it even on the sscreen? */ + if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid != psPresent) + { + if (psDroid->sDisplay.screenY < psPresent->sDisplay.screenY) + { + dif = psPresent->sDisplay.screenY - psDroid->sDisplay.screenY; + if (dif < bestSoFar) + { + bestSoFar = dif; + bSuccess = TRUE; + psNew = psDroid; + } + } + } + } + break; + case LEADER_DOWN: + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is it even on the sscreen? */ + if (DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid != psPresent) + { + if (psDroid->sDisplay.screenY > psPresent->sDisplay.screenY) + { + dif = psDroid->sDisplay.screenY - psPresent->sDisplay.screenY; + if (dif < bestSoFar) + { + bestSoFar = dif; + bSuccess = TRUE; + psNew = psDroid; + } + } + } + } + break; + case LEADER_STATIC: + break; + } + if (bSuccess) + { + camAllignWithTarget((BASE_OBJECT*)psNew); + } +} + + +/* Sets up the dummy target for the camera */ +static void setUpRadarTarget(SDWORD x, SDWORD y) +{ + radarTarget.x = x; + radarTarget.y = y; + + if ((x < 0) OR (y < 0) OR (x > (SDWORD)((mapWidth - 1) * TILE_UNITS)) + OR (y > (SDWORD)((mapHeight - 1) * TILE_UNITS))) + { + radarTarget.z = 128 * ELEVATION_SCALE; + } + else + { + radarTarget.z = map_Height(x,y); + } + radarTarget.direction = (UWORD)calcDirection(player.p.x, player.p.z, x, y); + radarTarget.pitch = 0; + radarTarget.roll = 0; + radarTarget.type = OBJ_TARGET; + radarTarget.died = 0; +} + + +/* Attempts to find the target for the camera to track */ +static BASE_OBJECT *camFindTarget(void) +{ + /* See if we can find a selected droid. If there's more than one + droid selected for the present player, then we track the oldest + one. */ + + if (bRadarTrackingRequested) + { + setUpRadarTarget(radarX, radarY); + bRadarTrackingRequested = FALSE; + return(&radarTarget); + } + + return camFindDroidTarget(); +} + + +BOOL camTrackCamera(void); + /* Updates the camera position/angle along with the object movement */ BOOL processWarCam( void ) { @@ -350,24 +528,6 @@ BASE_OBJECT *camFindDroidTarget(void) } - -/* Attempts to find the target for the camera to track */ -BASE_OBJECT *camFindTarget(void) -{ - /* See if we can find a selected droid. If there's more than one - droid selected for the present player, then we track the oldest - one. */ - - if(bRadarTrackingRequested) - { - setUpRadarTarget(radarX, radarY); - bRadarTrackingRequested = FALSE; - return(&radarTarget); - } - - return camFindDroidTarget(); -} - //----------------------------------------------------------------------------------- UDWORD getTestAngle(void) { @@ -420,10 +580,149 @@ void camAllignWithTarget(BASE_OBJECT *psTarget) OldViewValid = TRUE; } + //----------------------------------------------------------------------------------- +static SDWORD getAverageTrackAngle( BOOL bCheckOnScreen ) +{ + DROID *psDroid; + FRACT xShift, yShift; + FRACT xTotal = 0.0, yTotal = 0.0; + FRACT averageAngleFloat = 0; + SDWORD droidCount = 0, averageAngle = 0; + SDWORD retVal; + + /* Got thru' all droids */ + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is he worth selecting? */ + if (psDroid->selected) + { + if (bCheckOnScreen ? droidOnScreen(psDroid, DISP_WIDTH / 6) : TRUE) + { + droidCount++; + averageAngle += psDroid->direction; + xShift = trigSin(psDroid->direction); + yShift = trigCos(psDroid->direction); + xTotal += xShift; + yTotal += yShift; + } + } + } + if (droidCount) + { + retVal = (averageAngle / droidCount); + averageAngleFloat = (float)RAD_TO_DEG(atan2(xTotal, yTotal)); + } + else + { + retVal = 0; + } + // FIXME: Should we return 0 when retVal is 0? + presAvAngle = MAKEINT(averageAngleFloat);//retVal; + return presAvAngle; +} +//----------------------------------------------------------------------------------- +static SDWORD getGroupAverageTrackAngle(UDWORD groupNumber, BOOL bCheckOnScreen) +{ + DROID *psDroid; + FRACT xShift, yShift; + FRACT xTotal = 0.0, yTotal = 0.0; + FRACT averageAngleFloat = 0; + SDWORD droidCount = 0, averageAngle = 0; + SDWORD retVal; + /* Got thru' all droids */ + for (psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + /* Is he worth considering? */ + if (psDroid->group == groupNumber) + { + if (bCheckOnScreen ? droidOnScreen(psDroid, DISP_WIDTH / 6) : TRUE) + { + droidCount++; + averageAngle += psDroid->direction; + xShift = trigSin(psDroid->direction); + yShift = trigCos(psDroid->direction); + xTotal += xShift; + yTotal += yShift; + } + } + } + if (droidCount) + { + retVal = (averageAngle / droidCount); + averageAngleFloat = RAD_TO_DEG(atan2(xTotal, yTotal)); + } + else + { + retVal = 0; + } + // FIXME: Return 0 when retVal is 0? + presAvAngle = MAKEINT(averageAngleFloat);//retVal; + return presAvAngle; +} + + +//----------------------------------------------------------------------------------- +static void getTrackingConcerns(SDWORD *x, SDWORD *y, SDWORD *z) +{ + SDWORD xTotals = 0, yTotals = 0, zTotals = 0; + DROID *psDroid; + UDWORD count; + + for (count = 0, psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + if (psDroid->selected) + { + if (droidOnScreen(psDroid, DISP_WIDTH / 4)) + { + count++; + xTotals += psDroid->x; + yTotals += psDroid->z; // note the flip + zTotals += psDroid->y; + } + } + } + + if (count) // necessary!!!!!!! + { + *x = xTotals / count; + *y = yTotals / count; + *z = zTotals / count; + } +} + + +//----------------------------------------------------------------------------------- +static void getGroupTrackingConcerns(SDWORD *x, SDWORD *y, SDWORD *z, UDWORD groupNumber, BOOL bOnScreen) +{ + SDWORD xTotals = 0, yTotals = 0, zTotals = 0; + DROID *psDroid; + UDWORD count; + + for (count = 0, psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) + { + if (psDroid->group == groupNumber) + { + if (bOnScreen ? droidOnScreen(psDroid, DISP_WIDTH / 4) : TRUE) + { + count++; + xTotals += psDroid->x; + yTotals += psDroid->z; // note the flip + zTotals += psDroid->y; + } + } + } + + if (count) // necessary!!!!!!! + { + *x = xTotals / count; + *y = yTotals / count; + *z = zTotals / count; + } +} //----------------------------------------------------------------------------------- @@ -465,7 +764,7 @@ in the case of location and degrees of arc in the case of rotation. //----------------------------------------------------------------------------------- -void updateCameraAcceleration(UBYTE update) +static void updateCameraAcceleration(UBYTE update) { FRACT separation; SDWORD realPos; @@ -625,7 +924,7 @@ SDWORD angle; //----------------------------------------------------------------------------------- -void updateCameraVelocity( UBYTE update ) +static void updateCameraVelocity( UBYTE update ) { //UDWORD frameTime; FRACT fraction; @@ -656,7 +955,7 @@ FRACT fraction; //----------------------------------------------------------------------------------- -void updateCameraPosition(UBYTE update) +static void updateCameraPosition(UBYTE update) { //UDWORD frameTime; BOOL bFlying; @@ -709,7 +1008,7 @@ PROPULSION_STATS *psPropStats; //----------------------------------------------------------------------------------- /* Calculate the acceleration that the camera spins around at */ -void updateCameraRotationAcceleration( UBYTE update ) +static void updateCameraRotationAcceleration( UBYTE update ) { SDWORD worldAngle; FRACT separation; @@ -872,7 +1171,7 @@ SDWORD xPos,yPos,zPos; //----------------------------------------------------------------------------------- /* Calculate the velocity that the camera spins around at - just add previously calculated acceleration */ -void updateCameraRotationVelocity( UBYTE update ) +static void updateCameraRotationVelocity( UBYTE update ) { //UDWORD frameTime; FRACT fraction; @@ -897,7 +1196,7 @@ FRACT fraction; //----------------------------------------------------------------------------------- /* Move the camera around by adding the velocity */ -void updateCameraRotationPosition( UBYTE update ) +static void updateCameraRotationPosition( UBYTE update ) { //UDWORD frameTime; FRACT fraction; @@ -936,6 +1235,35 @@ SDWORD yPos; return(retVal); } + +/* Returns how far away we are from our goal in a radar track */ +static UDWORD getPositionMagnitude( void ) +{ + iVector dif; + UDWORD val; + + dif.x = abs(player.p.x - oldPosition.x); + dif.y = abs(player.p.y - oldPosition.y); + dif.z = abs(player.p.z - oldPosition.z); + val = (dif.x * dif.x) + (dif.y * dif.y) + (dif.z * dif.z); + return val; +} + + +static UDWORD getRotationMagnitude( void ) +{ + iVector dif; + UDWORD val; + + dif.x = abs(player.r.x - oldRotation.x); + dif.y = abs(player.r.y - oldRotation.y); + dif.z = abs(player.r.z - oldRotation.z); + val = (dif.x * dif.x) + (dif.y * dif.y) + (dif.z * dif.z); + return val; +} + + +/* Returns how far away we are from our goal in rotation */ /* Updates the viewpoint according to the object being tracked */ BOOL camTrackCamera( void ) { @@ -1087,161 +1415,6 @@ BOOL bFlying; return(TRUE); } //----------------------------------------------------------------------------------- -#define LEADER_LEFT 1 -#define LEADER_RIGHT 2 -#define LEADER_UP 3 -#define LEADER_DOWN 4 -#define LEADER_STATIC 5 - -void processLeaderSelection( void ) -{ -DROID *psDroid; -DROID *psPresent; -DROID *psNew=NULL; -UDWORD leaderClass; -BOOL bSuccess; -UDWORD dif; -UDWORD bestSoFar; - - if(demoGetStatus()) - { - return; - } - - if(getWarCamStatus()) - { - /* Only do if we're tracking a droid */ - if(trackingCamera.target->type != OBJ_DROID) - { - return; - } - } - else - { - return; - } - - /* Don't do if we're driving?! */ - if(getDrivingStatus()) - { - return; - } - - psPresent = (DROID*)trackingCamera.target; - - if(keyPressed(KEY_LEFTARROW)) - { - leaderClass = LEADER_LEFT; - } - - else if(keyPressed(KEY_RIGHTARROW)) - { - leaderClass = LEADER_RIGHT; - } - - else if(keyPressed(KEY_UPARROW)) - { - leaderClass = LEADER_UP; - } - - else if(keyPressed(KEY_DOWNARROW)) - { - leaderClass = LEADER_DOWN; - } - else - { - leaderClass = LEADER_STATIC; - } - - bSuccess = FALSE; - bestSoFar = UDWORD_MAX; - switch(leaderClass) - { - case LEADER_LEFT: - for(psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid=psDroid->psNext) - { - /* Is it even on the sscreen? */ - if(DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid!=psPresent) - { - if(psDroid->sDisplay.screenXsDisplay.screenX) - { - dif = psPresent->sDisplay.screenX - psDroid->sDisplay.screenX; - if(difpsNext) - { - /* Is it even on the sscreen? */ - if(DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid!=psPresent) - { - if(psDroid->sDisplay.screenX>psPresent->sDisplay.screenX) - { - dif = psDroid->sDisplay.screenX - psPresent->sDisplay.screenX; - if(difpsNext) - { - /* Is it even on the sscreen? */ - if(DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid!=psPresent) - { - if(psDroid->sDisplay.screenYsDisplay.screenY) - { - dif = psPresent->sDisplay.screenY - psDroid->sDisplay.screenY; - if(difpsNext) - { - /* Is it even on the sscreen? */ - if(DrawnInLastFrame(psDroid->sDisplay.frameNumber) AND psDroid->selected AND psDroid!=psPresent) - { - if(psDroid->sDisplay.screenY>psPresent->sDisplay.screenY) - { - dif = psDroid->sDisplay.screenY - psPresent->sDisplay.screenY; - if(difpsNext) - { - /* Is he worth considering? */ - if(psDroid->group == groupNumber) - { - if(bCheckOnScreen ? droidOnScreen(psDroid,DISP_WIDTH/6) : TRUE) - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - } - /* - if(bCheckOnScreen) - { - if(droidOnScreen(psDroid,DISP_WIDTH/6)) - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - - } - } - else - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - - - } - */ - } - } - if(droidCount) - { - retVal = (averageAngle/droidCount); - averageAngleFloat = RAD_TO_DEG(atan2(xTotal,yTotal)); - } - else - { - retVal = 0; - } - presAvAngle = MAKEINT(averageAngleFloat);//retVal; - return(presAvAngle); -} - -//----------------------------------------------------------------------------------- -SDWORD getAverageTrackAngle( BOOL bCheckOnScreen ) -{ -DROID *psDroid; -FRACT xShift,yShift; -FRACT xTotal,yTotal; -FRACT averageAngleFloat = 0; -SDWORD droidCount, averageAngle; -SDWORD retVal; - - /* Initialise all the stuff */ - droidCount = 0; - averageAngle = 0; - /* Set totals to zero */ - xTotal = yTotal = 0.0f; - - /* Got thru' all droids */ - for(psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) - { - /* Is he worth selecting? */ - if(psDroid->selected) - { - if(bCheckOnScreen ? droidOnScreen(psDroid,DISP_WIDTH/6) : TRUE) - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - } - /* - if(bCheckOnScreen) - { - if(droidOnScreen(psDroid,DISP_WIDTH/6)) - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - - } - } - else - { - droidCount++; - averageAngle+=psDroid->direction; - xShift = trigSin(psDroid->direction); - yShift = trigCos(psDroid->direction); - xTotal += xShift; - yTotal += yShift; - - - } - */ - } - } - if(droidCount) - { - retVal = (averageAngle/droidCount); - averageAngleFloat = (float)RAD_TO_DEG(atan2(xTotal,yTotal)); - } - else - { - retVal = 0; - } - presAvAngle = MAKEINT(averageAngleFloat);//retVal; - return(presAvAngle); -} - //----------------------------------------------------------------------------------- SDWORD getPresAngle( void ) { @@ -1423,80 +1452,6 @@ UDWORD count; } //----------------------------------------------------------------------------------- -void getTrackingConcerns(SDWORD *x,SDWORD *y, SDWORD *z) -{ -SDWORD xTotals,yTotals,zTotals; -DROID *psDroid; -UDWORD count; - - xTotals = yTotals = zTotals = 0; - for(count = 0, psDroid = apsDroidLists[selectedPlayer]; - psDroid; psDroid = psDroid->psNext) - { - if(psDroid->selected) - { - if(droidOnScreen(psDroid,DISP_WIDTH/4)) - { - count++; - xTotals+=psDroid->x; - yTotals+=psDroid->z; // note the flip - zTotals+=psDroid->y; - } - } - } - - if(count) // necessary!!!!!!! - { - *x = xTotals/count; - *y = yTotals/count; - *z = zTotals/count; - } -} -//----------------------------------------------------------------------------------- -void getGroupTrackingConcerns(SDWORD *x,SDWORD *y, SDWORD *z,UDWORD groupNumber, BOOL bOnScreen) -{ -SDWORD xTotals,yTotals,zTotals; -DROID *psDroid; -UDWORD count; - - xTotals = yTotals = zTotals = 0; - for(count = 0, psDroid = apsDroidLists[selectedPlayer]; - psDroid; psDroid = psDroid->psNext) - { - if(psDroid->group == groupNumber) - { - if(bOnScreen ? droidOnScreen(psDroid,DISP_WIDTH/4) : TRUE) - { -// if(droidOnScreen(psDroid,DISP_WIDTH/4)) -// { - count++; - xTotals+=psDroid->x; - yTotals+=psDroid->z; // note the flip - zTotals+=psDroid->y; -// } - } -// else -// { -// count++; -// xTotals+=psDroid->x; -// yTotals+=psDroid->z; // note the flip -// zTotals+=psDroid->y; -// } - } - } - - if(count) // necessary!!!!!!! - { - *x = xTotals/count; - *y = yTotals/count; - *z = zTotals/count; - } -} -//----------------------------------------------------------------------------------- - - - - void camSetOldView(int x,int y,int z,int rx,int ry,int dist) { //DBPRINTF(("camSetOldView(%d %d %d %d %d %d)\n",x,y,z,rx,ry,dist)); @@ -1510,23 +1465,6 @@ void camSetOldView(int x,int y,int z,int rx,int ry,int dist) } -/* Static function that switches off tracking - and might not be desirable? - Jim?*/ -void camSwitchOff( void ) -{ - /* Restore the angles */ - -// player.r.x = trackingCamera.oldView.r.x; - player.r.z = trackingCamera.oldView.r.z; - - /* And height */ - /* Is this desirable??? */ -// player.p.y = trackingCamera.oldView.p.y; - - /* Restore distance */ - setViewDistance(trackingCamera.oldDistance); - -} - //----------------------------------------------------------------------------------- /* Returns whether or not the tracking camera is active */ @@ -1576,28 +1514,6 @@ void camToggleInfo(void) bFullInfo = !bFullInfo; } -/* Sets up the dummy target for the camera */ -//void setUpRadarTarget(SDWORD x, SDWORD y) -void setUpRadarTarget(SDWORD x, SDWORD y) -{ - - radarTarget.x = x; - radarTarget.y = y; - if( (x<0) OR (y<0) OR (x > (SDWORD)((mapWidth-1)*TILE_UNITS)) OR (y > (SDWORD)((mapHeight-1)*TILE_UNITS)) ) - { - radarTarget.z = 128 * ELEVATION_SCALE; - } - else - { - radarTarget.z = map_Height(x,y); - } - radarTarget.direction = (UWORD)calcDirection(player.p.x,player.p.z,x,y); - radarTarget.pitch = 0; - radarTarget.roll = 0; - radarTarget.type = OBJ_TARGET; - radarTarget.died = 0; -} - /* Informs the tracking camera that we want to start tracking to a new radar target */ void requestRadarTrack(SDWORD x, SDWORD y) { @@ -1669,32 +1585,6 @@ void toggleRadarAllignment( void ) bRadarAllign = !bRadarAllign; } -/* Returns how far away we are from our goal in a radar track */ -UDWORD getPositionMagnitude( void ) -{ -iVector dif; -UDWORD val; - - dif.x = abs(player.p.x - oldPosition.x); - dif.y = abs(player.p.y - oldPosition.y); - dif.z = abs(player.p.z - oldPosition.z); - val = (dif.x*dif.x) + (dif.y*dif.y) + (dif.z*dif.z); - return(val); -} - -/* Rteurns how far away we are from our goal in rotation */ -UDWORD getRotationMagnitude( void ) -{ -iVector dif; -UDWORD val; - - dif.x = abs(player.r.x - oldRotation.x); - dif.y = abs(player.r.y - oldRotation.y); - dif.z = abs(player.r.z - oldRotation.z); - val = (dif.x*dif.x) + (dif.y*dif.y) + (dif.z*dif.z); - return(val); -} - void camInformOfRotation( iVector *rotation ) { trackingCamera.rotation.x = rotation->x; diff --git a/src/winmain.h b/src/winmain.h index f892516b1..718e6b42b 100644 --- a/src/winmain.h +++ b/src/winmain.h @@ -18,4 +18,6 @@ extern BOOL bDisableLobby; extern UDWORD GetGameMode(void); extern void SetGameMode(UDWORD status); +extern char SaveGamePath[]; + #endif diff --git a/src/wrappers.c b/src/wrappers.c index 844c58804..dccfb4f9e 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -72,7 +72,6 @@ STAR stars[30]; // quick hack for loading stuff #define LOAD_BOX_SHADES 6 -extern IMAGEFILE *FrontImages; extern int WFont; extern BOOL bLoadSaveUp;