From ef9e770ab37485bf67fd1b360d8e38234f7c40ee Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Thu, 3 Sep 2009 20:40:58 +0000 Subject: [PATCH] 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 --- src/multigifts.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/multigifts.c b/src/multigifts.c index d28ab9df9..8693f5dd8 100644 --- a/src/multigifts.c +++ b/src/multigifts.c @@ -730,15 +730,14 @@ void recvMultiPlayerRandomArtifacts() // /////////////////////////////////////////////////////////////// void giftArtifact(UDWORD owner, UDWORD x, UDWORD y) { - PLAYER_RESEARCH *pO,*pR; - UDWORD topic=0; - pR = asPlayerResList[selectedPlayer]; + PLAYER_RESEARCH *pR = asPlayerResList[selectedPlayer]; 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]) && !IsResearchPossible(&pR[topic]))