From df397efcf9c0188f26eebb5bb8d26b221f6a8e7f Mon Sep 17 00:00:00 2001 From: meep-eep Date: Thu, 19 Jan 2006 23:09:01 +0000 Subject: [PATCH] Better instant-move (for debugging). git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2203 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/planets/pstarmap.c | 20 ++++++++-- sc2/src/sc2code/uqmdebug.c | 64 ++++++++++++++++++++++++++++++ sc2/src/sc2code/uqmdebug.h | 6 +++ 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 0146550fd..073861c38 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.5: +- Better instant-move (for debugging) - SvdB - Fixed version checking in unix build scripts. SDL 1.2.10 is now recognised as newer than 1.2.9. - SvdB - Some small improvements to the portability of the build system, diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 85fa8ad1b..95ac9f8af 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -1237,9 +1237,8 @@ DoMoveCursor (PMENU_STATE pMS) { GLOBAL (autopilot) = pMS->first_item; #ifdef DEBUG - if (instantMove) { - GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX(pMS->first_item.x); - GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY(pMS->first_item.y); + if (instantMove) + { PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 3), 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); if (pMS->flash_task) @@ -1247,6 +1246,21 @@ DoMoveCursor (PMENU_STATE pMS) ConcludeTask (pMS->flash_task); pMS->flash_task = 0; } + + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) + { + // Move to the new location immediately. + doInstantMove (); + } + else if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY) + { + // We're in a solar system; exit it. + GLOBAL (CurrentActivity) |= END_INTERPLANETARY; + + // Set a hook to move to the new location: + debugHook = doInstantMove; + } + return (FALSE); } #endif diff --git a/sc2/src/sc2code/uqmdebug.c b/sc2/src/sc2code/uqmdebug.c index 2aedcef55..a826fa94e 100644 --- a/sc2/src/sc2code/uqmdebug.c +++ b/sc2/src/sc2code/uqmdebug.c @@ -325,6 +325,70 @@ equipShip (void) //////////////////////////////////////////////////////////////////////////// +#if 0 +// Not needed anymore, but could be useful in the future. + +// Find the HELEMENT belonging to the Flagship. +static HELEMENT +findFlagshipElement (void) +{ + HELEMENT hElement, hNextElement; + ELEMENTPTR ElementPtr; + + // Find the ship element. + for (hElement = GetTailElement (); hElement != 0; + hElement = hNextElement) + { + LockElement (hElement, &ElementPtr); + + if ((ElementPtr->state_flags & PLAYER_SHIP) != 0) + { + UnlockElement (hElement); + return hElement; + } + + hNextElement = GetPredElement (ElementPtr); + UnlockElement (hElement); + } + return 0; +} +#endif + +// Move the Flagship to the destination of the autopilot. +// Should only be called from HyperSpace/QuasiSpace. +// It can be called from debugHook directly after entering HS/QS though. +void +doInstantMove (void) +{ + // Move to the new location: + GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX((GLOBAL (autopilot)).x); + GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY((GLOBAL (autopilot)).y); + + // Check for a solar systems at the destination. + if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) + { + // If there's a solar system at the destination, enter it. + CurStarDescPtr = FindStar (0, &(GLOBAL (autopilot)), 0, 0); + if (CurStarDescPtr) + { + // Leave HyperSpace/QuasiSpace if we're there: + SET_GAME_STATE (USED_BROADCASTER, 0); + GLOBAL (CurrentActivity) &= ~IN_BATTLE; + + // Enter IP: + GLOBAL (ShipStamp.frame) = 0; + // This causes the ship position in IP to be reset. + GLOBAL (CurrentActivity) |= START_INTERPLANETARY; + } + } + + // Turn off the autopilot: + (GLOBAL (autopilot)).x = ~0; + (GLOBAL (autopilot)).y = ~0; +} + +//////////////////////////////////////////////////////////////////////////// + void showSpheres (void) { diff --git a/sc2/src/sc2code/uqmdebug.h b/sc2/src/sc2code/uqmdebug.h index 34201f607..b5668b536 100644 --- a/sc2/src/sc2code/uqmdebug.h +++ b/sc2/src/sc2code/uqmdebug.h @@ -55,6 +55,12 @@ void showSpheres (void); // Make the ships of all races available for building at the shipyard. void activateAllShips (void); +// Move the Flagship to the destination of the autopilot. +// Should only be called from HS/QS. +// It can be called from debugHook directly after entering HS/QS though. +void doInstantMove (void); + + // Call a function for all stars. void forAllStars (void (*callback) (STAR_DESC *, void *), void *arg); // Call a function for all planets in a star system.