Merge branch 'master' into cpp
Conflicts: lib/widget/bar.cpp lib/widget/editbox.cppmaster
commit
0d2e373456
|
@ -35,6 +35,7 @@
|
|||
#include "frameint.h"
|
||||
#include "frameresource.h"
|
||||
#include "input.h"
|
||||
#include "lib/widget/scrap.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "physfs_ext.h"
|
||||
|
||||
|
@ -264,6 +265,9 @@ bool frameInitialise(
|
|||
/* Initialise the input system */
|
||||
inputInitialise();
|
||||
|
||||
// Initialise clipboard stuff.
|
||||
init_scrap();
|
||||
|
||||
/* Initialise the frame rate stuff */
|
||||
InitFrameStuff();
|
||||
|
||||
|
|
|
@ -3089,7 +3089,7 @@ static void sendDebugSync(uint8_t *buf, uint32_t bufLen, uint32_t time)
|
|||
NETend();
|
||||
}
|
||||
|
||||
static uint8_t debugSyncTmpBuf[1000000];
|
||||
static uint8_t debugSyncTmpBuf[2000000];
|
||||
static void recvDebugSync(NETQUEUE queue)
|
||||
{
|
||||
uint32_t time = 0;
|
||||
|
@ -3139,12 +3139,15 @@ bool checkDebugSync(uint32_t checkGameTime, uint32_t checkCrc)
|
|||
// Dump our version, and also erase it, so we only dump it at most once.
|
||||
debug(LOG_ERROR, "Inconsistent sync debug at gameTime %u. My version has %u lines, CRC = 0x%08X.", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF);
|
||||
bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "===== BEGIN gameTime=%u, %u lines, CRC 0x%08X =====\n", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF);
|
||||
bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
|
||||
for (i = 0; i < syncDebugNum[index]; ++i)
|
||||
{
|
||||
bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "[%s] %s\n", syncDebugFunctions[index][i], syncDebugStrings[index][i]);
|
||||
bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
|
||||
free(syncDebugStrings[index][i]);
|
||||
}
|
||||
bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "===== END gameTime=%u, %u lines, CRC 0x%08X =====\n", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF);
|
||||
bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
|
||||
if (numDumps < 5)
|
||||
{
|
||||
++numDumps;
|
||||
|
|
|
@ -38,6 +38,8 @@ W_BARGRAPH::W_BARGRAPH(W_BARINIT const *init)
|
|||
, iRange(init->iRange)
|
||||
, iValue(0)
|
||||
, iOriginal(0)
|
||||
, denominator(MAX(init->denominator, 1))
|
||||
, precision(init->precision)
|
||||
, majorCol(init->sCol)
|
||||
, minorCol(init->sMinorCol)
|
||||
, pTip(init->pTip)
|
||||
|
|
|
@ -36,6 +36,8 @@ struct W_BARGRAPH : public WIDGET
|
|||
UWORD iRange; // Maximum range
|
||||
UWORD iValue; // Current value
|
||||
UWORD iOriginal; // hack to keep uncapped value around
|
||||
int denominator; // Denominator, 1 by default.
|
||||
int precision; // Number of places after the decimal point to display, 0 by default.
|
||||
PIELIGHT majorCol; // Colour for the major bar
|
||||
PIELIGHT minorCol; // Colour for the minor bar
|
||||
const char *pTip; // The tool tip for the graph
|
||||
|
|
|
@ -78,8 +78,6 @@ W_EDITBOX::W_EDITBOX(W_EDBINIT const *init)
|
|||
}
|
||||
|
||||
editBoxInitialise(this);
|
||||
|
||||
init_scrap();
|
||||
}
|
||||
|
||||
W_EDITBOX::~W_EDITBOX()
|
||||
|
|
|
@ -209,6 +209,8 @@ struct W_BARINIT : public W_INIT
|
|||
UWORD size; ///< Initial percentage of the graph that is filled
|
||||
UWORD minorSize; ///< Percentage of second bar graph if there is one
|
||||
UWORD iRange; ///< Maximum range
|
||||
int denominator; ///< Denominator, 1 by default.
|
||||
int precision; ///< Number of places after the decimal point to display, 0 by default.
|
||||
PIELIGHT sCol; ///< Bar colour
|
||||
PIELIGHT sMinorCol; ///< Minor bar colour
|
||||
const char *pTip; ///< Tool tip text
|
||||
|
|
|
@ -1545,13 +1545,19 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats)
|
|||
/* Add the bar graphs*/
|
||||
sBarInit.id = IDDES_SENSORRANGE;
|
||||
sBarInit.iRange = (UWORD)getMaxSensorRange();//DBAR_SENSORMAXRANGE;
|
||||
sBarInit.pTip = _("Sensor Range");
|
||||
sBarInit.denominator = TILE_UNITS;
|
||||
sBarInit.precision = 1;
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sBarInit.denominator = 0;
|
||||
sBarInit.precision = 0;
|
||||
sBarInit.id = IDDES_SENSORPOWER;
|
||||
sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.iRange = (UWORD)getMaxSensorPower();//DBAR_SENSORMAXPOWER;
|
||||
sBarInit.pTip = _("Sensor Power");
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
|
@ -1559,6 +1565,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats)
|
|||
sBarInit.id = IDDES_SENSORWEIGHT;
|
||||
sBarInit.y = DES_STATBAR_Y3; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT;
|
||||
sBarInit.pTip = _("Weight");
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
|
@ -1598,6 +1605,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats)
|
|||
/* Add the bar graphs */
|
||||
sBarInit.id = IDDES_ECMPOWER;
|
||||
sBarInit.iRange = (UWORD)getMaxECMPower();//DBAR_ECMMAXPOWER;
|
||||
sBarInit.pTip = _("ECM Power");
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
|
@ -1605,6 +1613,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats)
|
|||
sBarInit.id = IDDES_ECMWEIGHT;
|
||||
sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT;
|
||||
sBarInit.pTip = _("Weight");
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
|
@ -1714,10 +1723,14 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats)
|
|||
sBarInit.id = IDDES_WEAPRANGE;
|
||||
sBarInit.iRange = (UWORD)getMaxWeaponRange();//DBAR_WEAPMAXRANGE;
|
||||
sBarInit.pTip = _("Range");
|
||||
sBarInit.denominator = TILE_UNITS;
|
||||
sBarInit.precision = 1;
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sBarInit.denominator = 0;
|
||||
sBarInit.precision = 0;
|
||||
sBarInit.id = IDDES_WEAPDAMAGE;
|
||||
sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.iRange = (UWORD)getMaxWeaponDamage();//DBAR_WEAPMAXDAMAGE;
|
||||
|
@ -1900,10 +1913,14 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats)
|
|||
sBarInit.id = IDDES_PROPAIR;
|
||||
sBarInit.iRange = (UWORD)getMaxPropulsionSpeed();//DBAR_PROPMAXSPEED;
|
||||
sBarInit.pTip = _("Air Speed");
|
||||
sBarInit.denominator = TILE_UNITS;
|
||||
sBarInit.precision = 2;
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sBarInit.denominator = 0;
|
||||
sBarInit.precision = 0;
|
||||
sBarInit.id = IDDES_PROPWEIGHT;
|
||||
sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT;
|
||||
|
@ -1937,6 +1954,8 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats)
|
|||
sBarInit.id = IDDES_PROPROAD;
|
||||
sBarInit.pTip = _("Road Speed");
|
||||
sBarInit.iRange = (UWORD)getMaxPropulsionSpeed();//DBAR_PROPMAXSPEED;
|
||||
sBarInit.denominator = TILE_UNITS;
|
||||
sBarInit.precision = 2;
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
return false;
|
||||
|
@ -1957,6 +1976,8 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
sBarInit.denominator = 0;
|
||||
sBarInit.precision = 0;
|
||||
sBarInit.id = IDDES_PROPWEIGHT;
|
||||
sBarInit.y = DES_STATBAR_Y4; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP;
|
||||
sBarInit.pTip = _("Weight");
|
||||
|
|
538
src/hci.cpp
538
src/hci.cpp
File diff suppressed because it is too large
Load Diff
|
@ -259,9 +259,6 @@ typedef enum {
|
|||
INT_MAXMODE, //leave as last so we can start the objMode at this value
|
||||
} INTMODE;
|
||||
|
||||
//NOT ANYMORE! 10/08/98 AB
|
||||
//#define INCLUDE_PRODSLIDER // Include quantity slider in manufacture window.
|
||||
|
||||
extern INTMODE intMode;
|
||||
|
||||
/* The widget screen */
|
||||
|
|
|
@ -2902,108 +2902,73 @@ void StatGetResearchImage(BASE_STATS *psStat, SDWORD *Image, iIMDShape **Shape,
|
|||
}
|
||||
}
|
||||
|
||||
/* Draws a stats bar for the design screen */
|
||||
void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void intDisplayBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, bool isPowerBar)
|
||||
{
|
||||
W_BARGRAPH *BarGraph = (W_BARGRAPH*)psWidget;
|
||||
SDWORD x0, y0, iX, iY;
|
||||
static char szVal[6], szCheckWidth[6] = "00000";
|
||||
W_BARGRAPH *BarGraph = (W_BARGRAPH *)psWidget;
|
||||
char szVal[30];
|
||||
char const *szCheckWidth = "00000";
|
||||
int x0 = xOffset + BarGraph->x;
|
||||
int y0 = yOffset + BarGraph->y;
|
||||
int arbitaryOffset = 3;
|
||||
int iX, iY;
|
||||
int barWidth = 100, width;
|
||||
int i, precisionFactor = 1, value;
|
||||
|
||||
x0 = xOffset + BarGraph->x;
|
||||
y0 = yOffset + BarGraph->y;
|
||||
|
||||
// //draw the background image
|
||||
// iV_DrawImage(IntImages,IMAGE_DES_STATSBACK,x0,y0);
|
||||
|
||||
//increment for the position of the level indicator
|
||||
x0 += 3;
|
||||
y0 += 3;
|
||||
|
||||
/* indent to allow text value */
|
||||
iX = x0 + iV_GetTextWidth( szCheckWidth );
|
||||
iY = y0 + (iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 -
|
||||
iV_GetTextAboveBase();
|
||||
|
||||
//draw current value section
|
||||
iV_DrawImageRect( IntImages, IMAGE_DES_STATSCURR, iX, y0,
|
||||
BarGraph->majorSize, iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR));
|
||||
|
||||
/* draw text value */
|
||||
sprintf(szVal, "%d", BarGraph->iOriginal);
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
iV_DrawText( szVal, x0, iY );
|
||||
|
||||
//draw the comparison value - only if not zero
|
||||
if (BarGraph->minorSize != 0)
|
||||
if (isPowerBar)
|
||||
{
|
||||
y0 -= 1;
|
||||
iV_DrawImage(IntImages,IMAGE_DES_STATSCOMP,iX+BarGraph->minorSize ,y0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Draws a Template Power Bar for the Design Screen */
|
||||
void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
{
|
||||
W_BARGRAPH *BarGraph = (W_BARGRAPH*)psWidget;
|
||||
SDWORD x0, y0, iX, iY;
|
||||
UDWORD width, barWidth;
|
||||
static char szVal[6], szCheckWidth[6] = "00000";
|
||||
UBYTE arbitaryOffset;
|
||||
|
||||
x0 = xOffset + BarGraph->x;
|
||||
y0 = yOffset + BarGraph->y;
|
||||
|
||||
//draw the background image
|
||||
iV_DrawImage(IntImages,IMAGE_DES_POWERBAR_LEFT,x0,y0);
|
||||
iV_DrawImage(IntImages,IMAGE_DES_POWERBAR_RIGHT,
|
||||
//xOffset+psWidget->width-iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT),y0);
|
||||
x0 + psWidget->width-iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT),y0);
|
||||
iV_DrawImage(IntImages, IMAGE_DES_POWERBAR_LEFT, x0, y0);
|
||||
iV_DrawImage(IntImages, IMAGE_DES_POWERBAR_RIGHT, x0 + psWidget->width - iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT), y0);
|
||||
}
|
||||
|
||||
//increment for the position of the bars within the background image
|
||||
arbitaryOffset = 3;
|
||||
// Arbitrary increment for the position of the bars
|
||||
x0 += arbitaryOffset;
|
||||
y0 += arbitaryOffset;
|
||||
|
||||
/* indent to allow text value */
|
||||
iX = x0 + iV_GetTextWidth( szCheckWidth );
|
||||
iY = y0 + (iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 -
|
||||
iV_GetTextAboveBase();
|
||||
iX = x0 + iV_GetTextWidth(szCheckWidth);
|
||||
iY = y0 + (iV_GetImageHeight(IntImages, IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 - iV_GetTextAboveBase();
|
||||
|
||||
if (isPowerBar)
|
||||
{
|
||||
// Adjust the width based on the text drawn
|
||||
barWidth = BarGraph->width - (iX - x0 + arbitaryOffset);
|
||||
width = BarGraph->majorSize * barWidth / 100;
|
||||
// Quick check that don't go over the end - ensure % is not > 100
|
||||
if (width > barWidth)
|
||||
{
|
||||
width = barWidth;
|
||||
}
|
||||
|
||||
//draw current value section
|
||||
iV_DrawImageRect(IntImages,IMAGE_DES_STATSCURR, iX, y0,
|
||||
width, iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR));
|
||||
width = MIN(BarGraph->majorSize * barWidth / 100, barWidth);
|
||||
iV_DrawImageRect(IntImages, IMAGE_DES_STATSCURR, iX, y0, width, iV_GetImageHeight(IntImages, IMAGE_DES_STATSCURR));
|
||||
|
||||
/* draw text value */
|
||||
sprintf(szVal, "%d", BarGraph->iOriginal);
|
||||
for (i = 0; i < BarGraph->precision; ++i)
|
||||
{
|
||||
precisionFactor *= 10;
|
||||
}
|
||||
value = (BarGraph->iOriginal * precisionFactor + BarGraph->denominator/2) / BarGraph->denominator;
|
||||
sprintf(szVal, "%d%s%.*d", value/precisionFactor, precisionFactor == 1? "" : ".", BarGraph->precision, value%precisionFactor);
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
iV_DrawText( szVal, x0, iY );
|
||||
iV_DrawText(szVal, x0, iY);
|
||||
|
||||
//draw the comparison value - only if not zero
|
||||
if (BarGraph->minorSize != 0)
|
||||
{
|
||||
y0 -= 1;
|
||||
width = BarGraph->minorSize * barWidth / 100;
|
||||
if (width > barWidth)
|
||||
{
|
||||
width = barWidth;
|
||||
}
|
||||
//iV_DrawImage(IntImages,IMAGE_DES_STATSCOMP,x0+BarGraph->minorSize ,y0);
|
||||
iV_DrawImage(IntImages, IMAGE_DES_STATSCOMP, iX + width ,y0);
|
||||
width = MIN(BarGraph->minorSize * barWidth / 100, barWidth);
|
||||
iV_DrawImage(IntImages, IMAGE_DES_STATSCOMP, iX + width, y0 - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draws a stats bar for the design screen */
|
||||
void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
{
|
||||
intDisplayBar(psWidget, xOffset, yOffset, false);
|
||||
}
|
||||
|
||||
/* Draws a Template Power Bar for the Design Screen */
|
||||
void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
{
|
||||
intDisplayBar(psWidget, xOffset, yOffset, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Widget callback function to play an audio track.
|
||||
|
|
|
@ -3198,9 +3198,16 @@ void runMultiOptions(void)
|
|||
}
|
||||
|
||||
if (CancelPressed())
|
||||
{
|
||||
if (multiRequestUp)
|
||||
{
|
||||
changeTitleMode(lastTitleMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
processMultiopWidgets(CON_CANCEL); // "Press" the cancel button to clean up net connections and stuff.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL startMultiOptions(BOOL bReenter)
|
||||
|
|
138
src/order.cpp
138
src/order.cpp
|
@ -1052,7 +1052,6 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
{
|
||||
DROID *psSpotter = (DROID *)psDroid->psTarget;
|
||||
|
||||
// psFireTarget = orderStateObj((DROID *)psDroid->psTarget, DORDER_OBSERVE);
|
||||
if (psSpotter->action == DACTION_OBSERVE
|
||||
|| (psSpotter->droidType == DROID_COMMAND && psSpotter->action == DACTION_ATTACK))
|
||||
{
|
||||
|
@ -1140,11 +1139,9 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
{
|
||||
// not doing anything, make sure the droid is close enough
|
||||
// to the thing it is defending
|
||||
//if ((psDroid->droidType != DROID_REPAIR) &&
|
||||
if ((!(psDroid->droidType == DROID_REPAIR || psDroid->droidType ==
|
||||
DROID_CYBORG_REPAIR)) && psDroid->psTarget != NULL &&
|
||||
psDroid->psTarget->type == OBJ_DROID &&
|
||||
((DROID *)psDroid->psTarget)->droidType == DROID_COMMAND)
|
||||
if ((!(psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR))
|
||||
&& psDroid->psTarget != NULL && psDroid->psTarget->type == OBJ_DROID
|
||||
&& ((DROID *)psDroid->psTarget)->droidType == DROID_COMMAND)
|
||||
{
|
||||
// guarding a commander, allow more space
|
||||
orderCheckGuardPosition(psDroid, DEFEND_CMD_BASEDIST);
|
||||
|
@ -1154,28 +1151,26 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
orderCheckGuardPosition(psDroid, DEFEND_BASEDIST);
|
||||
}
|
||||
}
|
||||
else if (psDroid->droidType == DROID_REPAIR ||
|
||||
psDroid->droidType == DROID_CYBORG_REPAIR)
|
||||
else if (psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR)
|
||||
{
|
||||
// repairing something, make sure the droid doesn't go too far
|
||||
orderCheckGuardPosition(psDroid, REPAIR_MAXDIST);
|
||||
}
|
||||
else if (psDroid->droidType == DROID_CONSTRUCT ||
|
||||
psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||
else if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||
{
|
||||
// repairing something, make sure the droid doesn't go too far
|
||||
orderCheckGuardPosition(psDroid, CONSTRUCT_MAXDIST);
|
||||
}
|
||||
else if (psDroid->droidType == DROID_TRANSPORTER)
|
||||
{
|
||||
//check transporter isn't sitting there waiting to be filled when nothing exists!
|
||||
// check transporter isn't sitting there waiting to be filled when nothing exists!
|
||||
if (psDroid->player == selectedPlayer && getDroidsToSafetyFlag() &&
|
||||
!missionDroidsRemaining(selectedPlayer))
|
||||
{
|
||||
//check that nothing is on the transporter (transporter counts as first in group)
|
||||
// check that nothing is on the transporter (transporter counts as first in group)
|
||||
if (psDroid->psGroup && psDroid->psGroup->refCount < 2)
|
||||
{
|
||||
//the script can call startMission for this callback for offworld missions
|
||||
// the script can call startMission for this callback for offworld missions
|
||||
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_START_NEXT_LEVEL);
|
||||
}
|
||||
}
|
||||
|
@ -1232,8 +1227,7 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
|
||||
//repair droids default to repairing droids within a given range
|
||||
psObj = NULL;
|
||||
if ((psDroid->droidType == DROID_REPAIR ||
|
||||
psDroid->droidType == DROID_CYBORG_REPAIR))
|
||||
if ((psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR))
|
||||
{
|
||||
if (psDroid->action == DACTION_NONE)
|
||||
{
|
||||
|
@ -1250,8 +1244,7 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
}
|
||||
//construct droids default to repairing structures within a given range
|
||||
psObj = NULL;
|
||||
if ((psDroid->droidType == DROID_CONSTRUCT ||
|
||||
psDroid->droidType == DROID_CYBORG_CONSTRUCT))
|
||||
if ((psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT))
|
||||
{
|
||||
if (psDroid->action == DACTION_NONE)
|
||||
{
|
||||
|
@ -2835,18 +2828,9 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
}
|
||||
}
|
||||
//check for transporters first
|
||||
if (psObj->type == OBJ_DROID && ((DROID *)psObj)->droidType == DROID_TRANSPORTER
|
||||
&& psObj->player == psDroid->player)
|
||||
if (psObj->type == OBJ_DROID && ((DROID *)psObj)->droidType == DROID_TRANSPORTER && psObj->player == psDroid->player)
|
||||
{
|
||||
order = DORDER_EMBARK;
|
||||
|
||||
//Cannot test this here since bMultiPlayer will have been set to false
|
||||
/* //in multiPlayer can only put cyborgs onto a Transporter
|
||||
if (bMultiPlayer && psDroid->droidType != DROID_CYBORG)
|
||||
{
|
||||
order = DORDER_NONE;
|
||||
}
|
||||
*/
|
||||
}
|
||||
// go to recover an artifact/oil drum - don't allow VTOL's to get this order
|
||||
else if (psObj->type == OBJ_FEATURE &&
|
||||
|
@ -2867,7 +2851,7 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
&& psObj->player != psDroid->player
|
||||
&& !aiCheckAlliances(psObj->player , psDroid->player) )
|
||||
{
|
||||
//check valid weapon/prop combination
|
||||
// check valid weapon/prop combination
|
||||
if (!validTarget((BASE_OBJECT *)psDroid, psObj, 0))
|
||||
{
|
||||
order = DORDER_NONE;
|
||||
|
@ -2882,9 +2866,9 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
&& !aiCheckAlliances(psObj->player , psDroid->player) )
|
||||
{
|
||||
//check for standard sensor or VTOL intercept sensor
|
||||
if (asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == STANDARD_SENSOR ||
|
||||
asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == VTOL_INTERCEPT_SENSOR ||
|
||||
asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == SUPER_SENSOR)
|
||||
if (asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == STANDARD_SENSOR
|
||||
|| asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == VTOL_INTERCEPT_SENSOR
|
||||
|| asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == SUPER_SENSOR)
|
||||
{
|
||||
// a sensor droid observing an object
|
||||
order = DORDER_OBSERVE;
|
||||
|
@ -2906,24 +2890,15 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
psDroid->droidType != DROID_COMMAND &&
|
||||
psDroid->droidType != DROID_CONSTRUCT &&
|
||||
psDroid->droidType != DROID_CYBORG_CONSTRUCT)
|
||||
{
|
||||
// if (!isVtolDroid(psDroid))
|
||||
{
|
||||
// get a droid to join a command droids group
|
||||
cmdDroidAddDroid((DROID *) psObj, psDroid);
|
||||
DeSelectDroid(psDroid);
|
||||
|
||||
order = DORDER_NONE;
|
||||
}
|
||||
/* else
|
||||
{
|
||||
order = DORDER_FIRESUPPORT;
|
||||
}*/
|
||||
}
|
||||
//repair droid
|
||||
else if (aiCheckAlliances(psObj->player, psDroid->player) &&
|
||||
psObj->type == OBJ_DROID &&
|
||||
//psDroid->droidType == DROID_REPAIR &&
|
||||
(psDroid->droidType == DROID_REPAIR ||
|
||||
psDroid->droidType == DROID_CYBORG_REPAIR) &&
|
||||
droidIsDamaged((DROID *)psObj))
|
||||
|
@ -2950,8 +2925,7 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
psObj->type == OBJ_STRUCTURE )
|
||||
{
|
||||
psStruct = (STRUCTURE *) psObj;
|
||||
ASSERT( psObj != NULL,
|
||||
"chooseOrderObj: invalid structure pointer" );
|
||||
ASSERT(psObj != NULL, "Invalid structure pointer");
|
||||
|
||||
/* check whether construction droid */
|
||||
order = DORDER_NONE;
|
||||
|
@ -3007,7 +2981,6 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
/* check repair facility and in need of repair */
|
||||
if ( psStruct->pStructureType->type == REF_REPAIR_FACILITY &&
|
||||
psStruct->status == SS_BUILT)
|
||||
// ((SDWORD)(PERCENT(psDroid->body,psDroid->originalBody)) < 100) )
|
||||
{
|
||||
order = DORDER_RTR_SPECIFIED;
|
||||
}
|
||||
|
@ -3021,12 +2994,10 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
//check for counter battery assignment
|
||||
else if (structSensorDroidWeapon(psStruct, psDroid))
|
||||
{
|
||||
// secondarySetState(psDroid, DSO_HALTTYPE, DSS_HALT_HOLD);
|
||||
order = DORDER_FIRESUPPORT;
|
||||
//inform display system
|
||||
setSensorAssigned();
|
||||
//deselect droid
|
||||
// psDroid->selected = false;
|
||||
DeSelectDroid(psDroid);
|
||||
}
|
||||
//REARM VTOLS
|
||||
|
@ -3038,13 +3009,9 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
if (psStruct->pStructureType->type == REF_REARM_PAD)
|
||||
{
|
||||
//don't bother checking cos we want it to go there if directed
|
||||
//check if need to be rearmed/repaired
|
||||
//if (!vtolHappy(psDroid))
|
||||
{
|
||||
order = DORDER_REARM;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Some droids shouldn't be guarding
|
||||
else if ((psDroid->droidType == DROID_WEAPON ||
|
||||
psDroid->droidType == DROID_CYBORG ||
|
||||
|
@ -3056,13 +3023,11 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder)
|
|||
}
|
||||
}
|
||||
//check for constructor droid clearing up wrecked buildings
|
||||
else if ( (psDroid->droidType == DROID_CONSTRUCT ||
|
||||
psDroid->droidType == DROID_CYBORG_CONSTRUCT) &&
|
||||
psObj->type == OBJ_FEATURE )
|
||||
else if ((psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||
&& psObj->type == OBJ_FEATURE)
|
||||
{
|
||||
psFeature = (FEATURE *) psObj;
|
||||
ASSERT( psObj != NULL,
|
||||
"chooseOrderObj: invalid feature pointer" );
|
||||
ASSERT(psObj != NULL, "Invalid feature pointer");
|
||||
if (psFeature->psStats->subType == FEAT_BUILD_WRECK)
|
||||
{
|
||||
order = DORDER_CLEARWRECK;
|
||||
|
@ -3289,9 +3254,9 @@ BOOL secondarySupported(DROID *psDroid, SECONDARY_ORDER sec)
|
|||
{
|
||||
supported = false;
|
||||
}
|
||||
//don't allow factories to be assigned to commanders during a Limbo Expand mission
|
||||
if ((sec == DSO_ASSIGN_PRODUCTION || sec == DSO_ASSIGN_CYBORG_PRODUCTION ||
|
||||
sec == DSO_ASSIGN_VTOL_PRODUCTION) && missionLimboExpand())
|
||||
// don't allow factories to be assigned to commanders during a Limbo Expand mission
|
||||
if ((sec == DSO_ASSIGN_PRODUCTION || sec == DSO_ASSIGN_CYBORG_PRODUCTION || sec == DSO_ASSIGN_VTOL_PRODUCTION)
|
||||
&& missionLimboExpand())
|
||||
{
|
||||
supported = false;
|
||||
}
|
||||
|
@ -3299,13 +3264,11 @@ BOOL secondarySupported(DROID *psDroid, SECONDARY_ORDER sec)
|
|||
|
||||
case DSO_ATTACK_RANGE:
|
||||
case DSO_ATTACK_LEVEL:
|
||||
if (psDroid->droidType == DROID_REPAIR ||
|
||||
psDroid->droidType == DROID_CYBORG_REPAIR)
|
||||
if (psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR)
|
||||
{
|
||||
supported = false;
|
||||
}
|
||||
if (psDroid->droidType == DROID_CONSTRUCT ||
|
||||
psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||
if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||
{
|
||||
supported = false;
|
||||
}
|
||||
|
@ -3386,7 +3349,6 @@ SECONDARY_STATE secondaryGetState(DROID *psDroid, SECONDARY_ORDER sec)
|
|||
return (SECONDARY_STATE)(state & DSS_RTL_MASK);
|
||||
break;
|
||||
case DSO_FIRE_DESIGNATOR:
|
||||
// *pState = state & DSS_FIREDES_MASK;
|
||||
if (cmdDroidGetDesignator(psDroid->player) == psDroid)
|
||||
{
|
||||
return DSS_FIREDES_SET;
|
||||
|
@ -3539,8 +3501,7 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
|
|||
CurrState = (CurrState & ~DSS_ALEV_MASK) | State;
|
||||
if (State == DSS_ALEV_NEVER)
|
||||
{
|
||||
if ( orderState(psDroid, DORDER_ATTACK) )// ||
|
||||
// orderState(psDroid, DORDER_FIRESUPPORT) )
|
||||
if (orderState(psDroid, DORDER_ATTACK))
|
||||
{
|
||||
// just kill these orders
|
||||
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
|
||||
|
@ -3755,19 +3716,9 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
|
|||
switch (State & DSS_RTL_MASK)
|
||||
{
|
||||
case DSS_RTL_REPAIR:
|
||||
// if (FindARepairFacility() != NULL)
|
||||
{
|
||||
order = DORDER_RTR;
|
||||
CurrState |= DSS_RTL_REPAIR;
|
||||
// can't clear the selection here cos it breaks
|
||||
// the secondary order screen
|
||||
// psDroid->selected = false;
|
||||
// psDroid->group = UBYTE_MAX;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// retVal = false;
|
||||
// }
|
||||
// can't clear the selection here cos it breaks the secondary order screen
|
||||
break;
|
||||
case DSS_RTL_BASE:
|
||||
order = DORDER_RTB;
|
||||
|
@ -3777,7 +3728,7 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
|
|||
psTransport = FindATransporter(psDroid->player);
|
||||
if (psTransport != NULL)
|
||||
{
|
||||
//in multiPlayer can only put cyborgs onto a Transporter
|
||||
// in multiPlayer can only put cyborgs onto a Transporter
|
||||
if (bMultiPlayer && !cyborgDroid(psDroid))
|
||||
{
|
||||
retVal = false;
|
||||
|
@ -3968,7 +3919,6 @@ void orderMoralCheck(UDWORD player)
|
|||
// too many units, don't run
|
||||
return;
|
||||
}
|
||||
// debug( LOG_NEVER, "moral check for player %d\n", player );
|
||||
|
||||
// calculate the overall leadership
|
||||
leadership = asRunData[player].leadership + 10;
|
||||
|
@ -3994,7 +3944,6 @@ void orderMoralCheck(UDWORD player)
|
|||
{
|
||||
if (check > personLShip)
|
||||
{
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id );
|
||||
syncDebug("Person running.");
|
||||
orderDroid(psCurr, DORDER_RUN, ModeImmediate);
|
||||
}
|
||||
|
@ -4003,7 +3952,6 @@ void orderMoralCheck(UDWORD player)
|
|||
{
|
||||
if (check > leadership)
|
||||
{
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id );
|
||||
syncDebug("Droid running.");
|
||||
orderDroid(psCurr, DORDER_RUN, ModeImmediate);
|
||||
}
|
||||
|
@ -4062,7 +4010,6 @@ void orderGroupMoralCheck(DROID_GROUP *psGroup)
|
|||
{
|
||||
if (check > personLShip)
|
||||
{
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id );
|
||||
syncDebug("Person running.");
|
||||
orderDroidLoc(psCurr, DORDER_RUN, psRunData->sPos.x, psRunData->sPos.y, ModeImmediate);
|
||||
}
|
||||
|
@ -4071,7 +4018,6 @@ void orderGroupMoralCheck(DROID_GROUP *psGroup)
|
|||
{
|
||||
if (check > leadership)
|
||||
{
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id );
|
||||
syncDebug("Droid running.");
|
||||
orderDroidLoc(psCurr, DORDER_RUN, psRunData->sPos.x, psRunData->sPos.y, ModeImmediate);
|
||||
}
|
||||
|
@ -4091,7 +4037,7 @@ void orderHealthCheck(DROID *psDroid)
|
|||
return;
|
||||
}
|
||||
|
||||
//get the health value to compare with
|
||||
// get the health value to compare with
|
||||
if (psDroid->psGroup)
|
||||
{
|
||||
healthLevel = psDroid->psGroup->sRunData.healthLevel;
|
||||
|
@ -4099,19 +4045,19 @@ void orderHealthCheck(DROID *psDroid)
|
|||
retreatY = psDroid->psGroup->sRunData.sPos.y;
|
||||
}
|
||||
|
||||
//if health has not been set for the group - use players'
|
||||
// if health has not been set for the group - use players'
|
||||
if (!healthLevel)
|
||||
{
|
||||
healthLevel = asRunData[psDroid->player].healthLevel;
|
||||
}
|
||||
|
||||
//if not got a health level set then ignore
|
||||
// if not got a health level set then ignore
|
||||
if (!healthLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if pos has not been set for the group - use players'
|
||||
// if pos has not been set for the group - use players'
|
||||
if (retreatX == 0 && retreatY == 0)
|
||||
{
|
||||
retreatX = asRunData[psDroid->player].sPos.x;
|
||||
|
@ -4120,7 +4066,7 @@ void orderHealthCheck(DROID *psDroid)
|
|||
|
||||
if (PERCENT(psDroid->body, psDroid->originalBody) < healthLevel)
|
||||
{
|
||||
//order this droid to turn and run - // if already running - ignore
|
||||
// order this droid to turn and run - // if already running - ignore
|
||||
if (!(orderState(psDroid, DORDER_RUN) ||
|
||||
orderState(psDroid, DORDER_RUNBURN) ||
|
||||
orderState(psDroid, DORDER_RETREAT) ||
|
||||
|
@ -4128,7 +4074,6 @@ void orderHealthCheck(DROID *psDroid)
|
|||
orderState(psDroid, DORDER_RTR) ||
|
||||
orderState(psDroid, DORDER_DESTRUCT)))
|
||||
{
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psDroid->id );
|
||||
syncDebug("Droid running.");
|
||||
orderDroidLoc(psDroid, DORDER_RUN, retreatX, retreatY, ModeImmediate);
|
||||
}
|
||||
|
@ -4138,18 +4083,12 @@ void orderHealthCheck(DROID *psDroid)
|
|||
{
|
||||
for(psCurr = psDroid->psGroup->psList; psCurr; psCurr=psCurr->psGrpNext)
|
||||
{
|
||||
if (orderState(psCurr, DORDER_RUN) ||
|
||||
orderState(psCurr, DORDER_RUNBURN) ||
|
||||
orderState(psCurr, DORDER_RETREAT) ||
|
||||
orderState(psCurr, DORDER_RTB) ||
|
||||
orderState(psCurr, DORDER_RTR) ||
|
||||
orderState(psCurr, DORDER_DESTRUCT))
|
||||
if (orderState(psCurr, DORDER_RUN) || orderState(psCurr, DORDER_RUNBURN) || orderState(psCurr, DORDER_RETREAT)
|
||||
|| orderState(psCurr, DORDER_RTB) || orderState(psCurr, DORDER_RTR) || orderState(psCurr, DORDER_DESTRUCT))
|
||||
{
|
||||
// already running - ignore
|
||||
continue;
|
||||
}
|
||||
|
||||
// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id );
|
||||
syncDebug("Group running.");
|
||||
orderDroidLoc(psCurr, DORDER_RUN, retreatX, retreatY, ModeImmediate);
|
||||
}
|
||||
|
@ -4230,11 +4169,7 @@ BOOL getFactoryState(STRUCTURE *psStruct, SECONDARY_ORDER sec, SECONDARY_STATE *
|
|||
{
|
||||
UDWORD state;
|
||||
|
||||
if (!StructIsFactory(psStruct))
|
||||
{
|
||||
ASSERT( false, "getFactoryState: structure is not a factory" );
|
||||
return false;
|
||||
}
|
||||
ASSERT_OR_RETURN(false, StructIsFactory(psStruct), "Structure is not a factory");
|
||||
|
||||
state = ((FACTORY *)psStruct->pFunctionality)->secondaryOrder;
|
||||
|
||||
|
@ -4301,8 +4236,7 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
|
|||
psStruct->asWeaps[0].lastFired = gameTime;
|
||||
|
||||
//play 5 second countdown message
|
||||
audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN,
|
||||
psObj->pos.x, psObj->pos.y, psObj->pos.z );
|
||||
audio_QueueTrackPos(ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -3213,7 +3213,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
|||
objTrace(psDroid->id, "Repair not needed - move to delivery point");
|
||||
orderDroidLoc(psDroid, DORDER_MOVE,
|
||||
psRepairFac->psDeliveryPoint->coords.x,
|
||||
psRepairFac->psDeliveryPoint->coords.y, ModeImmediate);
|
||||
psRepairFac->psDeliveryPoint->coords.y, ModeQueue); // ModeQueue because delivery points are not yet synchronised!
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -3699,7 +3699,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
|||
objTrace(psDroid->id, "Repair complete - move to delivery point");
|
||||
orderDroidLoc( psDroid, DORDER_MOVE,
|
||||
psRepairFac->psDeliveryPoint->coords.x,
|
||||
psRepairFac->psDeliveryPoint->coords.y, ModeImmediate);
|
||||
psRepairFac->psDeliveryPoint->coords.y, ModeQueue); // ModeQueue because delivery points are not yet synchronised!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue