Fix fencepost error in giftArtifact() properly. Now we do not skip research item zero,

and we do not underflow an unsigned value. Patch by Adam Olsen (Rhamphoryncus). 
Closes ticket:373


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8082 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-09-03 20:40:58 +00:00 committed by Git SVN Gateway
parent 2cabd14a50
commit ef9e770ab3
1 changed files with 4 additions and 5 deletions

View File

@ -730,15 +730,14 @@ void recvMultiPlayerRandomArtifacts()
// /////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////
void giftArtifact(UDWORD owner, UDWORD x, UDWORD y) void giftArtifact(UDWORD owner, UDWORD x, UDWORD y)
{ {
PLAYER_RESEARCH *pO,*pR; PLAYER_RESEARCH *pR = asPlayerResList[selectedPlayer];
UDWORD topic=0;
pR = asPlayerResList[selectedPlayer];
if (owner < MAX_PLAYERS) if (owner < MAX_PLAYERS)
{ {
pO = asPlayerResList[owner]; PLAYER_RESEARCH *pO = asPlayerResList[owner];
int topic;
for (topic = numResearch - 1; topic > 0; topic--) for (topic = numResearch - 1; topic >= 0; topic--)
{ {
if (IsResearchCompleted(&pO[topic]) if (IsResearchCompleted(&pO[topic])
&& !IsResearchPossible(&pR[topic])) && !IsResearchPossible(&pR[topic]))