newnet: Fix some selectedPlayer abuse.

master
Cyp 2010-02-23 09:13:13 +01:00
parent c42c9a276a
commit 853d87580b
6 changed files with 28 additions and 24 deletions

View File

@ -149,8 +149,7 @@ void gameTimeUpdate()
baseTime = currTime;
timeOffset = graphicsTime;
debug(LOG_SYNC, "Waiting for other players. gameTime = %u, player times are {%u, %u, %u, %u, %u, %u, %u, %u}", gameTime, gameQueueTime[0], gameQueueTime[1], gameQueueTime[2], gameQueueTime[3], gameQueueTime[4], gameQueueTime[5], gameQueueTime[6], gameQueueTime[7]);
//debug(LOG_SYNC, "Waiting for other players.");
debug(LOG_NEVER, "Waiting for other players. gameTime = %u, player times are {%u, %u, %u, %u, %u, %u, %u, %u}", gameTime, gameQueueTime[0], gameQueueTime[1], gameQueueTime[2], gameQueueTime[3], gameQueueTime[4], gameQueueTime[5], gameQueueTime[6], gameQueueTime[7]);
mayUpdate = false;
}

View File

@ -9,6 +9,8 @@ GAME_BUILD should fix the structure ID of the structure being built. GAME_BUILD
**************
Remove bMultiPlayer and turnOffMultiMsg() hacks, cleaning up any duplicate or dead code on the way.
Sanity check all use of selectedPlayer. It should be used for deciding how the interface works, not for changing the game state in random places for no good reason...
*************
* Somewhere *
*************
@ -36,4 +38,9 @@ Check that this file doesn't modify droids directly...
******************
* src/research.c *
******************
Check the researchResult function. Should a message be sent there, and if so, then should wait for it?
Check the researchResult function. Should a message be sent there, and if so, then should wait for it?
***************
* src/order.c *
***************
Just before transporterAddDroid, it changes the droid state directly. Should either not test for selectedPlayer, or should not change the droid state directly. See also: unloadTransporter.

View File

@ -411,7 +411,7 @@ void combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
}
else /* Deal with a missed shot */
{
int missDir = rand() % BUL_MAXSCATTERDIR, missDist = 2 * (100 - resultHitChance);
int missDir = gameRand(BUL_MAXSCATTERDIR), missDist = 2 * (100 - resultHitChance);
Vector3i miss = {
aScatterDir[missDir].x * missDist + psTarget->pos.x + minOffset,
aScatterDir[missDir].y * missDist + psTarget->pos.y + minOffset,

View File

@ -321,18 +321,6 @@ void orderUpdateDroid(DROID *psDroid)
}
}
// default to guarding if the correct secondary order is set
else if ((psDroid->player == selectedPlayer) &&
(psDroid->psTarStats != (BASE_STATS *) structGetDemolishStat()) && // stop the constructor auto repairing when it is about to demolish
secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_GUARD &&
!isVtolDroid(psDroid))
{
UDWORD actionX = psDroid->pos.x;
UDWORD actionY = psDroid->pos.y;
orderDroidLoc(psDroid, DORDER_GUARD, actionX,actionY);
}
//repair droids default to repairing droids within a given range
else if ((psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR)
&& !orderState(psDroid, DORDER_GUARD))
@ -372,6 +360,14 @@ void orderUpdateDroid(DROID *psDroid)
}
}
// default to guarding if the correct secondary order is set
else if (psDroid->psTarStats != (BASE_STATS *)structGetDemolishStat() && // stop the constructor auto repairing when it is about to demolish
secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_GUARD &&
!isVtolDroid(psDroid))
{
orderDroidLoc(psDroid, DORDER_GUARD, psDroid->pos.x, psDroid->pos.y);
}
break;
case DORDER_TRANSPORTRETURN:
if (psDroid->action == DACTION_NONE)
@ -3281,11 +3277,12 @@ void orderSelectedStatsTwoLoc(UDWORD player, DROID_ORDER order,
// See if the player has access to a transporter in this map.
//
DROID *FindATransporter(void)
DROID *FindATransporter(unsigned player)
{
DROID *psDroid;
for(psDroid = apsDroidLists[selectedPlayer]; (psDroid != NULL); psDroid = psDroid->psNext) {
for (psDroid = apsDroidLists[player]; psDroid != NULL; psDroid = psDroid->psNext)
{
if( psDroid->droidType == DROID_TRANSPORTER ) {
return psDroid;
}
@ -3318,11 +3315,12 @@ static STRUCTURE *FindAFactory(UDWORD player, UDWORD factoryType)
// See if the player has access to a repair facility in this map.
//
static STRUCTURE *FindARepairFacility(void)
static STRUCTURE *FindARepairFacility(unsigned player)
{
STRUCTURE *psStruct;
for(psStruct = apsStructLists[selectedPlayer]; (psStruct != NULL); psStruct = psStruct->psNext) {
for (psStruct = apsStructLists[player]; psStruct != NULL; psStruct = psStruct->psNext)
{
if(psStruct->pStructureType->type == REF_REPAIR_FACILITY) {
return psStruct;
}
@ -3401,7 +3399,7 @@ BOOL secondarySupported(DROID *psDroid, SECONDARY_ORDER sec)
if ((FindAFactory(psDroid->player, REF_FACTORY) == NULL) &&
(FindAFactory(psDroid->player, REF_CYBORG_FACTORY) == NULL) &&
(FindAFactory(psDroid->player, REF_VTOL_FACTORY) == NULL) &&
(FindARepairFacility() == NULL))
(FindARepairFacility(psDroid->player) == NULL))
{
supported = false;
}
@ -3854,7 +3852,7 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
CurrState |= DSS_RTL_BASE;
break;
case DSS_RTL_TRANSPORT:
psTransport = FindATransporter();
psTransport = FindATransporter(psDroid->player);
if (psTransport != NULL)
{
//in multiPlayer can only put cyborgs onto a Transporter

View File

@ -238,7 +238,7 @@ extern void orderGroupMoralCheck(struct _droid_group *psGroup);
extern const char* getDroidOrderName(DROID_ORDER order);
extern DROID *FindATransporter(void);
extern DROID *FindATransporter(unsigned player);
/*For a given constructor droid, check if there are any damaged buildings within
a defined range*/

View File

@ -1114,7 +1114,7 @@ BOOL OrderDroidToEmbark(DROID *psDroid)
{
DROID *psTransporter;
psTransporter = FindATransporter();
psTransporter = FindATransporter(psDroid->player);
if(psTransporter != NULL)
{