diff --git a/sc2/ChangeLog b/sc2/ChangeLog index f18a7f775..bf58be148 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.4: +- Cleaned up use of the DEBUG define, SvdB - Talking Pet .txt file corrected to match the .ogg files, and talkpet.ts corrections, from Nic - Abstracted window-drawing code from confirm.c -Michael diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index cf6e2925c..4e83dcd9c 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -68,7 +68,7 @@ uqm_prepare_config() CHOICE_debug_OPTION_debug_TITLE="Debugging information" CHOICE_debug_OPTION_debug_ACTION='debug_action' debug_action() { - CFLAGS="$CFLAGS -g -O0 -W -Wall" + CFLAGS="$CFLAGS -g -O0 -W -Wall -DDEBUG" LDFLAGS="$LDFLAGS -O0" DEBUG=1 } diff --git a/sc2/src/msvc++/UrQuanMasters.dsp b/sc2/src/msvc++/UrQuanMasters.dsp index eaed94c4e..b46750794 100644 --- a/sc2/src/msvc++/UrQuanMasters.dsp +++ b/sc2/src/msvc++/UrQuanMasters.dsp @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "_DEBUG" /D "DEBUG_TRACK_SEM" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "DEBUG" /D "_DEBUG" /D "DEBUG_TRACK_SEM" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/sc2/src/options.c b/sc2/src/options.c index c481c2850..5ca46064f 100644 --- a/sc2/src/options.c +++ b/sc2/src/options.c @@ -126,9 +126,9 @@ prepareSaveDir (void) { // Create the path upto the save dir, if not already existing. if (mkdirhier (buf) == -1) exit (EXIT_FAILURE); -//#ifdef DEBUG +#ifdef DEBUG fprintf(stderr, "Saved games are kept in %s.\n", buf); -//#endif +#endif saveDir = uio_openDirRelative (configDir, "save", 0); if (saveDir == NULL) { diff --git a/sc2/src/sc2code/collide.c b/sc2/src/sc2code/collide.c index a247b6f3a..23a5c35ac 100644 --- a/sc2/src/sc2code/collide.c +++ b/sc2/src/sc2code/collide.c @@ -18,7 +18,7 @@ #include "starcon.h" -/* #define DEBUG */ +//#define DEBUG_COLLIDE void collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1) @@ -55,13 +55,13 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1) ImpactAngle1 = TravelAngle1 + HALF_CIRCLE; } -#ifdef DEBUG +#ifdef DEBUG_COLLIDE fprintf (stderr, "Centers: <%d, %d> <%d, %d>\n", ElementPtr0->next.location.x, ElementPtr0->next.location.y, ElementPtr1->next.location.x, ElementPtr1->next.location.y); fprintf (stderr, "RelTravelAngle : %d, ImpactAngles <%d, %d>\n", RelTravelAngle, ImpactAngle0, ImpactAngle1); -#endif /* DEBUG */ +#endif /* DEBUG_COLLIDE */ if (ElementPtr0->next.location.x == ElementPtr0->current.location.x && ElementPtr0->next.location.y == ElementPtr0->current.location.y @@ -77,10 +77,10 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1) } ElementPtr0->state_flags |= (DEFY_PHYSICS | COLLISION); ElementPtr1->state_flags |= (DEFY_PHYSICS | COLLISION); -#ifdef DEBUG +#ifdef DEBUG_COLLIDE fprintf (stderr, "No movement before collision -- <(%d, %d) = %d, (%d, %d) = %d>\n", dx0, dy0, ImpactAngle0 - OCTANT, dx1, dy1, ImpactAngle1 - OCTANT); -#endif /* DEBUG */ +#endif /* DEBUG_COLLIDE */ } { @@ -164,12 +164,12 @@ collide (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1) SINE (ImpactAngle1, WORLD_TO_VELOCITY (SCALED_ONE) - 1)); } -#ifdef DEBUG +#ifdef DEBUG_COLLIDE GetCurrentVelocityComponents (&ElementPtr0->velocity, &dx0, &dy0); GetCurrentVelocityComponents (&ElementPtr1->velocity, &dx1, &dy1); fprintf (stderr, "After: <%d, %d> <%d, %d>\n\n", dx0, dy0, dx1, dy1); -#endif /* DEBUG */ +#endif /* DEBUG_COLLIDE */ } } diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 80e2b06b9..505fdabf2 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -44,7 +44,6 @@ void Slider (void); #define SLIDER_Y 107 #define SLIDER_HEIGHT 15 -// #define DEBUG LOCDATA CommData; int cur_comm; diff --git a/sc2/src/sc2code/commglue.c b/sc2/src/sc2code/commglue.c index b416e51cd..e455542fd 100644 --- a/sc2/src/sc2code/commglue.c +++ b/sc2/src/sc2code/commglue.c @@ -236,90 +236,37 @@ construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...) UNICODE *name; va_list vlist; - // fprintf(stderr, "DEBUG: We've entered into construct_response!\n"); - va_start (vlist, R); - // fprintf(stderr, "DEBUG: R = %d\n", R); - do { COUNT len; STRING S; - // fprintf(stderr, "DEBUG: len = %d\n",len); - S = SetAbsStringTableIndex (CommData.ConversationPhrases, R - 1); - // fprintf(stderr, "DEBUG: Returned from call to SetAbsStringTableIndex\n"); - // fprintf(stderr, "DEBUG: GetStringAddress(S) = %s\n",(UNICODE *)GetStringAddress(S)); - // fprintf(stderr, "DEBUG: buf = '%s' (%d) \n", buf, *buf); - // fprintf(stderr, "DEBUG: strlen(buf) = %d\n", strlen(buf)); - wstrcpy (buf, (UNICODE *)GetStringAddress (S)); - // fprintf(stderr, "DEBUG: buf = '%s' (%d) \n", buf, *buf); - // fprintf(stderr, "DEBUG: strlen(buf) = %d\n", strlen(buf)); - len = wstrlen (buf); - // fprintf(stderr, "DEBUG: len = %d\n",len); - buf += len; - // fprintf(stderr, "DEBUG: buf = '%s' (%d) \n", buf, *buf); - // fprintf(stderr, "DEBUG: strlen(buf) = %d\n", strlen(buf)); - name = va_arg (vlist, UNICODE *); - // fprintf(stderr, "DEBUG: returned from va_arg call\n"); - // fprintf(stderr, "DEBUG: name = %s\n",name); - if (name) { - /* - fprintf(stderr, "DEBUG: ------------------------------------\n"); - fprintf(stderr, "DEBUG: We are in the special va_args loop!\n"); - fprintf(stderr, "DEBUG: Current critical variables read:\n"); - fprintf(stderr, "DEBUG: ------------------------------------\n"); - fprintf(stderr, "DEBUG: name = %s\n", name); - fprintf(stderr, "DEBUG: buf = '%s' (%d)\n", buf, *buf); - fprintf(stderr, "DEBUG: len = %d\n", len); - fprintf(stderr, "DEBUG: strlen(name) = %d\n", strlen(name)); - fprintf(stderr, "DEBUG: strlen(buf) = %d\n", strlen(buf)); - fprintf(stderr, "DEBUG: ---- continuing ----\n"); - */ - len = wstrlen (name); - - // fprintf(stderr, "DEBUG: len = %d\n", len); - wstrncpy (buf, name, len); - - // fprintf(stderr, "DEBUG: buf = '%s' (%d)\n", buf, *buf); - // fprintf(stderr, "DEBUG: strlen(buf) = %d\n", strlen(buf)); - buf += len; - // fprintf(stderr, "DEBUG: buf = '%s' (%d)\n", buf, *buf); - - // fprintf(stderr, "DEBUG: Calling va_arg\n"); - /* - The old code follows.. I've broken this all down while troubleshooting. - if ((R = va_arg (vlist, RESPONSE_REF)) == (RESPONSE_REF)-1) name = 0; */ R = va_arg(vlist, int); - - // fprintf(stderr, "DEBUG: Return from call to va_arg\n"); - // fprintf(stderr, "DEBUG: R = %d\n", R); - - if (R == ((RESPONSE_REF)-1)) name = 0; - - // fprintf(stderr, "DEBUG: name = %s\n", name); + if (R == ((RESPONSE_REF) -1)) + name = 0; } } while (name); va_end (vlist); diff --git a/sc2/src/sc2code/cyborg.c b/sc2/src/sc2code/cyborg.c index a6abf764c..ee9586f39 100644 --- a/sc2/src/sc2code/cyborg.c +++ b/sc2/src/sc2code/cyborg.c @@ -18,6 +18,8 @@ #include "starcon.h" +//#define DEBUG_CYBORG + COUNT PlotIntercept (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1, COUNT max_turns, COUNT margin_of_error) @@ -279,19 +281,11 @@ PlotIntercept (ELEMENTPTR ElementPtr0, ELEMENTPTR ElementPtr1, COUNT STARSHIPPTR CyborgDescPtr; -#ifdef DEBUG -static COUNT turn_counter[NUM_PLAYERS]; -#endif /* DEBUG */ - static void InitCyborg (STARSHIPPTR StarShipPtr) { COUNT Index, Divisor; -#ifdef DEBUG - //turn_counter[which_ship] = 0; -#endif /* DEBUG */ - Index = StarShipPtr->RaceDescPtr->characteristics.max_thrust * StarShipPtr->RaceDescPtr->characteristics.thrust_increment; if ((Divisor = StarShipPtr->RaceDescPtr->characteristics.turn_wait @@ -311,9 +305,6 @@ InitCyborg (STARSHIPPTR StarShipPtr) } #endif /* PRINT_MI */ StarShipPtr->RaceDescPtr->cyborg_control.ManeuverabilityIndex = Index; -#ifdef DEBUG - //turn_counter[which_ship] = 0; -#endif /* DEBUG */ } static void @@ -1021,10 +1012,6 @@ tactical_intelligence (void) STARSHIPPTR StarShipPtr, EnemyStarShipPtr; RACE_DESCPTR RDPtr, EnemyRDPtr; -#ifdef DEBUG -++turn_counter[cur_player]; -#endif /* DEBUG */ - StarShipPtr = CyborgDescPtr; RDPtr = StarShipPtr->RaceDescPtr; diff --git a/sc2/src/sc2code/gravity.c b/sc2/src/sc2code/gravity.c index d406a0a4b..90b8171ae 100644 --- a/sc2/src/sc2code/gravity.c +++ b/sc2/src/sc2code/gravity.c @@ -18,6 +18,8 @@ #include "starcon.h" +//#define DEBUG_GRAVITY + BOOLEAN CalculateGravity (PELEMENT ElementPtr) { @@ -56,27 +58,27 @@ CalculateGravity (PELEMENT ElementPtr) dy = ElementPtr->next.location.y - TestElementPtr->next.location.y; } -#if 0 //def DEBUG +#ifdef DEBUG_GRAVITY if (TestElementPtr->state_flags & PLAYER_SHIP) { fprintf (stderr, "CalculateGravity:\n"); fprintf (stderr, "\tdx = %d, dy = %d\n", dx, dy); } -#endif /* DEBUG */ +#endif /* DEBUG_GRAVITY */ dx = WRAP_DELTA_X (dx); dy = WRAP_DELTA_Y (dy); -#if 0 //def DEBUG +#ifdef DEBUG_GRAVITY if (TestElementPtr->state_flags & PLAYER_SHIP) fprintf (stderr, "\twrap_dx = %d, wrap_dy = %d\n", dx, dy); -#endif /* DEBUG */ +#endif /* DEBUG_GRAVITY */ abs_dx = dx >= 0 ? dx : -dx; abs_dy = dy >= 0 ? dy : -dy; abs_dx = WORLD_TO_DISPLAY (abs_dx); abs_dy = WORLD_TO_DISPLAY (abs_dy); -#if 0 //def DEBUG +#ifdef DEBUG_GRAVITY if (TestElementPtr->state_flags & PLAYER_SHIP) fprintf (stderr, "\tdisplay_dx = %d, display_dy = %d\n", abs_dx, abs_dy); -#endif /* DEBUG */ +#endif /* DEBUG_GRAVITY */ if (abs_dx <= GRAVITY_THRESHOLD && abs_dy <= GRAVITY_THRESHOLD) { @@ -104,10 +106,10 @@ CalculateGravity (PELEMENT ElementPtr) fprintf (stderr, "magnitude = %u ", magnitude); #endif /* NEVER */ -#if 0 //def DEBUG +#ifdef DEBUG_GRAVITY if (TestElementPtr->state_flags & PLAYER_SHIP) fprintf (stderr, "dist_squared = %lu\n", dist_squared); -#endif /* DEBUG */ +#endif /* DEBUG_GRAVITY */ if (TestHasGravity) { retval = TRUE; diff --git a/sc2/src/sc2code/grpinfo.c b/sc2/src/sc2code/grpinfo.c index 14c475fb8..6f99cf113 100644 --- a/sc2/src/sc2code/grpinfo.c +++ b/sc2/src/sc2code/grpinfo.c @@ -22,7 +22,7 @@ #endif #include "file.h" -//#define DEBUG +//#define DEBUG_GROUPS typedef struct { @@ -290,10 +290,10 @@ FlushGroupInfo (GROUP_HEADER *pGH, DWORD offset, BYTE which_group, PVOID } SeekResFile (fp, offset, SEEK_SET); WriteResFile (pGH, sizeof (*pGH), 1, fp); -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "1)FlushGroupInfo(%lu): WG = %u(%lu), NG = %u, SI = %u\n", offset, which_group, pGH->GroupOffset[which_group], pGH->NumGroups, pGH->star_index); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ NumShips = (BYTE)CountLinks (&GLOBAL (npc_built_ship_q)); @@ -322,7 +322,7 @@ FlushGroupInfo (GROUP_HEADER *pGH, DWORD offset, BYTE which_group, PVOID RaceType = GET_RACE_ID (FragPtr); WriteResFile ((PBYTE)&RaceType, sizeof (RaceType), 1, fp); -#ifdef DEBUG +#ifdef DEBUG_GROUPS if (which_group == 0) fprintf (stderr, "F) type %u, loc %u<%d, %d>, task 0x%02x:%u\n", RaceType, @@ -331,7 +331,7 @@ FlushGroupInfo (GROUP_HEADER *pGH, DWORD offset, BYTE which_group, PVOID FragPtr->ShipInfo.loc.y, GET_GROUP_MISSION (FragPtr), GET_GROUP_DEST (FragPtr)); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ Ptr = (PBYTE)&FragPtr->RaceDescPtr; WriteResFile ((PBYTE)Ptr, ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, @@ -360,17 +360,17 @@ GetGroupInfo (DWORD offset, BYTE which_group) SeekResFile (fp, offset, SEEK_SET); ReadResFile (&GH, sizeof (GH), 1, fp); -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "GetGroupInfo(%lu): %u(%lu) out of %u\n", offset, which_group, GH.GroupOffset[which_group], GH.NumGroups); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ if (which_group == (BYTE)~0) { COUNT month_index, day_index, year_index; ReinitQueue (&GLOBAL (npc_built_ship_q)); -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "%u == %u\n", GH.star_index, (COUNT)(CurStarDescPtr - star_array)); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ day_index = GH.day_index; month_index = GH.month_index; year_index = GH.year_index; @@ -381,11 +381,11 @@ GetGroupInfo (DWORD offset, BYTE which_group) { res_CloseResFile (fp); -#ifdef DEBUG +#ifdef DEBUG_GROUPS if (GH.star_index == (COUNT)(CurStarDescPtr - star_array)) fprintf (stderr, "GetGroupInfo: battle groups out of date %u/%u/%u!\n", month_index, day_index, year_index); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ fp = res_OpenResFile (tempDir, RANDGRPINFO_FILE, "wb"); GH.NumGroups = 0; GH.star_index = (COUNT)~0; @@ -470,7 +470,7 @@ GetGroupInfo (DWORD offset, BYTE which_group) SET_GROUP_MISSION (FragPtr, task); SET_GROUP_LOC (FragPtr, group_loc); -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "battle group %u(0x%04x) strength %u, " "type %u, loc %u<%d, %d>, task %u\n", which_group, @@ -481,7 +481,7 @@ GetGroupInfo (DWORD offset, BYTE which_group) FragPtr->ShipInfo.loc.x, FragPtr->ShipInfo.loc.y, task); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ UnlockStarShip ( &GLOBAL (npc_built_ship_q), hStarShip ); @@ -551,7 +551,7 @@ GetGroupInfo (DWORD offset, BYTE which_group) ((PBYTE)&FragPtr->ShipInfo.race_strings) - Ptr, 1, fp); -#ifdef DEBUG +#ifdef DEBUG_GROUPS if (which_group == 0) fprintf (stderr, "G) type %u, loc %u<%d, %d>, task 0x%02x:%u\n", RaceType, @@ -560,14 +560,14 @@ GetGroupInfo (DWORD offset, BYTE which_group) FragPtr->ShipInfo.loc.y, GET_GROUP_MISSION (FragPtr), GET_GROUP_DEST (FragPtr)); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ if (GET_GROUP_ID (FragPtr) != BaseGroup || which_group || ShipsLeft) { -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "\n"); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ if (RaceType == SHOFIXTI_SHIP && which_group && !GET_GAME_STATE (SHOFIXTI_RECRUITED)) @@ -588,9 +588,9 @@ GetGroupInfo (DWORD offset, BYTE which_group) } else { -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, " -- REMOVING\n"); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ UnlockStarShip ( &GLOBAL (npc_built_ship_q), hStarShip ); @@ -658,11 +658,11 @@ PutGroupInfo (DWORD offset, BYTE which_group) GH.year_index = year_index; } GH.star_index = CurStarDescPtr - star_array; -#ifdef DEBUG +#ifdef DEBUG_GROUPS fprintf (stderr, "PutGroupInfo(%lu): %u out of %u -- %u/%u/%u\n", offset, which_group, GH.NumGroups, GH.month_index, GH.day_index, GH.year_index); -#endif /* DEBUG */ +#endif /* DEBUG_GROUPS */ FlushGroupInfo (&GH, offset, which_group, fp); diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index 92294377a..298c0135b 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -180,11 +180,7 @@ check_hyperspace_encounter (void) if (!GET_GAME_STATE (STARBASE_AVAILABLE)) percent = 100; else -#ifdef TESTING -percent = 0; -#else /* TESTING */ percent *= GET_GAME_STATE (SLYLANDRO_MULTIPLIER); -#endif /* TESTING */ } else if (Type == MELNORME_SHIP && (GLOBAL_SIS (FuelOnBoard) == 0 @@ -229,14 +225,7 @@ percent = 0; (DWORD)encounter_radius * encounter_radius && ((COUNT)TFB_Random () % 100) < percent) { -#ifndef DEBUG - char buf[20]; - - GetStringContents (SetAbsStringTableIndex ( - TemplatePtr->ShipInfo.race_strings, 1 - ), (STRINGPTR)buf, FALSE); -// fprintf (stderr, "%s encounter\n", buf); -#endif /* DEBUG */ + // Ship spawned for encounter. hEncounter = AllocEncounter (); if (hEncounter) { diff --git a/sc2/src/sc2code/libs/sound/mixer/mixer.c b/sc2/src/sc2code/libs/sound/mixer/mixer.c index 4faa7bcb0..95ad04ede 100644 --- a/sc2/src/sc2code/libs/sound/mixer/mixer.c +++ b/sc2/src/sc2code/libs/sound/mixer/mixer.c @@ -25,8 +25,6 @@ #include "libs/misc.h" #include "libs/threadlib.h" -#define DEBUG - static uint32 mixer_initialized = 0; static uint32 mixer_format; static uint32 mixer_chansize; diff --git a/sc2/src/sc2code/libs/threadlib.h b/sc2/src/sc2code/libs/threadlib.h index 903bd1399..e1232a2e2 100644 --- a/sc2/src/sc2code/libs/threadlib.h +++ b/sc2/src/sc2code/libs/threadlib.h @@ -23,7 +23,7 @@ #define THREADLIB SDL #define NAMED_SYNCHRO /* Should synchronizable objects have names? */ -// #define TRACK_CONTENTION /* Should we report when a thread sleeps on synchronize? */ +#define TRACK_CONTENTION /* Should we report when a thread sleeps on synchronize? */ /* TRACK_CONTENTION implies NAMED_SYNCHRO. */ #ifdef TRACK_CONTENTION @@ -39,9 +39,9 @@ #endif /* DEBUG */ #ifdef DEBUG_THREADS -# ifndef PROFILE_THREADS -# define PROFILE_THREADS -# endif +//# ifndef PROFILE_THREADS +//# define PROFILE_THREADS +//# endif #endif /* DEBUG_THREADS */ #include diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c index de2f0a9ce..8c7713afe 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c @@ -271,8 +271,8 @@ CreateThread_SDL (ThreadFunction func, void *data, SDWORD stackSize QueueThread (thread); #ifdef DEBUG_THREADS - fprintf (stderr, "Thread '%s' created.\n", ThreadName (thread)); - fflush (stderr); +// fprintf (stderr, "Thread '%s' created.\n", ThreadName (thread)); +// fflush (stderr); #endif // Signal to the new thread that the thread structure is ready diff --git a/sc2/src/sc2code/load.c b/sc2/src/sc2code/load.c index 7af4b0e86..e6a0e4037 100644 --- a/sc2/src/sc2code/load.c +++ b/sc2/src/sc2code/load.c @@ -22,6 +22,8 @@ #include "options.h" #include "file.h" +//#define DEBUG_LOAD + ACTIVITY NextActivity; static void @@ -162,9 +164,9 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) cread ((PBYTE)&num_links, sizeof (num_links), 1, fh); { -#ifdef DEBUG +#ifdef DEBUG_LOAD fprintf (stderr, "EVENTS:\n"); -#endif /* DEBUG */ +#endif /* DEBUG_LOAD */ while (num_links--) { HEVENT hEvent; @@ -175,13 +177,13 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc) cread ((PBYTE)EventPtr, sizeof (*EventPtr), 1, fh); -#ifdef DEBUG +#ifdef DEBUG_LOAD fprintf (stderr, "\t%u/%u/%u -- %u\n", EventPtr->month_index, EventPtr->day_index, EventPtr->year_index, EventPtr->func_index); -#endif /* DEBUG */ +#endif /* DEBUG_LOAD */ UnlockEvent (hEvent); PutEvent (hEvent); } diff --git a/sc2/src/sc2code/planets/calc.c b/sc2/src/sc2code/planets/calc.c index c11be420d..0ad520012 100644 --- a/sc2/src/sc2code/planets/calc.c +++ b/sc2/src/sc2code/planets/calc.c @@ -22,6 +22,8 @@ /* -------------------------------- CODE -------------------------------- */ +//#define DEBUG_PLANET_CALC + #define CalcMass(b) CalcFromBase (b, b) #define CalcRadius(b) CalcFromBase (b, ((b) >> 1) + 1) @@ -231,7 +233,7 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC CalcSysInfo (SysInfoPtr); -#ifdef DEBUG +#ifdef DEBUG_PLANET_CALC { BYTE ColorClass[6][8] = { "Red", @@ -253,7 +255,7 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC fprintf (stderr, "Stellar Energy: %d (sol = 3)\n", SysInfoPtr->StarEnergy); } -#endif /* DEBUG */ +#endif /* DEBUG_PLANET_CALC */ { SIZE radius; @@ -330,7 +332,7 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC SysInfoPtr->PlanetInfo.Tectonics >>= 5; SysInfoPtr->PlanetInfo.Weather >>= 5; -#ifdef DEBUG +#ifdef DEBUG_PLANET_CALC radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS)); fprintf (stderr, "\tOrbital Distance : %d.%02d AU\n", radius / 100, radius % 100); //fprintf (stderr, "\tPlanetary Mass : %d.%02d Earth masses\n", @@ -391,7 +393,7 @@ DoPlanetaryAnalysis (SYSTEM_INFOPTR SysInfoPtr, PPLANET_DESC SysInfoPtr->PlanetInfo.RotationPeriod / 10, SysInfoPtr->PlanetInfo.RotationPeriod % 10); } -#endif /* DEBUG */ +#endif /* DEBUG_PLANET_CALC */ } return (TFB_SeedRandom (old_seed)); diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index f6a3d62fe..414148148 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -19,6 +19,8 @@ #include "starcon.h" #include "controls.h" +//#define DEBUG_DEVICES + static COUNT lpstrchr (UNICODE *pStr, UNICODE ch) { @@ -597,9 +599,9 @@ InventoryDevices (BYTE *pDeviceMap) break; } -#ifndef DEBUG +#ifndef DEBUG_DEVICES if (DeviceState) -#endif /* DEBUG */ +#endif /* DEBUG_DEVICES */ { *pDeviceMap++ = i; ++DevicesOnBoard; diff --git a/sc2/src/sc2code/planets/orbits.c b/sc2/src/sc2code/planets/orbits.c index dde3c521f..f21b5e49e 100644 --- a/sc2/src/sc2code/planets/orbits.c +++ b/sc2/src/sc2code/planets/orbits.c @@ -18,6 +18,8 @@ #include "starcon.h" +//#define DEBUG_ORBITS + enum { PLANET_NEVER = 0, @@ -479,11 +481,11 @@ FillOrbits (BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN {GIANT_ROCK_DIST, GIANT_GASG_DIST}, {SUPERGIANT_ROCK_DIST, SUPERGIANT_GASG_DIST}, }; -#ifdef DEBUG +#ifdef DEBUG_ORBITS UNICODE buf[40]; char stype[] = {'D', 'G', 'S'}; char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; -#endif /* DEBUG */ +#endif /* DEBUG_ORBITS */ pPD = pBaseDesc; StarSize = pSolarSysState->SunDesc[0].data_index; @@ -498,12 +500,12 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; pSolarSysState->SunDesc[0].NumPlanets = NumPlanets; } -#ifdef DEBUG +#ifdef DEBUG_ORBITS GetClusterName (CurStarDescPtr, buf); fprintf (stderr, "cluster name = %s color = %c type = %c\n", buf, scolor[STAR_COLOR (CurStarDescPtr->Type)], stype[STAR_TYPE (CurStarDescPtr->Type)]); -#endif /* DEBUG */ +#endif /* DEBUG_ORBITS */ GeneratingMoons = (BOOLEAN) (pBaseDesc == pSolarSysState->MoonDesc); if (GeneratingMoons) MaxPlanet = FIRST_LARGE_ROCKY_WORLD; diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index df7d128c0..df9f713cb 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -20,6 +20,8 @@ #include "libs/graphics/gfx_common.h" #include "controls.h" +//#define DEBUG_SOLARSYS + //Added by Chris void LoadLanderData (void); @@ -414,13 +416,13 @@ ShowPlanet: pSolarSysState->pOrbitalDesc = pCurDesc; } -#ifdef DEBUG +#ifdef DEBUG_SOLARSYS fprintf (stderr, "Star index = %d, Planet index = %d, <%d, %d>\n", CurStarDescPtr - star_array, pCurDesc - pSolarSysState->PlanetDesc, pSolarSysState->SunDesc[0].location.x, pSolarSysState->SunDesc[0].location.y); -#endif /* DEBUG */ +#endif /* DEBUG_SOLARSYS */ return; } } @@ -1554,7 +1556,7 @@ GenerateRandomIP (BYTE control) break; case GENERATE_ORBITAL: { -#ifdef DEBUG +#ifdef DEBUG_SOLARSYS if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) fprintf (stderr, "Planet index = %d\n", pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc); @@ -1562,7 +1564,7 @@ GenerateRandomIP (BYTE control) fprintf (stderr, "Planet index = %d, Moon index = %d\n", pSolarSysState->pOrbitalDesc->pPrevDesc - pSolarSysState->PlanetDesc, pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc); -#endif /* DEBUG */ +#endif /* DEBUG_SOLARSYS */ rand_val = DoPlanetaryAnalysis ( &pSolarSysState->SysInfo, pSolarSysState->pOrbitalDesc ); diff --git a/sc2/src/sc2code/planets/surface.c b/sc2/src/sc2code/planets/surface.c index f199483e1..7619cc6ef 100644 --- a/sc2/src/sc2code/planets/surface.c +++ b/sc2/src/sc2code/planets/surface.c @@ -19,6 +19,8 @@ #include "starcon.h" #include "lifeform.h" +//#define DEBUG_SURFACE + const BYTE *Elements; const PlanetFrame *PlanData; @@ -72,11 +74,11 @@ CalcMineralDeposits (SYSTEM_INFOPTR SysInfoPtr, COUNT which_deposit) deposit_quality_gross, deposit_quality_fine / 10 + 1 ); SysInfoPtr->PlanetInfo.CurType = eptr->ElementType; -#ifdef DEBUG - //fprintf (stderr, "\t\t%d units of %Fs\n", - // SysInfoPtr->PlanetInfo.CurDensity, - // Elements[eptr->ElementType].name); -#endif /* DEBUG */ +#ifdef DEBUG_SURFACE + fprintf (stderr, "\t\t%d units of %Fs\n", + SysInfoPtr->PlanetInfo.CurDensity, + Elements[eptr->ElementType].name); +#endif /* DEBUG_SURFACE */ if ((num_deposits >= which_deposit && !(SysInfoPtr->PlanetInfo.ScanRetrieveMask[MINERAL_SCAN] & (1L << num_deposits))) @@ -235,11 +237,11 @@ CalcLifeForms (SYSTEM_INFOPTR SysInfoPtr, COUNT which_life) } while (--num_creatures); } while (--num_types); } -#ifdef DEBUG +#ifdef DEBUG_SURFACE else fprintf (stderr, "It's dead, Jim! (%d >= %d)\n", life_var, SysInfoPtr->PlanetInfo.LifeChance); -#endif /* DEBUG */ +#endif /* DEBUG_SURFACE */ } return (num_life_forms); diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index 59fb54688..fca6a4bad 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -22,6 +22,8 @@ #include "libs/graphics/drawcmd.h" #include "options.h" +//#define DEBUG_PROCESS + COUNT DisplayFreeList; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; extern POINT SpaceOrg; @@ -389,10 +391,10 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr, &TestElementPtr->IntersectControl, min_time)) == 1 && !((state_flags | test_state_flags) & FINITE_LIFE)) { -#ifdef DEBUG +#ifdef DEBUG_PROCESS fprintf (stderr, "BAD NEWS 0x%x <--> 0x%x\n", ElementPtr, TestElementPtr); -#endif /* DEBUG */ +#endif /* DEBUG_PROCESS */ if (state_flags & COLLISION) { InitIntersectEndPoint (TestElementPtr); @@ -511,10 +513,10 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr, { POINT SavePt, TestSavePt; -#ifdef DEBUG +#ifdef DEBUG_PROCESS fprintf (stderr, "0x%x <--> 0x%x at %u\n", ElementPtr, TestElementPtr, time_val); -#endif /* DEBUG */ +#endif /* DEBUG_PROCESS */ SavePt = ElementPtr->IntersectControl.EndPoint; TestSavePt = TestElementPtr->IntersectControl.EndPoint; InitIntersectEndPoint (ElementPtr); @@ -533,10 +535,10 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr, state_flags = ElementPtr->state_flags; test_state_flags = TestElementPtr->state_flags; -#ifdef DEBUG +#ifdef DEBUG_PROCESS fprintf (stderr, "PROCESSING 0x%x <--> 0x%x at %u\n", ElementPtr, TestElementPtr, time_val); -#endif /* DEBUG */ +#endif /* DEBUG_PROCESS */ if (test_state_flags & PLAYER_SHIP) { (*TestElementPtr->collision_func) (