Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

newnet: Make AI research synchronised. Games with AIs now seem to sta…

…y in synch.
  • Loading branch information...
commit 94a555329a15ae9060f8654daa62aa4b9dc9e331 1 parent 6f4b9f5
@Cyp Cyp authored
View
1  newnet.TODO
@@ -55,3 +55,4 @@ Check the researchResult function. Should a message be sent there, and if so, th
* src/scriptfuncs.c *
*********************
Sanity check that this file doesn't do anything stupid, such as modifying the game state directly.
+Such as unloading transporters directly, not sure if that's used in multiplayer, though. And scrResetPlayerVisibility, scrSetDroidKills, scrFireWeaponAtLoc, scrFireWeaponAtObj, scrTakeOver..., some others, scrAddPower, scrCompleteResearch, scrDestroyStructure and many others.
View
4 src/hci.c
@@ -6159,7 +6159,7 @@ static BOOL setResearchStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
if (psStats != NULL)
{
// Say that we want to do reseach [sic].
- sendReseachStatus(psBuilding, ((RESEARCH *)psStats)->ref - REF_RESEARCH_START, selectedPlayer, true);
+ sendResearchStatus(psBuilding, ((RESEARCH *)psStats)->ref - REF_RESEARCH_START, selectedPlayer, true);
}
else
{
@@ -6206,7 +6206,7 @@ static BOOL setResearchStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
psResFacilty->powerAccrued = 0;
}
- sendReseachStatus(psBuilding,count,selectedPlayer,true); // inform others, I'm researching this.
+ sendResearchStatus(psBuilding,count,selectedPlayer,true); // inform others, I'm researching this.
MakeResearchStarted(pPlayerRes);
//psResFacilty->timeStarted = gameTime;
View
2  src/multiplay.c
@@ -915,7 +915,7 @@ static BOOL recvResearch(NETQUEUE queue)
// ////////////////////////////////////////////////////////////////////////////
// New research stuff, so you can see what others are up to!
// inform others that I'm researching this.
-BOOL sendReseachStatus(STRUCTURE *psBuilding, uint32_t index, uint8_t player, BOOL bStart)
+BOOL sendResearchStatus(STRUCTURE *psBuilding, uint32_t index, uint8_t player, BOOL bStart)
{
if (!myResponsibility(player) || gameTime < 5)
{
View
2  src/multiplay.h
@@ -210,7 +210,7 @@ extern BOOL sendPing (void); // allow game to request pings.
extern BOOL ForceDroidSync(const DROID* droidToSend);
// multijoin
-extern BOOL sendReseachStatus (STRUCTURE *psBuilding ,UDWORD index, UBYTE player, BOOL bStart);
+extern BOOL sendResearchStatus (STRUCTURE *psBuilding, UDWORD index, UBYTE player, BOOL bStart);
extern void displayAIMessage (char *pStr, SDWORD from, SDWORD to); //make AI process a message
View
6 src/research.c
@@ -1126,7 +1126,7 @@ void researchResult(UDWORD researchIndex, UBYTE player, BOOL bDisplay, STRUCTURE
ASSERT( researchIndex < numResearch, "researchResult: invalid research index" );
- sendReseachStatus(NULL, researchIndex, player, false);
+ sendResearchStatus(NULL, researchIndex, player, false);
// Confused whether we should wait for our message before doing anything, and confused what this function does...
MakeResearchCompleted(&pPlayerRes[researchIndex]);
@@ -1978,8 +1978,8 @@ void cancelResearch(STRUCTURE *psBuilding)
{
if (bMultiMessages)
{
- // Tell others that we want to stop reseaching [sic] something.
- sendReseachStatus(NULL, topicInc, psBuilding->player, false);
+ // Tell others that we want to stop researching something.
+ sendResearchStatus(NULL, topicInc, psBuilding->player, false);
return; // Wait for our message before doing anything. (Whatever this function does...)
}
View
39 src/scriptai.c
@@ -1667,32 +1667,37 @@ 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))
+ pResearch = asResearch + i;
+ if (bMultiMessages)
{
- psResFacilty->powerAccrued = pResearch->researchPower;//set up as if all power available for cancelled topics
+ sendResearchStatus(psBuilding, pResearch->ref - REF_RESEARCH_START, player, true);
}
else
{
- psResFacilty->powerAccrued = 0;
- }
+ pPlayerRes = asPlayerResList[player]+ i;
+ psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
- MakeResearchStarted(pPlayerRes);
- psResFacilty->timeStarted = ACTION_START_TIME;
- psResFacilty->timeStartHold = 0;
- psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
- if (psResFacilty->timeToResearch == 0)
- {
- psResFacilty->timeToResearch = 1;
+ 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;
+ }
}
sprintf(sTemp,"player:%d starts topic: %s",player, asResearch[i].pName );
NETlogEntry(sTemp,0,0);
-
-
}
return true;
View
134 src/scriptfuncs.c
@@ -936,12 +936,6 @@ BOOL scrAddDroidToMissionList(void)
return false;
}
-/* if ((UBYTE)player == selectedPlayer )
- {
- ASSERT( false, "scrAddDroidToMissionList: can't add own player to list" );
- return false;
- }*/
-
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrAddUnitToMissionList:player number is too high" );
@@ -976,7 +970,6 @@ BOOL scrAddDroidToMissionList(void)
BOOL scrAddDroid(void)
{
SDWORD x, y, player;
-// INTERP_VAL sVal;
DROID_TEMPLATE *psTemplate;
DROID *psDroid;
@@ -984,17 +977,6 @@ BOOL scrAddDroid(void)
{
return false;
}
-/* if (!stackPop(&sVal))
- {
- return false;
- }
- if (sVal.type != ST_TEMPLATE)
- {
- ASSERT( false, "scrAddDroid: type mismatch for object" );
- return false;
- }
- psTemplate = (DROID_TEMPLATE *)sVal.v.ival;
-*/
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrAddUnit:player number is too high" );
@@ -1078,7 +1060,6 @@ BOOL scrBuildingDestroyed(void)
{
SDWORD player;
UDWORD structureID;
-// INTERP_VAL sVal;
BOOL destroyed;
STRUCTURE *psCurr;
@@ -1086,18 +1067,6 @@ BOOL scrBuildingDestroyed(void)
{
return false;
}
-/* if (!stackPop(&sVal))
- {
- return false;
- }
-
- if (sVal.type != ST_STRUCTUREID)
- {
- ASSERT( false, "scrBuildingDestroyed: type mismatch for object" );
- return false;
- }
- structureID = (UDWORD)sVal.v.ival;
-*/
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrBuildingDestroyed:player number is too high" );
@@ -1128,22 +1097,11 @@ BOOL scrBuildingDestroyed(void)
BOOL scrEnableStructure(void)
{
SDWORD player, index;
-// INTERP_VAL sVal;
if (!stackPopParams(2, ST_STRUCTURESTAT, &index, VAL_INT, &player))
{
return false;
}
-/* if (!stackPop(&sVal))
- {
- return false;
- }
-
- if (sVal.type != ST_STRUCTURESTAT)
- {
- ASSERT( false, "scrEnableStructure: type mismatch for object" );
- return false;
- }*/
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrEnableStructure:player number is too high" );
@@ -1200,24 +1158,12 @@ BOOL scrIsStructureAvailable(void)
BOOL scrSelectDroidByID(void)
{
SDWORD player, droidID;
-// INTERP_VAL sVal;
BOOL selected;
if (!stackPopParams(2, ST_DROIDID, &droidID, VAL_INT, &player))
{
return false;
}
-/* if (!stackPop(&sVal))
- {
- return false;
- }
-
- if (sVal.type != ST_DROIDID)
- {
- ASSERT( false, "scrSelectDroidByID: type mismatch for object" );
- return false;
- }
-*/
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrSelectUnitByID:player number is too high" );
@@ -1403,7 +1349,6 @@ BOOL scrAddMessage(void)
MESSAGE_TYPE msgType;
SDWORD player;
BOOL playImmediate;
-// INTERP_VAL sVal;
VIEWDATA *psViewData;
UDWORD height;
@@ -1414,18 +1359,6 @@ BOOL scrAddMessage(void)
return false;
}
-/*
- if (!stackPop(&sVal))
- {
- return false;
- }
-
- if (sVal.type != ST_INTMESSAGE)
- {
- ASSERT( false, "scrAddMessage: type mismatch for object" );
- return false;
- }
-*/
if (player >= MAX_PLAYERS)
{
ASSERT( false, "scrAddMessage:player number is too high" );
@@ -1497,37 +1430,6 @@ BOOL scrRemoveMessage(void)
}
// -----------------------------------------------------------------------------------------
-// add a tutorial message to the Intelligence Display
-/*BOOL scrAddTutorialMessage(void)
-{
- SDWORD player;
- VIEWDATA *psViewData;
-
-
- if (!stackPopParams(2, ST_INTMESSAGE, &psViewData , VAL_INT, &player))
- {
- return false;
- }
-
- if (player >= MAX_PLAYERS)
- {
- ASSERT( false, "scrAddTutorialMessage:player number is too high" );
- return false;
- }
-
- //set the data
- tutorialMessage.pViewData = psViewData;
- tutorialMessage.player = player;
-
- //play the tutorial message immediately
- psCurrentMsg = &tutorialMessage;
- initTextDisplay(psCurrentMsg, font_regular, 255);
- addIntelScreen(true);
-
- return true;
-}*/
-
-// -----------------------------------------------------------------------------------------
/*builds a droid in the specified factory*/
BOOL scrBuildDroid(void)
{
@@ -10675,26 +10577,32 @@ BOOL scrPursueResearch(void)
&& foundIndex < numResearch)
{
pResearch = (asResearch + foundIndex);
- pPlayerRes = asPlayerResList[player]+ foundIndex;
- psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
- debug(LOG_ERROR, "FIXME! Not synchronised! And probably duplicate code!");
-
- if (IsResearchCancelled(pPlayerRes))
+ if (bMultiMessages)
{
- psResFacilty->powerAccrued = pResearch->researchPower;//set up as if all power available for cancelled topics
+ sendResearchStatus(psBuilding, pResearch->ref - REF_RESEARCH_START, player, true);
}
else
{
- psResFacilty->powerAccrued = 0;
- }
+ pPlayerRes = asPlayerResList[player]+ foundIndex;
+ psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
- MakeResearchStarted(pPlayerRes);
- psResFacilty->timeStarted = ACTION_START_TIME;
- psResFacilty->timeStartHold = 0;
- psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints;
- if (psResFacilty->timeToResearch == 0)
- {
- psResFacilty->timeToResearch = 1;
+ 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;
+ }
}
sprintf(sTemp,"player:%d starts topic: %s",player, asResearch[foundIndex].pName );
Please sign in to comment.
Something went wrong with that request. Please try again.