Fix synch error, don't let AIs bypass the message queue when starting researching.

master
Cyp 2010-10-23 16:44:12 +02:00
parent e8ebb11d4a
commit 9b52ee44b4
5 changed files with 32 additions and 73 deletions

View File

@ -6213,9 +6213,6 @@ static BOOL setResearchStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
{
// Say that we want to do reseach [sic].
sendResearchStatus(psBuilding, ((RESEARCH *)psStats)->ref - REF_RESEARCH_START, selectedPlayer, true);
// Tell UI to remove from the list of available research.
MakeResearchStartedPending(asPlayerResList[selectedPlayer] + (((RESEARCH *)psStats)->ref - REF_RESEARCH_START));
}
else
{

View File

@ -904,7 +904,7 @@ static BOOL recvResearch(NETQUEUE queue)
}
pPlayerRes = asPlayerResList[player] + index;
syncDebug("research status = %d", pPlayerRes->ResearchStatus);
syncDebug("research status = %d", pPlayerRes->ResearchStatus & RESBITS);
if (!IsResearchCompleted(pPlayerRes))
{
@ -968,6 +968,9 @@ BOOL sendResearchStatus(STRUCTURE *psBuilding, uint32_t index, uint8_t player, B
NETuint32_t(&index);
NETend();
// Tell UI to remove from the list of available research.
MakeResearchStartedPending(asPlayerResList[selectedPlayer] + index);
return true;
}

View File

@ -1637,8 +1637,6 @@ BOOL scrSkDoResearch(void)
STRUCTURE *psBuilding;
RESEARCH_FACILITY *psResFacilty;
PLAYER_RESEARCH *pPlayerRes;
RESEARCH *pResearch;
if (!stackPopParams(3, ST_STRUCTURE, &psBuilding, VAL_INT, &player, VAL_INT, &bias))
{
@ -1664,48 +1662,7 @@ BOOL scrSkDoResearch(void)
if(i != numResearch)
{
pResearch = (asResearch + i);
pPlayerRes = asPlayerResList[player] + i;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
if (IsResearchCancelled(pPlayerRes))
{
psResFacilty->powerAccrued = pResearch->researchPower; //set up as if all power available for cancelled topics
}
else
{
pPlayerRes = asPlayerResList[player]+ i;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
if (IsResearchCancelled(pPlayerRes))
{
psResFacilty->powerAccrued = pResearch->researchPower;//set up as if all power available for cancelled topics
}
else
{
psResFacilty->powerAccrued = 0;
}
MakeResearchStarted(pPlayerRes);
psResFacilty->timeStarted = ACTION_START_TIME;
psResFacilty->timeStartHold = 0;
psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
if (psResFacilty->timeToResearch == 0)
{
psResFacilty->timeToResearch = 1;
}
}
sendResearchStatus(psBuilding, i, player, true); // inform others, I'm researching this.
MakeResearchStarted(pPlayerRes);
psResFacilty->timeStarted = ACTION_START_TIME;
psResFacilty->timeStartHold = 0;
psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
if (psResFacilty->timeToResearch == 0)
{
psResFacilty->timeToResearch = 1;
}
#if defined (DEBUG)
{
char sTemp[128];

View File

@ -10448,7 +10448,6 @@ BOOL scrPursueResearch(void)
PLAYER_RESEARCH *pPlayerRes;
STRUCTURE *psBuilding;
RESEARCH_FACILITY *psResFacilty;
RESEARCH *pResearch;
if (!stackPopParams(3,ST_STRUCTURE, &psBuilding, VAL_INT, &player, ST_RESEARCH, &psResearch ))
{
@ -10586,29 +10585,7 @@ BOOL scrPursueResearch(void)
if (found && foundIndex < numResearch)
{
pResearch = (asResearch + foundIndex);
pPlayerRes = asPlayerResList[player] + foundIndex;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
if (IsResearchCancelled(pPlayerRes))
{
psResFacilty->powerAccrued = pResearch->researchPower; //set up as if all power available for cancelled topics
}
else
{
psResFacilty->powerAccrued = 0;
}
sendResearchStatus(psBuilding, foundIndex, player, true); // inform others, I'm researching this.
MakeResearchStarted(pPlayerRes);
psResFacilty->timeStarted = ACTION_START_TIME;
psResFacilty->timeStartHold = 0;
psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
if (psResFacilty->timeToResearch == 0)
{
psResFacilty->timeToResearch = 1;
}
#if defined (DEBUG)
{
char sTemp[128];

View File

@ -3825,14 +3825,39 @@ static float CalcStructureSmokeInterval(float damage)
void _syncDebugStructure(const char *function, STRUCTURE *psStruct, char ch)
{
// TODO psBuilding->status == SS_BEING_BUILT test is because structure ids are not synchronised until after they start building...
_syncDebug(function, "%c structure%d = p%d;pos(%d,%d,%d),stat%d,type%d,bld%d,pwr%d,bp%d, power = %"PRId64"", ch,
int ref = 0;
char const *refStr = "";
// Print what the structure is producing, too.
switch (psStruct->pStructureType->type)
{
case REF_RESEARCH:
if (psStruct->pFunctionality->researchFacility.psSubject != NULL)
{
ref = psStruct->pFunctionality->researchFacility.psSubject->ref;
refStr = ",research";
}
break;
case REF_FACTORY:
case REF_CYBORG_FACTORY:
case REF_VTOL_FACTORY:
if (psStruct->pFunctionality->factory.psSubject != NULL)
{
ref = psStruct->pFunctionality->factory.psSubject->ref;
refStr = ",production";
}
break;
default:
break;
}
_syncDebug(function, "%c structure%d = p%d;pos(%d,%d,%d),stat%d,type%d%s%.0d,bld%d,pwr%d,bp%d, power = %"PRId64"", ch,
psStruct->id,
psStruct->player,
psStruct->pos.x, psStruct->pos.y, psStruct->pos.z,
psStruct->status,
psStruct->pStructureType->type,
psStruct->pStructureType->type, refStr, ref,
psStruct->currentBuildPts,
psStruct->currentPowerAccrued,
psStruct->body,