Fix ticket:1478 "Non-host players do not get info about the research in progress by allied AIs in MP"

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/2.3@11556 4a71c877-e1ca-e34f-864e-861f7616d084
(cherry picked from commit edadbb83fd34e65d125d396110db13f8e5cc8097)

Conflicts:

	src/scriptai.c
	src/scriptfuncs.c
master
buginator 2010-10-18 23:02:34 -04:00
parent 5f83b41456
commit ccb286ceaa
2 changed files with 47 additions and 46 deletions

View File

@ -1640,7 +1640,7 @@ BOOL scrSkDoResearch(void)
PLAYER_RESEARCH *pPlayerRes;
RESEARCH *pResearch;
if (!stackPopParams(3,ST_STRUCTURE, &psBuilding, VAL_INT, &player, VAL_INT,&bias ))
if (!stackPopParams(3, ST_STRUCTURE, &psBuilding, VAL_INT, &player, VAL_INT, &bias))
{
return false;
}
@ -1654,7 +1654,7 @@ BOOL scrSkDoResearch(void)
}
// choose a topic to complete.
for(i=0;i<numResearch;i++)
for(i=0; i < numResearch; i++)
{
if (skTopicAvail(i, player) && (!bMultiPlayer || !beingResearchedByAlly(i, player)))
{
@ -1664,10 +1664,13 @@ BOOL scrSkDoResearch(void)
if(i != numResearch)
{
pResearch = asResearch + i;
if (bMultiMessages)
pResearch = (asResearch + i);
pPlayerRes = asPlayerResList[player] + i;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
if (IsResearchCancelled(pPlayerRes))
{
sendResearchStatus(psBuilding, pResearch->ref - REF_RESEARCH_START, player, true);
psResFacilty->powerAccrued = pResearch->researchPower; //set up as if all power available for cancelled topics
}
else
{
@ -1693,6 +1696,16 @@ BOOL scrSkDoResearch(void)
}
}
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

@ -10441,16 +10441,13 @@ BOOL objectInRangeVis(BASE_OBJECT *psList, SDWORD x, SDWORD y, SDWORD range, SDW
BOOL scrPursueResearch(void)
{
RESEARCH *psResearch;
SDWORD foundIndex = 0,player,cur,tempIndex,Stack[400];
SDWORD foundIndex = 0, player, cur, tempIndex, Stack[400];
UDWORD index;
SWORD top;
BOOL found;
PLAYER_RESEARCH *pPlayerRes;
STRUCTURE *psBuilding;
RESEARCH_FACILITY *psResFacilty;
RESEARCH *pResearch;
if (!stackPopParams(3,ST_STRUCTURE, &psBuilding, VAL_INT, &player, ST_RESEARCH, &psResearch ))
@ -10459,7 +10456,7 @@ BOOL scrPursueResearch(void)
return false;
}
if(psResearch == NULL)
if (psResearch == NULL)
{
ASSERT(false, ": no such research topic");
return false;
@ -10467,7 +10464,7 @@ BOOL scrPursueResearch(void)
psResFacilty = (RESEARCH_FACILITY*)psBuilding->pFunctionality;
if(psResFacilty->psSubject != NULL) // not finished yet
if (psResFacilty->psSubject != NULL) // not finished yet
{
scrFunctionResult.v.bval = false;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
@ -10488,28 +10485,27 @@ BOOL scrPursueResearch(void)
found = false;
if(beingResearchedByAlly(index, player)) //an ally is already researching it
if (beingResearchedByAlly(index, player)) //an ally is already researching it
{
found = false;
}
else if(IsResearchCompleted(&pPlayerRes[index]))
else if (IsResearchCompleted(&pPlayerRes[index]))
{
found = false;
//DbgMsg("Research already completed: %d", index);
}
else if(IsResearchStarted(&pPlayerRes[index]))
else if (IsResearchStarted(&pPlayerRes[index]))
{
found = false;
//DbgMsg("Research already in progress, %d", index);
}
else if(IsResearchPossible(&pPlayerRes[index])
|| IsResearchCancelled(&pPlayerRes[index]))
else if (IsResearchPossible(&pPlayerRes[index]) || IsResearchCancelled(&pPlayerRes[index]))
{
foundIndex = index;
found = true;
//DbgMsg("Research possible or cancelled: %d", index);
}
else if(skTopicAvail(index,player))
else if (skTopicAvail(index, player))
{
foundIndex = index;
found = true;
@ -10526,12 +10522,12 @@ BOOL scrPursueResearch(void)
{
//DbgMsg("Going on with %d, numPR: %d, %s", index, asResearch[index].numPRRequired, asResearch[index].pName);
if(cur >= asResearch[index].numPRRequired) //node has nodes?
if (cur >= asResearch[index].numPRRequired) //node has nodes?
{
//DbgMsg("cur >= numPRRequired : %d (%d >= %d)", index, cur, asResearch[index].numPRRequired);
top = top - 2;
if(top < (-1))
if (top < (-1))
{
//DbgMsg("Nothing on stack");
break; //end of stack
@ -10545,17 +10541,17 @@ BOOL scrPursueResearch(void)
tempIndex = asResearch[index].pPRList[cur]; //get cur node's index
//DbgMsg("evaluating node: %d, (cur = %d), %s", tempIndex, cur, asResearch[tempIndex].pName);
if(skTopicAvail(tempIndex,player) && (!beingResearchedByAlly(tempIndex, player))) //<NEW> - ally check added
if (skTopicAvail(tempIndex,player) && (!beingResearchedByAlly(tempIndex, player))) //<NEW> - ally check added
{
//DbgMsg("avail: %d (cur=%d), %s", tempIndex, cur, asResearch[tempIndex].pName);
found = true;
foundIndex = tempIndex; //done
break;
}
else if((IsResearchCompleted(&pPlayerRes[tempIndex])==false) && (IsResearchStarted(&pPlayerRes[tempIndex])==false)) //not avail and not busy with it, can check this PR's PR
else if ((IsResearchCompleted(&pPlayerRes[tempIndex]) == false) && (IsResearchStarted(&pPlayerRes[tempIndex]) == false)) //not avail and not busy with it, can check this PR's PR
{
//DbgMsg("node not complete, not started: %d, (cur=%d), %s", tempIndex,cur, asResearch[tempIndex].pName);
if(asResearch[tempIndex].numPRRequired > 0) //node has any nodes itself
if (asResearch[tempIndex].numPRRequired > 0) //node has any nodes itself
{
//DbgMsg("node has nodes, so selecting as main node: %d, %s", tempIndex, asResearch[tempIndex].pName);
@ -10582,43 +10578,36 @@ BOOL scrPursueResearch(void)
cur++; //try next node of the main node
if((cur >= asResearch[index].numPRRequired) && (top <= (-1))) //nothing left
{
//DbgMsg("END");
break;
}
} // while(true)
}
if(found
&& foundIndex < numResearch)
if (found && foundIndex < numResearch)
{
pResearch = (asResearch + foundIndex);
if (bMultiMessages)
pPlayerRes = asPlayerResList[player] + foundIndex;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
if (IsResearchCancelled(pPlayerRes))
{
sendResearchStatus(psBuilding, pResearch->ref - REF_RESEARCH_START, player, true);
psResFacilty->powerAccrued = pResearch->researchPower; //set up as if all power available for cancelled topics
}
else
{
pPlayerRes = asPlayerResList[player]+ foundIndex;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
psResFacilty->powerAccrued = 0;
}
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;
MakeResearchStarted(pPlayerRes);
psResFacilty->timeStarted = ACTION_START_TIME;
psResFacilty->timeStartHold = 0;
psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
if (psResFacilty->timeToResearch == 0)
{
psResFacilty->timeToResearch = 1;
}
if (psResFacilty->timeToResearch == 0)
{
psResFacilty->timeToResearch = 1;
}
#if defined (DEBUG)
{
@ -10628,7 +10617,6 @@ BOOL scrPursueResearch(void)
}
#endif
}
scrFunctionResult.v.bval = found;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
{