From 92a27386af0890da37312a25b77399b04ca8b428 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Fri, 10 Mar 2006 07:57:29 +0000 Subject: [PATCH] Debugging function to add crew during battle. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2266 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 3 +++ sc2/src/sc2code/uqmdebug.c | 52 ++++++++++++++++++++++++++++++++++++++ sc2/src/sc2code/uqmdebug.h | 6 +++++ 3 files changed, 61 insertions(+) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 3af3f4554..1facb169e 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,6 +1,9 @@ Changes towards version 0.6: +- Debugging function to add crew during battle. - SvdB +- More documentation - SvdB. - RMPLIFIED PRECURSOR BOMB is now AMPLIFIED, from Vorn (bug #812) -Michael + Changes towards version 0.5: - Innocent origiginal c&p bug fixed, from bpoint. - Handle relative dirs in -C correctly, from Jan Lönnberg (part of bug #738). diff --git a/sc2/src/sc2code/uqmdebug.c b/sc2/src/sc2code/uqmdebug.c index a826fa94e..e250578a3 100644 --- a/sc2/src/sc2code/uqmdebug.c +++ b/sc2/src/sc2code/uqmdebug.c @@ -63,6 +63,7 @@ debugKeyPressed (void) { // State modifying: equipShip (); + resetCrewBattle (); instantMove = !instantMove; showSpheres (); activateAllShips (); @@ -1234,6 +1235,57 @@ depositQualityString (BYTE quality) } } +//////////////////////////////////////////////////////////////////////////// + +// Which should be GOOD_GUY or BAD_GUY +STARSHIPPTR +findPlayerShip(ELEMENT_FLAGS which) { + HELEMENT hElement, hNextElement; + + for (hElement = GetHeadElement (); hElement; hElement = hNextElement) + { + ELEMENTPTR ElementPtr; + + LockElement (hElement, &ElementPtr); + hNextElement = GetSuccElement (ElementPtr); + + if ((ElementPtr->state_flags & PLAYER_SHIP) && + (ElementPtr->state_flags & (GOOD_GUY | BAD_GUY)) == which) + { + STARSHIPPTR StarShipPtr; + GetElementStarShip (ElementPtr, &StarShipPtr); + UnlockElement (hElement); + return StarShipPtr; + } + + UnlockElement (hElement); + } + return NULL; +} + +//////////////////////////////////////////////////////////////////////////// + +void +resetCrewBattle(void) { + STARSHIPPTR StarShipPtr; + COUNT delta; + CONTEXT OldContext; + + if (!(GLOBAL (CurrentActivity) & IN_BATTLE)) + return; + + StarShipPtr = findPlayerShip (GOOD_GUY); + if (StarShipPtr == NULL || StarShipPtr->RaceDescPtr == NULL) + return; + + delta = StarShipPtr->RaceDescPtr->ship_info.max_crew - + StarShipPtr->RaceDescPtr->ship_info.crew_level; + + OldContext = SetContext (StatusContext); + DeltaCrew (StarShipPtr->hShip, delta); + SetContext (OldContext); +} + #endif /* DEBUG */ diff --git a/sc2/src/sc2code/uqmdebug.h b/sc2/src/sc2code/uqmdebug.h index b5668b536..b66b99aec 100644 --- a/sc2/src/sc2code/uqmdebug.h +++ b/sc2/src/sc2code/uqmdebug.h @@ -19,6 +19,7 @@ #include "clock.h" #include "planets/planets.h" +#include "races.h" #include "libs/compiler.h" #include @@ -141,6 +142,11 @@ const char *densityString (BYTE density); const char *depositQualityString (BYTE quality); +// Find a player ship. Setting which to BAD_GUY is only meaningful in battle. +STARSHIPPTR findPlayerShip(ELEMENT_FLAGS which); + +// Resets the crew of the first player (the bottom one) to its maximum. +void resetCrewBattle(void); // Move instantly across hyperspace/quasispace.