You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(147) |
Oct
(219) |
Nov
(189) |
Dec
(380) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(301) |
Feb
(369) |
Mar
(155) |
Apr
(61) |
May
(77) |
Jun
(101) |
Jul
(191) |
Aug
(107) |
Sep
(180) |
Oct
(37) |
Nov
(7) |
Dec
(28) |
| 2004 |
Jan
(34) |
Feb
(45) |
Mar
(7) |
Apr
(17) |
May
(6) |
Jun
(59) |
Jul
(4) |
Aug
(8) |
Sep
(6) |
Oct
(18) |
Nov
(11) |
Dec
(15) |
| 2005 |
Jan
(148) |
Feb
(146) |
Mar
(73) |
Apr
(154) |
May
(192) |
Jun
(11) |
Jul
(23) |
Aug
(23) |
Sep
(26) |
Oct
(68) |
Nov
(109) |
Dec
(294) |
| 2006 |
Jan
(172) |
Feb
(22) |
Mar
(81) |
Apr
(79) |
May
(83) |
Jun
(23) |
Jul
(35) |
Aug
(66) |
Sep
(39) |
Oct
(133) |
Nov
(125) |
Dec
(90) |
| 2007 |
Jan
(49) |
Feb
(21) |
Mar
(3) |
Apr
(33) |
May
(19) |
Jun
(26) |
Jul
(32) |
Aug
(18) |
Sep
(14) |
Oct
(2) |
Nov
(8) |
Dec
(22) |
| 2008 |
Jan
(23) |
Feb
(14) |
Mar
(28) |
Apr
(11) |
May
(55) |
Jun
(8) |
Jul
(1) |
Aug
(36) |
Sep
(8) |
Oct
(20) |
Nov
(6) |
Dec
|
| 2009 |
Jan
(2) |
Feb
(7) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(46) |
Jul
(15) |
Aug
(1) |
Sep
(3) |
Oct
(88) |
Nov
(108) |
Dec
(119) |
| 2010 |
Jan
(31) |
Feb
(3) |
Mar
(5) |
Apr
(1) |
May
(5) |
Jun
(5) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
(23) |
Mar
(1) |
Apr
(20) |
May
(27) |
Jun
(2) |
Jul
(40) |
Aug
(14) |
Sep
(17) |
Oct
(5) |
Nov
|
Dec
(28) |
| 2012 |
Jan
(31) |
Feb
(19) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
(1) |
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
|
From: <Mee...@us...> - 2012-01-29 15:44:01
|
Revision: 3757
http://sc2.svn.sourceforge.net/sc2/?rev=3757&view=rev
Author: Meep-Eep
Date: 2012-01-29 15:43:55 +0000 (Sun, 29 Jan 2012)
Log Message:
-----------
Generalised some functions.
Modified Paths:
--------------
trunk/sc2/src/uqm/build.c
trunk/sc2/src/uqm/build.h
Modified: trunk/sc2/src/uqm/build.c
===================================================================
--- trunk/sc2/src/uqm/build.c 2012-01-28 21:10:41 UTC (rev 3756)
+++ trunk/sc2/src/uqm/build.c 2012-01-29 15:43:55 UTC (rev 3757)
@@ -271,18 +271,19 @@
}
/*
- * Returns true if and only if a ship of the specified race is among the
+ * Returns the number of ships of the specified race among the
* escort ships.
*/
-BOOLEAN
-HaveEscortShip (COUNT race)
+COUNT
+CountEscortShips (COUNT race)
{
HFLEETINFO hFleet;
HSHIPFRAG hStarShip, hNextShip;
+ COUNT result = 0;
hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race);
if (!hFleet)
- return FALSE;
+ return 0;
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
hStarShip = hNextShip)
@@ -296,12 +297,22 @@
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
if (ship_type == race)
- return TRUE;
+ result++;
}
- return FALSE;
+ return result;
}
/*
+ * Returns true if and only if a ship of the specified race is among the
+ * escort ships.
+ */
+BOOLEAN
+HaveEscortShip (COUNT race)
+{
+ return (CountEscortShips (race) > 0);
+}
+
+/*
* Test if the SIS can have an escort of the specified race.
* Returns 0 if 'race' is not available.
* Otherwise, returns the number of ships that can be added.
@@ -342,14 +353,18 @@
}
/*
- * Remove all escort ships of the specified race.
+ * Remove a number of escort ships of the specified race (if present).
+ * Returns the number of escort ships removed.
*/
-void
-RemoveEscortShips (COUNT race)
+COUNT
+RemoveSomeEscortShips (COUNT race, COUNT count)
{
- HSHIPFRAG hStarShip, hNextShip;
- BOOLEAN ShipRemoved = FALSE;
+ HSHIPFRAG hStarShip;
+ HSHIPFRAG hNextShip;
+ if (count == 0)
+ return 0;
+
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
hStarShip = hNextShip)
{
@@ -363,20 +378,34 @@
if (RemoveShip)
{
- ShipRemoved = TRUE;
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
FreeShipFrag (&GLOBAL (built_ship_q), hStarShip);
+ count--;
+ if (count == 0)
+ break;
}
}
- if (ShipRemoved)
+ if (count > 0)
{
+ // Update the display.
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
+
+ return count;
}
+/*
+ * Remove all escort ships of the specified race.
+ */
+void
+RemoveEscortShips (COUNT race)
+{
+ RemoveSomeEscortShips (race, (COUNT) -1);
+}
+
COUNT
GetIndexFromStarShip (QUEUE *pShipQ, HLINK hStarShip)
{
Modified: trunk/sc2/src/uqm/build.h
===================================================================
--- trunk/sc2/src/uqm/build.h 2012-01-28 21:10:41 UTC (rev 3756)
+++ trunk/sc2/src/uqm/build.h 2012-01-29 15:43:55 UTC (rev 3757)
@@ -51,9 +51,11 @@
//extern COUNT GetRaceKnownSize (COUNT race);
extern COUNT SetRaceAllied (COUNT race, BOOLEAN flag);
extern COUNT StartSphereTracking (COUNT race);
+extern COUNT CountEscortShips (COUNT race);
extern BOOLEAN HaveEscortShip (COUNT race);
extern COUNT EscortFeasibilityStudy (COUNT race);
extern COUNT CheckAlliance (COUNT race);
+extern COUNT RemoveSomeEscortShips (COUNT race, COUNT count);
extern void RemoveEscortShips (COUNT race);
extern RACE_DESC *load_ship (SPECIES_ID SpeciesID, BOOLEAN LoadBattleData);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-28 21:10:47
|
Revision: 3756
http://sc2.svn.sourceforge.net/sc2/?rev=3756&view=rev
Author: Meep-Eep
Date: 2012-01-28 21:10:41 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Ships to buy didn't flash in the shipyard in PC menu mode.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-28 19:47:22 UTC (rev 3755)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-28 21:10:41 UTC (rev 3756)
@@ -647,7 +647,7 @@
break;
case DMS_Mode_addEscort:
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
- SetFlashRect (SFR_MENU_3DO);
+ SetFlashRect (SFR_MENU_ANY);
break;
case DMS_Mode_editCrew:
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-28 19:47:28
|
Revision: 3755
http://sc2.svn.sourceforge.net/sc2/?rev=3755&view=rev
Author: Meep-Eep
Date: 2012-01-28 19:47:22 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Fix for src\uqm\outfit.c(569) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
Modified Paths:
--------------
trunk/sc2/src/uqm/outfit.c
Modified: trunk/sc2/src/uqm/outfit.c
===================================================================
--- trunk/sc2/src/uqm/outfit.c 2012-01-28 19:30:52 UTC (rev 3754)
+++ trunk/sc2/src/uqm/outfit.c 2012-01-28 19:47:22 UTC (rev 3755)
@@ -566,7 +566,7 @@
{
const int maxFit = GetFuelTankCapacity () - GLOBAL_SIS (FuelOnBoard);
const int maxAfford = GLOBAL_SIS (ResUnits) / GLOBAL (FuelCost);
- const int minFit = -GLOBAL_SIS (FuelOnBoard);
+ const int minFit = - (int) GLOBAL_SIS (FuelOnBoard);
if (incr > maxFit)
incr = maxFit; // All we can hold.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-28 19:30:58
|
Revision: 3754
http://sc2.svn.sourceforge.net/sc2/?rev=3754&view=rev
Author: Meep-Eep
Date: 2012-01-28 19:30:52 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Hibernate, not Sleep.
Modified Paths:
--------------
trunk/sc2/src/uqm.c
Modified: trunk/sc2/src/uqm.c
===================================================================
--- trunk/sc2/src/uqm.c 2012-01-28 19:08:30 UTC (rev 3753)
+++ trunk/sc2/src/uqm.c 2012-01-28 19:30:52 UTC (rev 3754)
@@ -452,7 +452,7 @@
}
else if (!GameActive)
{ // Throttle down the main loop when game is inactive
- SleepThread (ONE_SECOND / 4);
+ HibernateThread (ONE_SECOND / 4);
}
TFB_ProcessEvents ();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-28 19:08:36
|
Revision: 3753
http://sc2.svn.sourceforge.net/sc2/?rev=3753&view=rev
Author: avolkov
Date: 2012-01-28 19:08:30 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Fixes 3d planet lighting map calculations, bug #1151, from Louis Delacroix
Relative lighting factor in GenerateLightMap() should now be reexamined to determine what algorithm works best.
Modified Paths:
--------------
trunk/sc2/src/uqm/planets/plangen.c
Modified: trunk/sc2/src/uqm/planets/plangen.c
===================================================================
--- trunk/sc2/src/uqm/planets/plangen.c 2012-01-28 19:02:33 UTC (rev 3752)
+++ trunk/sc2/src/uqm/planets/plangen.c 2012-01-28 19:08:30 UTC (rev 3753)
@@ -1572,8 +1572,8 @@
if (y1 > MAP_HEIGHT)
y1 = MAP_HEIGHT;
- elev = pTopo + y0 * MAP_HEIGHT + x;
- for (i = y0; i < y1; ++i, elev += MAP_HEIGHT)
+ elev = pTopo + y0 * MAP_WIDTH + x;
+ for (i = y0; i < y1; ++i, elev += MAP_WIDTH)
{
int delta = abs (i - y);
int weight = 255; // full weight
@@ -1589,7 +1589,7 @@
max = v;
if (v < min)
min = v;
- avg += pblk->avg * weight;
+ avg += v * weight;
total_weight += weight;
}
avg /= total_weight;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-28 19:02:39
|
Revision: 3752
http://sc2.svn.sourceforge.net/sc2/?rev=3752&view=rev
Author: Meep-Eep
Date: 2012-01-28 19:02:33 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Add/Remove fuel 10 at a time with PageUp/PageDown, from from Scott A. Colcord, Nic.
Modified Paths:
--------------
trunk/sc2/ChangeLog
trunk/sc2/src/uqm/outfit.c
Modified: trunk/sc2/ChangeLog
===================================================================
--- trunk/sc2/ChangeLog 2012-01-28 17:07:35 UTC (rev 3751)
+++ trunk/sc2/ChangeLog 2012-01-28 19:02:33 UTC (rev 3752)
@@ -1,4 +1,6 @@
Changes towards version 0.8:
+- PageUp/PageDown now add/remove 10 fuel in the shipyard, from
+ Scott A. Colcord, Nic
- Annihigate flash thread - SvdB
- Switch SetFlashRect() to the new flash code - SvdB
- Add C++ support to the build system, from Scott A. Colcord
Modified: trunk/sc2/src/uqm/outfit.c
===================================================================
--- trunk/sc2/src/uqm/outfit.c 2012-01-28 17:07:35 UTC (rev 3751)
+++ trunk/sc2/src/uqm/outfit.c 2012-01-28 19:02:33 UTC (rev 3752)
@@ -85,7 +85,8 @@
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
- sprintf (buf, "%u", GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
+ sprintf (buf, "%u",
+ GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
SetContextFont (TinyFont);
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
@@ -98,43 +99,38 @@
static void
RedistributeFuel (void)
{
- COUNT m;
- DWORD FuelVolume;
+ const DWORD FuelVolume = GLOBAL_SIS (FuelOnBoard);
+ const CONTEXT OldContext = SetContext (SpaceContext);
RECT r;
-
- FuelVolume = GLOBAL_SIS (FuelOnBoard);
- if (FuelVolume <= FUEL_RESERVE)
- return;
-
- GLOBAL_SIS (FuelOnBoard) = 0;
- m = FUEL_VOLUME_PER_ROW;
-
- r.extent.width = 3;
r.extent.height = 1;
- while (FuelVolume -= m)
- {
- GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW;
- GetFTankCapacity (&r.corner);
- DrawPoint (&r.corner);
- r.corner.x += r.extent.width + 1;
- DrawPoint (&r.corner);
- r.corner.x -= r.extent.width;
- SetContextForeGroundColor (SetContextBackGroundColor (BLACK_COLOR));
- DrawFilledRectangle (&r);
- if (FuelVolume < FUEL_VOLUME_PER_ROW)
- m = (COUNT)FuelVolume;
- }
- FuelVolume = GLOBAL_SIS (FuelOnBoard) + m;
-
- r.extent.width = 5;
- while ((GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW) <
- GetFTankCapacity (&r.corner))
+ // Loop through all the rows to draw
+ BatchGraphics ();
+ for (GLOBAL_SIS (FuelOnBoard) = FUEL_RESERVE;
+ GLOBAL_SIS (FuelOnBoard) < GetFTankCapacity (&r.corner);
+ GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW)
{
- SetContextForeGroundColor (
- BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
+ // If we're less than the fuel level, draw fuel.
+ if (GLOBAL_SIS (FuelOnBoard) < FuelVolume)
+ {
+ r.extent.width = 3;
+ DrawPoint (&r.corner);
+ r.corner.x += r.extent.width + 1;
+ DrawPoint (&r.corner);
+ r.corner.x -= r.extent.width;
+ SetContextForeGroundColor (
+ SetContextBackGroundColor (BLACK_COLOR));
+ }
+ else // Otherwise, draw an empty bar.
+ {
+ r.extent.width = 5;
+ SetContextForeGroundColor (
+ BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
+ }
DrawFilledRectangle (&r);
}
+ UnbatchGraphics ();
+ SetContext (OldContext);
GLOBAL_SIS (FuelOnBoard) = FuelVolume;
}
@@ -348,7 +344,8 @@
GLOBAL (ModuleCost[old_slot_piece])
* MODULE_COST_SCALE);
- if (pMS->CurState == PLANET_LANDER || pMS->CurState == EMPTY_SLOT + 3)
+ if (pMS->CurState == PLANET_LANDER ||
+ pMS->CurState == EMPTY_SLOT + 3)
DisplayLanders (pMS);
else
{
@@ -402,7 +399,8 @@
NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item;
do
{
- if (NewState >= EMPTY_SLOT && (PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]))
+ if (NewState >= EMPTY_SLOT && (PulsedInputState.menu[KEY_MENU_UP]
+ || PulsedInputState.menu[KEY_MENU_DOWN]))
{
if (PulsedInputState.menu[KEY_MENU_UP])
{
@@ -551,69 +549,58 @@
static void
ChangeFuelQuantity (void)
{
- RECT r;
+ int incr = 0; // Fuel increment in fuel points (not units).
- r.extent.height = 1;
-
- if (PulsedInputState.menu[KEY_MENU_UP])
+ if (PulsedInputState.menu[KEY_MENU_UP])
+ incr = FUEL_TANK_SCALE; // +1 Unit
+ else if (PulsedInputState.menu[KEY_MENU_DOWN])
+ incr = -FUEL_TANK_SCALE; // -1 Unit
+ else if (PulsedInputState.menu[KEY_MENU_PAGE_UP])
+ incr = FUEL_VOLUME_PER_ROW; // +1 Bar
+ else if (PulsedInputState.menu[KEY_MENU_PAGE_DOWN])
+ incr = -FUEL_VOLUME_PER_ROW; // -1 Bar
+ else
+ return;
+
+ // Clamp incr to what we can afford/hold/have.
{
- LockMutex (GraphicsLock);
- SetContext (SpaceContext);
- if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard)
- && GLOBAL_SIS (ResUnits) >= (DWORD)GLOBAL (FuelCost))
- {
- if (GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE)
- {
- r.extent.width = 3;
- DrawPoint (&r.corner);
- r.corner.x += r.extent.width + 1;
- DrawPoint (&r.corner);
- r.corner.x -= r.extent.width;
- SetContextForeGroundColor (
- SetContextBackGroundColor (BLACK_COLOR));
- DrawFilledRectangle (&r);
- }
- PreUpdateFlashRect ();
- DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));
- PostUpdateFlashRect ();
- SetContext (StatusContext);
- GetGaugeRect (&r, FALSE);
- SetFlashRect (&r);
- }
- else
- { // no more room for fuel or not enough RUs
- PlayMenuSound (MENU_SOUND_FAILURE);
- }
- UnlockMutex (GraphicsLock);
+ const int maxFit = GetFuelTankCapacity () - GLOBAL_SIS (FuelOnBoard);
+ const int maxAfford = GLOBAL_SIS (ResUnits) / GLOBAL (FuelCost);
+ const int minFit = -GLOBAL_SIS (FuelOnBoard);
+
+ if (incr > maxFit)
+ incr = maxFit; // All we can hold.
+
+ if (incr > maxAfford * FUEL_TANK_SCALE)
+ incr = maxAfford * FUEL_TANK_SCALE; // All we can afford.
+
+ if (incr < minFit)
+ incr = minFit; // All we have.
}
- else if (PulsedInputState.menu[KEY_MENU_DOWN])
+
+ LockMutex (GraphicsLock);
+ if (!incr)
{
- LockMutex (GraphicsLock);
- SetContext (SpaceContext);
- if (GLOBAL_SIS (FuelOnBoard))
- {
- PreUpdateFlashRect ();
- DeltaSISGauges (0, -FUEL_TANK_SCALE, GLOBAL (FuelCost));
- PostUpdateFlashRect ();
- if (GLOBAL_SIS (FuelOnBoard) % FUEL_VOLUME_PER_ROW == 0 &&
- GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE)
- {
- GetFTankCapacity (&r.corner);
- SetContextForeGroundColor (
- BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
- r.extent.width = 5;
- DrawFilledRectangle (&r);
- }
- }
- else
- { // no fuel left to drain
- PlayMenuSound (MENU_SOUND_FAILURE);
- }
- SetContext (StatusContext);
+ // No more room, not enough RUs, or no fuel left to drain.
+ PlayMenuSound (MENU_SOUND_FAILURE);
+ }
+ else
+ {
+ const int cost = (incr / FUEL_TANK_SCALE) * GLOBAL (FuelCost);
+ PreUpdateFlashRect ();
+ DeltaSISGauges (0, incr, -cost);
+ PostUpdateFlashRect ();
+ RedistributeFuel ();
+ }
+
+ { // Make fuel gauge flash.
+ RECT r;
+ CONTEXT oldContext = SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r);
- UnlockMutex (GraphicsLock);
+ SetContext (oldContext);
}
+ UnlockMutex (GraphicsLock);
}
static void
@@ -810,7 +797,9 @@
switch (pMS->CurState)
{
case OUTFIT_DOFUEL:
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
+ SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN |
+ MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN,
+ MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
break;
default:
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-28 17:07:42
|
Revision: 3751
http://sc2.svn.sourceforge.net/sc2/?rev=3751&view=rev
Author: Meep-Eep
Date: 2012-01-28 17:07:35 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Some cleanups and bug fixes.
Modified Paths:
--------------
trunk/sc2/src/libs/strings/getstr.c
Modified: trunk/sc2/src/libs/strings/getstr.c
===================================================================
--- trunk/sc2/src/libs/strings/getstr.c 2012-01-27 23:29:03 UTC (rev 3750)
+++ trunk/sc2/src/libs/strings/getstr.c 2012-01-28 17:07:35 UTC (rev 3751)
@@ -61,6 +61,40 @@
}
}
+// Check whether a buffer has a certain minimum size, and enlarge it
+// if necessary.
+// buf: pointer to the pointer to the buffer. May be NULL.
+// curSize: pointer to the current size (multiple of 'increment')
+// minSize: required minimum size
+// increment: size to increment the buffer with if necessary
+// On success, *buf and *curSize are updated. On failure, they are
+// unchanged.
+// returns FALSE if and only if the buffer needs to be enlarged but
+// memory allocation failed.
+static BOOLEAN
+ensureBufSize (char **buf, size_t *curSize, size_t minSize, size_t increment)
+{
+ char *newBuf;
+ size_t newSize;
+
+ if (minSize <= *curSize)
+ {
+ // Buffer is large enough as it is.
+ return TRUE;
+ }
+
+ newSize = ((minSize + (increment - 1)) / increment) * increment;
+ // Smallest multiple of 'increment' larger or equal to minSize.
+ newBuf = HRealloc (*buf, newSize);
+ if (newBuf == NULL)
+ return FALSE;
+
+ // Success
+ *buf = newBuf;
+ *curSize = newSize;
+ return TRUE;
+}
+
void
_GetConversationData (const char *path, RESOURCE_DATA *resdata)
{
@@ -174,10 +208,22 @@
StringOffs = 0;
ClipOffs = 0;
TSOffs = 0;
- while (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) && n < MAX_STRINGS - 1)
+ for (;;)
{
int l;
+ if (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) == NULL)
+ {
+ // EOF or read error.
+ break;
+ }
+
+ if (n >= MAX_STRINGS - 1)
+ {
+ // Too many strings.
+ break;
+ }
+
if (CurrentLine[0] == '#')
{
// String header, of the following form:
@@ -226,13 +272,9 @@
if (*tsptr)
{
l = strlen (tsptr) + 1;
- if (TSOffs + l > tot_ts_size)
- {
- tot_ts_size += POOL_SIZE;
- ts_data = HRealloc (ts_data, tot_ts_size);
- if (ts_data == 0)
- goto err; // BUG: old ts_data leaks
- }
+ if (!ensureBufSize (&ts_data, &tot_ts_size, TSOffs + l,
+ POOL_SIZE))
+ goto err;
strcpy (&ts_data[TSOffs], tsptr);
TSOffs += l;
@@ -257,13 +299,9 @@
if (s)
{
l = path_len + strlen (s) + 1;
- if (ClipOffs + l > tot_clip_size)
- {
- tot_clip_size += POOL_SIZE;
- clipdata = HRealloc (clipdata, tot_clip_size);
- if (clipdata == 0)
- goto err; // BUG: old clipdata leaks
- }
+ if (!ensureBufSize (&clipdata, &tot_clip_size,
+ ClipOffs + l, POOL_SIZE))
+ goto err;
if (clip_path)
strcpy (&clipdata[ClipOffs], clip_path);
@@ -277,14 +315,11 @@
{
char *s;
l = strlen (CurrentLine) + 1;
- if (StringOffs + l > tot_string_size)
- {
- tot_string_size += POOL_SIZE;
- strdata = HRealloc (strdata, tot_string_size);
- if (strdata == 0)
- goto err; // BUG: old strdata leaks
- }
+ if (!ensureBufSize (&strdata, &tot_string_size, StringOffs + l,
+ POOL_SIZE))
+ goto err;
+
if (slen[n])
{
--slen[n];
@@ -385,21 +420,37 @@
void *result;
int n;
- DWORD opos, slen[MAX_STRINGS], StringOffs, tot_string_size;
- char CurrentLine[1024], *strdata;
+ DWORD opos;
+ DWORD slen[MAX_STRINGS];
+ DWORD StringOffs;
+ DWORD tot_string_size;
+ char CurrentLine[1024];
+ char *strdata = NULL;
tot_string_size = POOL_SIZE;
strdata = HMalloc (tot_string_size);
if (strdata == 0)
- return 0;
+ goto err;
opos = uio_ftell (fp);
n = -1;
StringOffs = 0;
- while (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) && n < MAX_STRINGS - 1)
+ for (;;)
{
int l;
+ if (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) == NULL)
+ {
+ // EOF or read error.
+ break;
+ }
+
+ if (n >= MAX_STRINGS - 1)
+ {
+ // Too many strings.
+ break;
+ }
+
if (CurrentLine[0] == '#')
{
char CopyLine[1024];
@@ -428,14 +479,11 @@
{
char *s;
l = strlen (CurrentLine) + 1;
- if (StringOffs + l > tot_string_size)
- {
- tot_string_size += POOL_SIZE;
- strdata = HRealloc (strdata, tot_string_size);
- if (strdata == 0)
- return 0; // BUG: old strdata leaks
- }
+ if (!ensureBufSize (&strdata, &tot_string_size, StringOffs + l,
+ POOL_SIZE))
+ goto err;
+
if (slen[n])
{
--slen[n];
@@ -489,6 +537,11 @@
HFree (strdata);
return result;
+
+err:
+ if (strdata != NULL)
+ HFree (strdata);
+ return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-27 23:29:11
|
Revision: 3750
http://sc2.svn.sourceforge.net/sc2/?rev=3750&view=rev
Author: Meep-Eep
Date: 2012-01-27 23:29:03 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
Annihigate flash thread.
Modified Paths:
--------------
trunk/sc2/ChangeLog
trunk/sc2/build/msvc6/UrQuanMasters.dsp
trunk/sc2/src/libs/Makeinfo
trunk/sc2/src/libs/callback/Makeinfo
trunk/sc2/src/libs/callback/alarm.c
trunk/sc2/src/libs/callback/alarm.h
trunk/sc2/src/libs/callback/callback.c
trunk/sc2/src/libs/callback/callback.h
trunk/sc2/src/libs/sound/mixer/nosound/audiodrv_nosound.c
trunk/sc2/src/libs/sound/stream.c
trunk/sc2/src/libs/threadlib.h
trunk/sc2/src/libs/threads/thrcommon.c
trunk/sc2/src/uqm/battle.c
trunk/sc2/src/uqm/confirm.c
trunk/sc2/src/uqm/gameinp.c
trunk/sc2/src/uqm/sis.c
trunk/sc2/src/uqm/sis.h
trunk/sc2/src/uqm/starcon.c
trunk/sc2/src/uqm/supermelee/netplay/netmelee.c
trunk/sc2/src/uqm/supermelee/pickmele.c
Added Paths:
-----------
trunk/sc2/src/libs/async.h
trunk/sc2/src/libs/callback/async.c
trunk/sc2/src/libs/callback/async.h
Modified: trunk/sc2/ChangeLog
===================================================================
--- trunk/sc2/ChangeLog 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/ChangeLog 2012-01-27 23:29:03 UTC (rev 3750)
@@ -1,5 +1,6 @@
Changes towards version 0.8:
-- Switch SetFlashRect() to the new flash code -- SvdB
+- Annihigate flash thread - SvdB
+- Switch SetFlashRect() to the new flash code - SvdB
- Add C++ support to the build system, from Scott A. Colcord
- Cleaning up DoModifyShips() - SvdB
- Added Valgrind suppression file, from Louis Delacroix
Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp
===================================================================
--- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2012-01-27 23:29:03 UTC (rev 3750)
@@ -215,6 +215,14 @@
# End Source File
# Begin Source File
+SOURCE=..\..\src\libs\callback\async.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\libs\callback\async.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\src\libs\callback\callback.c
# End Source File
# Begin Source File
@@ -1470,6 +1478,10 @@
# End Source File
# Begin Source File
+SOURCE=..\..\src\libs\async.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\src\libs\callback.h
# End Source File
# Begin Source File
Modified: trunk/sc2/src/libs/Makeinfo
===================================================================
--- trunk/sc2/src/libs/Makeinfo 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/Makeinfo 2012-01-27 23:29:03 UTC (rev 3750)
@@ -12,8 +12,8 @@
# uqm_SUBDIRS="$UQM_SUBDIRS debug"
#fi
-uqm_HFILES="alarm.h callback.h cdplib.h compiler.h declib.h file.h gfxlib.h
- heap.h inplib.h list.h log.h mathlib.h md5.h memlib.h misc.h net.h
- platform.h reslib.h sndlib.h strlib.h tasklib.h threadlib.h
- timelib.h uio.h uioutils.h unicode.h vidlib.h"
+uqm_HFILES="alarm.h async.h callback.h cdplib.h compiler.h declib.h file.h
+ gfxlib.h heap.h inplib.h list.h log.h mathlib.h md5.h memlib.h
+ misc.h net.h platform.h reslib.h sndlib.h strlib.h tasklib.h
+ threadlib.h timelib.h uio.h uioutils.h unicode.h vidlib.h"
Added: trunk/sc2/src/libs/async.h
===================================================================
--- trunk/sc2/src/libs/async.h (rev 0)
+++ trunk/sc2/src/libs/async.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -0,0 +1,10 @@
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#include "callback/async.h"
+
+#if defined(__cplusplus)
+}
+#endif
+
Modified: trunk/sc2/src/libs/callback/Makeinfo
===================================================================
--- trunk/sc2/src/libs/callback/Makeinfo 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/callback/Makeinfo 2012-01-27 23:29:03 UTC (rev 3750)
@@ -1,2 +1,2 @@
-uqm_CFILES="alarm.c callback.c"
-uqm_HFILES="alarm.h callback.h"
+uqm_CFILES="alarm.c async.c callback.c"
+uqm_HFILES="alarm.h async.h callback.h"
Modified: trunk/sc2/src/libs/callback/alarm.c
===================================================================
--- trunk/sc2/src/libs/callback/alarm.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/callback/alarm.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -18,6 +18,7 @@
#include "alarm.h"
+#include SDL_INCLUDE(SDL.h)
#include "libs/heap.h"
#include <assert.h>
@@ -71,19 +72,19 @@
}
static inline AlarmTime
-AlarmTime_nowMS(void) {
+AlarmTime_nowMs(void) {
return SDL_GetTicks();
}
Alarm *
-Alarm_addRelativeMs(Uint32 ms, AlarmCallback callback,
+Alarm_addAbsoluteMs(uint32 ms, AlarmCallback callback,
AlarmCallbackArg arg) {
Alarm *alarm;
assert(alarmHeap != NULL);
alarm = Alarm_alloc();
- alarm->time = AlarmTime_nowMS() + ms;
+ alarm->time = ms;
alarm->callback = callback;
alarm->arg = arg;
@@ -92,6 +93,23 @@
return alarm;
}
+Alarm *
+Alarm_addRelativeMs(uint32 ms, AlarmCallback callback,
+ AlarmCallbackArg arg) {
+ Alarm *alarm;
+
+ assert(alarmHeap != NULL);
+
+ alarm = Alarm_alloc();
+ alarm->time = AlarmTime_nowMs() + ms;
+ alarm->callback = callback;
+ alarm->arg = arg;
+
+ Heap_add(alarmHeap, (HeapValue *) alarm);
+
+ return alarm;
+}
+
void
Alarm_remove(Alarm *alarm) {
assert(alarmHeap != NULL);
@@ -99,15 +117,40 @@
Alarm_free(alarm);
}
+// Process at most one alarm, if its time has come.
// It is safe to call this function again from inside a callback function
// that it called. It should not be called from multiple threads at once.
+bool
+Alarm_processOne(void)
+{
+ AlarmTime now;
+ Alarm *alarm;
+
+ assert(alarmHeap != NULL);
+ if (!Heap_hasMore(alarmHeap))
+ return false;
+
+ now = AlarmTime_nowMs();
+ alarm = (Alarm *) Heap_first(alarmHeap);
+ if (now < alarm->time)
+ return false;
+
+ Heap_pop(alarmHeap);
+ alarm->callback(alarm->arg);
+ Alarm_free(alarm);
+ return true;
+}
+
+#if 0
+// It is safe to call this function again from inside a callback function
+// that it called. It should not be called from multiple threads at once.
void
-Alarm_process(void) {
+Alarm_processAll(void) {
AlarmTime now;
assert(alarmHeap != NULL);
- now = AlarmTime_nowMS();
+ now = AlarmTime_nowMs();
while (Heap_hasMore(alarmHeap)) {
Alarm *alarm = (Alarm *) Heap_first(alarmHeap);
@@ -119,8 +162,9 @@
Alarm_free(alarm);
}
}
+#endif
-Uint32
+uint32
Alarm_timeBeforeNextMs(void) {
Alarm *alarm;
@@ -131,4 +175,3 @@
return alarmTimeToMsUint32(alarm->time);
}
-
Modified: trunk/sc2/src/libs/callback/alarm.h
===================================================================
--- trunk/sc2/src/libs/callback/alarm.h 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/callback/alarm.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -22,11 +22,10 @@
#include "port.h"
#include "types.h"
-#include SDL_INCLUDE(SDL.h)
-typedef Uint32 AlarmTime;
-static inline Uint32
+typedef uint32 AlarmTime;
+static inline uint32
alarmTimeToMsUint32(AlarmTime time) {
- return (Uint32) time;
+ return (uint32) time;
}
typedef struct Alarm Alarm;
@@ -44,11 +43,14 @@
void Alarm_init(void);
void Alarm_uninit(void);
-Alarm *Alarm_addRelativeMs(Uint32 ms, AlarmCallback callback,
+Alarm *Alarm_addAbsoluteMs(uint32 ms, AlarmCallback callback,
AlarmCallbackArg arg);
+Alarm *Alarm_addRelativeMs(uint32 ms, AlarmCallback callback,
+ AlarmCallbackArg arg);
void Alarm_remove(Alarm *alarm);
-void Alarm_process(void);
-Uint32 Alarm_timeBeforeNextMs(void);
+bool Alarm_processOne(void);
+void Alarm_processAll(void);
+uint32 Alarm_timeBeforeNextMs(void);
#endif /* _ALARM_H */
Added: trunk/sc2/src/libs/callback/async.c
===================================================================
--- trunk/sc2/src/libs/callback/async.c (rev 0)
+++ trunk/sc2/src/libs/callback/async.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 Serge van den Boom <sv...@st...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "async.h"
+
+#include "libs/alarm.h"
+#include "libs/callback.h"
+
+
+// Process all alarms and callbacks.
+// First, all scheduled callbacks are called.
+// Then each alarm due is called, and after each of these alarms, the
+// callbacks scheduled by this alarm are called.
+void
+Async_process(void)
+{
+ // Call pending callbacks.
+ Callback_process();
+
+ for (;;) {
+ if (!Alarm_processOne())
+ return;
+
+ // Call callbacks scheduled from the last alarm.
+ Callback_process();
+ }
+}
+
+// Returns the next time that some asynchronous callback is
+// to be called. Note that all values lower than the current time
+// should be considered as 'somewhere in the past'.
+uint32
+Async_timeBeforeNextMs(void) {
+ if (Callback_haveMore()) {
+ // Any time before the current time is ok, though we reserve 0 so
+ // that the caller may use it as a special value in its own code.
+ return 1;
+ }
+ return Alarm_timeBeforeNextMs();
+}
+
Added: trunk/sc2/src/libs/callback/async.h
===================================================================
--- trunk/sc2/src/libs/callback/async.h (rev 0)
+++ trunk/sc2/src/libs/callback/async.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012 Serge van den Boom <sv...@st...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _ASYNC_H
+#define _ASYNC_H
+
+#include "types.h"
+
+void Async_process(void);
+uint32 Async_timeBeforeNextMs(void);
+
+#endif /* _ASYNC_H */
+
Modified: trunk/sc2/src/libs/callback/callback.c
===================================================================
--- trunk/sc2/src/libs/callback/callback.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/callback/callback.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -170,4 +170,14 @@
}
}
+bool
+Callback_haveMore(void) {
+ bool result;
+ CallbackList_lock();
+ result = (callbacks != NULL);
+ CallbackList_unlock();
+
+ return result;
+}
+
Modified: trunk/sc2/src/libs/callback/callback.h
===================================================================
--- trunk/sc2/src/libs/callback/callback.h 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/callback/callback.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -36,6 +36,7 @@
CallbackID Callback_add(CallbackFunction callback, CallbackArg arg);
bool Callback_remove(CallbackID id);
void Callback_process(void);
+bool Callback_haveMore(void);
#endif /* _CALLBACK_H */
Modified: trunk/sc2/src/libs/sound/mixer/nosound/audiodrv_nosound.c
===================================================================
--- trunk/sc2/src/libs/sound/mixer/nosound/audiodrv_nosound.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/sound/mixer/nosound/audiodrv_nosound.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -211,7 +211,7 @@
mixer_MixFake (NULL, stream, len);
delay = period - (GetTimeCounter () - entryTime);
if (delay > 0)
- SleepThread (delay);
+ HibernateThread (delay);
}
HFree (stream);
Modified: trunk/sc2/src/libs/sound/stream.c
===================================================================
--- trunk/sc2/src/libs/sound/stream.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/sound/stream.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -568,7 +568,7 @@
if (active_streams == 0)
{ // Throttle down the thread when there are no active streams
- SleepThread (ONE_SECOND / 10);
+ HibernateThread (ONE_SECOND / 10);
}
else
TaskSwitch ();
Modified: trunk/sc2/src/libs/threadlib.h
===================================================================
--- trunk/sc2/src/libs/threadlib.h 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/threadlib.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -145,6 +145,8 @@
void DestroyThreadLocal (ThreadLocal *tl);
ThreadLocal *GetMyThreadLocal (void);
+void HibernateThread (TimePeriod timePeriod);
+void HibernateThreadUntil (TimeCount wakeTime);
void SleepThread (TimePeriod timePeriod);
void SleepThreadUntil (TimeCount wakeTime);
void DestroyThread (Thread);
Modified: trunk/sc2/src/libs/threads/thrcommon.c
===================================================================
--- trunk/sc2/src/libs/threads/thrcommon.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/libs/threads/thrcommon.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -19,6 +19,7 @@
#include "libs/threadlib.h"
#include "libs/timelib.h"
#include "libs/log.h"
+#include "libs/async.h"
#include "libs/memlib.h"
#include "thrcommon.h"
@@ -284,19 +285,82 @@
NativeWaitThread (thread, status);
}
+#ifdef DEBUG_SLEEP
+extern uint32 mainThreadId;
+extern uint32 SDL_ThreadID(void);
+#endif /* DEBUG_SLEEP */
+
void
-SleepThread (TimePeriod timePeriod)
+HibernateThread (TimePeriod timePeriod)
{
+#ifdef DEBUG_SLEEP
+ if (SDL_ThreadID() == mainThreadId)
+ log_add (log_Debug, "HibernateThread called from main thread.\n");
+#endif /* DEBUG_SLEEP */
+
NativeSleepThread (timePeriod);
}
void
-SleepThreadUntil (TimeCount wakeTime)
+HibernateThreadUntil (TimeCount wakeTime)
{
+#ifdef DEBUG_SLEEP
+ if (SDL_ThreadID() == mainThreadId)
+ log_add (log_Debug, "HibernateThreadUntil called from main "
+ "thread.\n");
+#endif /* DEBUG_SLEEP */
+
NativeSleepThreadUntil (wakeTime);
}
void
+SleepThread (TimePeriod timePeriod)
+{
+ TimeCount now;
+
+#ifdef DEBUG_SLEEP
+ if (SDL_ThreadID() != mainThreadId)
+ log_add (log_Debug, "SleepThread called from non-main "
+ "thread.\n");
+#endif /* DEBUG_SLEEP */
+
+ now = GetTimeCounter ();
+ SleepThreadUntil (now + timePeriod);
+}
+
+// Sleep until wakeTime, but call asynchrounous operations until then.
+void
+SleepThreadUntil (TimeCount wakeTime)
+{
+#ifdef DEBUG_SLEEP
+ if (SDL_ThreadID() != mainThreadId)
+ log_add (log_Debug, "SleepThreadUntil called from non-main "
+ "thread.\n");
+#endif /* DEBUG_SLEEP */
+
+ for (;;) {
+ uint32 nextTimeMs;
+ TimeCount nextTime;
+ TimeCount now;
+
+ Async_process ();
+
+ now = GetTimeCounter ();
+ if (wakeTime <= now)
+ return;
+
+ nextTimeMs = Async_timeBeforeNextMs ();
+ nextTime = (nextTimeMs / 1000) * ONE_SECOND +
+ ((nextTimeMs % 1000) * ONE_SECOND / 1000);
+ // Overflow-safe conversion.
+ if (wakeTime < nextTime)
+ nextTime = wakeTime;
+
+ NativeSleepThreadUntil (nextTime);
+ }
+}
+
+void
TaskSwitch (void)
{
NativeTaskSwitch ();
Modified: trunk/sc2/src/uqm/battle.c
===================================================================
--- trunk/sc2/src/uqm/battle.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/battle.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -40,6 +40,7 @@
#include "setup.h"
#include "settings.h"
#include "sounds.h"
+#include "libs/async.h"
#include "libs/graphics/gfx_common.h"
#include "libs/log.h"
#include "libs/mathlib.h"
@@ -334,6 +335,7 @@
battle_speed = HIBYTE (nth_frame);
if (battle_speed == (BYTE)~0)
{ // maximum speed, nothing rendered at all
+ Async_process ();
TaskSwitch ();
}
else
Modified: trunk/sc2/src/uqm/confirm.c
===================================================================
--- trunk/sc2/src/uqm/confirm.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/confirm.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -83,6 +83,8 @@
if (PlayingTrack ())
PauseTrack ();
+ PauseFlash ();
+
LockMutex (GraphicsLock);
{
RECT r;
@@ -160,6 +162,8 @@
}
UnlockMutex (GraphicsLock);
+ ContinueFlash ();
+
if (PlayingTrack ())
ResumeTrack ();
@@ -212,6 +216,7 @@
label.line_count = SplitString (msg, '\n', 30, lines, bank);
label.lines = lines;
+ PauseFlash ();
LockMutex (GraphicsLock);
oldContext = SetContext (ScreenContext);
@@ -242,6 +247,8 @@
SetContextClipRect (&oldRect);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
+ ContinueFlash ();
SetMenuSounds (s0, s1);
StringBank_Free (bank);
}
+
Modified: trunk/sc2/src/uqm/gameinp.c
===================================================================
--- trunk/sc2/src/uqm/gameinp.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/gameinp.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -28,6 +28,7 @@
#include "sounds.h"
#include "tactrans.h"
#include "uqmdebug.h"
+#include "libs/async.h"
#include "libs/inplib.h"
#include "libs/timelib.h"
#include "libs/threadlib.h"
@@ -359,6 +360,7 @@
do
{
MENU_SOUND_FLAGS soundFlags;
+ Async_process ();
TaskSwitch ();
UpdateInputState ();
Modified: trunk/sc2/src/uqm/sis.c
===================================================================
--- trunk/sc2/src/uqm/sis.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/sis.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -34,6 +34,7 @@
#include "flash.h"
#include "libs/graphics/gfx_common.h"
#include "libs/tasklib.h"
+#include "libs/alarm.h"
#include "libs/log.h"
#include <stdio.h>
@@ -1590,28 +1591,32 @@
}
-static Task flash_task = 0;
static FlashContext *flashContext = NULL;
static RECT flash_rect;
-static Mutex flash_mutex = 0;
+static Alarm *flashAlarm = NULL;
+static BOOLEAN flashPaused = FALSE;
-static int
-flash_rect_func (void *data)
+static void scheduleFlashAlarm (void);
+
+static void
+updateFlashRect (void *arg)
{
- Task task = (Task)data;
+ if (flashContext == NULL)
+ return;
- while (!Task_ReadState(task, TASK_EXIT))
- {
- TimeCount nextTime;
- LockMutex (flash_mutex);
- Flash_process (flashContext);
- nextTime = Flash_nextTime (flashContext);
- UnlockMutex (flash_mutex);
- SleepThreadUntil (nextTime);
- }
+ Flash_process (flashContext);
+ scheduleFlashAlarm ();
+ (void) arg;
+}
- FinishTask (task);
- return 0;
+static void
+scheduleFlashAlarm (void)
+{
+ TimeCount nextTime = Flash_nextTime (flashContext);
+ DWORD nextTimeMs = (nextTime / ONE_SECOND) * 1000 +
+ ((nextTime % ONE_SECOND) * 1000 / ONE_SECOND);
+ // Overflow-safe conversion.
+ flashAlarm = Alarm_addAbsoluteMs (nextTimeMs, updateFlashRect, NULL);
}
// Pre: the caller holds the GraphicsLock
@@ -1621,10 +1626,6 @@
RECT clip_r = {{0, 0}, {0, 0}};
RECT temp_r;
- if (!flash_mutex)
- flash_mutex = CreateMutex ("FlashRect Lock",
- SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO);
-
if (pRect != SFR_MENU_3DO && pRect != SFR_MENU_ANY)
{
// The caller specified their own flash area, or NULL (stop flashing).
@@ -1654,47 +1655,42 @@
}
}
- // Conclude an old flash task.
- if (flashContext != NULL)
- {
- UnlockMutex (GraphicsLock);
- ConcludeTask (flash_task);
- LockMutex (GraphicsLock);
- flash_task = 0;
-
- Flash_terminate (flashContext);
- flashContext = 0;
- }
-
- // Start a new flash task.
if (pRect != 0 && pRect->extent.width != 0)
{
+ // Flash rectangle is not empty, start or continue flashing.
flash_rect = *pRect;
flash_rect.corner.x += clip_r.corner.x;
flash_rect.corner.y += clip_r.corner.y;
- flashContext = Flash_createHighlight (ScreenContext, &flash_rect);
- Flash_setMergeFactors(flashContext, 3, 2, 2);
- Flash_setSpeed (flashContext, 0, ONE_SECOND / 16, 0, ONE_SECOND / 16);
- Flash_setFrameTime (flashContext, ONE_SECOND / 16);
- Flash_start (flashContext);
-
- flash_task = AssignTask (flash_rect_func, 2048, "flash rectangle");
+ if (flashContext == NULL)
+ {
+ // Create a new flash context.
+ flashContext = Flash_createHighlight (ScreenContext, &flash_rect);
+ Flash_setMergeFactors(flashContext, 3, 2, 2);
+ Flash_setSpeed (flashContext, 0, ONE_SECOND / 16, 0, ONE_SECOND / 16);
+ Flash_setFrameTime (flashContext, ONE_SECOND / 16);
+ Flash_start (flashContext);
+ scheduleFlashAlarm ();
+ }
+ else
+ {
+ // Reuse an existing flash context
+ Flash_setRect (flashContext, &flash_rect);
+ }
}
-}
-
-// Sleep while calling the flash rectangle update when necessary.
-void
-FlashRectSleepUntil (TimeCount wakeTime)
-{
- while (GetTimeCounter() < wakeTime)
+ else
{
- TimeCount flashNextTime = Flash_nextTime (flashContext);
- TimeCount nextTime = (flashNextTime < wakeTime) ?
- flashNextTime : wakeTime;
- SleepThreadUntil (nextTime);
- if (nextTime == flashNextTime)
- Flash_process (flashContext);
+ // Flash rectangle is empty. Stop flashing.
+ if (flashContext != NULL)
+ {
+ UnlockMutex (GraphicsLock);
+ Alarm_remove(flashAlarm);
+ LockMutex (GraphicsLock);
+ flashAlarm = 0;
+
+ Flash_terminate (flashContext);
+ flashContext = NULL;
+ }
}
}
@@ -1708,18 +1704,12 @@
void
PreUpdateFlashRect (void)
{
- if (flash_task)
+ if (flashAlarm)
{
updateFlashRectRecursion++;
if (updateFlashRectRecursion > 1)
return;
-
- LockMutex (flash_mutex);
- Flash_pause (flashContext);
- // We need to actually pause, as the flash update function
- // is called from another thread.
Flash_preUpdate (flashContext);
- UnlockMutex (flash_mutex);
}
}
@@ -1727,16 +1717,13 @@
void
PostUpdateFlashRect (void)
{
- if (flash_task)
+ if (flashAlarm)
{
updateFlashRectRecursion--;
if (updateFlashRectRecursion > 0)
return;
- LockMutex (flash_mutex);
Flash_postUpdate (flashContext);
- Flash_continue (flashContext);
- UnlockMutex (flash_mutex);
}
}
@@ -1760,3 +1747,27 @@
LockMutex (GraphicsLock);
}
+// Stop flashing if flashing is active.
+void
+PauseFlash (void)
+{
+ if (flashContext != NULL)
+ {
+ Alarm_remove(flashAlarm);
+ flashAlarm = 0;
+ flashPaused = TRUE;
+ }
+}
+
+// Continue flashing after PauseFlash (), if flashing was active.
+void
+ContinueFlash (void)
+{
+ if (flashPaused)
+ {
+ scheduleFlashAlarm ();
+ flashPaused = FALSE;
+ }
+}
+
+
Modified: trunk/sc2/src/uqm/sis.h
===================================================================
--- trunk/sc2/src/uqm/sis.h 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/sis.h 2012-01-27 23:29:03 UTC (rev 3750)
@@ -186,6 +186,9 @@
extern void PostUpdateFlashRect (void);
extern void PreUpdateFlashRectLocked (void);
extern void PostUpdateFlashRectLocked (void);
+extern void PauseFlash (void);
+extern void ContinueFlash (void);
+
#define SFR_MENU_3DO ((RECT*)~0L)
#define SFR_MENU_ANY ((RECT*)~1L)
extern void DrawHyperCoords (POINT puniverse);
Modified: trunk/sc2/src/uqm/starcon.c
===================================================================
--- trunk/sc2/src/uqm/starcon.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/starcon.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -50,6 +50,10 @@
#include "options.h"
volatile int MainExited = FALSE;
+#ifdef DEBUG_SLEEP
+uint32 mainThreadId;
+extern uint32 SDL_ThreadID(void);
+#endif
// Open or close the periodically occuring QuasiSpace portal.
// It changes the appearant portal size when necessary.
@@ -143,6 +147,10 @@
int
Starcon2Main (void *threadArg)
{
+#ifdef DEBUG_SLEEP
+ mainThreadId = SDL_ThreadID();
+#endif
+
#if CREATE_JOURNAL
{
int ac = argc;
Modified: trunk/sc2/src/uqm/supermelee/netplay/netmelee.c
===================================================================
--- trunk/sc2/src/uqm/supermelee/netplay/netmelee.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/supermelee/netplay/netmelee.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -17,7 +17,7 @@
*/
#include "netmelee.h"
-#include "libs/alarm.h"
+#include "libs/async.h"
#include "libs/callback.h"
#include "libs/log.h"
#include "libs/net.h"
@@ -146,8 +146,7 @@
NetManager_process(&timeoutMs);
// This may cause more packets to be queued, hence the
// flushPacketQueues().
- Alarm_process();
- Callback_process();
+ Async_process();
flushPacketQueues();
// During the flush, a disconnect may be noticed, which triggers
// another callback. It must be handled immediately, before
@@ -166,11 +165,11 @@
void
netInputBlocking(uint32 timeoutMs) {
- uint32 nextAlarmMs;
+ uint32 nextAsyncMs;
- nextAlarmMs = Alarm_timeBeforeNextMs();
- if (nextAlarmMs < timeoutMs)
- timeoutMs = nextAlarmMs;
+ nextAsyncMs = Async_timeBeforeNextMs();
+ if (nextAsyncMs < timeoutMs)
+ timeoutMs = nextAsyncMs;
netInputAux(timeoutMs);
}
Modified: trunk/sc2/src/uqm/supermelee/pickmele.c
===================================================================
--- trunk/sc2/src/uqm/supermelee/pickmele.c 2012-01-23 20:14:45 UTC (rev 3749)
+++ trunk/sc2/src/uqm/supermelee/pickmele.c 2012-01-27 23:29:03 UTC (rev 3750)
@@ -37,6 +37,7 @@
#include "../races.h"
#include "../setup.h"
#include "../sounds.h"
+#include "libs/async.h"
#include "libs/log.h"
#include "libs/mathlib.h"
@@ -676,6 +677,7 @@
ButtonState = FALSE;
}
+ Async_process ();
TaskSwitch ();
} while (!(GLOBAL (CurrentActivity) & CHECK_ABORT) && (!ButtonState
&& (!(PlayerControl[0] & PlayerControl[1] & PSYTRON_CONTROL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-23 20:14:52
|
Revision: 3749
http://sc2.svn.sourceforge.net/sc2/?rev=3749&view=rev
Author: Meep-Eep
Date: 2012-01-23 20:14:45 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
Switch SetFlashRect() to the new flash code, as the next step towards getting rid of threads. Also some small cleanups.
Modified Paths:
--------------
trunk/sc2/ChangeLog
trunk/sc2/src/uqm/flash.c
trunk/sc2/src/uqm/gameopt.c
trunk/sc2/src/uqm/menu.c
trunk/sc2/src/uqm/outfit.c
trunk/sc2/src/uqm/planets/roster.c
trunk/sc2/src/uqm/shipyard.c
trunk/sc2/src/uqm/sis.c
trunk/sc2/src/uqm/sis.h
Modified: trunk/sc2/ChangeLog
===================================================================
--- trunk/sc2/ChangeLog 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/ChangeLog 2012-01-23 20:14:45 UTC (rev 3749)
@@ -1,4 +1,6 @@
Changes towards version 0.8:
+- Switch SetFlashRect() to the new flash code -- SvdB
+- Add C++ support to the build system, from Scott A. Colcord
- Cleaning up DoModifyShips() - SvdB
- Added Valgrind suppression file, from Louis Delacroix
- Fix several memory leaks, from Loius Delacroix
Modified: trunk/sc2/src/uqm/flash.c
===================================================================
--- trunk/sc2/src/uqm/flash.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/flash.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -18,6 +18,12 @@
// areas, drawing directly to the screen, using a cache, are
// currently in use.
+// NOTE:
+// - If you change the properties of the original CONTEXT, specifically the
+// dimensions and origin, you'll need to call Flash_preUpdate() before and
+// Flash_postUpdate() after that change. Note that this may change which
+// part of the screen is flashing.
+
// TODO:
// - During a few frames during the sequence, the frame to be displayed
// is equal to a frame which was supplied as a parameter to the flash
@@ -472,7 +478,8 @@
}
}
-// Call before you update the graphics in the currently flashing area.
+// Call before you update the graphics in the currently flashing area,
+// or before you change the dimensions or origin of the graphics context.
void
Flash_preUpdate (FlashContext *context)
{
@@ -483,7 +490,8 @@
}
}
-// Call after you update the graphics in the currently flashing area.
+// Call after you update the graphics in the currently flashing area,
+// or after you change the dimensions or origin of the graphics context.
void
Flash_postUpdate (FlashContext *context)
{
@@ -803,5 +811,3 @@
Flash_drawCachedFrame (context, numer, denom);
}
-
-
Modified: trunk/sc2/src/uqm/gameopt.c
===================================================================
--- trunk/sc2/src/uqm/gameopt.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/gameopt.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -176,6 +176,26 @@
#define DDSHS_EDIT 1
#define DDSHS_BLOCKCUR 2
+static const RECT captainNameRect = {
+ /* .corner = */ {
+ /* .x = */ 3,
+ /* .y = */ 10
+ }, /* .extent = */ {
+ /* .width = */ SHIP_NAME_WIDTH - 2,
+ /* .height = */ SHIP_NAME_HEIGHT
+ }
+};
+static const RECT shipNameRect = {
+ /* .corner = */ {
+ /* .x = */ 2,
+ /* .y = */ 20
+ }, /* .extent = */ {
+ /* .width = */ SHIP_NAME_WIDTH,
+ /* .height = */ SHIP_NAME_HEIGHT
+ }
+};
+
+
static BOOLEAN
DrawNameString (bool nameCaptain, UNICODE *Str, COUNT CursorPos,
COUNT state)
@@ -185,20 +205,11 @@
Color BackGround, ForeGround;
FONT Font;
- LockMutex (GraphicsLock);
-
{
- r.corner.x = 2;
- r.extent.width = SHIP_NAME_WIDTH;
- r.extent.height = SHIP_NAME_HEIGHT;
-
- SetContext (StatusContext);
if (nameCaptain)
{ // Naming the captain
Font = TinyFont;
- r.corner.y = 10;
- ++r.corner.x;
- r.extent.width -= 2;
+ r = captainNameRect;
lf.baseline.x = r.corner.x + (r.extent.width >> 1) - 1;
BackGround = BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09);
@@ -207,7 +218,7 @@
else
{ // Naming the flagship
Font = StarConFont;
- r.corner.y = 20;
+ r = shipNameRect;
lf.baseline.x = r.corner.x + (r.extent.width >> 1);
BackGround = BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D);
@@ -218,6 +229,8 @@
lf.align = ALIGN_CENTER;
}
+ LockMutex (GraphicsLock);
+ SetContext (StatusContext);
SetContextFont (Font);
lf.pStr = Str;
lf.CharCount = (COUNT)~0;
@@ -244,6 +257,10 @@
// disallow the change
return (FALSE);
}
+
+ UnlockMutex (GraphicsLock);
+ PreUpdateFlashRect ();
+ LockMutex (GraphicsLock);
SetContextForeGroundColor (BackGround);
DrawFilledRectangle (&r);
@@ -281,8 +298,8 @@
SetContextForeGroundColor (ForeGround);
font_DrawText (&lf);
-
- SetFlashRect (&r);
+
+ PostUpdateFlashRectLocked ();
}
UnlockMutex (GraphicsLock);
@@ -309,7 +326,7 @@
UNICODE *Setting;
LockMutex (GraphicsLock);
- SetFlashRect (NULL);
+ SetFlashRect (nameCaptain ? &captainNameRect : &shipNameRect);
UnlockMutex (GraphicsLock);
DrawNameString (nameCaptain, buf, 0, DDSHS_EDIT);
Modified: trunk/sc2/src/uqm/menu.c
===================================================================
--- trunk/sc2/src/uqm/menu.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/menu.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -28,9 +28,6 @@
#include "libs/tasklib.h"
#include "libs/log.h"
-extern Task flash_task;
-extern RECT flash_rect;
-
static BYTE GetEndMenuState (BYTE BaseState);
static BYTE GetBeginMenuState (BYTE BaseState);
static BYTE FixMenuState (BYTE BadState);
@@ -500,6 +497,7 @@
if (NewState <= end_index - beg_index)
s.frame = SetAbsFrameIndex (PlayFrame, beg_index + NewState);
+ PreUpdateFlashRect ();
LockMutex (GraphicsLock);
OldContext = SetContext (StatusContext);
GetContextClipRect (&r);
@@ -600,13 +598,8 @@
}
}
UnbatchGraphics ();
- if (flash_task
- && flash_rect.corner.x == RADAR_X
- && flash_rect.corner.y == RADAR_Y
- && flash_rect.extent.width == RADAR_WIDTH
- && flash_rect.extent.height == RADAR_HEIGHT)
- SetFlashRect (SFR_MENU_3DO);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
+ PostUpdateFlashRect ();
}
Modified: trunk/sc2/src/uqm/outfit.c
===================================================================
--- trunk/sc2/src/uqm/outfit.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/outfit.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -448,9 +448,9 @@
if (NewItem != pMS->CurState)
{
pMS->CurState = NewItem;
+ PreUpdateFlashRect ();
DrawModuleStrings (pMS, NewItem);
- // flash with PC menus too
- SetFlashRect (SFR_MENU_ANY);
+ PostUpdateFlashRect ();
}
}
else if (NewItem != pMS->delta_item || NewState != pMS->CurState)
@@ -573,7 +573,9 @@
SetContextBackGroundColor (BLACK_COLOR));
DrawFilledRectangle (&r);
}
+ PreUpdateFlashRect ();
DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));
+ PostUpdateFlashRect ();
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r);
@@ -590,7 +592,9 @@
SetContext (SpaceContext);
if (GLOBAL_SIS (FuelOnBoard))
{
+ PreUpdateFlashRect ();
DeltaSISGauges (0, -FUEL_TANK_SCALE, GLOBAL (FuelCost));
+ PostUpdateFlashRect ();
if (GLOBAL_SIS (FuelOnBoard) % FUEL_VOLUME_PER_ROW == 0 &&
GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE)
{
Modified: trunk/sc2/src/uqm/planets/roster.c
===================================================================
--- trunk/sc2/src/uqm/planets/roster.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/planets/roster.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -198,7 +198,9 @@
StarShipPtr->crew_level,
TemplatePtr->crew_level);
+ PreUpdateFlashRect ();
DrawStatusMessage (buf);
+ PostUpdateFlashRect ();
DeltaSISGauges (-crew_delta, 0, 0);
if (crew_delta)
{
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -219,8 +219,7 @@
r.corner = s.origin;
r.extent.width = RADAR_WIDTH;
r.extent.height = RADAR_HEIGHT;
- SetContextForeGroundColor (
- BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00));
+ SetContextForeGroundColor (BLACK_COLOR);
DrawFilledRectangle (&r);
if (NewRaceItem != (BYTE)~0)
{
@@ -232,19 +231,22 @@
hStarShip = GetAvailableRaceFromIndex (NewRaceItem);
NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q),
hStarShip);
+
+ // Draw the ship name, above the ship image.
s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem);
- // Ship name, above the ship image.
DrawStamp (&s);
+
+ // Draw the ship image.
FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
s.frame = FleetPtr->melee_icon;
- // Ship image.
UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
-
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
t.baseline.y = s.origin.y + RADAR_HEIGHT - 2;
s.origin.x += (RADAR_WIDTH >> 1);
s.origin.y += (RADAR_HEIGHT >> 1);
DrawStamp (&s);
+
+ // Print the ship cost.
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
@@ -257,8 +259,6 @@
UnbatchGraphics ();
SetContext (OldContext);
- // Flash the ship purchase menu even when optMenu == OPT_PC
- SetFlashRect (SFR_MENU_ANY);
UnlockMutex (GraphicsLock);
}
@@ -266,6 +266,10 @@
#define SHIP_WIN_HEIGHT (SHIP_WIN_WIDTH + 6)
#define SHIP_WIN_FRAMES ((SHIP_WIN_WIDTH >> 1) + 1)
+// Print the crew count of an escort ship on top of its (already drawn)
+// image, either as '30' (full), '28/30' (partially full), or 'SCRAP'
+// (empty).
+// pRect is the rectangle of the ship image.
static void
ShowShipCrew (SHIP_FRAGMENT *StarShipPtr, const RECT *pRect)
{
@@ -274,20 +278,21 @@
UNICODE buf[80];
HFLEETINFO hTemplate;
FLEET_INFO *TemplatePtr;
+ COUNT maxCrewLevel;
hTemplate = GetStarShipFromIndex (&GLOBAL (avail_race_q),
StarShipPtr->race_id);
TemplatePtr = LockFleetInfo (&GLOBAL (avail_race_q), hTemplate);
- if (StarShipPtr->crew_level >= TemplatePtr->crew_level)
+ maxCrewLevel = TemplatePtr->crew_level;
+ UnlockFleetInfo (&GLOBAL (avail_race_q), hTemplate);
+
+ if (StarShipPtr->crew_level >= maxCrewLevel)
sprintf (buf, "%u", StarShipPtr->crew_level);
else if (StarShipPtr->crew_level == 0)
// XXX: "SCRAP" needs to be moved to starcon.txt
utf8StringCopy (buf, sizeof (buf), "SCRAP");
else
- sprintf (buf, "%u/%u",
- StarShipPtr->crew_level,
- TemplatePtr->crew_level);
- UnlockFleetInfo (&GLOBAL (avail_race_q), hTemplate);
+ sprintf (buf, "%u/%u", StarShipPtr->crew_level, maxCrewLevel);
r = *pRect;
t.baseline.x = r.corner.x + (r.extent.width >> 1);
@@ -313,14 +318,17 @@
ShowCombatShip (MENU_STATE *pMS, COUNT which_window,
SHIP_FRAGMENT *YankedStarShipPtr)
{
- COUNT i, num_ships;
+ COUNT i;
+ COUNT num_ships;
HSHIPFRAG hStarShip, hNextShip;
SHIP_FRAGMENT *StarShipPtr;
struct
{
SHIP_FRAGMENT *StarShipPtr;
POINT finished_s;
- STAMP ship_s, lfdoor_s, rtdoor_s;
+ STAMP ship_s;
+ STAMP lfdoor_s;
+ STAMP rtdoor_s;
} ship_win_info[MAX_BUILT_SHIPS], *pship_win_info;
num_ships = 1;
@@ -388,6 +396,10 @@
hNextShip = _GetSuccLink (StarShipPtr);
pship_win_info->StarShipPtr = StarShipPtr;
+ // XXX BUG: this looks wrong according to the original
+ // semantics of LockShipFrag(): StarShipPtr is not valid
+ // anymore after UnlockShipFrag() is called, but it is
+ // used thereafter.
pship_win_info->lfdoor_s.origin.x = -1;
pship_win_info->rtdoor_s.origin.x = 1;
@@ -496,6 +508,7 @@
}
}
+// Pre: GraphicsLock is unlocked.
static void
CrewTransaction (SIZE crew_delta)
{
@@ -519,10 +532,7 @@
&& crew_bought - crew_delta < CREW_EXPENSE_THRESHOLD)
{
GLOBAL (CrewCost) += 2;
-
- UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
- LockMutex (GraphicsLock);
}
}
else
@@ -531,10 +541,7 @@
&& crew_bought - crew_delta >= CREW_EXPENSE_THRESHOLD)
{
GLOBAL (CrewCost) -= 2;
-
- UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
- LockMutex (GraphicsLock);
}
}
if (CheckAlliance (SHOFIXTI_SHIP) != GOOD_GUY)
@@ -739,8 +746,14 @@
return 0;
}
+ // Draw a crew member.
DrawPoint (&r.corner);
+
+ // Update the crew counter and RU. Note that the crew counter is
+ // flashing.
+ PreUpdateFlashRectLocked ();
DeltaSISGauges (1, 0, -GLOBAL (CrewCost));
+ PostUpdateFlashRectLocked ();
return 1;
}
@@ -765,9 +778,14 @@
GET_GAME_STATE (CREW_PURCHASED0),
GET_GAME_STATE (CREW_PURCHASED1));
+ // Update the crew counter and RU. Note that the crew counter is
+ // flashing.
+ PreUpdateFlashRectLocked ();
DeltaSISGauges (-1, 0, GLOBAL (CrewCost) -
(crew_bought == CREW_EXPENSE_THRESHOLD ? 2 : 0));
+ PostUpdateFlashRectLocked ();
+ // Remove the pixel representing the crew member.
GetCPodCapacity (&r.corner);
SetContextForeGroundColor (BLACK_COLOR);
DrawPoint (&r.corner);
@@ -824,8 +842,11 @@
}
++StarShipPtr->crew_level;
+
+ PreUpdateFlashRectLocked ();
DMS_GetEscortShipRect (&r, StarShipPtr->index);
ShowShipCrew (StarShipPtr, &r);
+ PostUpdateFlashRectLocked ();
return 1;
}
@@ -867,8 +888,10 @@
PlayMenuSound (MENU_SOUND_FAILURE);
}
+ PreUpdateFlashRectLocked ();
DMS_GetEscortShipRect (&r, StarShipPtr->index);
ShowShipCrew (StarShipPtr, &r);
+ PostUpdateFlashRectLocked ();
return crew_delta;
}
@@ -880,6 +903,7 @@
// selected.
// 'dy' is -1 if the 'up' button was pressed, or '1' if the down button was
// pressed.
+// Pre: caller holds the GraphicsLock
static void
DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
{
@@ -936,12 +960,15 @@
pMS->delta_item &= MODIFY_CREW_FLAG;
}
+ UnlockMutex (GraphicsLock);
CrewTransaction (crew_delta);
+ LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses the
// select button when the cursor is over an empty escort ship slot.
// Try to add the currently selected ship as an escort ship.
+// Pre: caller does not hold the GraphicsLock
static void
DMS_TryAddEscortShip (MENU_STATE *pMS)
{
@@ -1000,7 +1027,7 @@
// Cancel selecting an escort ship.
pMS->delta_item &= ~MODIFY_CREW_FLAG;
LockMutex (GraphicsLock);
- SetFlashRect (SFR_MENU_3DO);
+ SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
LockMutex (GraphicsLock);
@@ -1032,7 +1059,9 @@
if (currentShip != LOBYTE (pMS->delta_item))
{
+ PreUpdateFlashRect ();
DrawRaceStrings (pMS, currentShip);
+ PostUpdateFlashRect ();
pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
}
}
@@ -1041,6 +1070,7 @@
// Helper function for DoModifyShips(), called when the player presses
// 'select' or 'cancel' after selling all the crew.
+// Pre: caller holds the GraphicsLock
static void
DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
{
@@ -1108,6 +1138,7 @@
// Helper function for DoModifyShips(), called every time DoModifyShip() is
// called when we are in crew editing mode.
+// Pre: Caller holds the GraphicsLock
static void
DMS_EditCrewMode (MENU_STATE *pMS, HSHIPFRAG hStarShip,
BOOLEAN select, BOOLEAN cancel, SBYTE dy)
@@ -1132,9 +1163,7 @@
}
pMS->delta_item &= ~MODIFY_CREW_FLAG;
- LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_navigate);
- UnlockMutex (GraphicsLock);
}
else if (dy)
{
@@ -1146,7 +1175,7 @@
// Helper function for DoModifyShips(), called every time DoModifyShip() is
// called when we are in the mode where you can select a ship or empty slot.
-void
+static void
DMS_NavigateShipSlots (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
BOOLEAN cancel, SBYTE dx, SBYTE dy)
{
Modified: trunk/sc2/src/uqm/sis.c
===================================================================
--- trunk/sc2/src/uqm/sis.c 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/sis.c 2012-01-23 20:14:45 UTC (rev 3749)
@@ -31,6 +31,7 @@
#include "element.h"
#include "setup.h"
#include "state.h"
+#include "flash.h"
#include "libs/graphics/gfx_common.h"
#include "libs/tasklib.h"
#include "libs/log.h"
@@ -1589,248 +1590,173 @@
}
-Task flash_task = 0;
-RECT flash_rect;
-static FRAME flash_screen_frame = 0;
- // The original contents of the flash rectangle.
-static int flash_changed;
-Mutex flash_mutex = 0;
+static Task flash_task = 0;
+static FlashContext *flashContext = NULL;
+static RECT flash_rect;
+static Mutex flash_mutex = 0;
static int
flash_rect_func (void *data)
{
-#define NORMAL_STRENGTH 4
-#define NORMAL_F_STRENGTH 0
-#define CACHE_SIZE 10
- DWORD TimeIn;
- const DWORD WaitTime = ONE_SECOND / 16;
- SIZE strength;
- RECT cached_rect = {{0, 0}, {0, 0}};
- FRAME cached_screen_frame = 0;
Task task = (Task)data;
- bool cached[CACHE_SIZE];
- STAMP cached_stamp[CACHE_SIZE];
- int i;
- // Init cache
- for (i = 0; i < CACHE_SIZE; i++)
- {
- cached[i] = false;
- cached_stamp[i].frame = 0;
- }
-
- strength = NORMAL_STRENGTH;
- TimeIn = GetTimeCounter ();
while (!Task_ReadState(task, TASK_EXIT))
{
- CONTEXT OldContext;
-
+ TimeCount nextTime;
LockMutex (flash_mutex);
- if (flash_changed)
- {
- cached_rect = flash_rect;
- if (cached_screen_frame)
- DestroyDrawable (ReleaseDrawable (cached_screen_frame));
- flash_changed = 0;
- // Wait for the flash_screen_frame to get initialized
- FlushGraphics ();
- cached_screen_frame = CaptureDrawable (
- CloneFrame (flash_screen_frame));
- UnlockMutex (flash_mutex);
-
- // Clear the cache.
- for (i = 0; i < CACHE_SIZE; i++)
- {
- cached[i] = false;
- if (cached_stamp[i].frame)
- DestroyDrawable (ReleaseDrawable (cached_stamp[i].frame));
- cached_stamp[i].frame = 0;
- }
- }
- else
- UnlockMutex (flash_mutex);
-
- if (cached_rect.extent.width)
- {
- STAMP *pStamp;
-
-#define MIN_STRENGTH 4
-#define MAX_STRENGTH 6
- strength += 2;
- if (strength > MAX_STRENGTH)
- strength = MIN_STRENGTH;
- if (cached[strength - MIN_STRENGTH])
- pStamp = &cached_stamp[strength - MIN_STRENGTH];
- else
- {
- pStamp = &cached_stamp[strength - MIN_STRENGTH];
- cached[strength - MIN_STRENGTH] = true;
- pStamp->frame = CaptureDrawable (
- CloneFrame (cached_screen_frame));
- pStamp->origin.x = 0;
- pStamp->origin.y = 0;
-
- if (strength != 4)
- { // brighten the frame with an additive
- DrawMode oldMode;
- STAMP s;
- int factor;
-
- s.origin.x = 0;
- s.origin.y = 0;
- s.frame = cached_screen_frame;
-
- factor = (strength - MIN_STRENGTH) * DRAW_FACTOR_1 / 4;
-
- LockMutex (GraphicsLock);
- OldContext = SetContext (OffScreenContext);
- SetContextFGFrame (pStamp->frame);
- SetContextClipRect (NULL);
- oldMode = SetContextDrawMode (MAKE_DRAW_MODE (
- DRAW_ADDITIVE, factor));
- DrawStamp (&s);
- SetContextDrawMode (oldMode);
- SetContext (OldContext);
- UnlockMutex (GraphicsLock);
- }
- }
-
- LockMutex (GraphicsLock);
- OldContext = SetContext (ScreenContext);
- SetContextClipRect (&cached_rect);
- // flash changed_can't be modified while GraphicSem is held
- if (!flash_changed)
- DrawStamp (pStamp);
- // XXX: Shouldn't we save and restore the original cliprect?
- SetContextClipRect (NULL);
- SetContext (OldContext);
- UnlockMutex (GraphicsLock);
- }
- FlushGraphics ();
- SleepThreadUntil (TimeIn + WaitTime);
- TimeIn = GetTimeCounter ();
+ Flash_process (flashContext);
+ nextTime = Flash_nextTime (flashContext);
+ UnlockMutex (flash_mutex);
+ SleepThreadUntil (nextTime);
}
- // Clear cache
- {
- if (cached_screen_frame)
- DestroyDrawable (ReleaseDrawable (cached_screen_frame));
-
- for (i = 0; i < CACHE_SIZE; i++)
- {
- if(cached_stamp[i].frame)
- DestroyDrawable (ReleaseDrawable (cached_stamp[i].frame));
- }
- }
- LockMutex (flash_mutex);
- flash_task = 0;
- UnlockMutex (flash_mutex);
-
FinishTask (task);
return 0;
}
+// Pre: the caller holds the GraphicsLock
void
-SetFlashRect (RECT *pRect)
+SetFlashRect (const RECT *pRect)
{
RECT clip_r = {{0, 0}, {0, 0}};
- RECT temp_r, flash_rect1, old_r;
- CONTEXT OldContext;
- int create_flash = 0;
-
+ RECT temp_r;
+
if (!flash_mutex)
flash_mutex = CreateMutex ("FlashRect Lock",
SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO);
- old_r = flash_rect;
- flash_rect1 = flash_rect;
-
if (pRect != SFR_MENU_3DO && pRect != SFR_MENU_ANY)
{
+ // The caller specified their own flash area, or NULL (stop flashing).
GetContextClipRect (&clip_r);
- OldContext = SetContext (ScreenContext);
}
else
{
- //Don't flash when using the PC menu
if (optWhichMenu == OPT_PC && pRect != SFR_MENU_ANY)
{
- OldContext = SetContext (ScreenContext);
+ // The player wants PC menus and this flash is not used
+ // for a PC menu.
+ // Don't flash.
pRect = 0;
}
else
{
- OldContext = SetContext (StatusContext);
+ // The player wants 3DO menus, or the flash is used in both
+ // 3DO and PC mode.
+ CONTEXT OldContext = SetContext (StatusContext);
GetContextClipRect (&clip_r);
pRect = &temp_r;
temp_r.corner.x = RADAR_X - clip_r.corner.x;
temp_r.corner.y = RADAR_Y - clip_r.corner.y;
temp_r.extent.width = RADAR_WIDTH;
temp_r.extent.height = RADAR_HEIGHT;
- SetContext (ScreenContext);
+ SetContext (OldContext);
}
}
- if (pRect == 0 || pRect->extent.width == 0)
+ // Conclude an old flash task.
+ if (flashContext != NULL)
{
- // End the flashing.
- flash_rect1.extent.width = 0;
- if (flash_task)
- {
- UnlockMutex (GraphicsLock);
- ConcludeTask (flash_task);
- LockMutex (GraphicsLock);
- }
+ UnlockMutex (GraphicsLock);
+ ConcludeTask (flash_task);
+ LockMutex (GraphicsLock);
+ flash_task = 0;
+
+ Flash_terminate (flashContext);
+ flashContext = 0;
}
- else
+
+ // Start a new flash task.
+ if (pRect != 0 && pRect->extent.width != 0)
{
- flash_rect1 = *pRect;
- flash_rect1.corner.x += clip_r.corner.x;
- flash_rect1.corner.y += clip_r.corner.y;
- create_flash = 1;
+ flash_rect = *pRect;
+ flash_rect.corner.x += clip_r.corner.x;
+ flash_rect.corner.y += clip_r.corner.y;
+
+ flashContext = Flash_createHighlight (ScreenContext, &flash_rect);
+ Flash_setMergeFactors(flashContext, 3, 2, 2);
+ Flash_setSpeed (flashContext, 0, ONE_SECOND / 16, 0, ONE_SECOND / 16);
+ Flash_setFrameTime (flashContext, ONE_SECOND / 16);
+ Flash_start (flashContext);
+
+ flash_task = AssignTask (flash_rect_func, 2048, "flash rectangle");
}
-
- LockMutex (flash_mutex);
- flash_rect = flash_rect1;
+}
- if (old_r.extent.width && !rectsEqual (old_r, flash_rect))
+// Sleep while calling the flash rectangle update when necessary.
+void
+FlashRectSleepUntil (TimeCount wakeTime)
+{
+ while (GetTimeCounter() < wakeTime)
{
- // We had a flash rectangle, and now a different one is set.
- if (flash_screen_frame)
- {
- // The screen contents may have changed; we grab a new copy.
- STAMP old_s;
- old_s.origin.x = old_r.corner.x;
- old_s.origin.y = old_r.corner.y;
- old_s.frame = flash_screen_frame;
- DrawStamp (&old_s);
- DestroyDrawable (ReleaseDrawable (flash_screen_frame));
- flash_screen_frame = 0;
- }
- else
- log_add (log_Debug, "Couldn't locate flash_screen_rect");
+ TimeCount flashNextTime = Flash_nextTime (flashContext);
+ TimeCount nextTime = (flashNextTime < wakeTime) ?
+ flashNextTime : wakeTime;
+ SleepThreadUntil (nextTime);
+ if (nextTime == flashNextTime)
+ Flash_process (flashContext);
}
-
- if (flash_rect.extent.width)
+}
+
+COUNT updateFlashRectRecursion = 0;
+// XXX This is necessary at least because DMS_AddEscortShip() calls
+// DrawRaceStrings() in an UpdateFlashRect block, which calls
+// ClearSISRect(), which calls DrawMenuStateStrings(), which starts its own
+// UpdateFlashRect block. This should probably be cleaned up.
+
+// GraphicsLock must be unlocked.
+void
+PreUpdateFlashRect (void)
+{
+ if (flash_task)
{
- // A new flash rectangle is set.
- // Copy the original contents of the rectangle from the screen.
- if (flash_screen_frame)
- DestroyDrawable (ReleaseDrawable (flash_screen_frame));
- flash_screen_frame =
- CaptureDrawable (LoadDisplayPixmap (&flash_rect, (FRAME)0));
+ updateFlashRectRecursion++;
+ if (updateFlashRectRecursion > 1)
+ return;
+
+ LockMutex (flash_mutex);
+ Flash_pause (flashContext);
+ // We need to actually pause, as the flash update function
+ // is called from another thread.
+ Flash_preUpdate (flashContext);
+ UnlockMutex (flash_mutex);
}
- flash_changed = 1;
- UnlockMutex (flash_mutex);
- // we create the thread after the LoadDisplayPixmap()
- // so there is no race between the FlushGraphics in flash_task
- // and the Enqueue in LoadDisplayPixmap()
- if (create_flash && flash_task == 0)
+}
+
+// GraphicsLock must be unlocked.
+void
+PostUpdateFlashRect (void)
+{
+ if (flash_task)
{
- flash_task = AssignTask (flash_rect_func, 2048,
- "flash rectangle");
+ updateFlashRectRecursion--;
+ if (updateFlashRectRecursion > 0)
+ return;
+
+ LockMutex (flash_mutex);
+ Flash_postUpdate (flashContext);
+ Flash_continue (flashContext);
+ UnlockMutex (flash_mutex);
}
+}
- SetContext (OldContext);
+// Because the situation occurs a lot where the GraphicsLock is already
+// locked, we add this function.
+void
+PreUpdateFlashRectLocked (void)
+{
+ UnlockMutex (GraphicsLock);
+ PreUpdateFlashRect ();
+ LockMutex (GraphicsLock);
}
+// Because the situation occurs a lot where the GraphicsLock is already
+// locked, we add this function.
+void
+PostUpdateFlashRectLocked (void)
+{
+ UnlockMutex (GraphicsLock);
+ PostUpdateFlashRect ();
+ LockMutex (GraphicsLock);
+}
+
Modified: trunk/sc2/src/uqm/sis.h
===================================================================
--- trunk/sc2/src/uqm/sis.h 2012-01-15 20:37:31 UTC (rev 3748)
+++ trunk/sc2/src/uqm/sis.h 2012-01-23 20:14:45 UTC (rev 3749)
@@ -181,7 +181,11 @@
extern void InitSISContexts (void);
extern void DrawSISFrame (void);
extern void ClearSISRect (BYTE ClearFlags);
-extern void SetFlashRect (RECT *pRect);
+extern void SetFlashRect (const RECT *pRect);
+extern void PreUpdateFlashRect (void);
+extern void PostUpdateFlashRect (void);
+extern void PreUpdateFlashRectLocked (void);
+extern void PostUpdateFlashRectLocked (void);
#define SFR_MENU_3DO ((RECT*)~0L)
#define SFR_MENU_ANY ((RECT*)~1L)
extern void DrawHyperCoords (POINT puniverse);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-15 20:37:38
|
Revision: 3748
http://sc2.svn.sourceforge.net/sc2/?rev=3748&view=rev
Author: Meep-Eep
Date: 2012-01-15 20:37:31 +0000 (Sun, 15 Jan 2012)
Log Message:
-----------
--unix_depend_format was there before after all. Putting it back.
Modified Paths:
--------------
trunk/sc2/build/unix/config_proginfo_build
Modified: trunk/sc2/build/unix/config_proginfo_build
===================================================================
--- trunk/sc2/build/unix/config_proginfo_build 2012-01-15 20:01:20 UTC (rev 3747)
+++ trunk/sc2/build/unix/config_proginfo_build 2012-01-15 20:37:31 UTC (rev 3748)
@@ -124,7 +124,7 @@
BUILDTOOL_PREPROC_C_COMMAND="\$PROG_armcc_FILE -E $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_PREPROC_C_DEPEND='armcc'
- BUILDTOOL_MKDEP_C_COMMAND="\$PROG_armcc_FILE -MM $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_C_COMMAND="\$PROG_armcc_FILE -MM --unix_depend_format $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_MKDEP_C_DEPEND='armcc'
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_armcc_FILE -c $EXTRA_ARMV5_FLAGS_COMPILE"
@@ -133,7 +133,7 @@
BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_armcc_FILE -E $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_PREPROC_CXX_DEPEND='armcc'
- BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_armcc_FILE -MM $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_armcc_FILE -MM --unix_depend_format $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_MKDEP_CXX_DEPEND='armcc'
BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_armcc_FILE -c $EXTRA_ARMV5_FLAGS_COMPILE"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-15 20:01:27
|
Revision: 3747
http://sc2.svn.sourceforge.net/sc2/?rev=3747&view=rev
Author: Meep-Eep
Date: 2012-01-15 20:01:20 +0000 (Sun, 15 Jan 2012)
Log Message:
-----------
Add C++ support to the build system, from Scott A. Colcord.
Modified Paths:
--------------
trunk/sc2/Makefile.build
trunk/sc2/Makeproject
trunk/sc2/build/unix/build.config
trunk/sc2/build/unix/build.sh
trunk/sc2/build/unix/build_functions
trunk/sc2/build/unix/config_proginfo_build
trunk/sc2/build/unix/make/buildtools-armv5
trunk/sc2/build/unix/make/buildtools-generic
trunk/sc2/build/unix/make/buildtools-winscw
trunk/sc2/build.vars.in
Modified: trunk/sc2/Makefile.build
===================================================================
--- trunk/sc2/Makefile.build 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/Makefile.build 2012-01-15 20:01:20 UTC (rev 3747)
@@ -42,6 +42,13 @@
fi
$(call act,act_mkdep_c,MKDEP ,$@)
+$(OBJDIR)%.cpp.d: $(BUILD_ROOT)%.cpp
+ @DIR=$(dir $@); \
+ if [ ! -d $$DIR ]; then \
+ mkdir -p "$$DIR"; \
+ fi
+ $(call act,act_mkdep_cxx,MKDEP ,$@)
+
$(OBJDIR)%.m.d: $(BUILD_ROOT)%.m
@DIR=$(dir $@); \
if [ ! -d $$DIR ]; then \
@@ -63,6 +70,13 @@
fi
$(call act,act_cc,CC ,$@)
+%.cpp.o:
+ @DIR=$(dir $@); \
+ if [ ! -d $$DIR ]; then \
+ mkdir -p "$$DIR"; \
+ fi
+ $(call act,act_cxx,CXX ,$@)
+
%.m.o:
@DIR=$(dir $@); \
if [ ! -d $$DIR ]; then \
Modified: trunk/sc2/Makeproject
===================================================================
--- trunk/sc2/Makeproject 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/Makeproject 2012-01-15 20:01:20 UTC (rev 3747)
@@ -17,8 +17,10 @@
;;
esac
uqm_CFLAGS="$uqm_CFLAGS -Isrc"
+uqm_CXXFLAGS="$uqm_CXXFLAGS -Isrc"
if [ "$uqm_HAVE_REGEX" = 0 ]; then
uqm_CFLAGS="$uqm_CFLAGS -Isrc/regex"
+ uqm_CXXFLAGS="$uqm_CXXFLAGS -Isrc/regex"
fi
# Stuff to install under the directory for libraries, as specified during
Modified: trunk/sc2/build/unix/build.config
===================================================================
--- trunk/sc2/build/unix/build.config 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/build.config 2012-01-15 20:01:20 UTC (rev 3747)
@@ -10,6 +10,7 @@
{
# Some requirements:
have_build_tools_language C || exit 1
+ have_build_tools_language CXX || exit 1
have_build_tool LINK || exit 1
case "$HOST_SYSTEM" in
MINGW32*|cegcc)
@@ -108,16 +109,16 @@
nodebug_action() {
case "$HOST_SYSTEM" in
WINSCW)
- CFLAGS="$CFLAGS -O2 -d NDEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -O2 -d NDEBUG"
;;
ARMV5)
- CFLAGS="$CFLAGS -O3 -Otime -DNDEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -O3 -Otime -DNDEBUG"
;;
GCCE)
- CFLAGS="$CFLAGS -O3 -DNDEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -O3 -DNDEBUG"
;;
*)
- CFLAGS="$CFLAGS -O3 -DNDEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -O3 -DNDEBUG"
;;
esac
DEBUG=0
@@ -127,13 +128,13 @@
debug_action() {
case "$HOST_SYSTEM" in
WINSCW)
- CFLAGS="$CFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
;;
ARMV5|GCCE)
- CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -D_DEBUG"
;;
*)
- CFLAGS="$CFLAGS -g -O0 -W -Wall -DDEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W -Wall -DDEBUG"
LDFLAGS="$LDFLAGS -O0"
;;
esac
@@ -144,43 +145,46 @@
strictdebug_action() {
case "$HOST_SYSTEM" in
WINSCW)
- CFLAGS="$CFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
;;
ARMV5|GCCE)
- CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -D_DEBUG"
;;
*)
- CFLAGS="$CFLAGS -g -O0 -DDEBUG -W -Wall"
-# CFLAGS="$CFLAGS -O1"
+ CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -W -Wall"
+# CCOMMONFLAGS="$CCOMMONFLAGS -O1"
# This is needed for -Wunitialized with gcc 3.4
- CFLAGS="$CFLAGS -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \
- -Wstrict-prototypes -Wmissing-declarations \
+ CCOMMONFLAGS="$CCOMMONFLAGS -Wcast-qual -Wmissing-declarations \
-Wwrite-strings -Wimplicit -Wreturn-type -Wformat \
-Wswitch -Wcomment -Wchar-subscripts \
- -Wparentheses -Wcast-align \
- -Wuninitialized"
+ -Wparentheses -Wcast-align -Wuninitialized"
+ CFLAGS="$CFLAGS -Wbad-function-cast -Wmissing-prototypes \
+ -Wstrict-prototypes"
+ # CFLAGS is for flags not valid in C++.
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
# Until we abandon MSVC 6
-# CFLAGS="$CFLAGS -Waggregate-return"
+# CCOMMONFLAGS="$CCOMMONFLAGS -Waggregate-return"
# It's not unreasonable to return structs at times.
-# CFLAGS="$CFLAGS "-Wpointer-arith"
+# CCOMMONFLAGS="$CCOMMONFLAGS "-Wpointer-arith"
# Some standard header won't even compile with this on
-# CFLAGS="$CFLAGS -Wshadow"
+# CCOMMONFLAGS="$CCOMMONFLAGS -Wshadow"
# This gives absurd conflicts with standard files,
# like from 'y0 and y1'
-# CFLAGS="$CFLAGS -Werror"
+# CCOMMONFLAGS="$CCOMMONFLAGS -Werror"
# We shouldn't do this until we actually nail them
# all in the original code. Then we can enforce them
# on ourselves.
-# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
-# CFLAGS="$CFLAGS -Wnested-externs"
+# CCOMMONFLAGS="$CCOMMONFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
+# CCOMMONFLAGS="$CCOMMONFLAGS -Wnested-externs"
# We know they're in the code, and though we'd like to
# get rid of them, they're not bugs.
-# CFLAGS="$CFLAGS -Winline"
+# CCOMMONFLAGS="$CCOMMONFLAGS -Winline"
# This gives too many warnings which we can do nothing
# about, obscuring legitimate warnings.
CFLAGS=`echo $CFLAGS`
- # Remove all the unnecessary spaces from $CFLAGS,
+ CXXFLAGS=`echo $CXXFLAGS`
+ CCOMMONFLAGS=`echo $CCOMMONFLAGS`
+ # Remove all the unnecessary spaces from the flags vars
# for more readable messages.
LDFLAGS="$LDFLAGS -O0"
;;
@@ -202,7 +206,7 @@
CHOICE_graphics_OPTION_pure_TITLE="Don't include OpenGL graphics support"
CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action'
graphics_pure_action() {
- CFLAGS="$CFLAGS -DGFXMODULE_SDL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DGFXMODULE_SDL"
GFXMODULE=sdl
HAVE_OPENGL=0
}
@@ -210,7 +214,7 @@
CHOICE_graphics_OPTION_opengl_ACTION='graphics_opengl_action'
CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl"
graphics_opengl_action() {
- CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL"
GFXMODULE=sdl
HAVE_OPENGL=1
use_library opengl
@@ -228,7 +232,7 @@
CHOICE_sound_OPTION_openal_PRECOND="have_library openal"
CHOICE_sound_OPTION_openal_ACTION=sound_openal_action
sound_openal_action() {
- CFLAGS="$CFLAGS -DHAVE_OPENAL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_OPENAL"
SOUNDMODULE=openal
use_library openal
}
@@ -249,14 +253,14 @@
CHOICE_ovcodec_OPTION_tremor_PRECOND="have_library tremor"
CHOICE_ovcodec_OPTION_tremor_ACTION=ovcodec_tremor_action
ovcodec_tremor_action() {
- CFLAGS="$CFLAGS -DOVCODEC_TREMOR"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DOVCODEC_TREMOR"
OGGVORBIS=tremor
use_library tremor
}
CHOICE_ovcodec_OPTION_none_TITLE="No Ogg Vorbis support"
CHOICE_ovcodec_OPTION_none_ACTION=ovcodec_none_action
ovcodec_none_action() {
- CFLAGS="$CFLAGS -DOVCODEC_NONE"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DOVCODEC_NONE"
OGGVORBIS=none
}
CHOICE_ovcodec_DEFAULT=standard
@@ -266,7 +270,7 @@
CHOICE_mikmod_OPTION_internal_TITLE="Included libmikmod"
CHOICE_mikmod_OPTION_internal_ACTION=mikmod_internal_action
mikmod_internal_action() {
- CFLAGS="$CFLAGS -DUSE_INTERNAL_MIKMOD"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DUSE_INTERNAL_MIKMOD"
USE_INTERNAL_MIKMOD=1
}
CHOICE_mikmod_OPTION_external_TITLE="System libmikmod"
@@ -285,7 +289,7 @@
# TODO: Check whether SDL has joystick support.
CHOICE_joystick_OPTION_enabled_ACTION=joystick_enabled_action
joystick_enabled_action() {
- CFLAGS="$CFLAGS -DHAVE_JOYSTICK"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_JOYSTICK"
}
CHOICE_joystick_OPTION_disabled_TITLE="disabled"
case "$HOST_SYSTEM" in
@@ -309,7 +313,7 @@
CHOICE_netplay_OPTION_full_PRECOND="have_library netlibs"
CHOICE_netplay_OPTION_full_ACTION=netplay_full_action
netplay_full_action() {
- CFLAGS="$CFLAGS -DNETPLAY=NETPLAY_FULL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DNETPLAY=NETPLAY_FULL"
if [ -n "$MACRO_WIN32" ]; then
LDFLAGS="$LDFLAGS -lws2_32"
fi
@@ -320,7 +324,7 @@
CHOICE_netplay_OPTION_ipv4_PRECOND="have_library netlibs"
CHOICE_netplay_OPTION_ipv4_ACTION=netplay_ipv4_action
netplay_ipv4_action() {
- CFLAGS="$CFLAGS -DNETPLAY=NETPLAY_IPV4"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DNETPLAY=NETPLAY_IPV4"
NETPLAY="IPV4"
use_library netlibs
}
@@ -333,7 +337,7 @@
CHOICE_ioformat_OPTION_stdio_zip_PRECOND="have_library zlib"
CHOICE_ioformat_OPTION_stdio_zip_ACTION="ioformat_stdio_zip_action"
ioformat_stdio_zip_action() {
- CFLAGS="$CFLAGS -DHAVE_ZIP=1"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_ZIP=1"
USE_ZIP_IO=1
use_library zlib
}
@@ -344,7 +348,7 @@
CHOICE_accel_OPTION_asm_TITLE="Platform acceleration (asm, etc.)"
CHOICE_accel_OPTION_asm_ACTION="accel_asm_action"
accel_asm_action() {
- CFLAGS="$CFLAGS -DUSE_PLATFORM_ACCEL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DUSE_PLATFORM_ACCEL"
USE_PLATFORM_ACCEL=1
}
CHOICE_accel_OPTION_plainc_TITLE="Only plain C code"
@@ -359,14 +363,14 @@
CHOICE_threadlib_OPTION_sdl_TITLE="SDL-controlled thread library"
CHOICE_threadlib_OPTION_sdl_ACTION="threadlib_sdl_action"
threadlib_sdl_action() {
- CFLAGS="$CFLAGS -DTHREADLIB_SDL"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DTHREADLIB_SDL"
THREADLIB="SDL"
}
CHOICE_threadlib_OPTION_pthread_TITLE="Pthread thread library"
CHOICE_threadlib_OPTION_pthread_PRECOND="have_library pthread"
CHOICE_threadlib_OPTION_pthread_ACTION="threadlib_pthread_action"
threadlib_pthread_action() {
- CFLAGS="$CFLAGS -DTHREADLIB_PTHREAD"
+ CCOMMONFLAGS="$CCOMMONFLAGS -DTHREADLIB_PTHREAD"
THREADLIB="PTHREAD"
use_library pthread
}
@@ -419,8 +423,17 @@
# Set the content dir
CONTENTDIR="${INSTALL_SHAREDIR}uqm/content"
- CFLAGS="$CFLAGS -I\"$BUILD_WORK\""
+ CCOMMONFLAGS="$CCOMMONFLAGS -I\"$BUILD_WORK\""
+ # Set C++ only flags
+ # These allow use of C++ without the standard library
+ CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions -nostdinc++"
+
+ # At this point, all the compiler flags must be set.
+ CFLAGS="$CFLAGS $CCOMMONFLAGS"
+ CXXFLAGS="$CXXFLAGS $CCOMMONFLAGS"
+ CCOMMONFLAGS=""
+
# Export the HAVE_ symbols to config_unix.h, using config_unix.h.in
# as template (or config_win.h/config_win.h.in).
SUBSTITUTE_VARS="$HAVE_SYMBOLS CONTENTDIR"
@@ -435,8 +448,9 @@
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK"
# Make build.vars from build.vars.in, substituting variables.
- SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS LDFLAGS LINK \
+ SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS CXXFLAGS LDFLAGS LINK \
PREPROC_C MKDEP_C COMPILE_C \
+ PREPROC_CXX MKDEP_CXX COMPILE_CXX \
PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC \
MAKE ECHON SED DEBUG JOYSTICK NETPLAY \
OGGVORBIS SOUNDMODULE USE_INTERNAL_MIKMOD \
Modified: trunk/sc2/build/unix/build.sh
===================================================================
--- trunk/sc2/build/unix/build.sh 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/build.sh 2012-01-15 20:01:20 UTC (rev 3747)
@@ -83,8 +83,8 @@
fi
BUILD_PROJECT="$TARGET"
export TARGET BUILD_PROJECT ECHON
-export PREPROC_C MKDEP_C COMPILE_C PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC LINK
-export "${BUILD_PROJECT}_CFLAGS" "${BUILD_PROJECT}_LDFLAGS"
+export PREPROC_C MKDEP_C COMPILE_C PREPROC_CXX MKDEP_CXX COMPILE_CXX PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC LINK
+export "${BUILD_PROJECT}_CFLAGS" "${BUILD_PROJECT}_CXXFLAGS" "${BUILD_PROJECT}_LDFLAGS"
# Add trailing / from objs dir
eval ${BUILD_PROJECT}_OBJS=\${${BUILD_PROJECT}_OBJS%/}/
Modified: trunk/sc2/build/unix/build_functions
===================================================================
--- trunk/sc2/build/unix/build_functions 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/build_functions 2012-01-15 20:01:20 UTC (rev 3747)
@@ -104,9 +104,10 @@
# Compile the lot.
# With the depend info set up, we can leave everything to make.
build_compile() {
- local CFLAGS LDFLAGS TARGET_FILE DEPEND_FILE OBJDIR
+ local CFLAGS CXXFLAGS LDFLAGS TARGET_FILE DEPEND_FILE OBJDIR
eval CFLAGS="\${${BUILD_PROJECT}_CFLAGS}"
+ eval CXXFLAGS="\${${BUILD_PROJECT}_CXXFLAGS}"
eval LDFLAGS="\${${BUILD_PROJECT}_LDFLAGS}"
eval OBJDIR=\""\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}"\"
eval TARGET_FILE=\""\$BUILD_WORK/\${${BUILD_PROJECT}_NAME}"\"
@@ -114,7 +115,7 @@
eval "${TARGET}_pre_build"
- CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS \
+ CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS \
OBJDIR=$OBJDIR \
BUILD_ROOT= \
TARGET_FILE=$TARGET_FILE DEPEND_FILE=$DEPEND_FILE \
Modified: trunk/sc2/build/unix/config_proginfo_build
===================================================================
--- trunk/sc2/build/unix/config_proginfo_build 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/config_proginfo_build 2012-01-15 20:01:20 UTC (rev 3747)
@@ -26,6 +26,9 @@
# CFLAGS
SYSTEM_BUILD_CFLAGS=""
+# CXXFLAGS
+SYSTEM_BUILD_CXXFLAGS=""
+
# LDFLAGS
SYSTEM_BUILD_LDFLAGS=""
@@ -33,6 +36,9 @@
BUILDTOOL_PREPROC_C_NAME="C preprocessor"
BUILDTOOL_MKDEP_C_NAME="C dependency generator"
BUILDTOOL_COMPILE_C_NAME="C compiler"
+BUILDTOOL_PREPROC_CXX_NAME="C++ preprocessor"
+BUILDTOOL_MKDEP_CXX_NAME="C++ dependency generator"
+BUILDTOOL_COMPILE_CXX_NAME="C++ compiler"
BUILDTOOL_PREPROC_OBJC_NAME="Objective-C preprocessor"
BUILDTOOL_MKDEP_OBJC_NAME="Objective-C dependency generator"
BUILDTOOL_COMPILE_OBJC_NAME="Objective-C compiler"
@@ -48,6 +54,15 @@
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_gcc_FILE -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C"
BUILDTOOL_COMPILE_C_DEPEND='gcc'
+ BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_gcc_FILE -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_CXX"
+ BUILDTOOL_PREPROC_CXX_DEPEND='gcc'
+
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_gcc_FILE -MM $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_CXX"
+ BUILDTOOL_MKDEP_CXX_DEPEND='gcc'
+
+ BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_gcc_FILE -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_CXX"
+ BUILDTOOL_COMPILE_CXX_DEPEND='gcc'
+
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_gcc_FILE -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_OBJC"
BUILDTOOL_PREPROC_OBJC_DEPEND='gcc'
@@ -63,6 +78,7 @@
case "$HOST_SYSTEM" in
Darwin)
EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C='-mmacosx-version-min=10.4 -arch i386'
+ EXTRA_PLATFORM_GCC_FLAGS_COMPILE_CXX='-mmacosx-version-min=10.4 -arch i386'
EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC='-mmacosx-version-min=10.4 -arch i386'
EXTRA_PLATFORM_GCC_FLAGS_LINK='-mmacosx-version-min=10.4 -arch i386'
useGccBuildTools
@@ -80,6 +96,15 @@
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_mwccsym2_FILE -c $EXTRA_WINSCW_FLAGS_COMPILE"
BUILDTOOL_COMPILE_C_DEPEND='mwccsym2'
+ BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_mwccsym2_FILE -E $EXTRA_WINSCW_FLAGS_COMPILE"
+ BUILDTOOL_PREPROC_CXX_DEPEND='mwccsym2'
+
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_mwccsym2_FILE -MM -ext .o -gccdep $EXTRA_WINSCW_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_CXX_DEPEND='mwccsym2'
+
+ BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_mwccsym2_FILE -c $EXTRA_WINSCW_FLAGS_COMPILE"
+ BUILDTOOL_COMPILE_CXX_DEPEND='mwccsym2'
+
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_mwccsym2_FILE -E"
BUILDTOOL_PREPROC_OBJC_DEPEND='mwccsym2'
@@ -99,12 +124,21 @@
BUILDTOOL_PREPROC_C_COMMAND="\$PROG_armcc_FILE -E $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_PREPROC_C_DEPEND='armcc'
- BUILDTOOL_MKDEP_C_COMMAND="\$PROG_armcc_FILE -MM --unix_depend_format $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_C_COMMAND="\$PROG_armcc_FILE -MM $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_MKDEP_C_DEPEND='armcc'
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_armcc_FILE -c $EXTRA_ARMV5_FLAGS_COMPILE"
BUILDTOOL_COMPILE_C_DEPEND='armcc'
+ BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_armcc_FILE -E $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_PREPROC_CXX_DEPEND='armcc'
+
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_armcc_FILE -MM $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_CXX_DEPEND='armcc'
+
+ BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_armcc_FILE -c $EXTRA_ARMV5_FLAGS_COMPILE"
+ BUILDTOOL_COMPILE_CXX_DEPEND='armcc'
+
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_armcc_FILE -E"
BUILDTOOL_PREPROC_OBJC_DEPEND='armcc'
@@ -130,6 +164,15 @@
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_gcce_FILE -c $EXTRA_GCCE_FLAGS_COMPILE"
BUILDTOOL_COMPILE_C_DEPEND='gcce'
+ BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_gcce_FILE -E $EXTRA_GCCE_FLAGS_COMPILE"
+ BUILDTOOL_PREPROC_CXX_DEPEND='gcce'
+
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_gcce_FILE -MM $EXTRA_GCCE_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_CXX_DEPEND='gcce'
+
+ BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_gcce_FILE -c $EXTRA_GCCE_FLAGS_COMPILE"
+ BUILDTOOL_COMPILE_CXX_DEPEND='gcce'
+
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_gcce_FILE -E"
BUILDTOOL_PREPROC_OBJC_DEPEND='gcce'
@@ -155,6 +198,15 @@
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_mingw_gcc_FILE -c $EXTRA_CYGWIN_FLAGS_COMPILE"
BUILDTOOL_COMPILE_C_DEPEND='mingw_gcc'
+ BUILDTOOL_PREPROC_CXX_COMMAND="\$PROG_mingw_gcc_FILE -E $EXTRA_CYGWIN_FLAGS_COMPILE"
+ BUILDTOOL_PREPROC_CXX_DEPEND='mingw_gcc'
+
+ BUILDTOOL_MKDEP_CXX_COMMAND="\$PROG_mingw_gcc_FILE -MM $EXTRA_CYGWIN_FLAGS_COMPILE"
+ BUILDTOOL_MKDEP_CXX_DEPEND='mingw_gcc'
+
+ BUILDTOOL_COMPILE_CXX_COMMAND="\$PROG_mingw_gcc_FILE -c $EXTRA_CYGWIN_FLAGS_COMPILE"
+ BUILDTOOL_COMPILE_CXX_DEPEND='mingw_gcc'
+
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_mingw_gcc_FILE -E"
BUILDTOOL_PREPROC_OBJC_DEPEND='mingw_gcc'
Modified: trunk/sc2/build/unix/make/buildtools-armv5
===================================================================
--- trunk/sc2/build/unix/make/buildtools-armv5 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/make/buildtools-armv5 2012-01-15 20:01:20 UTC (rev 3747)
@@ -7,6 +7,10 @@
$(MKDEP_C) $(CFLAGS) -o "$(@D)/$(<F).o" "$<" --depend "$@"
endef
+define act_mkdep_cxx
+ $(MKDEP_CXX) $(CXXFLAGS) -o "$(@D)/$(<F).o" "$<" --depend "$@"
+endef
+
define act_link
$(LINK) --create "$@" $^ $(LDFLAGS)
endef
Modified: trunk/sc2/build/unix/make/buildtools-generic
===================================================================
--- trunk/sc2/build/unix/make/buildtools-generic 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/make/buildtools-generic 2012-01-15 20:01:20 UTC (rev 3747)
@@ -6,6 +6,10 @@
$(MKDEP_C) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
endef
+define act_mkdep_cxx
+ $(MKDEP_CXX) $(CXXFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
+endef
+
define act_mkdep_m
$(MKDEP_OBJC) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
endef
@@ -18,6 +22,10 @@
$(COMPILE_C) -o "$@" $(CFLAGS) "$<"
endef
+define act_cxx
+ $(COMPILE_CXX) -o "$@" $(CXXFLAGS) "$<"
+endef
+
define act_objcc
$(COMPILE_OBJC) -o "$@" $(CFLAGS) "$<"
endef
Modified: trunk/sc2/build/unix/make/buildtools-winscw
===================================================================
--- trunk/sc2/build/unix/make/buildtools-winscw 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build/unix/make/buildtools-winscw 2012-01-15 20:01:20 UTC (rev 3747)
@@ -10,3 +10,10 @@
@rm -f "$@.tmp"
endef
+define act_mkdep_cxx
+ $(MKDEP_C) $(CXXFLAGS) "$<" -o "$@.tmp"
+ @echo -n "$(@D)/" > $@
+ @cat "$@.tmp" >> $@
+ @rm -f "$@.tmp"
+endef
+
Modified: trunk/sc2/build.vars.in
===================================================================
--- trunk/sc2/build.vars.in 2012-01-14 20:10:11 UTC (rev 3746)
+++ trunk/sc2/build.vars.in 2012-01-15 20:01:20 UTC (rev 3747)
@@ -20,6 +20,9 @@
PREPROC_C='@PREPROC_C@'
MKDEP_C='@MKDEP_C@'
COMPILE_C='@COMPILE_C@'
+PREPROC_CXX='@PREPROC_CXX@'
+MKDEP_CXX='@MKDEP_CXX@'
+COMPILE_CXX='@COMPILE_CXX@'
PREPROC_OBJC='@PREPROC_OBJC@'
MKDEP_OBJC='@MKDEP_OBJC@'
COMPILE_OBJC='@COMPILE_OBJC@'
@@ -30,6 +33,7 @@
REZ='@REZ@'
WINDRES='@WINDRES@'
uqm_CFLAGS='@CFLAGS@'
+uqm_CXXFLAGS='@CXXFLAGS@'
uqm_LDFLAGS='@LDFLAGS@'
uqm_INSTALL_BINDIR='@INSTALL_BINDIR@'
uqm_INSTALL_LIBDIR='@INSTALL_LIBDIR@'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-14 20:10:18
|
Revision: 3746
http://sc2.svn.sourceforge.net/sc2/?rev=3746&view=rev
Author: Meep-Eep
Date: 2012-01-14 20:10:11 +0000 (Sat, 14 Jan 2012)
Log Message:
-----------
No bitfields here.
Modified Paths:
--------------
trunk/sc2/src/uqm/flash.h
Modified: trunk/sc2/src/uqm/flash.h
===================================================================
--- trunk/sc2/src/uqm/flash.h 2012-01-13 18:09:31 UTC (rev 3745)
+++ trunk/sc2/src/uqm/flash.h 2012-01-14 20:10:11 UTC (rev 3746)
@@ -164,8 +164,8 @@
TimeCount lastFrameTime;
// Time of the last frame draw.
- BOOLEAN started : 1;
- BOOLEAN paused : 1;
+ BOOLEAN started;
+ BOOLEAN paused;
FRAME *cache;
COUNT cacheSize;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-13 18:09:37
|
Revision: 3745
http://sc2.svn.sourceforge.net/sc2/?rev=3745&view=rev
Author: avolkov
Date: 2012-01-13 18:09:31 +0000 (Fri, 13 Jan 2012)
Log Message:
-----------
More restrictive Valgrind suppression file, from Louis Delacroix
Modified Paths:
--------------
trunk/tools/valgrind/sc2-valgrind.supp
Modified: trunk/tools/valgrind/sc2-valgrind.supp
===================================================================
--- trunk/tools/valgrind/sc2-valgrind.supp 2012-01-13 17:16:23 UTC (rev 3744)
+++ trunk/tools/valgrind/sc2-valgrind.supp 2012-01-13 18:09:31 UTC (rev 3745)
@@ -1,49 +1,37 @@
# Valgrind suppression file.
# Usage:
-# valgrind --suppressions=sc2-valgrind.supp --log-file=sc2.vglog ./uqm-debug
+# valgrind --suppressions=sc2-valgrind.supp --log-file=sc2.vglog ./uqm-debug -l sc2.log
{
- memory leaks in SDL
- Memcheck:Leak
- ...
- obj:*/lib/libSDL*
-}
-{
memory leaks in PulseAudio
Memcheck:Leak
...
obj:*/lib/libpulse*
}
{
- memory leaks in libasound
+ memory leaks in libX11
Memcheck:Leak
...
- obj:*/lib/libasound*
+ obj:*/lib/libX11*
}
{
- memory leaks in libasound
- Memcheck:Overlap
+ memory leaks in CRT startup
+ Memcheck:Leak
+ fun:malloc
...
- obj:*/lib/libasound*
+ fun:_dl_catch_error
}
{
- ioctl param in libasound
- Memcheck:Param
- ioctl(arg)
+ memory leaks in CRT startup
+ Memcheck:Leak
+ fun:calloc
...
- obj:*/lib/libasound*
+ fun:_dl_catch_error
}
{
- semctl param in libasound
- Memcheck:Param
- semctl(IPC_SET, arg.buf)
- ...
- obj:*/lib/libasound*
-}
-{
- memory leaks in libX11
+ memory leaks in SDL_Init
Memcheck:Leak
...
- obj:*/lib/libX11*
+ fun:SDL_Init
}
{
memory leaks in libmikmod
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-13 17:16:33
|
Revision: 3744
http://sc2.svn.sourceforge.net/sc2/?rev=3744&view=rev
Author: avolkov
Date: 2012-01-13 17:16:23 +0000 (Fri, 13 Jan 2012)
Log Message:
-----------
Fix leaked TFB_Image.FilledImg
Modified Paths:
--------------
trunk/sc2/src/libs/graphics/tfb_draw.c
Modified: trunk/sc2/src/libs/graphics/tfb_draw.c
===================================================================
--- trunk/sc2/src/libs/graphics/tfb_draw.c 2012-01-10 07:20:33 UTC (rev 3743)
+++ trunk/sc2/src/libs/graphics/tfb_draw.c 2012-01-13 17:16:23 UTC (rev 3744)
@@ -415,10 +415,18 @@
TFB_DrawCanvas_Delete (image->NormalImg);
- if (image->ScaledImg) {
+ if (image->ScaledImg)
+ {
TFB_DrawCanvas_Delete (image->ScaledImg);
+ image->ScaledImg = 0;
}
+ if (image->FilledImg)
+ {
+ TFB_DrawCanvas_Delete (image->FilledImg);
+ image->FilledImg = 0;
+ }
+
UnlockMutex (image->mutex);
DestroyMutex (image->mutex);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mcm...@us...> - 2012-01-10 07:20:40
|
Revision: 3743
http://sc2.svn.sourceforge.net/sc2/?rev=3743&view=rev
Author: mcmartin
Date: 2012-01-10 07:20:33 +0000 (Tue, 10 Jan 2012)
Log Message:
-----------
Cleanup: purge the DCQ of the data it owns on the way out of the program.
Modified Paths:
--------------
trunk/sc2/src/libs/graphics/dcqueue.c
trunk/sc2/src/libs/graphics/gfx_common.h
trunk/sc2/src/uqm.c
Modified: trunk/sc2/src/libs/graphics/dcqueue.c
===================================================================
--- trunk/sc2/src/libs/graphics/dcqueue.c 2012-01-08 14:15:05 UTC (rev 3742)
+++ trunk/sc2/src/libs/graphics/dcqueue.c 2012-01-10 07:20:33 UTC (rev 3743)
@@ -587,3 +587,42 @@
RenderedFrames++;
BroadcastCondVar (RenderingCond);
}
+
+void
+TFB_PurgeDanglingGraphics (void)
+{
+ Lock_DCQ (-1);
+
+ for (;;)
+ {
+ TFB_DrawCommand DC;
+
+ if (!TFB_DrawCommandQueue_Pop (&DC))
+ {
+ // the Queue is now empty.
+ break;
+ }
+
+ switch (DC.Type)
+ {
+ case TFB_DRAWCOMMANDTYPE_DELETEIMAGE:
+ {
+ TFB_Image *DC_image = DC.data.deleteimage.image;
+ TFB_DrawImage_Delete (DC_image);
+ break;
+ }
+ case TFB_DRAWCOMMANDTYPE_DELETEDATA:
+ {
+ void *data = DC.data.deletedata.data;
+ HFree (data);
+ break;
+ }
+ case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
+ {
+ ClearSemaphore (DC.data.sendsignal.sem);
+ break;
+ }
+ }
+ }
+ Unlock_DCQ ();
+}
Modified: trunk/sc2/src/libs/graphics/gfx_common.h
===================================================================
--- trunk/sc2/src/libs/graphics/gfx_common.h 2012-01-08 14:15:05 UTC (rev 3742)
+++ trunk/sc2/src/libs/graphics/gfx_common.h 2012-01-10 07:20:33 UTC (rev 3743)
@@ -98,6 +98,7 @@
extern int FrameRateTickBase;
void TFB_FlushGraphics (void); // Only call from main thread!!
+void TFB_PurgeDanglingGraphics (void); // Only call from main thread as part of shutdown.
extern int ScreenWidth;
extern int ScreenHeight;
Modified: trunk/sc2/src/uqm.c
===================================================================
--- trunk/sc2/src/uqm.c 2012-01-08 14:15:05 UTC (rev 3742)
+++ trunk/sc2/src/uqm.c 2012-01-10 07:20:33 UTC (rev 3743)
@@ -470,6 +470,8 @@
unInitAudio ();
uninit_communication ();
UninitColorMaps ();
+ // TODO: Merge into TFB_UninitGraphics when it goes live
+ TFB_PurgeDanglingGraphics ();
// Not yet: TFB_UninitGraphics ();
#ifdef NETPLAY
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-08 14:15:11
|
Revision: 3742
http://sc2.svn.sourceforge.net/sc2/?rev=3742&view=rev
Author: Meep-Eep
Date: 2012-01-08 14:15:05 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
A few comments.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-08 13:49:39 UTC (rev 3741)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-08 14:15:05 UTC (rev 3742)
@@ -233,9 +233,11 @@
NewRaceItem = GetIndexFromStarShip (&GLOBAL (avail_race_q),
hStarShip);
s.frame = SetAbsFrameIndex (pMS->ModuleFrame, 3 + NewRaceItem);
+ // Ship name, above the ship image.
DrawStamp (&s);
FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
s.frame = FleetPtr->melee_icon;
+ // Ship image.
UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip);
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-08 13:49:45
|
Revision: 3741
http://sc2.svn.sourceforge.net/sc2/?rev=3741&view=rev
Author: Meep-Eep
Date: 2012-01-08 13:49:39 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Fix flashing when pressing the 'spin ship' button on an empty slot
or the flag ship.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-08 12:58:38 UTC (rev 3740)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-08 13:49:39 UTC (rev 3741)
@@ -712,10 +712,7 @@
SetContextClipRect (&OldClipRect);
SetContext (OldContext);
- if (hStarShip)
- return TRUE;
-
- return FALSE;
+ return TRUE;
}
#endif /* WANT_SHIP_SPINS */
@@ -985,9 +982,9 @@
if (special)
{
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->delta_item);
- DMS_SpinShip (pMS, hStarShip);
LockMutex (GraphicsLock);
- DMS_SetMode (pMS, DMS_Mode_addEscort);
+ if (DMS_SpinShip (pMS, hStarShip))
+ DMS_SetMode (pMS, DMS_Mode_addEscort);
UnlockMutex (GraphicsLock);
return;
}
@@ -1169,8 +1166,8 @@
#else
if (special)
{
- DMS_SpinShip (pMS, hStarShip);
- DMS_SetMode (pMS, DMS_Mode_navigate);
+ if (DMS_SpinShip (pMS, hStarShip))
+ DMS_SetMode (pMS, DMS_Mode_navigate);
}
else
#endif /* WANT_SHIP_SPINS */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-08 12:58:44
|
Revision: 3740
http://sc2.svn.sourceforge.net/sc2/?rev=3740&view=rev
Author: Meep-Eep
Date: 2012-01-08 12:58:38 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Locking fix. Also change the locking behaviour of DMS_SetMode, to avoid repeated locks/unlocks and make the code invoking this function a bit cleaner.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-08 04:04:51 UTC (rev 3739)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-08 12:58:38 UTC (rev 3740)
@@ -606,6 +606,7 @@
// Helper function for DoModifyShips(). Called to change the flash
// rectangle to the currently selected ship (flagship or escort ship).
+// The caller must hold the graphicsLock.
static void
DMS_FlashActiveShip (MENU_STATE *pMS)
{
@@ -626,10 +627,10 @@
// XXX: right now, this only switches the sound and flash rectangle.
// Perhaps we should move more of the code to modify other aspects
// here too.
+// The caller must hold the graphicsLock.
static void
DMS_SetMode (MENU_STATE *pMS, DMS_Mode mode)
{
- LockMutex (GraphicsLock);
switch (mode) {
case DMS_Mode_navigate:
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -658,7 +659,6 @@
SetFlashRect (SFR_MENU_3DO);
break;
}
- UnlockMutex (GraphicsLock);
}
#define MODIFY_CREW_FLAG (1 << 8)
@@ -960,8 +960,8 @@
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
-((int)ShipCost[Index]));
+ DMS_SetMode (pMS, DMS_Mode_editCrew);
UnlockMutex (GraphicsLock);
- DMS_SetMode (pMS, DMS_Mode_editCrew);
}
else
{
@@ -986,7 +986,9 @@
{
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->delta_item);
DMS_SpinShip (pMS, hStarShip);
+ LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_addEscort);
+ UnlockMutex (GraphicsLock);
return;
}
#else
@@ -1002,7 +1004,9 @@
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
+ LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_navigate);
+ UnlockMutex (GraphicsLock);
}
else if (select)
{
@@ -1059,9 +1063,7 @@
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
SetContext (SpaceContext);
- UnlockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_navigate);
- LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses
@@ -1131,7 +1133,9 @@
}
pMS->delta_item &= ~MODIFY_CREW_FLAG;
+ LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_navigate);
+ UnlockMutex (GraphicsLock);
}
else if (dy)
{
@@ -1176,11 +1180,11 @@
{
// Select button was pressed over an empty escort
// ship slot. Switch to 'add escort ship' mode.
+ pMS->delta_item = MODIFY_CREW_FLAG;
UnlockMutex (GraphicsLock);
- pMS->delta_item = MODIFY_CREW_FLAG;
DrawRaceStrings (pMS, 0);
+ LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_addEscort);
- LockMutex (GraphicsLock);
}
else
{
@@ -1193,12 +1197,12 @@
else if (cancel)
{
// Leave escort ship editor.
- UnlockMutex (GraphicsLock);
pMS->InputFunc = DoShipyard;
pMS->CurState = SHIPYARD_CREW;
+ UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, pMS->CurState);
+ LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_exit);
- LockMutex (GraphicsLock);
}
}
@@ -1225,10 +1229,10 @@
pMS->CurState = MAKE_BYTE (0, 0xF);
pMS->delta_item = 0;
- DMS_SetMode (pMS, DMS_Mode_navigate);
LockMutex (GraphicsLock);
SetContext (SpaceContext);
DMS_SetMode (pMS, DMS_Mode_navigate);
+ UnlockMutex (GraphicsLock);
}
else
{
@@ -1271,10 +1275,10 @@
DMS_EditCrewMode (pMS, hStarShip, select, cancel, dy);
}
}
+
+ UnlockMutex (GraphicsLock);
}
- UnlockMutex (GraphicsLock);
-
SleepThread (ONE_SECOND / 30);
return TRUE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-08 04:05:00
|
Revision: 3739
http://sc2.svn.sourceforge.net/sc2/?rev=3739&view=rev
Author: avolkov
Date: 2012-01-08 04:04:51 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Fix uninitialized img->dirty in TFB_DrawImage_New(), from Louis Delacroix
Modified Paths:
--------------
trunk/sc2/src/libs/graphics/tfb_draw.c
Modified: trunk/sc2/src/libs/graphics/tfb_draw.c
===================================================================
--- trunk/sc2/src/libs/graphics/tfb_draw.c 2012-01-08 04:01:44 UTC (rev 3738)
+++ trunk/sc2/src/libs/graphics/tfb_draw.c 2012-01-08 04:04:51 UTC (rev 3739)
@@ -301,6 +301,7 @@
img->last_scale_hs = NullHs;
img->last_scale_type = -1;
img->last_scale = 0;
+ img->dirty = FALSE;
TFB_DrawCanvas_GetExtent (canvas, &img->extent);
if (TFB_DrawCanvas_IsPaletted (canvas))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-08 04:01:51
|
Revision: 3738
http://sc2.svn.sourceforge.net/sc2/?rev=3738&view=rev
Author: avolkov
Date: 2012-01-08 04:01:44 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
fix out of bounds (off by 1) access of vcontrol_parse_state::line
Modified Paths:
--------------
trunk/sc2/src/libs/input/sdl/vcontrol.c
Modified: trunk/sc2/src/libs/input/sdl/vcontrol.c
===================================================================
--- trunk/sc2/src/libs/input/sdl/vcontrol.c 2012-01-08 01:12:22 UTC (rev 3737)
+++ trunk/sc2/src/libs/input/sdl/vcontrol.c 2012-01-08 04:01:44 UTC (rev 3738)
@@ -1265,7 +1265,7 @@
parse_state ps;
strncpy (ps.line, spec, LINE_SIZE);
- ps.line[LINE_SIZE] = '\0';
+ ps.line[LINE_SIZE - 1] = '\0';
ps.index = ps.error = 0;
ps.linenum = -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-08 01:12:29
|
Revision: 3737
http://sc2.svn.sourceforge.net/sc2/?rev=3737&view=rev
Author: Meep-Eep
Date: 2012-01-08 01:12:22 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
More DoModifyShips() cleanups. That should be all for now.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-04 04:35:29 UTC (rev 3736)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-08 01:12:22 UTC (rev 3737)
@@ -73,6 +73,14 @@
SHIPYARD_EXIT
};
+// Editing mode for DoModifyShips()
+typedef enum {
+ DMS_Mode_navigate, // Navigating the ship slots.
+ DMS_Mode_addEscort, // Selecting a ship to add to an empty slot.
+ DMS_Mode_editCrew, // Hiring or dismissing crew.
+ DMS_Mode_exit, // Leaving DoModifyShips() mode.
+} DMS_Mode;
+
static COUNT ShipCost[] =
{
RACE_SHIP_COST
@@ -596,6 +604,63 @@
SetFlashRect (&r);
}
+// Helper function for DoModifyShips(). Called to change the flash
+// rectangle to the currently selected ship (flagship or escort ship).
+static void
+DMS_FlashActiveShip (MENU_STATE *pMS)
+{
+ if (HINIBBLE (pMS->CurState))
+ {
+ // Flash the flag ship.
+ DMS_FlashFlagShip ();
+ }
+ else
+ {
+ // Flash the current escort ship slot.
+ DMS_FlashEscortShip (pMS->CurState);
+ }
+}
+
+// Helper function for DoModifyShips(). Called to switch between
+// the various edit modes.
+// XXX: right now, this only switches the sound and flash rectangle.
+// Perhaps we should move more of the code to modify other aspects
+// here too.
+static void
+DMS_SetMode (MENU_STATE *pMS, DMS_Mode mode)
+{
+ LockMutex (GraphicsLock);
+ switch (mode) {
+ case DMS_Mode_navigate:
+ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
+ DMS_FlashActiveShip (pMS);
+ break;
+ case DMS_Mode_addEscort:
+ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
+ SetFlashRect (SFR_MENU_3DO);
+ break;
+ case DMS_Mode_editCrew:
+ SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
+ MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
+ if (HINIBBLE (pMS->CurState))
+ {
+ // Enter crew editing mode for the flagship.
+ DMS_FlashFlagShipCrewCount ();
+ }
+ else
+ {
+ // Enter crew editing mode for an escort ship.
+ DMS_FlashEscortShipCrewCount (pMS->CurState);
+ }
+ break;
+ case DMS_Mode_exit:
+ SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
+ SetFlashRect (SFR_MENU_3DO);
+ break;
+ }
+ UnlockMutex (GraphicsLock);
+}
+
#define MODIFY_CREW_FLAG (1 << 8)
#ifdef WANT_SHIP_SPINS
// Helper function for DoModifyShips(), called when the player presses the
@@ -603,6 +668,7 @@
// It works both when the cursor is over an escort ship, while not editing
// the crew, and when a new ship is added.
// hStarShip is the ship in the slot under the cursor (or 0 if no such ship).
+// Pre: GraphicsLock is locked.
static BOOLEAN
DMS_SpinShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
{
@@ -649,7 +715,6 @@
if (hStarShip)
return TRUE;
- SetFlashRect (SFR_MENU_3DO);
return FALSE;
}
#endif /* WANT_SHIP_SPINS */
@@ -825,9 +890,6 @@
if (hStarShip)
StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
-
if (hStarShip == 0)
{
// Add/Dismiss crew for the flagship.
@@ -892,40 +954,46 @@
&& CloneShipFragment (Index, &GLOBAL (built_ship_q), 1))
{
ShowCombatShip (pMS, pMS->CurState, NULL);
- //Reset flash rectangle
- LockMutex (GraphicsLock);
- SetFlashRect (SFR_MENU_3DO);
- UnlockMutex (GraphicsLock);
+ // Reset flash rectangle
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
-((int)ShipCost[Index]));
-
- DMS_FlashEscortShipCrewCount (pMS->CurState);
UnlockMutex (GraphicsLock);
+ DMS_SetMode (pMS, DMS_Mode_editCrew);
}
else
{
// not enough RUs to build, or cloning the ship failed.
PlayMenuSound (MENU_SOUND_FAILURE);
}
-
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
}
// Helper function for DoModifyShips(), called when the player is in the
// mode to add a new escort ship to the fleet (after pressing select on an
// empty slot).
// LOBYTE (pMS->delta_item) is used to store the currently highlighted ship.
-static BOOLEAN
-DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
- SBYTE dx, SBYTE dy)
+// Returns FALSE if the flash rectangle needs to be updated.
+static void
+DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
+ BOOLEAN cancel, SBYTE dx, SBYTE dy)
{
- assert (select || cancel || dx || dy);
assert (pMS->delta_item & MODIFY_CREW_FLAG);
+#ifdef WANT_SHIP_SPINS
+ if (special)
+ {
+ HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->delta_item);
+ DMS_SpinShip (pMS, hStarShip);
+ DMS_SetMode (pMS, DMS_Mode_addEscort);
+ return;
+ }
+#else
+ (void) special; // Satisfying compiler.
+#endif /* WANT_SHIP_SPINS */
+
+ UnlockMutex (GraphicsLock);
if (cancel)
{
// Cancel selecting an escort ship.
@@ -934,18 +1002,15 @@
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
- SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
- return FALSE;
+ DMS_SetMode (pMS, DMS_Mode_navigate);
}
-
- if (select)
+ else if (select)
{
// Selected a ship to be inserted in an empty escort
// ship slot.
DMS_TryAddEscortShip (pMS);
- return TRUE;
}
-
+ else if (dx || dy)
{
// Motion key pressed while selecting a ship to be
// inserted in an empty escort ship slot.
@@ -967,9 +1032,8 @@
DrawRaceStrings (pMS, currentShip);
pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
}
-
- return TRUE;
}
+ LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses
@@ -995,7 +1059,9 @@
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
SetContext (SpaceContext);
- DMS_FlashEscortShip (slotNr);
+ UnlockMutex (GraphicsLock);
+ DMS_SetMode (pMS, DMS_Mode_navigate);
+ LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses
@@ -1039,7 +1105,104 @@
isFlagShipSelected ? 0xf : 0);
}
-/* in this routine, the least significant byte of pMS->CurState is used
+// Helper function for DoModifyShips(), called every time DoModifyShip() is
+// called when we are in crew editing mode.
+static void
+DMS_EditCrewMode (MENU_STATE *pMS, HSHIPFRAG hStarShip,
+ BOOLEAN select, BOOLEAN cancel, SBYTE dy)
+{
+ if (select || cancel)
+ {
+ // Leave crew editing mode.
+ if (hStarShip != 0)
+ {
+ // Exiting crew editing mode for an escort ship.
+ SHIP_FRAGMENT *StarShipPtr = LockShipFrag (
+ &GLOBAL (built_ship_q), hStarShip);
+ COUNT crew_level = StarShipPtr->crew_level;
+ UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
+
+ if (crew_level == 0)
+ {
+ // Scrapping the escort ship before exiting crew edit
+ // mode.
+ DMS_ScrapEscortShip (pMS, hStarShip);
+ }
+ }
+
+ pMS->delta_item &= ~MODIFY_CREW_FLAG;
+ DMS_SetMode (pMS, DMS_Mode_navigate);
+ }
+ else if (dy)
+ {
+ // Hire or dismiss crew for the flagship or an escort
+ // ship.
+ DMS_ModifyCrew (pMS, hStarShip, dy);
+ }
+}
+
+// Helper function for DoModifyShips(), called every time DoModifyShip() is
+// called when we are in the mode where you can select a ship or empty slot.
+void
+DMS_NavigateShipSlots (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
+ BOOLEAN cancel, SBYTE dx, SBYTE dy)
+{
+ HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->CurState);
+
+ if (dx || dy)
+ {
+ // Moving through the ship slots.
+ BYTE NewState = DMS_MoveCursor (pMS->CurState, dx, dy);
+ if (NewState != pMS->CurState)
+ {
+ pMS->CurState = NewState;
+ DMS_FlashActiveShip(pMS);
+ }
+ }
+
+#ifndef WANT_SHIP_SPINS
+ (void) special; // Satisfying compiler.
+#else
+ if (special)
+ {
+ DMS_SpinShip (pMS, hStarShip);
+ DMS_SetMode (pMS, DMS_Mode_navigate);
+ }
+ else
+#endif /* WANT_SHIP_SPINS */
+ if (select)
+ {
+ if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
+ {
+ // Select button was pressed over an empty escort
+ // ship slot. Switch to 'add escort ship' mode.
+ UnlockMutex (GraphicsLock);
+ pMS->delta_item = MODIFY_CREW_FLAG;
+ DrawRaceStrings (pMS, 0);
+ DMS_SetMode (pMS, DMS_Mode_addEscort);
+ LockMutex (GraphicsLock);
+ }
+ else
+ {
+ // Select button was pressed over an escort ship or
+ // the flagship. Entering crew editing mode
+ pMS->delta_item |= MODIFY_CREW_FLAG;
+ DMS_SetMode (pMS, DMS_Mode_editCrew);
+ }
+ }
+ else if (cancel)
+ {
+ // Leave escort ship editor.
+ UnlockMutex (GraphicsLock);
+ pMS->InputFunc = DoShipyard;
+ pMS->CurState = SHIPYARD_CREW;
+ DrawMenuStateStrings (PM_CREW, pMS->CurState);
+ DMS_SetMode (pMS, DMS_Mode_exit);
+ LockMutex (GraphicsLock);
+ }
+}
+
+/* In this routine, the least significant byte of pMS->CurState is used
* to store the current selected ship index
* a special case for the row is hi-nibble == -1 (0xf), which specifies
* SIS as the selected ship
@@ -1049,12 +1212,6 @@
static BOOLEAN
DoModifyShips (MENU_STATE *pMS)
{
-#ifdef WANT_SHIP_SPINS
- BOOLEAN special = PulsedInputState.menu[KEY_MENU_SPECIAL];
-#endif /* WANT_SHIP_SPINS */
- BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
- BOOLEAN cancel = PulsedInputState.menu[KEY_MENU_CANCEL];
-
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
{
pMS->InputFunc = DoShipyard;
@@ -1068,21 +1225,19 @@
pMS->CurState = MAKE_BYTE (0, 0xF);
pMS->delta_item = 0;
+ DMS_SetMode (pMS, DMS_Mode_navigate);
LockMutex (GraphicsLock);
SetContext (SpaceContext);
- goto ChangeFlashRect;
+ DMS_SetMode (pMS, DMS_Mode_navigate);
}
else
{
+ BOOLEAN special = (PulsedInputState.menu[KEY_MENU_SPECIAL] != 0);
+ BOOLEAN select = (PulsedInputState.menu[KEY_MENU_SELECT] != 0);
+ BOOLEAN cancel = (PulsedInputState.menu[KEY_MENU_CANCEL] != 0);
SBYTE dx = 0;
SBYTE dy = 0;
- BYTE NewState = pMS->CurState;
- if (!(pMS->delta_item & MODIFY_CREW_FLAG))
- {
- SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
- }
-
if (PulsedInputState.menu[KEY_MENU_RIGHT])
dx = 1;
if (PulsedInputState.menu[KEY_MENU_LEFT])
@@ -1092,155 +1247,34 @@
if (PulsedInputState.menu[KEY_MENU_DOWN])
dy = 1;
- if (pMS->delta_item & MODIFY_CREW_FLAG)
+ LockMutex (GraphicsLock);
+
+ if (!(pMS->delta_item & MODIFY_CREW_FLAG))
{
+ // Navigating through the ship slots.
+ DMS_NavigateShipSlots (pMS, special, select, cancel, dx, dy);
}
- else if (dx || dy)
+ else
{
- NewState = DMS_MoveCursor (NewState, dx, dy);
- }
+ // Add an escort ship or edit the crew of a ship.
+ HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->CurState);
- if (select || cancel
-#ifdef WANT_SHIP_SPINS
- || special
-#endif
- || NewState != pMS->CurState
- || ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy)))
- {
- HSHIPFRAG hStarShip;
-
- hStarShip = GetEscortByStarShipIndex (pMS->CurState);
-
- if ((pMS->delta_item & MODIFY_CREW_FLAG) && (hStarShip))
+ if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
{
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
- }
- else
- {
- SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
- }
-
- LockMutex (GraphicsLock);
-
-#ifdef WANT_SHIP_SPINS
- if (special)
- {
- if (DMS_SpinShip (pMS, hStarShip))
- goto ChangeFlashRect;
- }
- else
-#endif /* WANT_SHIP_SPINS */
- if (!(pMS->delta_item & MODIFY_CREW_FLAG) &&
- hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 && select)
- {
- // Select button was pressed over an empty escort
- // ship slot. Switch to 'add escort ship' mode.
- UnlockMutex (GraphicsLock);
- pMS->delta_item = MODIFY_CREW_FLAG;
- DrawRaceStrings (pMS, 0);
- return TRUE;
- }
- else if ((pMS->delta_item & MODIFY_CREW_FLAG) &&
- hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 &&
- (dx || dy || select || cancel))
- {
// Cursor is over an empty escort ship slot, while we're
// in 'add escort ship' mode.
- UnlockMutex (GraphicsLock);
- if (DMS_AddEscortShip (pMS, select, cancel, dx, dy))
- return TRUE;
-
- LockMutex (GraphicsLock);
- goto ChangeFlashRect;
+ DMS_AddEscortShip (pMS, special, select, cancel, dx, dy);
}
- else if (select || ((pMS->delta_item & MODIFY_CREW_FLAG)
- && (dx || dy || cancel)))
- {
- if (select || cancel)
- {
- if ((pMS->delta_item & MODIFY_CREW_FLAG)
- && hStarShip != 0)
- {
- // Pressing the select or cancel button in crew edit
- // mode for an escort ship.
- SHIP_FRAGMENT *StarShipPtr = LockShipFrag (
- &GLOBAL (built_ship_q), hStarShip);
- COUNT crew_level = StarShipPtr->crew_level;
- UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
-
- if (crew_level == 0)
- {
- // Scrap escort ship, then exiting crew edit
- // mode.
- DMS_ScrapEscortShip (pMS, hStarShip);
- }
- else
- {
- // Just exiting escort ship crew edit mode.
- }
- }
-
- pMS->delta_item ^= MODIFY_CREW_FLAG;
- if (!pMS->delta_item)
- goto ChangeFlashRect;
-
- if (hStarShip == 0)
- {
- // Enter crew editing mode for the flagship.
- DMS_FlashFlagShipCrewCount ();
- }
- else
- {
- // Enter crew editing mode for an escort ship.
- DMS_FlashEscortShipCrewCount (pMS->CurState);
- }
-
- // Entering crew editing mode
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
- }
- else if (pMS->delta_item & MODIFY_CREW_FLAG)
- {
- // Hire or dismiss crew for the flagship or an escort
- // ship.
- DMS_ModifyCrew (pMS, hStarShip, dy);
- }
- }
- else if (cancel)
- {
- // Leave escort ship editor.
- UnlockMutex (GraphicsLock);
-
- pMS->InputFunc = DoShipyard;
- pMS->CurState = SHIPYARD_CREW;
- DrawMenuStateStrings (PM_CREW, pMS->CurState);
- LockMutex (GraphicsLock);
- SetFlashRect (SFR_MENU_3DO);
- UnlockMutex (GraphicsLock);
-
- return TRUE;
- }
else
{
- pMS->CurState = NewState;
-
-ChangeFlashRect:
- if (HINIBBLE (pMS->CurState))
- {
- // Flash the flag ship.
- DMS_FlashFlagShip ();
- }
- else
- {
- // Flash the current escort ship slot.
- DMS_FlashEscortShip (pMS->CurState);
- }
+ // Crew editing mode.
+ DMS_EditCrewMode (pMS, hStarShip, select, cancel, dy);
}
- UnlockMutex (GraphicsLock);
}
}
+ UnlockMutex (GraphicsLock);
+
SleepThread (ONE_SECOND / 30);
return TRUE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-04 04:35:35
|
Revision: 3736
http://sc2.svn.sourceforge.net/sc2/?rev=3736&view=rev
Author: avolkov
Date: 2012-01-04 04:35:29 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
Fix uninitialized RECT member as per Louis Delacroix
Modified Paths:
--------------
trunk/sc2/src/uqm/planets/lander.c
Modified: trunk/sc2/src/uqm/planets/lander.c
===================================================================
--- trunk/sc2/src/uqm/planets/lander.c 2012-01-04 04:29:24 UTC (rev 3735)
+++ trunk/sc2/src/uqm/planets/lander.c 2012-01-04 04:35:29 UTC (rev 3736)
@@ -1285,6 +1285,7 @@
r.corner.x = 0;
r.corner.y = 0;
r.extent.width = 0;
+ r.extent.height = 0;
s.origin.x = 0;
s.origin.y = 0;
s.frame = farray;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <av...@us...> - 2012-01-04 04:29:31
|
Revision: 3735
http://sc2.svn.sourceforge.net/sc2/?rev=3735&view=rev
Author: avolkov
Date: 2012-01-04 04:29:24 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
Added libasound suppression as per Louis Delacroix
Modified Paths:
--------------
trunk/tools/valgrind/sc2-valgrind.supp
Modified: trunk/tools/valgrind/sc2-valgrind.supp
===================================================================
--- trunk/tools/valgrind/sc2-valgrind.supp 2012-01-01 20:08:51 UTC (rev 3734)
+++ trunk/tools/valgrind/sc2-valgrind.supp 2012-01-04 04:29:24 UTC (rev 3735)
@@ -20,6 +20,12 @@
obj:*/lib/libasound*
}
{
+ memory leaks in libasound
+ Memcheck:Overlap
+ ...
+ obj:*/lib/libasound*
+}
+{
ioctl param in libasound
Memcheck:Param
ioctl(arg)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-01 20:08:58
|
Revision: 3734
http://sc2.svn.sourceforge.net/sc2/?rev=3734&view=rev
Author: Meep-Eep
Date: 2012-01-01 20:08:51 +0000 (Sun, 01 Jan 2012)
Log Message:
-----------
More cleanups. Among other things, MENU_STATE.flash_rect0 is no longer used.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-01 19:02:27 UTC (rev 3733)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-01 20:08:51 UTC (rev 3734)
@@ -257,7 +257,7 @@
#define SHIP_WIN_FRAMES ((SHIP_WIN_WIDTH >> 1) + 1)
static void
-ShowShipCrew (SHIP_FRAGMENT *StarShipPtr, RECT *pRect)
+ShowShipCrew (SHIP_FRAGMENT *StarShipPtr, const RECT *pRect)
{
RECT r;
TEXT t;
@@ -535,6 +535,67 @@
}
}
+// Pre: GraphicsLock is locked.
+static void
+DMS_FlashFlagShip (void)
+{
+ RECT r;
+ r.corner.x = 0;
+ r.corner.y = 0;
+ r.extent.width = SIS_SCREEN_WIDTH;
+ r.extent.height = 61;
+ SetFlashRect (&r);
+}
+
+static void
+DMS_GetEscortShipRect (RECT *rOut, BYTE slotNr)
+{
+ BYTE row = slotNr / HANGAR_SHIPS_ROW;
+ BYTE col = slotNr % HANGAR_SHIPS_ROW;
+
+ rOut->corner.x = hangar_x_coords[col];
+ rOut->corner.y = HANGAR_Y + (HANGAR_DY * row);
+ rOut->extent.width = SHIP_WIN_WIDTH;
+ rOut->extent.height = SHIP_WIN_HEIGHT;
+}
+
+// Pre: GraphicsLock is locked.
+static void
+DMS_FlashEscortShip (BYTE slotNr)
+{
+ RECT r;
+ DMS_GetEscortShipRect (&r, slotNr);
+ SetFlashRect (&r);
+}
+
+// Pre: GraphicsLock is locked.
+static void
+DMS_FlashFlagShipCrewCount (void)
+{
+ RECT r;
+ SetContext (StatusContext);
+ GetGaugeRect (&r, TRUE);
+ SetFlashRect (&r);
+ SetContext (SpaceContext);
+}
+
+// Pre: GraphicsLock is locked.
+static void
+DMS_FlashEscortShipCrewCount (BYTE slotNr)
+{
+ RECT r;
+ BYTE row = slotNr / HANGAR_SHIPS_ROW;
+ BYTE col = slotNr % HANGAR_SHIPS_ROW;
+
+ r.corner.x = hangar_x_coords[col];
+ r.corner.y = (HANGAR_Y + (HANGAR_DY * row)) + (SHIP_WIN_HEIGHT - 6);
+ r.extent.width = SHIP_WIN_WIDTH;
+ r.extent.height = 5;
+
+ SetContext (SpaceContext);
+ SetFlashRect (&r);
+}
+
#define MODIFY_CREW_FLAG (1 << 8)
#ifdef WANT_SHIP_SPINS
// Helper function for DoModifyShips(), called when the player presses the
@@ -655,9 +716,10 @@
// Buy crew for an escort ship
// Returns the change in crew (1 on success, 0 on failure).
static SIZE
-DMS_HireEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
+DMS_HireEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
{
COUNT templateMaxCrew;
+ RECT r;
{
// XXX Split this off into a separate function?
@@ -698,7 +760,8 @@
}
++StarShipPtr->crew_level;
- ShowShipCrew (StarShipPtr, &pMS->flash_rect0);
+ DMS_GetEscortShipRect (&r, StarShipPtr->index);
+ ShowShipCrew (StarShipPtr, &r);
return 1;
}
@@ -708,9 +771,10 @@
// Dismiss crew from an escort ship
// Returns the change in crew (-1 on success, 0 on failure).
static SIZE
-DMS_DismissEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
+DMS_DismissEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
{
SIZE crew_delta = 0;
+ RECT r;
if (StarShipPtr->crew_level > 0)
{
@@ -727,8 +791,7 @@
}
else
{
- // With the last crew member, the ship
- // will be scrapped.
+ // With the last crew member, the ship will be scrapped.
// Give RU for the ship.
DeltaSISGauges (0, 0, (COUNT)ShipCost[StarShipPtr->race_id]);
}
@@ -740,7 +803,8 @@
PlayMenuSound (MENU_SOUND_FAILURE);
}
- ShowShipCrew (StarShipPtr, &pMS->flash_rect0);
+ DMS_GetEscortShipRect (&r, StarShipPtr->index);
+ ShowShipCrew (StarShipPtr, &r);
return crew_delta;
}
@@ -779,13 +843,7 @@
}
if (crew_delta != 0)
- {
- RECT r;
- SetContext (StatusContext);
- GetGaugeRect (&r, TRUE);
- SetFlashRect (&r);
- SetContext (SpaceContext);
- }
+ DMS_FlashFlagShipCrewCount ();
}
else
{
@@ -793,26 +851,16 @@
if (dy < 0)
{
// Add crew for an escort ship.
- crew_delta = DMS_HireEscortShipCrew (pMS, StarShipPtr);
+ crew_delta = DMS_HireEscortShipCrew (StarShipPtr);
}
else
{
// Dismiss crew from an escort ship.
- crew_delta = DMS_DismissEscortShipCrew (pMS, StarShipPtr);
+ crew_delta = DMS_DismissEscortShipCrew (StarShipPtr);
}
if (crew_delta != 0)
- {
- RECT r;
- r.corner.x = pMS->flash_rect0.corner.x;
- r.corner.y = pMS->flash_rect0.corner.y
- + pMS->flash_rect0.extent.height - 6;
- r.extent.width = SHIP_WIN_WIDTH;
- r.extent.height = 5;
-
- SetContext (SpaceContext);
- SetFlashRect (&r);
- }
+ DMS_FlashEscortShipCrewCount (StarShipPtr->index);
}
if (crew_delta == 0)
@@ -843,7 +891,6 @@
if (GLOBAL_SIS (ResUnits) >= (DWORD)ShipCost[Index]
&& CloneShipFragment (Index, &GLOBAL (built_ship_q), 1))
{
- RECT r;
ShowCombatShip (pMS, pMS->CurState, NULL);
//Reset flash rectangle
LockMutex (GraphicsLock);
@@ -854,13 +901,8 @@
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
-((int)ShipCost[Index]));
- r.corner.x = pMS->flash_rect0.corner.x;
- r.corner.y = pMS->flash_rect0.corner.y
- + pMS->flash_rect0.extent.height - 6;
- r.extent.width = SHIP_WIN_WIDTH;
- r.extent.height = 5;
- SetContext (SpaceContext);
- SetFlashRect (&r);
+
+ DMS_FlashEscortShipCrewCount (pMS->CurState);
UnlockMutex (GraphicsLock);
}
else
@@ -935,15 +977,16 @@
static void
DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
{
- RECT r;
SHIP_FRAGMENT *StarShipPtr =
LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
+ BYTE slotNr;
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
ShowCombatShip (pMS, pMS->CurState, StarShipPtr);
LockMutex (GraphicsLock);
+ slotNr = StarShipPtr->index;
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
@@ -951,13 +994,8 @@
// refresh SIS display
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
- r.corner.x = pMS->flash_rect0.corner.x;
- r.corner.y = pMS->flash_rect0.corner.y;
- r.extent.width = SHIP_WIN_WIDTH;
- r.extent.height = SHIP_WIN_HEIGHT;
-
SetContext (SpaceContext);
- SetFlashRect (&r);
+ DMS_FlashEscortShip (slotNr);
}
// Helper function for DoModifyShips(), called when the player presses
@@ -1070,7 +1108,6 @@
|| ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy)))
{
HSHIPFRAG hStarShip;
- RECT r;
hStarShip = GetEscortByStarShipIndex (pMS->CurState);
@@ -1150,28 +1187,18 @@
if (hStarShip == 0)
{
- // Enter crew editing mode for an escort ship.
- SetContext (StatusContext);
- GetGaugeRect (&r, TRUE);
- SetFlashRect (&r);
- SetContext (SpaceContext);
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
+ // Enter crew editing mode for the flagship.
+ DMS_FlashFlagShipCrewCount ();
}
else
{
- // Enter crew editing mode for the flagship.
- r.corner.x = pMS->flash_rect0.corner.x;
- r.corner.y = pMS->flash_rect0.corner.y
- + pMS->flash_rect0.extent.height - 6;
- r.extent.width = SHIP_WIN_WIDTH;
- r.extent.height = 5;
+ // Enter crew editing mode for an escort ship.
+ DMS_FlashEscortShipCrewCount (pMS->CurState);
+ }
- SetContext (SpaceContext);
- SetFlashRect (&r);
- SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
- MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
- }
+ // Entering crew editing mode
+ SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
+ MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
}
else if (pMS->delta_item & MODIFY_CREW_FLAG)
{
@@ -1202,24 +1229,13 @@
if (HINIBBLE (pMS->CurState))
{
// Flash the flag ship.
- pMS->flash_rect0.corner.x = 0;
- pMS->flash_rect0.corner.y = 0;
- pMS->flash_rect0.extent.width = SIS_SCREEN_WIDTH;
- pMS->flash_rect0.extent.height = 61;
+ DMS_FlashFlagShip ();
}
else
{
// Flash the current escort ship slot.
- BYTE row = pMS->CurState / HANGAR_SHIPS_ROW;
- BYTE col = pMS->CurState % HANGAR_SHIPS_ROW;
-
- pMS->flash_rect0.corner.x = hangar_x_coords[col];
- pMS->flash_rect0.corner.y =
- HANGAR_Y + (HANGAR_DY * row);
- pMS->flash_rect0.extent.width = SHIP_WIN_WIDTH;
- pMS->flash_rect0.extent.height = SHIP_WIN_HEIGHT;
+ DMS_FlashEscortShip (pMS->CurState);
}
- SetFlashRect (&pMS->flash_rect0);
}
UnlockMutex (GraphicsLock);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Mee...@us...> - 2012-01-01 19:02:33
|
Revision: 3733
http://sc2.svn.sourceforge.net/sc2/?rev=3733&view=rev
Author: Meep-Eep
Date: 2012-01-01 19:02:27 +0000 (Sun, 01 Jan 2012)
Log Message:
-----------
More cleanups.
Modified Paths:
--------------
trunk/sc2/src/uqm/shipyard.c
Modified: trunk/sc2/src/uqm/shipyard.c
===================================================================
--- trunk/sc2/src/uqm/shipyard.c 2012-01-01 17:36:50 UTC (rev 3732)
+++ trunk/sc2/src/uqm/shipyard.c 2012-01-01 19:02:27 UTC (rev 3733)
@@ -876,11 +876,11 @@
// Helper function for DoModifyShips(), called when the player is in the
// mode to add a new escort ship to the fleet (after pressing select on an
// empty slot).
+// LOBYTE (pMS->delta_item) is used to store the currently highlighted ship.
static BOOLEAN
DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
- SBYTE dx, SBYTE dy, BYTE *newStateOut)
+ SBYTE dx, SBYTE dy)
{
- BYTE NewState;
assert (select || cancel || dx || dy);
assert (pMS->delta_item & MODIFY_CREW_FLAG);
@@ -907,26 +907,25 @@
{
// Motion key pressed while selecting a ship to be
// inserted in an empty escort ship slot.
- COUNT Index = GetAvailableRaceCount ();
- NewState = LOBYTE (pMS->delta_item);
+ COUNT availableCount = GetAvailableRaceCount ();
+ BYTE currentShip = LOBYTE (pMS->delta_item);
if (dx < 0 || dy < 0)
{
- if (NewState-- == 0)
- NewState = Index - 1;
+ if (currentShip-- == 0)
+ currentShip = availableCount - 1;
}
else if (dx > 0 || dy > 0)
{
- if (++NewState == Index)
- NewState = 0;
+ if (++currentShip == availableCount)
+ currentShip = 0;
}
- if (NewState != LOBYTE (pMS->delta_item))
+ if (currentShip != LOBYTE (pMS->delta_item))
{
- DrawRaceStrings (pMS, NewState);
- pMS->delta_item = NewState | MODIFY_CREW_FLAG;
+ DrawRaceStrings (pMS, currentShip);
+ pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
}
- *newStateOut = NewState;
return TRUE;
}
}
@@ -1095,8 +1094,8 @@
}
else
#endif /* WANT_SHIP_SPINS */
- if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 &&
- !(pMS->delta_item & MODIFY_CREW_FLAG) && select)
+ if (!(pMS->delta_item & MODIFY_CREW_FLAG) &&
+ hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 && select)
{
// Select button was pressed over an empty escort
// ship slot. Switch to 'add escort ship' mode.
@@ -1105,21 +1104,22 @@
DrawRaceStrings (pMS, 0);
return TRUE;
}
+ else if ((pMS->delta_item & MODIFY_CREW_FLAG) &&
+ hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 &&
+ (dx || dy || select || cancel))
+ {
+ // Cursor is over an empty escort ship slot, while we're
+ // in 'add escort ship' mode.
+ UnlockMutex (GraphicsLock);
+ if (DMS_AddEscortShip (pMS, select, cancel, dx, dy))
+ return TRUE;
+
+ LockMutex (GraphicsLock);
+ goto ChangeFlashRect;
+ }
else if (select || ((pMS->delta_item & MODIFY_CREW_FLAG)
&& (dx || dy || cancel)))
{
- if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
- {
- // Cursor is over an empty escort ship slot, while we're
- // in 'add escort ship' mode.
- UnlockMutex (GraphicsLock);
- if (DMS_AddEscortShip (pMS, select, cancel, dx, dy, &NewState))
- return TRUE;
-
- LockMutex (GraphicsLock);
- goto ChangeFlashRect;
- }
-
if (select || cancel)
{
if ((pMS->delta_item & MODIFY_CREW_FLAG)
@@ -1146,11 +1146,11 @@
pMS->delta_item ^= MODIFY_CREW_FLAG;
if (!pMS->delta_item)
- {
goto ChangeFlashRect;
- }
- else if (hStarShip == 0)
+
+ if (hStarShip == 0)
{
+ // Enter crew editing mode for an escort ship.
SetContext (StatusContext);
GetGaugeRect (&r, TRUE);
SetFlashRect (&r);
@@ -1160,11 +1160,13 @@
}
else
{
+ // Enter crew editing mode for the flagship.
r.corner.x = pMS->flash_rect0.corner.x;
r.corner.y = pMS->flash_rect0.corner.y
+ pMS->flash_rect0.extent.height - 6;
r.extent.width = SHIP_WIN_WIDTH;
r.extent.height = 5;
+
SetContext (SpaceContext);
SetFlashRect (&r);
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
@@ -1180,6 +1182,7 @@
}
else if (cancel)
{
+ // Leave escort ship editor.
UnlockMutex (GraphicsLock);
pMS->InputFunc = DoShipyard;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|