From 518e9b9f1f272e8678b4a00d77118d0b1ac4a96e Mon Sep 17 00:00:00 2001 From: gewlitys Date: Wed, 4 Dec 2002 02:28:29 +0000 Subject: [PATCH] l0ci's fixes (spheres of influence now move correctly) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@309 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/libs/graphics/boxint.c | 19 +++++++++++++++++++ sc2/src/sc2code/planets/pstarmap.c | 2 ++ 3 files changed, 22 insertions(+) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 0e5594c89..d6cfcefb8 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ 0.2: +- Spheres of influence now move correctly in starmap, from l0ci@hotmail.com - Linux OpenAL fixes (music plays now as stereo) - Fuel giveaway bug fixed, from steve@blckknght.org - Starmap fuel range calculator and actual consumption matches now diff --git a/sc2/src/sc2code/libs/graphics/boxint.c b/sc2/src/sc2code/libs/graphics/boxint.c index 38c7fee6b..8eaee46c1 100644 --- a/sc2/src/sc2code/libs/graphics/boxint.c +++ b/sc2/src/sc2code/libs/graphics/boxint.c @@ -18,6 +18,9 @@ #include "gfxintrn.h" +#define min(a, b) ((a <= b) ? a : b) +#define max(a, b) ((a >= b) ? a : b) + INTERSECT_CODE BoxIntersect (PRECT pr1, PRECT pr2, PRECT pinter) { @@ -100,6 +103,20 @@ void BoxUnion (PRECT pr1, PRECT pr2, PRECT punion) { COORD x2, y2, w2, h2; + // Union is A AND B, put together, correct? Returns a bigger box that + // encompasses the two. + punion->corner.x = min(pr1->corner.x, pr2->corner.x); + punion->corner.y = min(pr1->corner.y, pr2->corner.y); + + punion->extent.width = max(pr1->corner.x + pr1->extent.width, + pr2->corner.x + pr2->extent.width) - punion->corner.x; + punion->extent.height = max(pr1->corner.y + pr1->extent.height, + pr2->corner.y + pr2->extent.height) - punion->corner.y; + + +#if NEVER // FIXME - I think this is broken, but keeping it around for reference + // FIXME - just in case. + #if 1 /* alter based on 0 widths */ x2 = @@ -155,5 +172,7 @@ BoxUnion (PRECT pr1, PRECT pr2, PRECT punion) punion->corner.y = y2; punion->extent.width = w2; punion->extent.height = h2; + +#endif // NEVER } diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 30144ee5b..8448bc4fb 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -226,6 +226,8 @@ GetSphereRect (EXTENDED_SHIP_FRAGMENTPTR StarShipPtr, PRECT pRect, PRECT pRepairRect->corner.y = SIS_SCREEN_HEIGHT - pRepairRect->extent.height - 1; BoxUnion (pRepairRect, pRect, pRepairRect); + pRepairRect->extent.width++; + pRepairRect->extent.height++; } }