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: <av...@us...> - 2011-09-05 16:11:02
|
Revision: 3682 http://sc2.svn.sourceforge.net/sc2/?rev=3682&view=rev Author: avolkov Date: 2011-09-05 16:10:56 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Dodge compiler warning in MikMod driver because MikMod_Init() does not take 'const char*' Modified Paths: -------------- trunk/sc2/src/libs/sound/decoders/modaud.c Modified: trunk/sc2/src/libs/sound/decoders/modaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-05 16:06:48 UTC (rev 3681) +++ trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-05 16:10:56 UTC (rev 3682) @@ -276,7 +276,7 @@ md_pansep = 64; - if (MikMod_Init ("")) + if (MikMod_Init (NULL)) { log_add (log_Error, "MikMod_Init() failed, %s", MikMod_strerror (MikMod_errno)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-05 16:06:55
|
Revision: 3681 http://sc2.svn.sourceforge.net/sc2/?rev=3681&view=rev Author: avolkov Date: 2011-09-05 16:06:48 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Removed retired function TFB_BlitSurface() Modified Paths: -------------- trunk/sc2/src/libs/graphics/sdl/sdl_common.c Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2011-09-01 18:58:13 UTC (rev 3680) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2011-09-05 16:06:48 UTC (rev 3681) @@ -337,251 +337,6 @@ } void -TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, - SDL_Rect *dstrect, int blend_numer, int blend_denom) -{ - BOOLEAN has_colorkey; - int x, y, x1, y1, x2, y2, dst_x2, dst_y2, nr, ng, nb; - int srcx, srcy, w, h; - Uint8 sr, sg, sb, dr, dg, db; - Uint32 src_pixval, dst_pixval, colorkey; - GetPixelFn src_getpix, dst_getpix; - PutPixelFn putpix; - SDL_Rect fulldst; - - if (blend_numer == blend_denom) - { - // normal blit: dst = src - - // log_add (log_Debug, "normal blit\n"); - SDL_BlitSurface (src, srcrect, dst, dstrect); - return; - } - - // NOTE: following clipping code is copied from SDL-1.2.4 sources - - // If the destination rectangle is NULL, use the entire dest surface - if (dstrect == NULL) - { - fulldst.x = fulldst.y = 0; - dstrect = &fulldst; - } - - // clip the source rectangle to the source surface - if (srcrect) - { - int maxw, maxh; - - srcx = srcrect->x; - w = srcrect->w; - if (srcx < 0) - { - w += srcx; - dstrect->x -= srcx; - srcx = 0; - } - maxw = src->w - srcx; - if (maxw < w) - w = maxw; - - srcy = srcrect->y; - h = srcrect->h; - if (srcy < 0) - { - h += srcy; - dstrect->y -= srcy; - srcy = 0; - } - maxh = src->h - srcy; - if (maxh < h) - h = maxh; - } - else - { - srcx = 0; - srcy = 0; - w = src->w; - h = src->h; - } - - // clip the destination rectangle against the clip rectangle - { - SDL_Rect *clip = &dst->clip_rect; - int dx, dy; - - dx = clip->x - dstrect->x; - if (dx > 0) - { - w -= dx; - dstrect->x += dx; - srcx += dx; - } - dx = dstrect->x + w - clip->x - clip->w; - if (dx > 0) - w -= dx; - - dy = clip->y - dstrect->y; - if (dy > 0) - { - h -= dy; - dstrect->y += dy; - srcy += dy; - } - dy = dstrect->y + h - clip->y - clip->h; - if (dy > 0) - h -= dy; - } - - dstrect->w = w; - dstrect->h = h; - - if (w <= 0 || h <= 0) - return; - - x1 = srcx; - y1 = srcy; - x2 = srcx + w; - y2 = srcy + h; - - if (src->flags & SDL_SRCCOLORKEY) - { - has_colorkey = TRUE; - colorkey = src->format->colorkey; - } - else - { - has_colorkey = FALSE; - colorkey = 0; /* Satisfying compiler */ - } - - src_getpix = getpixel_for (src); - dst_getpix = getpixel_for (dst); - putpix = putpixel_for (dst); - - if (blend_denom < 0) - { - // additive blit: dst = src + dst -#if 0 - log_add (log_Debug, "additive blit %d %d, src %d %d %d %d dst %d %d," - " srcbpp %d", blend_numer, blend_denom, x1, y1, x2, y2, - dstrect->x, dstrect->y, src->format->BitsPerPixel); -#endif - for (y = y1; y < y2; ++y) - { - dst_y2 = dstrect->y + (y - y1); - for (x = x1; x < x2; ++x) - { - dst_x2 = dstrect->x + (x - x1); - src_pixval = src_getpix (src, x, y); - - if (has_colorkey && src_pixval == colorkey) - continue; - - dst_pixval = dst_getpix (dst, dst_x2, dst_y2); - - SDL_GetRGB (src_pixval, src->format, &sr, &sg, &sb); - SDL_GetRGB (dst_pixval, dst->format, &dr, &dg, &db); - - nr = sr + dr; - ng = sg + dg; - nb = sb + db; - - if (nr > 255) - nr = 255; - if (ng > 255) - ng = 255; - if (nb > 255) - nb = 255; - - putpix (dst, dst_x2, dst_y2, - SDL_MapRGB (dst->format, nr, ng, nb)); - } - } - } - else if (blend_numer < 0) - { - // subtractive blit: dst = src - dst -#if 0 - log_add (log_Debug, "subtractive blit %d %d, src %d %d %d %d" - " dst %d %d, srcbpp %d", blend_numer, blend_denom, - x1, y1, x2, y2, dstrect->x, dstrect->y, - src->format->BitsPerPixel); -#endif - for (y = y1; y < y2; ++y) - { - dst_y2 = dstrect->y + (y - y1); - for (x = x1; x < x2; ++x) - { - dst_x2 = dstrect->x + (x - x1); - src_pixval = src_getpix (src, x, y); - - if (has_colorkey && src_pixval == colorkey) - continue; - - dst_pixval = dst_getpix (dst, dst_x2, dst_y2); - - SDL_GetRGB (src_pixval, src->format, &sr, &sg, &sb); - SDL_GetRGB (dst_pixval, dst->format, &dr, &dg, &db); - - nr = sr - dr; - ng = sg - dg; - nb = sb - db; - - if (nr < 0) - nr = 0; - if (ng < 0) - ng = 0; - if (nb < 0) - nb = 0; - - putpix (dst, dst_x2, dst_y2, - SDL_MapRGB (dst->format, nr, ng, nb)); - } - } - } - else - { - // modulated blit: dst = src * (blend_numer / blend_denom) - - float f = blend_numer / (float)blend_denom; -#if 0 - log_add (log_Debug, "modulated blit %d %d, f %f, src %d %d %d %d" - " dst %d %d, srcbpp %d\n", blend_numer, blend_denom, f, - x1, y1, x2, y2, dstrect->x, dstrect->y, - src->format->BitsPerPixel); -#endif - for (y = y1; y < y2; ++y) - { - dst_y2 = dstrect->y + (y - y1); - for (x = x1; x < x2; ++x) - { - dst_x2 = dstrect->x + (x - x1); - src_pixval = src_getpix (src, x, y); - - if (has_colorkey && src_pixval == colorkey) - continue; - - SDL_GetRGB (src_pixval, src->format, &sr, &sg, &sb); - - nr = (int)(sr * f); - ng = (int)(sg * f); - nb = (int)(sb * f); - - if (nr > 255) - nr = 255; - if (ng > 255) - ng = 255; - if (nb > 255) - nb = 255; - - putpix (dst, dst_x2, dst_y2, - SDL_MapRGB (dst->format, nr, ng, nb)); - } - } - } -} - -void TFB_UploadTransitionScreen (void) { #ifdef HAVE_OPENGL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-01 18:58:19
|
Revision: 3680 http://sc2.svn.sourceforge.net/sc2/?rev=3680&view=rev Author: avolkov Date: 2011-09-01 18:58:13 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Remove TotalElementMass from the strip ship random seed mix because the player can dump cargo and change the seed; bug #567 Modified Paths: -------------- trunk/sc2/src/uqm/comm/melnorm/melnorm.c Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-09-01 17:48:11 UTC (rev 3679) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-09-01 18:58:13 UTC (rev 3680) @@ -570,8 +570,9 @@ x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)) / 100; y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)) / 100; // prime numbers help randomness - return y * 1013 + x + GLOBAL_SIS (TotalElementMass) - + GLOBAL_SIS (NumLanders); + return y * 1013 + x + GLOBAL_SIS (NumLanders) + + GLOBAL_SIS (ModuleSlots[1]) + GLOBAL_SIS (ModuleSlots[4]) + + GLOBAL_SIS (ModuleSlots[7]) + GLOBAL_SIS (ModuleSlots[10]); } static BOOLEAN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-01 17:48:17
|
Revision: 3679 http://sc2.svn.sourceforge.net/sc2/?rev=3679&view=rev Author: avolkov Date: 2011-09-01 17:48:11 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Account for slight movement in HyperSpace due to encounters in Melnorme strip ship random seed; bug #567 Modified Paths: -------------- trunk/sc2/src/uqm/comm/melnorm/melnorm.c Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-08-30 15:59:39 UTC (rev 3678) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-09-01 17:48:11 UTC (rev 3679) @@ -558,6 +558,22 @@ return 0; } +static DWORD +getStripRandomSeed (void) +{ + DWORD x, y; + // We truncate the location because encounters move the ship slightly in + // HSpace, and throw some other relatively immutable values in the mix to + // vary the deal when stuck at the same general location again. + // It is still possible but unlikely for encounters to move the ship into + // another truncation sector so the player could choose from 2 deals. + x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)) / 100; + y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)) / 100; + // prime numbers help randomness + return y * 1013 + x + GLOBAL_SIS (TotalElementMass) + + GLOBAL_SIS (NumLanders); +} + static BOOLEAN StripShip (COUNT fuel_required) { @@ -619,7 +635,7 @@ // a repeatable pseudo-random function of where we got stuck and what, // exactly, is on our ship. rc = RandomContext_New(); - RandomContext_SeedRandom(rc, GLOBAL_SIS (log_y) * LOG_UNITS_X + GLOBAL_SIS (log_x)); + RandomContext_SeedRandom (rc, getStripRandomSeed ()); SIS_copy = GlobData.SIS_state; for (i = PLANET_LANDER; i < BOMB_MODULE_0; ++i) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-30 15:59:45
|
Revision: 3678 http://sc2.svn.sourceforge.net/sc2/?rev=3678&view=rev Author: avolkov Date: 2011-08-30 15:59:39 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Fix double free() of RandomContext in Melnorme comm Modified Paths: -------------- trunk/sc2/src/uqm/comm/melnorm/melnorm.c Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-08-28 20:22:44 UTC (rev 3677) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-08-30 15:59:39 UTC (rev 3678) @@ -712,8 +712,8 @@ end_mod = which_module; ++module_count[which_module]; total += GLOBAL (ModuleCost[which_module]); - RandomContext_Delete (rc); } + RandomContext_Delete (rc); if (total == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-08-28 20:22:50
|
Revision: 3677 http://sc2.svn.sourceforge.net/sc2/?rev=3677&view=rev Author: Meep-Eep Date: 2011-08-28 20:22:44 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Update Modified Paths: -------------- trunk/sc2/ChangeLog Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-08-28 20:15:45 UTC (rev 3676) +++ trunk/sc2/ChangeLog 2011-08-28 20:22:44 UTC (rev 3677) @@ -1,4 +1,6 @@ Changes towards version 0.8: +- Fixes to a few small bugs in UIO which shouldn't have had an impact on + UQM, but would in the future, from Alex - Allow F6 as a default alternate search key, from related projects. - "Player 1" and "Player 2" are now "Bottom" and "Top" player (#954) - McM - Fix Utwig dialog inconsistency (#756) - McM This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-08-28 20:15:51
|
Revision: 3676 http://sc2.svn.sourceforge.net/sc2/?rev=3676&view=rev Author: Meep-Eep Date: 2011-08-28 20:15:45 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Fix order of MountInfo. From fossil. Modified Paths: -------------- trunk/sc2/src/libs/uio/mount.c Modified: trunk/sc2/src/libs/uio/mount.c =================================================================== --- trunk/sc2/src/libs/uio/mount.c 2011-08-28 19:55:08 UTC (rev 3675) +++ trunk/sc2/src/libs/uio/mount.c 2011-08-28 20:15:45 UTC (rev 3676) @@ -61,7 +61,7 @@ repository->mounts[repository->numMounts] = mountInfo; repository->numMounts++; break; - case uio_MOUNT_BELOW: { + case uio_MOUNT_ABOVE: { int i; uio_MountInfo **newMounts; @@ -76,7 +76,7 @@ repository->numMounts++; break; } - case uio_MOUNT_ABOVE: { + case uio_MOUNT_BELOW: { int i; uio_MountInfo **newMounts; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-08-28 19:55:14
|
Revision: 3675 http://sc2.svn.sourceforge.net/sc2/?rev=3675&view=rev Author: Meep-Eep Date: 2011-08-28 19:55:08 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Increment correct ref counter. From fossil. Modified Paths: -------------- trunk/sc2/src/libs/uio/physical.c Modified: trunk/sc2/src/libs/uio/physical.c =================================================================== --- trunk/sc2/src/libs/uio/physical.c 2011-08-27 21:00:49 UTC (rev 3674) +++ trunk/sc2/src/libs/uio/physical.c 2011-08-28 19:55:08 UTC (rev 3675) @@ -157,7 +157,7 @@ #ifdef uio_MEM_DEBUG uio_MemDebug_debugRef(uio_PRoot, (void *) pRoot); #endif - pRoot->handleRef++; + pRoot->mountRef++; } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-08-27 21:00:55
|
Revision: 3674 http://sc2.svn.sourceforge.net/sc2/?rev=3674&view=rev Author: mcmartin Date: 2011-08-27 21:00:49 +0000 (Sat, 27 Aug 2011) Log Message: ----------- update ChangeLog Modified Paths: -------------- trunk/sc2/ChangeLog Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-08-27 20:55:32 UTC (rev 3673) +++ trunk/sc2/ChangeLog 2011-08-27 21:00:49 UTC (rev 3674) @@ -1,4 +1,8 @@ Changes towards version 0.8: +- Allow F6 as a default alternate search key, from related projects. +- "Player 1" and "Player 2" are now "Bottom" and "Top" player (#954) - McM +- Fix Utwig dialog inconsistency (#756) - McM +- Use a deterministic seed for Melnorme modules-for-fuel deals (#567) - McM - Various warnings cleanup (bug #50), from Scott A. Colcord - Fixed various Pkunk reincarnation and Shofixti Glory device interactions; Pkunk ditty plays in a simultaneous destruction (bug #666) - Alex This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-08-27 20:55:38
|
Revision: 3673 http://sc2.svn.sourceforge.net/sc2/?rev=3673&view=rev Author: mcmartin Date: 2011-08-27 20:55:32 +0000 (Sat, 27 Aug 2011) Log Message: ----------- Conversation logic refinements (#567, #756) Modified Paths: -------------- trunk/sc2/src/uqm/comm/melnorm/melnorm.c trunk/sc2/src/uqm/comm/utwig/utwigc.c Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c =================================================================== --- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-08-27 20:54:35 UTC (rev 3672) +++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2011-08-27 20:55:32 UTC (rev 3673) @@ -611,6 +611,15 @@ BYTE module_count[BOMB_MODULE_0]; BYTE slot; DWORD capacity; + RandomContext *rc; + + // Bug #567 + // In order to offer the same deal each time if it is refused, we seed + // the random number generator with our location, thus making the deal + // a repeatable pseudo-random function of where we got stuck and what, + // exactly, is on our ship. + rc = RandomContext_New(); + RandomContext_SeedRandom(rc, GLOBAL_SIS (log_y) * LOG_UNITS_X + GLOBAL_SIS (log_x)); SIS_copy = GlobData.SIS_state; for (i = PLANET_LANDER; i < BOMB_MODULE_0; ++i) @@ -654,7 +663,7 @@ { DWORD rand_val; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (rc); switch (which_module = LOBYTE (LOWORD (rand_val)) % (CREW_POD + 1)) { case PLANET_LANDER: @@ -703,6 +712,7 @@ end_mod = which_module; ++module_count[which_module]; total += GLOBAL (ModuleCost[which_module]); + RandomContext_Delete (rc); } if (total == 0) Modified: trunk/sc2/src/uqm/comm/utwig/utwigc.c =================================================================== --- trunk/sc2/src/uqm/comm/utwig/utwigc.c 2011-08-27 20:54:35 UTC (rev 3672) +++ trunk/sc2/src/uqm/comm/utwig/utwigc.c 2011-08-27 20:55:32 UTC (rev 3673) @@ -390,7 +390,7 @@ Response (what_now_homeworld, AlliedHome); if (PHRASE_ENABLED (how_is_ultron)) Response (how_is_ultron, AlliedHome); - if (NumVisits == 0) + if (NumVisits == 0 && ActivateStarShip (UTWIG_SHIP, FEASIBILITY_STUDY) != 0) Response (can_you_help, ExitConversation); Response (bye_allied_homeworld, ExitConversation); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-08-27 20:54:41
|
Revision: 3672 http://sc2.svn.sourceforge.net/sc2/?rev=3672&view=rev Author: mcmartin Date: 2011-08-27 20:54:35 +0000 (Sat, 27 Aug 2011) Log Message: ----------- Allow F6 as a search key, for user-friendliness and support for non-US keyboards. Modified Paths: -------------- trunk/sc2/content/menu.key Modified: trunk/sc2/content/menu.key =================================================================== --- trunk/sc2/content/menu.key 2011-08-27 20:52:38 UTC (rev 3671) +++ trunk/sc2/content/menu.key 2011-08-27 20:54:35 UTC (rev 3672) @@ -48,6 +48,7 @@ backspace.1 = STRING:key Backspace editcancel.1 = STRING:key Escape search.1 = STRING:key / +search.2 = STRING:key F6 next.1 = STRING:key Tab pause.1 = STRING:key Pause pause.2 = STRING:key F1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-08-27 20:52:44
|
Revision: 3671 http://sc2.svn.sourceforge.net/sc2/?rev=3671&view=rev Author: mcmartin Date: 2011-08-27 20:52:38 +0000 (Sat, 27 Aug 2011) Log Message: ----------- Rename Players 1 and 2 to Bottom/Top player (bug #954) Modified Paths: -------------- trunk/sc2/content/base/ui/setupmenu.txt Modified: trunk/sc2/content/base/ui/setupmenu.txt =================================================================== --- trunk/sc2/content/base/ui/setupmenu.txt 2011-08-25 23:33:17 UTC (rev 3670) +++ trunk/sc2/content/base/ui/setupmenu.txt 2011-08-27 20:52:38 UTC (rev 3671) @@ -30,8 +30,8 @@ Sound Driver Sound Quality Slave Shields -Player One -Player Two +Bottom Player +Top Player Control Set UQM Remixes Speech @@ -317,28 +317,28 @@ Placeholder #(CAT_18_OPT_0_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_18_OPT_1_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_18_OPT_2_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_18_OPT_3_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_18_OPT_4_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_18_OPT_5_DESC) -Player 1 controls the bottom player in -Super Melee, and the entire Full Game. +Controls the bottom player in Super +Melee, and the entire Full Game. #(CAT_19_OPTS) Placeholder @@ -349,27 +349,27 @@ Placeholder #(CAT_19_OPT_0_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_19_OPT_1_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_19_OPT_2_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_19_OPT_3_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_19_OPT_4_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_19_OPT_5_DESC) -Player 2 controls the top player +Controls the top player in Super Melee. #(CAT_20_OPTS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-25 23:33:23
|
Revision: 3670 http://sc2.svn.sourceforge.net/sc2/?rev=3670&view=rev Author: avolkov Date: 2011-08-25 23:33:17 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Cleanup of ENCOUNTER member fields abuse Modified Paths: -------------- trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/encount.h trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/load.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/save.c Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/comm.c 2011-08-25 23:33:17 UTC (rev 3670) @@ -1536,7 +1536,6 @@ else { /* Encounter with a black globe in HS, prepare enemy ship list */ - COUNT NumShips; ENCOUNTER *EncounterPtr; // The encounter globe that the flagship collided with is moved @@ -1544,10 +1543,9 @@ hEncounter = GetHeadEncounter (); LockEncounter (hEncounter, &EncounterPtr); - NumShips = LONIBBLE (EncounterPtr->SD.Index); - for (i = 0; i < NumShips; ++i) + for (i = 0; i < EncounterPtr->num_ships; ++i) { - CloneShipFragment (EncounterPtr->SD.Type, + CloneShipFragment (EncounterPtr->race_id, &GLOBAL (npc_built_ship_q), EncounterPtr->ShipList[i].crew_level); } @@ -1588,12 +1586,11 @@ LockEncounter (hEncounter, &EncounterPtr); - NumShips = (BYTE)CountLinks (&GLOBAL (npc_built_ship_q)); - EncounterPtr->SD.Index = MAKE_BYTE (NumShips, - HINIBBLE (EncounterPtr->SD.Index)); - EncounterPtr->SD.Index |= ENCOUNTER_REFORMING; + NumShips = CountLinks (&GLOBAL (npc_built_ship_q)); + EncounterPtr->num_ships = NumShips; + EncounterPtr->flags |= ENCOUNTER_REFORMING; if (status == 0) - EncounterPtr->SD.Index |= ONE_SHOT_ENCOUNTER; + EncounterPtr->flags |= ONE_SHOT_ENCOUNTER; for (i = 0; i < NumShips; ++i) { Modified: trunk/sc2/src/uqm/encount.h =================================================================== --- trunk/sc2/src/uqm/encount.h 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/encount.h 2011-08-25 23:33:17 UTC (rev 3670) @@ -38,8 +38,16 @@ typedef HLINK HENCOUNTER; #define MAX_HYPER_SHIPS 7 + +// ENCOUNTER.flags +// XXX: Currently, the flags are combined with num_ships into a single BYTE +// in the savegames: num_ships occupy the low nibble and flags the high one. +// Bits 4 and 5 are available for more flags in the savegames, +// and bits 0-3 available in the game but will not be saved. #define ONE_SHOT_ENCOUNTER (1 << 7) #define ENCOUNTER_REFORMING (1 << 6) +#define ENCOUNTER_SHIPS_MASK 0x0f +#define ENCOUNTER_FLAGS_MASK 0xf0 struct brief_ship_info { @@ -61,9 +69,14 @@ SIZE transition_state; POINT origin; COUNT radius; + BYTE race_id; + BYTE num_ships; + BYTE flags; + // See ENCOUNTER.flags above + POINT loc_pt; - STAR_DESC SD; BRIEF_SHIP_INFO ShipList[MAX_HYPER_SHIPS]; + // Only the crew_level member is currently used SDWORD log_x, log_y; }; Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/hyper.c 2011-08-25 23:33:17 UTC (rev 3670) @@ -225,13 +225,13 @@ encounter_flags = ONE_SHOT_ENCOUNTER; } - + // There can be only one! (of either Slylandro or Melnorme) for (hEncounter = GetHeadEncounter (); hEncounter; hEncounter = hNextEncounter) { LockEncounter (hEncounter, &EncounterPtr); hNextEncounter = GetSuccEncounter (EncounterPtr); - if (EncounterPtr->SD.Type == Type) + if (EncounterPtr->race_id == Type) { percent = 0; hNextEncounter = 0; @@ -266,8 +266,8 @@ memset (EncounterPtr, 0, sizeof (*EncounterPtr)); EncounterPtr->origin = FleetPtr->loc; EncounterPtr->radius = encounter_radius; - EncounterPtr->SD.Index = encounter_flags; - EncounterPtr->SD.Type = Type; + EncounterPtr->flags = encounter_flags; + EncounterPtr->race_id = Type; UnlockEncounter (hEncounter); PutEncounter (hEncounter); @@ -956,20 +956,20 @@ if (GET_GAME_STATE (ARILOU_SPACE_SIDE) >= 2) return 0; - if (EncounterPtr->SD.Index & ENCOUNTER_REFORMING) + if (EncounterPtr->flags & ENCOUNTER_REFORMING) { - EncounterPtr->SD.Index &= ~ENCOUNTER_REFORMING; + EncounterPtr->flags &= ~ENCOUNTER_REFORMING; EncounterPtr->transition_state = 100; - if ((EncounterPtr->SD.Index & ONE_SHOT_ENCOUNTER) - || LONIBBLE (EncounterPtr->SD.Index) == 0) + if ((EncounterPtr->flags & ONE_SHOT_ENCOUNTER) + || EncounterPtr->num_ships == 0) return 0; } - if (LONIBBLE (EncounterPtr->SD.Index)) + if (EncounterPtr->num_ships) { NewEncounter = FALSE; - enc_pt = EncounterPtr->SD.star_pt; + enc_pt = EncounterPtr->loc_pt; } else { @@ -987,7 +987,7 @@ radius_squared = (DWORD)EncounterPtr->radius * EncounterPtr->radius; - Type = EncounterPtr->SD.Type; + Type = EncounterPtr->race_id; NumShips = LONIBBLE (EncounterMakeup[Type]); for (i = HINIBBLE (EncounterMakeup[Type]) - NumShips; i; --i) { @@ -998,9 +998,7 @@ if (NumShips > MAX_HYPER_SHIPS) NumShips = MAX_HYPER_SHIPS; - - EncounterPtr->SD.Index = - MAKE_BYTE (NumShips, HINIBBLE (EncounterPtr->SD.Index)); + EncounterPtr->num_ships = NumShips; for (i = 0; i < NumShips; ++i) { BRIEF_SHIP_INFO *BSIPtr = &EncounterPtr->ShipList[i]; @@ -1038,7 +1036,7 @@ dy = enc_pt.y - EncounterPtr->origin.y; } while ((DWORD)((long)dx * dx + (long)dy * dy) > radius_squared); - EncounterPtr->SD.star_pt = enc_pt; + EncounterPtr->loc_pt = enc_pt; EncounterPtr->log_x = UNIVERSE_TO_LOGX (enc_pt.x); EncounterPtr->log_y = UNIVERSE_TO_LOGY (enc_pt.y); } @@ -1197,8 +1195,8 @@ cur_facing = ANGLE_TO_FACING ( GetVelocityTravelAngle (&ElementPtr->velocity)); delta_facing = NORMALIZE_FACING (cur_facing - ANGLE_TO_FACING ( - ARCTAN (puniverse->x - EncounterPtr->SD.star_pt.x, - puniverse->y - EncounterPtr->SD.star_pt.y))); + ARCTAN (puniverse->x - EncounterPtr->loc_pt.x, + puniverse->y - EncounterPtr->loc_pt.y))); if (delta_facing || (delta_x == 0 && delta_y == 0)) { SIZE speed; @@ -1208,7 +1206,7 @@ }; #define ENCOUNTER_TRACK_WAIT 3 - speed = RaceHyperSpeed[EncounterPtr->SD.Type]; + speed = RaceHyperSpeed[EncounterPtr->race_id]; if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) --cur_facing; else @@ -1233,14 +1231,14 @@ } EncounterPtr->log_x += delta_x; EncounterPtr->log_y -= delta_y; - EncounterPtr->SD.star_pt.x = LOGX_TO_UNIVERSE (EncounterPtr->log_x); - EncounterPtr->SD.star_pt.y = LOGY_TO_UNIVERSE (EncounterPtr->log_y); + EncounterPtr->loc_pt.x = LOGX_TO_UNIVERSE (EncounterPtr->log_x); + EncounterPtr->loc_pt.y = LOGY_TO_UNIVERSE (EncounterPtr->log_y); encounter_radius = EncounterPtr->radius + (GRID_OFFSET >> 1); - delta_x = EncounterPtr->SD.star_pt.x - EncounterPtr->origin.x; + delta_x = EncounterPtr->loc_pt.x - EncounterPtr->origin.x; if (delta_x < 0) delta_x = -delta_x; - delta_y = EncounterPtr->SD.star_pt.y - EncounterPtr->origin.y; + delta_y = EncounterPtr->loc_pt.y - EncounterPtr->origin.y; if (delta_y < 0) delta_y = -delta_y; if ((COUNT)delta_x >= encounter_radius @@ -1248,6 +1246,7 @@ || (DWORD)delta_x * delta_x + (DWORD)delta_y * delta_y >= (DWORD)encounter_radius * encounter_radius) { + // Encounter globe traveled outside the SoI and now disappears ElementPtr->state_flags |= NONSOLID; ElementPtr->life_span = 0; @@ -1266,8 +1265,8 @@ } } - ex = EncounterPtr->SD.star_pt.x; - ey = EncounterPtr->SD.star_pt.y; + ex = EncounterPtr->loc_pt.x; + ey = EncounterPtr->loc_pt.y; if (ex - puniverse->x >= -UNIT_SCREEN_WIDTH && ex - puniverse->x <= UNIT_SCREEN_WIDTH && ey - puniverse->y >= -UNIT_SCREEN_HEIGHT Modified: trunk/sc2/src/uqm/load.c =================================================================== --- trunk/sc2/src/uqm/load.c 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/load.c 2011-08-25 23:33:17 UTC (rev 3670) @@ -325,6 +325,7 @@ LoadEncounter (ENCOUNTER *EncounterPtr, DECODE_REF fh) { COUNT i; + BYTE tmpb; cread_ptr (fh); /* useless ptr; HENCOUNTER pred */ EncounterPtr->pred = 0; @@ -336,18 +337,19 @@ cread_16s (fh, &EncounterPtr->origin.x); cread_16s (fh, &EncounterPtr->origin.y); cread_16 (fh, &EncounterPtr->radius); - // STAR_DESC fields - cread_16s (fh, &EncounterPtr->SD.star_pt.x); - cread_16s (fh, &EncounterPtr->SD.star_pt.y); - cread_8 (fh, &EncounterPtr->SD.Type); - cread_8 (fh, &EncounterPtr->SD.Index); + // former STAR_DESC fields + cread_16s (fh, &EncounterPtr->loc_pt.x); + cread_16s (fh, &EncounterPtr->loc_pt.y); + cread_8 (fh, &EncounterPtr->race_id); + cread_8 (fh, &tmpb); + EncounterPtr->num_ships = tmpb & ENCOUNTER_SHIPS_MASK; + EncounterPtr->flags = tmpb & ENCOUNTER_FLAGS_MASK; cread_16 (fh, NULL); /* alignment padding */ // Load each entry in the BRIEF_SHIP_INFO array for (i = 0; i < MAX_HYPER_SHIPS; i++) { BRIEF_SHIP_INFO *ShipInfo = &EncounterPtr->ShipList[i]; - BYTE tmpb; cread_16 (fh, NULL); /* useless; was SHIP_INFO.ship_flags */ cread_8 (fh, &ShipInfo->race_id); Modified: trunk/sc2/src/uqm/planets/generate/genpet.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpet.c 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/planets/generate/genpet.c 2011-08-25 23:33:17 UTC (rev 3670) @@ -211,17 +211,18 @@ TemplatePtr = LockFleetInfo (&GLOBAL (avail_race_q), hStarShip); EncounterPtr->origin = TemplatePtr->loc; EncounterPtr->radius = TemplatePtr->actual_strength; - EncounterPtr->SD.Type = URQUAN_SHIP; - EncounterPtr->SD.Index = MAKE_BYTE (1, 0) | ONE_SHOT_ENCOUNTER; + EncounterPtr->race_id = URQUAN_SHIP; + EncounterPtr->num_ships = 1; + EncounterPtr->flags = ONE_SHOT_ENCOUNTER; BSIPtr = &EncounterPtr->ShipList[0]; BSIPtr->race_id = URQUAN_SHIP; BSIPtr->crew_level = TemplatePtr->crew_level; BSIPtr->max_crew = TemplatePtr->max_crew; BSIPtr->max_energy = TemplatePtr->max_energy; - EncounterPtr->SD.star_pt.x = 5288; - EncounterPtr->SD.star_pt.y = 4892; - EncounterPtr->log_x = UNIVERSE_TO_LOGX (EncounterPtr->SD.star_pt.x); - EncounterPtr->log_y = UNIVERSE_TO_LOGY (EncounterPtr->SD.star_pt.y); + EncounterPtr->loc_pt.x = 5288; + EncounterPtr->loc_pt.y = 4892; + EncounterPtr->log_x = UNIVERSE_TO_LOGX (EncounterPtr->loc_pt.x); + EncounterPtr->log_y = UNIVERSE_TO_LOGY (EncounterPtr->loc_pt.y); GLOBAL_SIS (log_x) = EncounterPtr->log_x; GLOBAL_SIS (log_y) = EncounterPtr->log_y; UnlockFleetInfo (&GLOBAL (avail_race_q), hStarShip); @@ -236,8 +237,8 @@ GLOBAL (CurrentActivity) = MAKE_WORD (IN_HYPERSPACE, 0) | START_ENCOUNTER; - dx = CurStarDescPtr->star_pt.x - EncounterPtr->SD.star_pt.x; - dy = CurStarDescPtr->star_pt.y - EncounterPtr->SD.star_pt.y; + dx = CurStarDescPtr->star_pt.x - EncounterPtr->loc_pt.x; + dy = CurStarDescPtr->star_pt.y - EncounterPtr->loc_pt.y; dx = (SIZE)square_root ((long)dx * dx + (long)dy * dy) + (FUEL_TANK_SCALE >> 1); @@ -250,7 +251,7 @@ DeltaSISGauges (0, dx, 0); } DrawSISMessage (NULL); - DrawHyperCoords (EncounterPtr->SD.star_pt); + DrawHyperCoords (EncounterPtr->loc_pt); UnlockMutex (GraphicsLock); UnlockEncounter (hEncounter); Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2011-08-25 21:34:10 UTC (rev 3669) +++ trunk/sc2/src/uqm/save.c 2011-08-25 23:33:17 UTC (rev 3670) @@ -276,11 +276,13 @@ cwrite_16 (fh, EncounterPtr->origin.x); cwrite_16 (fh, EncounterPtr->origin.y); cwrite_16 (fh, EncounterPtr->radius); - // STAR_DESC fields - cwrite_16 (fh, EncounterPtr->SD.star_pt.x); - cwrite_16 (fh, EncounterPtr->SD.star_pt.y); - cwrite_8 (fh, EncounterPtr->SD.Type); - cwrite_8 (fh, EncounterPtr->SD.Index); + // former STAR_DESC fields + cwrite_16 (fh, EncounterPtr->loc_pt.x); + cwrite_16 (fh, EncounterPtr->loc_pt.y); + cwrite_8 (fh, EncounterPtr->race_id); + // XXX: writing combined fields to maintain savegame compatibility + cwrite_8 (fh, (EncounterPtr->num_ships & ENCOUNTER_SHIPS_MASK) + | (EncounterPtr->flags & ENCOUNTER_FLAGS_MASK)); cwrite_16 (fh, 0); /* alignment padding */ // Save each entry in the BRIEF_SHIP_INFO array This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-25 21:34:16
|
Revision: 3669 http://sc2.svn.sourceforge.net/sc2/?rev=3669&view=rev Author: avolkov Date: 2011-08-25 21:34:10 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Cleanup: AllocHyperElement() only needs a POINT arg (in preparation for ENCOUNTER cleanup) Modified Paths: -------------- trunk/sc2/src/uqm/hyper.c Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2011-08-24 16:51:09 UTC (rev 3668) +++ trunk/sc2/src/uqm/hyper.c 2011-08-25 21:34:10 UTC (rev 3669) @@ -758,7 +758,7 @@ } static HELEMENT -AllocHyperElement (STAR_DESC *SDPtr) +AllocHyperElement (const POINT *elem_pt) { HELEMENT hHyperSpaceElement; @@ -776,11 +776,11 @@ { long lx, ly; - lx = UNIVERSE_TO_LOGX (SDPtr->star_pt.x) + lx = UNIVERSE_TO_LOGX (elem_pt->x) + (LOG_SPACE_WIDTH >> 1) - GLOBAL_SIS (log_x); HyperSpaceElementPtr->current.location.x = WRAP_X (lx); - ly = UNIVERSE_TO_LOGY (SDPtr->star_pt.y) + ly = UNIVERSE_TO_LOGY (elem_pt->y) + (LOG_SPACE_HEIGHT >> 1) - GLOBAL_SIS (log_y); HyperSpaceElementPtr->current.location.y = WRAP_Y (ly); } @@ -951,7 +951,7 @@ { BOOLEAN NewEncounter; HELEMENT hElement; - STAR_DESC SD; + POINT enc_pt; if (GET_GAME_STATE (ARILOU_SPACE_SIDE) >= 2) return 0; @@ -969,7 +969,7 @@ if (LONIBBLE (EncounterPtr->SD.Index)) { NewEncounter = FALSE; - SD.star_pt = EncounterPtr->SD.star_pt; + enc_pt = EncounterPtr->SD.star_pt; } else { @@ -1021,29 +1021,29 @@ rand_val = TFB_Random (); - SD.star_pt.x = puniverse->x + enc_pt.x = puniverse->x + (LOWORD (rand_val) % (XOFFS << 1)) - XOFFS; - if (SD.star_pt.x < 0) - SD.star_pt.x = 0; - else if (SD.star_pt.x > MAX_X_UNIVERSE) - SD.star_pt.x = MAX_X_UNIVERSE; - SD.star_pt.y = puniverse->y + if (enc_pt.x < 0) + enc_pt.x = 0; + else if (enc_pt.x > MAX_X_UNIVERSE) + enc_pt.x = MAX_X_UNIVERSE; + enc_pt.y = puniverse->y + (HIWORD (rand_val) % (YOFFS << 1)) - YOFFS; - if (SD.star_pt.y < 0) - SD.star_pt.y = 0; - else if (SD.star_pt.y > MAX_Y_UNIVERSE) - SD.star_pt.y = MAX_Y_UNIVERSE; + if (enc_pt.y < 0) + enc_pt.y = 0; + else if (enc_pt.y > MAX_Y_UNIVERSE) + enc_pt.y = MAX_Y_UNIVERSE; - dx = SD.star_pt.x - EncounterPtr->origin.x; - dy = SD.star_pt.y - EncounterPtr->origin.y; + dx = enc_pt.x - EncounterPtr->origin.x; + dy = enc_pt.y - EncounterPtr->origin.y; } while ((DWORD)((long)dx * dx + (long)dy * dy) > radius_squared); - EncounterPtr->SD.star_pt = SD.star_pt; - EncounterPtr->log_x = UNIVERSE_TO_LOGX (SD.star_pt.x); - EncounterPtr->log_y = UNIVERSE_TO_LOGY (SD.star_pt.y); + EncounterPtr->SD.star_pt = enc_pt; + EncounterPtr->log_x = UNIVERSE_TO_LOGX (enc_pt.x); + EncounterPtr->log_y = UNIVERSE_TO_LOGY (enc_pt.y); } - hElement = AllocHyperElement (&SD); + hElement = AllocHyperElement (&enc_pt); if (hElement) { SIZE i; @@ -1482,7 +1482,7 @@ || ey > (YOFFS / NUM_RADAR_SCREENS)) continue; - hHyperSpaceElement = AllocHyperElement (&SD[i]); + hHyperSpaceElement = AllocHyperElement (&SD[i].star_pt); if (hHyperSpaceElement == 0) continue; @@ -1527,7 +1527,7 @@ || ey > (YOFFS / NUM_RADAR_SCREENS)) continue; - hHyperSpaceElement = AllocHyperElement (SDPtr); + hHyperSpaceElement = AllocHyperElement (&SDPtr->star_pt); if (hHyperSpaceElement == 0) continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-24 16:51:15
|
Revision: 3668 http://sc2.svn.sourceforge.net/sc2/?rev=3668&view=rev Author: avolkov Date: 2011-08-24 16:51:09 +0000 (Wed, 24 Aug 2011) Log Message: ----------- Refactor planetary hazard code; bug #1140; from Scott A. Colcord Modified Paths: -------------- trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/lander.h Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2011-08-24 16:22:39 UTC (rev 3667) +++ trunk/sc2/src/uqm/planets/lander.c 2011-08-24 16:51:09 UTC (rev 3668) @@ -1857,40 +1857,65 @@ return crew_left > 0; } +// Maps a temperature to a (0-7) hazard rating. +// Thermal hazards aren't exposed to the user as a hazard number, +// but the code still works with them that way. +#define ARRAY_SIZE(array) (sizeof(array) / sizeof (*array)) +unsigned +GetThermalHazardRating (int temp) +{ + static const int tempBreakpoints[] = { 50, 100, 150, 250, 350, 550, 800 }; + const size_t numBreakpoints = ARRAY_SIZE (tempBreakpoints); + unsigned i; + + for (i = 0; i < numBreakpoints; ++i) + { + if (temp < tempBreakpoints[i]) + return i; + } + + return numBreakpoints; +} + +// Given a hazard type and rating, return the chance (out of 256) of the hazard +// being generated. +static BYTE +GetHazardChance (int hazardType, unsigned HazardRating) +{ + static const BYTE TectonicsChanceTab[] = {0*3, 0*3, 1*3, 2*3, 4*3, 8*3, 16*3, 32*3}; + static const BYTE WeatherChanceTab [] = {0*3, 0*3, 1*3, 2*3, 3*3, 6*3, 12*3, 24*3}; + static const BYTE FireChanceTab [] = {0*3, 0*3, 1*3, 2*3, 4*3, 12*3, 24*3, 48*3}; + + switch (hazardType) + { + case EARTHQUAKE_DISASTER: + return TectonicsChanceTab[HazardRating]; + case LIGHTNING_DISASTER: + return WeatherChanceTab[HazardRating]; + case LAVASPOT_DISASTER: + return FireChanceTab[HazardRating]; + } + + return 0; +} + void PlanetSide (POINT planetLoc) { SIZE index; LanderInputState landerInputState; PLANETSIDE_DESC PSD; - BYTE TectonicsChanceTab[] = {0*3, 0*3, 1*3, 2*3, 4*3, 8*3, 16*3, 32*3}; - BYTE WeatherChanceTab[] = {0*3, 0*3, 1*3, 2*3, 3*3, 6*3, 12*3, 24*3}; - BYTE FireChanceTab[] = {0*3, 0*3, 1*3, 2*3, 4*3, 12*3, 24*3, 48*3}; memset (&PSD, 0, sizeof (PSD)); PSD.InTransit = TRUE; - PSD.TectonicsChance = - TectonicsChanceTab[pSolarSysState->SysInfo.PlanetInfo.Tectonics]; - PSD.WeatherChance = - WeatherChanceTab[pSolarSysState->SysInfo.PlanetInfo.Weather]; - index = pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature; - if (index < 50) - PSD.FireChance = FireChanceTab[0]; - else if (index < 100) - PSD.FireChance = FireChanceTab[1]; - else if (index < 150) - PSD.FireChance = FireChanceTab[2]; - else if (index < 250) - PSD.FireChance = FireChanceTab[3]; - else if (index < 350) - PSD.FireChance = FireChanceTab[4]; - else if (index < 550) - PSD.FireChance = FireChanceTab[5]; - else if (index < 800) - PSD.FireChance = FireChanceTab[6]; - else - PSD.FireChance = FireChanceTab[7]; + // Set our chances of hazards occurring. + PSD.TectonicsChance = GetHazardChance (EARTHQUAKE_DISASTER, + pSolarSysState->SysInfo.PlanetInfo.Tectonics); + PSD.WeatherChance = GetHazardChance (LIGHTNING_DISASTER, + pSolarSysState->SysInfo.PlanetInfo.Weather); + PSD.FireChance = GetHazardChance (LAVASPOT_DISASTER, GetThermalHazardRating ( + pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature)); PSD.ElementLevel = GetStorageBayCapacity () - GLOBAL_SIS (TotalElementMass); PSD.MaxElementLevel = MAX_SCROUNGED; Modified: trunk/sc2/src/uqm/planets/lander.h =================================================================== --- trunk/sc2/src/uqm/planets/lander.h 2011-08-24 16:22:39 UTC (rev 3667) +++ trunk/sc2/src/uqm/planets/lander.h 2011-08-24 16:51:09 UTC (rev 3668) @@ -72,6 +72,8 @@ extern void SetLanderTakeoff (void); extern bool KillLanderCrewSeq (COUNT numKilled, DWORD period); +extern unsigned GetThermalHazardRating (int temp); + // ELEMENT.playerNr constants enum { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-24 16:22:46
|
Revision: 3667 http://sc2.svn.sourceforge.net/sc2/?rev=3667&view=rev Author: avolkov Date: 2011-08-24 16:22:39 +0000 (Wed, 24 Aug 2011) Log Message: ----------- Various warning cleanups from Scott A. Colcord, bug #50; reworked Umgah ship code so as not to compare FRAMEs Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/cleanup.c trunk/sc2/src/uqm/planets/Makeinfo trunk/sc2/src/uqm/planets/oval.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/setupmenu.c trunk/sc2/src/uqm/ships/androsyn/androsyn.c trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c trunk/sc2/src/uqm/ships/pkunk/pkunk.c trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c trunk/sc2/src/uqm/ships/umgah/umgah.c Added Paths: ----------- trunk/sc2/src/uqm/planets/solarsys.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/ChangeLog 2011-08-24 16:22:39 UTC (rev 3667) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Various warnings cleanup (bug #50), from Scott A. Colcord - Fixed various Pkunk reincarnation and Shofixti Glory device interactions; Pkunk ditty plays in a simultaneous destruction (bug #666) - Alex - Preparing for linking with C++ code, from Scott A. Colcord Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2011-08-24 16:22:39 UTC (rev 3667) @@ -2217,6 +2217,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\planets\solarsys.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\planets\sundata.h # End Source File # Begin Source File Modified: trunk/sc2/src/uqm/cleanup.c =================================================================== --- trunk/sc2/src/uqm/cleanup.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/cleanup.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -25,15 +25,12 @@ #include "planets/lander.h" #include "starcon.h" #include "setup.h" +#include "planets/solarsys.h" #include "sounds.h" #include "libs/sndlib.h" #include "libs/vidlib.h" -// XXX: we do not current have a header for this prototype to live in -// should be something like solarsys.h -extern void FreeIPData (void); - void FreeKernel (void) { Modified: trunk/sc2/src/uqm/planets/Makeinfo =================================================================== --- trunk/sc2/src/uqm/planets/Makeinfo 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/planets/Makeinfo 2011-08-24 16:22:39 UTC (rev 3667) @@ -3,5 +3,5 @@ oval.c pl_stuff.c planets.c plangen.c pstarmap.c report.c roster.c scan.c solarsys.c surface.c" uqm_HFILES="elemdata.h generate.h lander.h lifeform.h plandata.h planets.h - scan.h sundata.h" + scan.h solarsys.h sundata.h" Modified: trunk/sc2/src/uqm/planets/oval.c =================================================================== --- trunk/sc2/src/uqm/planets/oval.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/planets/oval.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -21,6 +21,7 @@ #include "libs/graphics/context.h" #include "libs/graphics/drawable.h" +#include "planets.h" #define NUM_QUADS 4 Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/planets/solarsys.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "solarsys.h" #include "lander.h" #include "../colors.h" #include "../controls.h" Added: trunk/sc2/src/uqm/planets/solarsys.h =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.h (rev 0) +++ trunk/sc2/src/uqm/planets/solarsys.h 2011-08-24 16:22:39 UTC (rev 3667) @@ -0,0 +1,34 @@ +//Copyright (C) 2011, Scott A. Colcord + +/* + * 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 SOLARSYS_H +#define SOLARSYS_H + +#if defined(__cplusplus) +extern "C" { +#endif + +extern void LoadIPData (void); +extern void FreeIPData (void); + +#if defined(__cplusplus) +} +#endif + +#endif /* SOLARSYS_H */ + Property changes on: trunk/sc2/src/uqm/planets/solarsys.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/races.h 2011-08-24 16:22:39 UTC (rev 3667) @@ -221,7 +221,7 @@ POSTPROCESS_FUNC *postprocess_func; INIT_WEAPON_FUNC *init_weapon_func; - intptr_t data; // private ship data, ship code owns this + void* data; // private ship data, ship code owns this void *CodeRef; }; Modified: trunk/sc2/src/uqm/setupmenu.c =================================================================== --- trunk/sc2/src/uqm/setupmenu.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/setupmenu.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -766,7 +766,7 @@ } static int -count_widgets (const WIDGET **widgets) +count_widgets (WIDGET **widgets) { int count; Modified: trunk/sc2/src/uqm/ships/androsyn/androsyn.c =================================================================== --- trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -110,6 +110,46 @@ 0, /* CodeRef */ }; + +// Private per-instance ship data +typedef struct +{ + ElementCollisionFunc* collision_func; +} ANDROSYNTH_DATA; + +// Local typedef +typedef ANDROSYNTH_DATA CustomShipData_t; + +// Retrieve race-specific ship data from a race desc +static CustomShipData_t * +GetCustomShipData (RACE_DESC *pRaceDesc) +{ + return pRaceDesc->data; +} + +// Set the race-specific data in a race desc +// (Re)Allocates its own storage for the data. +static void +SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data) +{ + if (pRaceDesc->data == data) + return; // no-op + + if (pRaceDesc->data) // Out with the old + { + HFree (pRaceDesc->data); + pRaceDesc->data = NULL; + } + + if (data) // In with the new + { + CustomShipData_t* newData = HMalloc (sizeof (*data)); + *newData = *data; + pRaceDesc->data = newData; + } +} + + #define BLAZER_DAMAGE 3 #define BLAZER_MASS 1 @@ -355,11 +395,14 @@ ElementPtr->mass_points = BLAZER_MASS; StarShipPtr->RaceDescPtr->characteristics.turn_wait = BLAZER_TURN_WAIT; + /* Save the current collision func because we were not the * ones who set it */ - StarShipPtr->RaceDescPtr->data = (intptr_t) - ElementPtr->collision_func; - ElementPtr->collision_func = blazer_collision; + { + const ANDROSYNTH_DATA shipData = { ElementPtr->collision_func }; + SetCustomShipData (StarShipPtr->RaceDescPtr, &shipData); + ElementPtr->collision_func = blazer_collision; + } } } @@ -426,8 +469,8 @@ StarShipPtr->RaceDescPtr->characteristics.special_wait; StarShipPtr->RaceDescPtr->characteristics.energy_regeneration = ENERGY_REGENERATION; ElementPtr->mass_points = SHIP_MASS; - ElementPtr->collision_func = (ElementCollisionFunc *) - StarShipPtr->RaceDescPtr->data; + ElementPtr->collision_func = + GetCustomShipData (StarShipPtr->RaceDescPtr)->collision_func; ElementPtr->next.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; ElementPtr->next.image.frame = @@ -463,11 +506,19 @@ StarShipPtr->cur_status_flags = cur_status_flags; } +static void +uninit_androsynth (RACE_DESC *pRaceDesc) +{ + SetCustomShipData (pRaceDesc, NULL); +} + + RACE_DESC* init_androsynth (void) { RACE_DESC *RaceDescPtr; + androsynth_desc.uninit_func = uninit_androsynth; androsynth_desc.preprocess_func = androsynth_preprocess; androsynth_desc.postprocess_func = androsynth_postprocess; androsynth_desc.init_weapon_func = initialize_bubble; Modified: trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c =================================================================== --- trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -124,7 +124,42 @@ #define MISSILE_SPEED DISPLAY_TO_WORLD (20) #define TRACK_WAIT 5 +// Private per-instance ship data +typedef CHARACTERISTIC_STUFF MMRNMHRM_DATA; + +// Local typedef +typedef MMRNMHRM_DATA CustomShipData_t; + +// Retrieve race-specific ship data from a race desc +static CustomShipData_t * +GetCustomShipData (RACE_DESC *pRaceDesc) +{ + return pRaceDesc->data; +} + +// Set the race-specific data in a race desc +// (Re)Allocates its own storage for the data. static void +SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data) +{ + if (pRaceDesc->data == data) + return; // no-op + + if (pRaceDesc->data) // Out with the old + { + HFree (pRaceDesc->data); + pRaceDesc->data = NULL; + } + + if (data) // In with the new + { + CustomShipData_t* newData = HMalloc (sizeof (*data)); + *newData = *data; + pRaceDesc->data = newData; + } +} + +static void missile_preprocess (ELEMENT *ElementPtr) { if (ElementPtr->turn_wait > 0) @@ -363,8 +398,8 @@ /* take care of transform effect */ if (ElementPtr->next.image.farray != ElementPtr->current.image.farray) { - CHARACTERISTIC_STUFF t; - CHARACTERISTIC_STUFF *otherwing_desc; + MMRNMHRM_DATA tempShipData; + MMRNMHRM_DATA *otherwing_desc; ProcessSound (SetAbsSoundIndex ( /* TRANSFORM */ @@ -373,11 +408,13 @@ StarShipPtr->weapon_counter = 0; /* Swap characteristics descriptors around */ - otherwing_desc = (CHARACTERISTIC_STUFF *) - StarShipPtr->RaceDescPtr->data; - t = *otherwing_desc; - *otherwing_desc = StarShipPtr->RaceDescPtr->characteristics; - StarShipPtr->RaceDescPtr->characteristics = t; + otherwing_desc = GetCustomShipData (StarShipPtr->RaceDescPtr); + if (!otherwing_desc) + return; // No ship data (?!) + + tempShipData = *otherwing_desc; + SetCustomShipData (StarShipPtr->RaceDescPtr, &StarShipPtr->RaceDescPtr->characteristics); + StarShipPtr->RaceDescPtr->characteristics = tempShipData; StarShipPtr->RaceDescPtr->cyborg_control.ManeuverabilityIndex = 0; if (ElementPtr->next.image.farray == StarShipPtr->RaceDescPtr->ship_data.special) @@ -444,8 +481,7 @@ static void uninit_mmrnmhrm (RACE_DESC *pRaceDesc) { - HFree ((void *)pRaceDesc->data); - pRaceDesc->data = 0; + SetCustomShipData (pRaceDesc, NULL); } RACE_DESC* @@ -454,7 +490,7 @@ RACE_DESC *RaceDescPtr; // The caller of this func will copy the struct static RACE_DESC new_mmrnmhrm_desc; - CHARACTERISTIC_STUFF *otherwing_desc; + MMRNMHRM_DATA otherwing_desc; mmrnmhrm_desc.uninit_func = uninit_mmrnmhrm; mmrnmhrm_desc.preprocess_func = mmrnmhrm_preprocess; @@ -464,20 +500,19 @@ new_mmrnmhrm_desc = mmrnmhrm_desc; - otherwing_desc = HMalloc (sizeof (*otherwing_desc)); - otherwing_desc->max_thrust = YWING_MAX_THRUST; - otherwing_desc->thrust_increment = YWING_THRUST_INCREMENT; - otherwing_desc->energy_regeneration = YWING_ENERGY_REGENERATION; - otherwing_desc->weapon_energy_cost = YWING_WEAPON_ENERGY_COST; - otherwing_desc->special_energy_cost = YWING_SPECIAL_ENERGY_COST; - otherwing_desc->energy_wait = YWING_ENERGY_WAIT; - otherwing_desc->turn_wait = YWING_TURN_WAIT; - otherwing_desc->thrust_wait = YWING_THRUST_WAIT; - otherwing_desc->weapon_wait = YWING_WEAPON_WAIT; - otherwing_desc->special_wait = YWING_SPECIAL_WAIT; - otherwing_desc->ship_mass = SHIP_MASS; + otherwing_desc.max_thrust = YWING_MAX_THRUST; + otherwing_desc.thrust_increment = YWING_THRUST_INCREMENT; + otherwing_desc.energy_regeneration = YWING_ENERGY_REGENERATION; + otherwing_desc.weapon_energy_cost = YWING_WEAPON_ENERGY_COST; + otherwing_desc.special_energy_cost = YWING_SPECIAL_ENERGY_COST; + otherwing_desc.energy_wait = YWING_ENERGY_WAIT; + otherwing_desc.turn_wait = YWING_TURN_WAIT; + otherwing_desc.thrust_wait = YWING_THRUST_WAIT; + otherwing_desc.weapon_wait = YWING_WEAPON_WAIT; + otherwing_desc.special_wait = YWING_SPECIAL_WAIT; + otherwing_desc.ship_mass = SHIP_MASS; - new_mmrnmhrm_desc.data = (intptr_t) otherwing_desc; + SetCustomShipData (&new_mmrnmhrm_desc, &otherwing_desc); RaceDescPtr = &new_mmrnmhrm_desc; Modified: trunk/sc2/src/uqm/ships/pkunk/pkunk.c =================================================================== --- trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -123,7 +123,39 @@ } PKUNK_DATA; +// Local typedef +typedef PKUNK_DATA CustomShipData_t; + +// Retrieve race-specific ship data from a race desc +static CustomShipData_t * +GetCustomShipData (RACE_DESC *pRaceDesc) +{ + return pRaceDesc->data; +} + +// Set the race-specific data in a race desc +// (Re)Allocates its own storage for the data. static void +SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data) +{ + if (pRaceDesc->data == data) + return; // no-op + + if (pRaceDesc->data) // Out with the old + { + HFree (pRaceDesc->data); + pRaceDesc->data = NULL; + } + + if (data) // In with the new + { + CustomShipData_t* newData = HMalloc (sizeof (*data)); + *newData = *data; + pRaceDesc->data = newData; + } +} + +static void animate (ELEMENT *ElementPtr) { if (ElementPtr->turn_wait > 0) @@ -200,7 +232,7 @@ PKUNK_DATA *PkunkData; GetElementStarShip (ShipPtr, &StarShipPtr); - PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr); if (PkunkData->hPhoenix && (StarShipPtr->control & STANDARD_RATING)) { RemoveElement (PkunkData->hPhoenix); @@ -227,7 +259,7 @@ PKUNK_DATA *PkunkData; GetElementStarShip (ElementPtr, &StarShipPtr); - PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr); ElementPtr->state_flags = APPEARING | PLAYER_SHIP | IGNORE_SIMILAR; ElementPtr->mass_points = SHIP_MASS; @@ -301,7 +333,7 @@ ELEMENT *ShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); - PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr); if (StarShipPtr->RaceDescPtr->ship_info.crew_level != 0) { // Ship not dead yet. @@ -447,7 +479,7 @@ PKUNK_DATA *PkunkData; GetElementStarShip (ElementPtr, &StarShipPtr); - PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr); if (ElementPtr->state_flags & APPEARING) { HELEMENT hPhoenix = 0; @@ -572,8 +604,7 @@ static void uninit_pkunk (RACE_DESC *pRaceDesc) { - HFree ((void *)pRaceDesc->data); - pRaceDesc->data = 0; + SetCustomShipData (pRaceDesc, NULL); } RACE_DESC* @@ -582,6 +613,8 @@ RACE_DESC *RaceDescPtr; // The caller of this func will copy the struct static RACE_DESC new_pkunk_desc; + PKUNK_DATA empty_data; + memset (&empty_data, 0, sizeof (empty_data)); pkunk_desc.uninit_func = uninit_pkunk; pkunk_desc.preprocess_func = pkunk_preprocess; @@ -591,7 +624,7 @@ /* copy initial ship settings to the new descriptor */ new_pkunk_desc = pkunk_desc; - new_pkunk_desc.data = (intptr_t) HCalloc (sizeof (PKUNK_DATA)); + SetCustomShipData (&new_pkunk_desc, &empty_data); RaceDescPtr = &new_pkunk_desc; Modified: trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c =================================================================== --- trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -136,10 +136,42 @@ const BYTE *DriveSlots); static void InitJetSlots (RACE_DESC *RaceDescPtr, const BYTE *JetSlots); -void uninit_sis (RACE_DESC *pRaceDesc); +static void uninit_sis (RACE_DESC *pRaceDesc); +// Local typedef +typedef SIS_DATA CustomShipData_t; + +// Retrieve race-specific ship data from a race desc +static CustomShipData_t * +GetCustomShipData (RACE_DESC *pRaceDesc) +{ + return pRaceDesc->data; +} + +// Set the race-specific data in a race desc +// (Re)Allocates its own storage for the data. static void +SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data) +{ + if (pRaceDesc->data == data) + return; // no-op + + if (pRaceDesc->data) // Out with the old + { + HFree (pRaceDesc->data); + pRaceDesc->data = NULL; + } + + if (data) // In with the new + { + CustomShipData_t* newData = HMalloc (sizeof (*data)); + *newData = *data; + pRaceDesc->data = newData; + } +} + +static void sis_hyper_preprocess (ELEMENT *ElementPtr) { SIZE udx = 0, udy = 0; @@ -566,7 +598,7 @@ SIS_DATA *SisData; GetElementStarShip (ShipPtr, &StarShipPtr); - SisData = (SIS_DATA *) StarShipPtr->RaceDescPtr->data; + SisData = GetCustomShipData (StarShipPtr->RaceDescPtr); nt = (BYTE)((4 - SisData->num_trackers) & 3); @@ -606,7 +638,7 @@ SIS_DATA *SisData; GetElementStarShip (ShipPtr, &StarShipPtr); - SisData = (SIS_DATA *) StarShipPtr->RaceDescPtr->data; + SisData = GetCustomShipData (StarShipPtr->RaceDescPtr); lpEvalDesc = &ObjectsOfConcern[ENEMY_WEAPON_INDEX]; if (lpEvalDesc->ObjectPtr) @@ -680,7 +712,7 @@ #define BLASTER_HITS 2 #define BLASTER_OFFSET 8 COUNT i; - SIS_DATA *SisData = (SIS_DATA *) RaceDescPtr->data; + SIS_DATA *SisData = GetCustomShipData (RaceDescPtr); MISSILE_BLOCK *lpMB = SisData->MissileBlock; SisData->num_blasters = 0; @@ -760,7 +792,7 @@ { COUNT i; COUNT num_trackers; - SIS_DATA *SisData = (SIS_DATA *) RaceDescPtr->data; + SIS_DATA *SisData = GetCustomShipData (RaceDescPtr); RaceDescPtr->ship_info.max_crew = 0; num_trackers = 0; @@ -851,6 +883,8 @@ COUNT i; // The caller of this func will copy the struct static RACE_DESC new_sis_desc; + SIS_DATA empty_data; + memset (&empty_data, 0, sizeof (empty_data)); /* copy initial ship settings to new_sis_desc */ new_sis_desc = sis_desc; @@ -888,7 +922,7 @@ SET_GAME_STATE (BOMB_CARRIER, 1); } - new_sis_desc.data = (intptr_t) HCalloc (sizeof (SIS_DATA)); + SetCustomShipData (&new_sis_desc, &empty_data); InitModuleSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots)); InitWeaponSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots)); InitDriveSlots (&new_sis_desc, GLOBAL_SIS (DriveSlots)); @@ -913,7 +947,7 @@ return (RaceDescPtr); } -void +static void uninit_sis (RACE_DESC *pRaceDesc) { if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE) @@ -923,8 +957,7 @@ GLOBAL_SIS (CrewEnlisted)--; } - HFree ((void *)pRaceDesc->data); - pRaceDesc->data = 0; + SetCustomShipData (pRaceDesc, NULL); } Modified: trunk/sc2/src/uqm/ships/umgah/umgah.c =================================================================== --- trunk/sc2/src/uqm/ships/umgah/umgah.c 2011-08-08 15:56:23 UTC (rev 3666) +++ trunk/sc2/src/uqm/ships/umgah/umgah.c 2011-08-24 16:22:39 UTC (rev 3667) @@ -110,7 +110,47 @@ 0, /* CodeRef */ }; + +// Private per-instance ship data +typedef struct +{ + UWORD prevFacing; +} UMGAH_DATA; + +// Local typedef +typedef UMGAH_DATA CustomShipData_t; + +// Retrieve race-specific ship data from a race desc +static CustomShipData_t * +GetCustomShipData (RACE_DESC *pRaceDesc) +{ + return pRaceDesc->data; +} + +// Set the race-specific data in a race desc +// (Re)Allocates its own storage for the data. static void +SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data) +{ + if (pRaceDesc->data == data) + return; // no-op + + if (pRaceDesc->data) // Out with the old + { + HFree (pRaceDesc->data); + pRaceDesc->data = NULL; + } + + if (data) // In with the new + { + CustomShipData_t* newData = HMalloc (sizeof (*data)); + *newData = *data; + pRaceDesc->data = newData; + } +} + + +static void cone_preprocess (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; @@ -266,6 +306,7 @@ #define MISSILE_LIFE 1 #define MISSILE_OFFSET 0 STARSHIP *StarShipPtr; + UMGAH_DATA* UmgahData; MISSILE_BLOCK MissileBlock; GetElementStarShip (ShipPtr, &StarShipPtr); @@ -285,15 +326,17 @@ // This func is called every frame while the player is holding down WEAPON // Don't reset the cone FRAME to the first image every time - if (ShipPtr->next.image.frame != (FRAME) StarShipPtr->RaceDescPtr->data) + UmgahData = GetCustomShipData (StarShipPtr->RaceDescPtr); + if (!UmgahData || StarShipPtr->ShipFacing != UmgahData->prevFacing) { - StarShipPtr->RaceDescPtr->data = (intptr_t) ShipPtr->next.image.frame; + const UMGAH_DATA shipData = {StarShipPtr->ShipFacing}; + SetCustomShipData (StarShipPtr->RaceDescPtr, &shipData); + StarShipPtr->RaceDescPtr->ship_data.special[0] = SetAbsFrameIndex ( StarShipPtr->RaceDescPtr->ship_data.special[0], - StarShipPtr->ShipFacing - ); + StarShipPtr->ShipFacing); } MissileBlock.index = GetFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0]); @@ -341,7 +384,7 @@ if (ElementPtr->state_flags & APPEARING) { // Reset the value just in case - StarShipPtr->RaceDescPtr->data = 0; + SetCustomShipData (StarShipPtr->RaceDescPtr, NULL); } else { @@ -366,11 +409,18 @@ } } +static void +uninit_umgah (RACE_DESC *pRaceDesc) +{ + SetCustomShipData (pRaceDesc, NULL); +} + RACE_DESC* init_umgah (void) { RACE_DESC *RaceDescPtr; + umgah_desc.uninit_func = uninit_umgah; umgah_desc.preprocess_func = umgah_preprocess; umgah_desc.postprocess_func = umgah_postprocess; umgah_desc.init_weapon_func = initialize_cone; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-08 15:56:29
|
Revision: 3666 http://sc2.svn.sourceforge.net/sc2/?rev=3666&view=rev Author: avolkov Date: 2011-08-08 15:56:23 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Compiling with no joystick warning fixes (bug #50); SDLKey signedness warning fixes and hardening Modified Paths: -------------- trunk/sc2/src/libs/input/sdl/input.c Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2011-08-03 20:27:14 UTC (rev 3665) +++ trunk/sc2/src/libs/input/sdl/input.c 2011-08-08 15:56:23 UTC (rev 3666) @@ -33,7 +33,7 @@ static int kbdhead=0, kbdtail=0; static UniChar kbdbuf[KBDBUFSIZE]; static UniChar lastchar; -static unsigned int num_keys = 0; +static int num_keys = 0; static int *kbdstate = NULL; // Holds all SDL keys +1 for holding invalid values @@ -213,20 +213,13 @@ num_flight = num_flight_; } -int -TFB_InitInput (int driver, int flags) +#ifdef HAVE_JOYSTICK + +static void +initJoystick (void) { - int i; int nJoysticks; - (void)driver; - (void)flags; - SDL_EnableUNICODE(1); - (void)SDL_GetKeyState (&num_keys); - kbdstate = (int *)HMalloc (sizeof (int) * (num_keys + 1)); - - -#ifdef HAVE_JOYSTICK if ((SDL_InitSubSystem(SDL_INIT_JOYSTICK)) == -1) { log_add (log_Fatal, "Couldn't initialize joystick subsystem: %s", @@ -239,6 +232,8 @@ nJoysticks = SDL_NumJoysticks (); if (nJoysticks > 0) { + int i; + log_add (log_Info, "The names of the joysticks are:"); for (i = 0; i < nJoysticks; i++) { @@ -246,8 +241,25 @@ } SDL_JoystickEventState (SDL_ENABLE); } +} + #endif /* HAVE_JOYSTICK */ +int +TFB_InitInput (int driver, int flags) +{ + (void)driver; + (void)flags; + + SDL_EnableUNICODE(1); + (void)SDL_GetKeyState (&num_keys); + kbdstate = (int *)HMalloc (sizeof (int) * (num_keys + 1)); + + +#ifdef HAVE_JOYSTICK + initJoystick (); +#endif /* HAVE_JOYSTICK */ + in_character_mode = FALSE; resetKeyboardState (); @@ -350,10 +362,12 @@ if (Event->type == SDL_KEYDOWN || Event->type == SDL_KEYUP) { // process character input event, if any - SDLKey k = Event->key.keysym.sym; + // keysym.sym is an SDLKey type which is an enum and can be signed + // or unsigned on different platforms; we'll use a guaranteed type + int k = Event->key.keysym.sym; UniChar map_key = Event->key.keysym.unicode; - if (k > num_keys) + if (k < 0 || k > num_keys) k = num_keys; // for unknown keys if (Event->type == SDL_KEYDOWN) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-08-03 20:27:20
|
Revision: 3665 http://sc2.svn.sourceforge.net/sc2/?rev=3665&view=rev Author: avolkov Date: 2011-08-03 20:27:14 +0000 (Wed, 03 Aug 2011) Log Message: ----------- Tools: map generator maintenance; added SVG output driver (from Jan L?\195?\182nnberg, bug #1100); attempt to load fonts with various filename capitalization Modified Paths: -------------- trunk/tools/map/Makefile trunk/tools/map/mapgen.c trunk/tools/map/mapgen.dsp trunk/tools/map/port.c trunk/tools/map/port.h trunk/tools/map/sdlpngdrv.c Added Paths: ----------- trunk/tools/map/sdlsvgdrv.c Modified: trunk/tools/map/Makefile =================================================================== --- trunk/tools/map/Makefile 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/Makefile 2011-08-03 20:27:14 UTC (rev 3665) @@ -3,22 +3,27 @@ # # You may need to compile or install libpng and/or zlib before # compiling this. +# When building on Cygwin, do not use Cygwin-supplied libpng. # TARGET = mapgen # These flags are needed to get it to compile with libpngX.dll on CYGWIN #CYGWINFLAGS = -DPNG_USE_DLL -CYGWINFLAGS = -PNGFLAGS = -I. +PNGFLAGS = -I/usr/include/libpng12 SDLFLAGS = $(shell sdl-config --cflags) CC = gcc CFLAGS += -W -Wall -O0 # -g -LIBS = -L/usr/local/lib -lpng -lm -lSDL_ttf -lSDL_image +LIBS = -L/usr/local/lib -lpng12 -lSDL_ttf -lSDL_image LDFLAGS += $(shell sdl-config --libs) +# This is needed for Cygwin; -L. so that we can link with private libpng +#LDFLAGS += -mconsole -L. BINS = $(TARGET) $(TARGET).exe -OBJS = mapgen.o alist.o scriptlib.o stringbank.o unicode.o sdlpngdrv.o SDL_gfxPrimitives.o port.o +OBJS = mapgen.o alist.o scriptlib.o stringbank.o unicode.o port.o +OBJS += SDL_gfxPrimitives.o +OBJS += sdlpngdrv.o +OBJS += sdlsvgdrv.o .SUFFIXES: .c .o @@ -28,7 +33,7 @@ all: $(TARGET) $(TARGET): $(OBJS) - $(CC) -o $(TARGET) $(OBJS) $(LIBS) $(LDFLAGS) + $(CC) -o $(TARGET) $(OBJS) $(LDFLAGS) $(LIBS) clean: rm -f $(BINS) *.o Modified: trunk/tools/map/mapgen.c =================================================================== --- trunk/tools/map/mapgen.c 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/mapgen.c 2011-08-03 20:27:14 UTC (rev 3665) @@ -30,10 +30,12 @@ #endif extern const mg_driver_t sdlpng_drv; +extern const mg_driver_t sdlsvg_drv; static const mg_driver_t* drvs[] = { &sdlpng_drv, + &sdlsvg_drv, 0 /* term */ }; static const mg_driver_t* drv; @@ -355,7 +357,7 @@ static void parseArguments(int argc, char *argv[], options_t *opts) { - char ch; + int ch; opterr = 0; memset(opts, 0, sizeof (options_t)); @@ -395,6 +397,7 @@ ; } } + // TODO: this does not work with all versions of getopt() optind = 1; // let the driver handle the rest } Modified: trunk/tools/map/mapgen.dsp =================================================================== --- trunk/tools/map/mapgen.dsp 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/mapgen.dsp 2011-08-03 20:27:14 UTC (rev 3665) @@ -25,7 +25,7 @@ # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=xicl6.exe +CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "mapgen - Win32 Release" @@ -42,13 +42,13 @@ # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\src\getopt" /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\sc2\src\getopt" /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=xilink6.exe +LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib libpng.lib SDLmain.lib SDL.lib SDL_image.lib SDL_ttf.lib /nologo /subsystem:console /machine:I386 @@ -66,13 +66,13 @@ # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\..\src\getopt" /I "." /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /YX /FD /GZ /c +# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\..\sc2\src\getopt" /I "." /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=xilink6.exe +LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib libpng.lib SDLmain.lib SDL.lib SDL_image.lib SDL_ttf.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept @@ -99,11 +99,11 @@ # End Source File # Begin Source File -SOURCE=..\..\src\getopt\getopt.c +SOURCE=..\..\sc2\src\getopt\getopt.c # End Source File # Begin Source File -SOURCE=..\..\src\getopt\getopt.h +SOURCE=..\..\sc2\src\getopt\getopt.h # End Source File # Begin Source File @@ -143,6 +143,10 @@ # End Source File # Begin Source File +SOURCE=.\sdlsvgdrv.c +# End Source File +# Begin Source File + SOURCE=.\stringbank.c # End Source File # Begin Source File Modified: trunk/tools/map/port.c =================================================================== --- trunk/tools/map/port.c 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/port.c 2011-08-03 20:27:14 UTC (rev 3665) @@ -20,3 +20,25 @@ #endif +#ifdef _MSC_VER +// MSVC does not have snprintf() and vsnprintf(). It does have a _snprintf() +// and _vsnprintf(), but these do not terminate a truncated string as +// the C standard prescribes. +#include <stdio.h> +#include <stdarg.h> + +int +snprintf(char *str, size_t size, const char *format, ...) +{ + int result; + va_list args; + + va_start (args, format); + result = _vsnprintf (str, size, format, args); + if (str != NULL && size != 0) + str[size - 1] = '\0'; + va_end (args); + + return result; +} +#endif /* _MSC_VER */ Modified: trunk/tools/map/port.h =================================================================== --- trunk/tools/map/port.h 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/port.h 2011-08-03 20:27:14 UTC (rev 3665) @@ -26,5 +26,10 @@ # define strcasecmp stricmp #endif +#ifdef _MSC_VER +// Defined in port.c +int snprintf(char *str, size_t size, const char *format, ...); +#endif /* _MSC_VER */ + #endif /* _PORT_H */ Modified: trunk/tools/map/sdlpngdrv.c =================================================================== --- trunk/tools/map/sdlpngdrv.c 2011-07-26 20:30:58 UTC (rev 3664) +++ trunk/tools/map/sdlpngdrv.c 2011-08-03 20:27:14 UTC (rev 3665) @@ -126,21 +126,6 @@ static FILE* fout; static int dpix, dpiy; -static char* strcopy(const char* str) -{ - int l; - char* s; - - if (!str) - return 0; - l = strlen(str); - s = malloc(l + 1); - if (!s) - return 0; - memcpy(s, str, l + 1); - return s; -} - static int drv_init(int argc, char *argv[]) { int ret; @@ -197,7 +182,7 @@ static int parseArguments(int argc, char* argv[]) { - char ch; + int ch; while (-1 != (ch = getopt(argc, argv, "-f:no:"))) { @@ -401,9 +386,42 @@ return EXIT_SUCCESS; } +static TTF_Font* openFont(const char* filename, int size) +{ + char buf[512]; + char namebuf[128]; + TTF_Font* font; + + strncpy(namebuf, filename, sizeof(namebuf)); + namebuf[sizeof(namebuf) - 1] = '\0'; + + // first try the proper case filename + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + // then try the lowercase filename + strlwr(namebuf); + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + // last try the uppercase filename + strupr(namebuf); + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + mg_verbose(2, "TTF_OpenFont(): %s\n", TTF_GetError()); + + return 0; +} + static mg_font_t drv_loadFont(const char* name, double size, const char* filename) { - char buf[512]; struct mg_font* fnt; if (!filename) @@ -416,9 +434,8 @@ if (!fnt) return 0; fnt->size = inchToPixelsY(size); - fnt->name = strcopy(name ? name : "<Unknown>"); - sprintf(buf, "%s/%s", fontdir, filename); - fnt->font = TTF_OpenFont(buf, fnt->size); + fnt->name = strdup(name ? name : "<Unknown>"); + fnt->font = openFont(filename, fnt->size); if (!fnt->font) { free(fnt); Added: trunk/tools/map/sdlsvgdrv.c =================================================================== --- trunk/tools/map/sdlsvgdrv.c (rev 0) +++ trunk/tools/map/sdlsvgdrv.c 2011-08-03 20:27:14 UTC (rev 3665) @@ -0,0 +1,499 @@ +/* + * UQM Starmap image generator + * SDL/SVG driver implementation + * + * Uses: SDL, SDL_ttf + * + * + * The GPL applies + * + */ + +#include "mapdrv.h" +#include <stdio.h> +#include <malloc.h> +#include <string.h> +#include <errno.h> +#include "SDL_image.h" +#include "SDL.h" +#include "SDL_ttf.h" + +static double width, height; + +struct mg_font +{ + char* name; + TTF_Font* font; + double size; +}; + +struct mg_image +{ + SDL_Surface* img; + char *filename; + double width; + double height; +}; + +static int drv_init(int argc, char *argv[]); +static int drv_term(void); +static void drv_usage(void); +static int drv_begin(double w, double h); +static int drv_write(void); +static int drv_end(void); +static mg_font_t drv_loadFont(const char* name, double size, const char*); +static void drv_freeFont(mg_font_t); +static mg_image_t drv_loadImage(const char*); +static void drv_freeImage(mg_image_t); +static int drv_getImageSize(mg_image_t, mg_rectf_t*); +static int drv_setResolution(int dpi_x, int dpi_y); +static void drv_setClipRect(const mg_rectf_t*); +static void drv_drawPixel(double x, double y, mg_color_t, double weight); +static void drv_drawLine(double x0, double y0, double x1, double y1, mg_color_t, double weight); +static void drv_drawRect(const mg_rectf_t*, mg_color_t color, double weight); +static void drv_drawFilledRect(const mg_rectf_t*, mg_color_t color); +static void drv_drawEllipse(double xc, double yc, double xr, double yr, mg_color_t, double weight); +static void drv_drawFilledEllipse(double xc, double yc, double xr, double yr, mg_color_t); +static void drv_drawImage(double x, double y, mg_image_t); +static void drv_drawText(mg_font_t, double x, double y, const unsigned char* utf8str, mg_color_t); +static void drv_getTextSize(mg_font_t, const unsigned char* utf8str, mg_rectf_t*); + +const mg_driver_t sdlsvg_drv = +{ + "sdlsvg", // name + "SDL/SVG image writer", // description + + // func ptrs + drv_init, + drv_term, + drv_usage, + drv_setResolution, + drv_begin, + drv_write, + drv_end, + drv_loadFont, + drv_freeFont, + drv_loadImage, + drv_freeImage, + drv_getImageSize, + + // draw func ptrs + drv_setClipRect, + drv_drawPixel, + drv_drawLine, + drv_drawRect, + drv_drawFilledRect, + drv_drawEllipse, + drv_drawFilledEllipse, + drv_drawImage, + drv_drawText, + drv_getTextSize, + +}; + +static int parseArguments(int argc, char* argv[]); + +static const char* fontdir = "."; +static const char* outdev = "starmap.svg"; +static FILE* fout; +static int dpix, dpiy; + +static inline int inchToPixelsY(double inch) +{ + int v = (int)(inch * dpiy); + // make sure it's at least 1 pixel wide if present + if (!v && inch) + v = 1; + return v; +} + +static char colbuffer[8]; + +static char *color_string(mg_color_t color) +{ + snprintf(colbuffer, 8, "#%2.2x%2.2x%2.2x", color.r, color.g, color.b); + return colbuffer; +} + +static char alphabuffer[6]; + +static char *alpha_string(mg_color_t color) +{ + snprintf(alphabuffer, 6, "%1.3f", color.a/255.0); + return alphabuffer; +} + +static int drv_init(int argc, char *argv[]) +{ + int ret; + ret = parseArguments(argc, argv); + if (ret) + return ret; + + if (SDL_Init(SDL_INIT_NOPARACHUTE)) + { + mg_verbose(1, "Cannot init SDL\n"); + return EXIT_FAILURE; + } + + if (TTF_Init()) + { + mg_verbose(1, "Cannot init SDL_ttf\n"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +static int drv_term(void) +{ + if (fout) + fclose(fout); + fout = 0; + + TTF_Quit(); + SDL_Quit(); + + return EXIT_SUCCESS; +} + +static void drv_usage(void) +{ + mg_verbose(0, + "sdlsvg driver : [-f <fontdir>] [-o <outfile>]\n" + "Options:\n" + "\t-f dir where font files are located\n" + "\t-o save image as <outfile> (default is 'starmap.svg')\n" + ); +} + +static int parseArguments(int argc, char* argv[]) +{ + int ch; + + while (-1 != (ch = getopt(argc, argv, "-f:o:"))) + { + switch (ch) + { + case 'f': + fontdir = optarg; + break; + case 'o': + outdev = optarg; + break; + default: + // non-option -- probably an arg to unknown option + ; + } + } + + return EXIT_SUCCESS; +} + +static int drv_setResolution(int dpi_x, int dpi_y) +{ + dpix = dpi_x; + dpiy = dpi_y; + + return EXIT_SUCCESS; +} + +static inline double pixelsToInchX(int pixels) +{ + return (double)pixels / dpix; +} + +static inline double pixelsToInchY(int pixels) +{ + return (double)pixels / dpiy; +} + +static int drv_begin(double w, double h) +{ + width = w; + height = h; + fout = fopen(outdev, "wt"); + if (!fout) + { + mg_verbose(1, "Cannot open file '%s' -- %s\n", outdev, strerror(errno)); + return EXIT_FAILURE; + } + + fprintf(fout, "<?xml version=\"1.0\" standalone=\"no\"?>\n"); + fprintf(fout, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n"); + fprintf(fout, "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); + fprintf(fout, "<svg width=\"%fin\" height=\"%fin\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\">\n", w, h); + + return EXIT_SUCCESS; +} + +static int drv_end(void) +{ + if (fout) + { + fprintf(fout, "</svg>\n"); + fclose(fout); + + fout = 0; + } + + return EXIT_SUCCESS; +} + +static int drv_write(void) +{ + if (!fout) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + +static TTF_Font* openFont(const char* filename, int size) +{ + char buf[512]; + char namebuf[128]; + TTF_Font* font; + + strncpy(namebuf, filename, sizeof(namebuf)); + namebuf[sizeof(namebuf) - 1] = '\0'; + + // first try the proper case filename + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + // then try the lowercase filename + strlwr(namebuf); + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + // last try the uppercase filename + strupr(namebuf); + snprintf(buf, sizeof(buf), "%s/%s", fontdir, namebuf); + font = TTF_OpenFont(buf, size); + if (font) + return font; + + mg_verbose(2, "TTF_OpenFont(): %s\n", TTF_GetError()); + + return 0; +} + +static mg_font_t drv_loadFont(const char* name, double size, const char* filename) +{ + struct mg_font* fnt; + + if (!filename) + { + mg_verbose(1, "sdlsvg: filename not specified for font '%s'\n", name); + return 0; + } + + fnt = calloc(1, sizeof(*fnt)); + if (!fnt) + return 0; + fnt->size = size; + fnt->name = strdup(name ? name : "<Unknown>"); + fnt->font = openFont(filename, inchToPixelsY(fnt->size)); + if (!fnt->font) + { + free(fnt); + return 0; + } + + return fnt; +} + +static void drv_freeFont(mg_font_t fnt) +{ + if (!fnt) + return; + + if (fnt->name) + free(fnt->name); + if (fnt->font) + TTF_CloseFont(fnt->font); + free(fnt); +} + +static mg_image_t drv_loadImage(const char* filename) +{ + struct mg_image* img; + + img = calloc(1, sizeof(*img)); + if (!img) + return 0; + img->img = IMG_Load(filename); + if (!img->img) + { + free(img); + return 0; + } + img->filename = strdup(filename); + if (!img->filename) + { + drv_freeImage(img); + return 0; + } + img->width = pixelsToInchX(img->img->w); + img->height = pixelsToInchY(img->img->h); + + return img; +} + +static void drv_freeImage(mg_image_t img) +{ + if (!img) + return; + + if (img->filename) + free(img->filename); + + if (img->img) + SDL_FreeSurface(img->img); + free(img); +} + +static int drv_getImageSize(mg_image_t img, mg_rectf_t* r) +{ + if (!r) + return EXIT_FAILURE; + + r->x = r->y = 0; + if (img) + { + r->w = img->width; + r->h = img->height; + } + else + { + r->w = 0; + r->h = 0; + } + return EXIT_SUCCESS; +} + +static int clipon = 0; +static int clipcount = 0; + +static void drv_setClipRect(const mg_rectf_t* r) +{ + if (clipon) + fprintf(fout, "</g>\n"); + if (!r) + clipon = 0; + else + { + mg_color_t t; + fprintf(fout, "<clipPath id=\"clip%d\">\n", clipcount); + t.r = t.g = t.b = t.a = 255; + drv_drawFilledRect(r, t); + fprintf(fout, "</clipPath>\n"); + clipon = 1; + fprintf(fout, "<g clip-path=\"url(#clip%d)\">\n", clipcount++); + } +} + +static void drv_drawPixel(double xf, double yf, mg_color_t color, double weightf) +{ + drv_drawLine(xf, yf, xf, yf, color, weightf); +} + +static void drv_drawLine(double x0f, double y0f, double x1f, double y1f, mg_color_t color, double weightf) +{ + fprintf(fout, + "<line x1=\"%fin\" y1=\"%fin\" x2=\"%fin\" y2=\"%fin\" stroke=\"%s\" stroke-width=\"%fin\" opacity=\"%s\"/>\n", + x0f, y0f, x1f, y1f, color_string(color), weightf, alpha_string(color)); +} + +static void drv_drawRect(const mg_rectf_t* r, mg_color_t color, double weightf) +{ + // draw the box + drv_drawLine(r->x, r->y, r->x + r->w, r->y, color, weightf); + drv_drawLine(r->x, r->y + r->h, r->x + r->w, r->y + r->h, color, weightf); + drv_drawLine(r->x, r->y, r->x, r->y + r->h, color, weightf); + drv_drawLine(r->x + r->w, r->y, r->x + r->w, r->y + r->h, color, weightf); +} + +static void drv_drawFilledRect(const mg_rectf_t* r, mg_color_t color) +{ + if (!r) + { + mg_rectf_t t; + t.x = t.y = 0; + t.w = width; + t.h = height; + drv_drawFilledRect(&t, color); + } + else + { + fprintf(fout, + "<rect x=\"%fin\" y=\"%fin\" width=\"%fin\" height=\"%fin\" stroke=\"none\" fill=\"%s\" opacity=\"%s\"/>\n", + r->x, r->y, r->w, r->h, color_string(color), + alpha_string(color)); + + } +} + +static void drv_drawEllipse(double xcf, double ycf, double xrf, double yrf, mg_color_t color, double weight) +{ + fprintf(fout, + "<ellipse cx=\"%fin\" cy=\"%fin\" rx=\"%fin\" ry=\"%fin\" stroke=\"%s\" opacity=\"%s\" fill=\"none\" stroke-width=\"%fin\"/>\n", + xcf, ycf, xrf, yrf, color_string(color), alpha_string(color), weight); + +} + +static void drv_drawFilledEllipse(double xcf, double ycf, double xrf, double yrf, mg_color_t color) +{ + fprintf(fout, + "<ellipse cx=\"%fin\" cy=\"%fin\" rx=\"%fin\" ry=\"%fin\" fill=\"%s\" opacity=\"%s\"/>\n", + xcf, ycf, xrf, yrf, color_string(color), alpha_string(color)); + +} + +static void drv_drawImage(double xf, double yf, struct mg_image* img) +{ + fprintf(fout, + "<image xlink:href=\"%s\" x=\"%fin\" y=\"%fin\" width=\"%fin\" height=\"%fin\"/>\n", + img->filename, xf, yf, img->width, img->height); +} + +static void drv_drawText(struct mg_font* fnt, double xf, double yf, const unsigned char* utf8str, mg_color_t color) +{ + mg_rectf_t t; + + if (!fnt || !utf8str) + return; + + drv_getTextSize(fnt, utf8str, &t); + + yf += t.h; + + fprintf(fout, + "<text x=\"%fin\" y=\"%fin\" font-size=\"%f\" font-family=\"%s\" fill=\"%s\" dominant-baseline=\"text-after-edge\" opacity=\"%s\">\n", + xf, yf, fnt->size*96.0, fnt->name, color_string(color), alpha_string(color)); + fprintf(fout, "%s</text>", utf8str); + +} + +static void drv_getTextSize(struct mg_font* fnt, const unsigned char* utf8str, mg_rectf_t* r) +{ + int w = 0; + int h = 0; + + if (!r) + return; + if (!fnt || !utf8str) + { + r->w = 0; + r->h = 0; + return; + } + + TTF_SizeUTF8(fnt->font, (const char*) utf8str, &w, &h); + r->w = (double)w / dpix; + r->h = (double)h / dpiy; +} Property changes on: trunk/tools/map/sdlsvgdrv.c ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-07-26 20:31:05
|
Revision: 3664 http://sc2.svn.sourceforge.net/sc2/?rev=3664&view=rev Author: avolkov Date: 2011-07-26 20:30:58 +0000 (Tue, 26 Jul 2011) Log Message: ----------- Refactoring of ship_death() code: Pkunk/Shofixti exception hacks removed (but not MAX_SHIP_MASS+1); both now have own death_func(); Pkunk ditty plays after a simultaneous destruction + reincarnation (bug #666); plus some comments Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/ship.c trunk/sc2/src/uqm/ships/androsyn/androsyn.c trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c trunk/sc2/src/uqm/ships/pkunk/pkunk.c trunk/sc2/src/uqm/ships/shofixti/shofixti.c trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqm/tactrans.h trunk/sc2/src/uqm/weapon.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/ChangeLog 2011-07-26 20:30:58 UTC (rev 3664) @@ -1,4 +1,6 @@ Changes towards version 0.8: +- Fixed various Pkunk reincarnation and Shofixti Glory device interactions; + Pkunk ditty plays in a simultaneous destruction (bug #666) - Alex - Preparing for linking with C++ code, from Scott A. Colcord - Fixed player's phrase leading to Tanaka's response about a solitary vigil (bug #859) - Alex Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/element.h 2011-07-26 20:30:58 UTC (rev 3664) @@ -96,7 +96,8 @@ typedef struct element ELEMENT; -typedef void (CollisionFunc) (ELEMENT *ElementPtr0, POINT *pPt0, +typedef void (ElementProcessFunc) (ELEMENT *ElementPtr); +typedef void (ElementCollisionFunc) (ELEMENT *ElementPtr0, POINT *pPt0, ELEMENT *ElementPtr1, POINT *pPt1); // Any physical object in the simulation. @@ -105,10 +106,10 @@ // LINK elements; must be first HELEMENT pred, succ; - void (*preprocess_func) (struct element *ElementPtr); - void (*postprocess_func) (struct element *ElementPtr); - CollisionFunc *collision_func; - void (*death_func) (struct element *ElementPtr); + ElementProcessFunc *preprocess_func; + ElementProcessFunc *postprocess_func; + ElementCollisionFunc *collision_func; + ElementProcessFunc *death_func; // Player this element belongs to // -1: neutral (planets, asteroids, crew, etc.) Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/planets/solarsys.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -1660,6 +1660,7 @@ RECT clipRect; FRAME frame; + // Use SpaceContext to find out the dimensions of the background oldContext = SetContext (SpaceContext); GetContextClipRect (&clipRect); Modified: trunk/sc2/src/uqm/ship.c =================================================================== --- trunk/sc2/src/uqm/ship.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ship.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -193,6 +193,9 @@ if (RDPtr->preprocess_func) (*RDPtr->preprocess_func) (ElementPtr); + // XXX: Hack: Pkunk sets hTarget!=0 when it reincarnates. In that + // case there is no ship_transition() but a Phoenix transition + // instead. if (ElementPtr->hTarget == 0) { ship_transition (ElementPtr); Modified: trunk/sc2/src/uqm/ships/androsyn/androsyn.c =================================================================== --- trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -426,7 +426,7 @@ StarShipPtr->RaceDescPtr->characteristics.special_wait; StarShipPtr->RaceDescPtr->characteristics.energy_regeneration = ENERGY_REGENERATION; ElementPtr->mass_points = SHIP_MASS; - ElementPtr->collision_func = (CollisionFunc *) + ElementPtr->collision_func = (ElementCollisionFunc *) StarShipPtr->RaceDescPtr->data; ElementPtr->next.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; Modified: trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c =================================================================== --- trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -452,7 +452,7 @@ init_mmrnmhrm (void) { RACE_DESC *RaceDescPtr; - + // The caller of this func will copy the struct static RACE_DESC new_mmrnmhrm_desc; CHARACTERISTIC_STUFF *otherwing_desc; Modified: trunk/sc2/src/uqm/ships/pkunk/pkunk.c =================================================================== --- trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -21,6 +21,7 @@ #include "resinst.h" #include "uqm/globdata.h" +#include "uqm/tactrans.h" #include "libs/mathlib.h" @@ -112,6 +113,16 @@ 0, /* CodeRef */ }; +// Private per-instance ship data +typedef struct +{ + HELEMENT hPhoenix; + ElementProcessFunc *saved_preprocess_func; + ElementProcessFunc *saved_postprocess_func; + ElementProcessFunc *saved_death_func; + +} PKUNK_DATA; + static void animate (ELEMENT *ElementPtr) { @@ -186,15 +197,15 @@ COUNT ConcernCounter) { STARSHIP *StarShipPtr; - HELEMENT hPhoenix; + PKUNK_DATA *PkunkData; GetElementStarShip (ShipPtr, &StarShipPtr); - hPhoenix = (HELEMENT) StarShipPtr->RaceDescPtr->data; - if (hPhoenix && (StarShipPtr->control & STANDARD_RATING)) + PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + if (PkunkData->hPhoenix && (StarShipPtr->control & STANDARD_RATING)) { - RemoveElement (hPhoenix); - FreeElement (hPhoenix); - StarShipPtr->RaceDescPtr->data = 0; + RemoveElement (PkunkData->hPhoenix); + FreeElement (PkunkData->hPhoenix); + PkunkData->hPhoenix = 0; } if (StarShipPtr->RaceDescPtr->ship_info.energy_level < @@ -208,108 +219,116 @@ } static void pkunk_preprocess (ELEMENT *ElementPtr); -static void pkunk_postprocess (ELEMENT *ElementPtr); static void new_pkunk (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; + PKUNK_DATA *PkunkData; GetElementStarShip (ElementPtr, &StarShipPtr); - if (!(ElementPtr->state_flags & PLAYER_SHIP)) - { - ELEMENT *ShipPtr; + PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; - LockElement (StarShipPtr->hShip, &ShipPtr); - ShipPtr->death_func = new_pkunk; - UnlockElement (StarShipPtr->hShip); - } - else - { - ElementPtr->state_flags = APPEARING | PLAYER_SHIP | IGNORE_SIMILAR; - ElementPtr->mass_points = SHIP_MASS; - ElementPtr->preprocess_func = StarShipPtr->RaceDescPtr->preprocess_func; - ElementPtr->postprocess_func = StarShipPtr->RaceDescPtr->postprocess_func; - ElementPtr->death_func = - (void (*) (ELEMENT *ElementPtr)) - StarShipPtr->RaceDescPtr->init_weapon_func; - StarShipPtr->RaceDescPtr->preprocess_func = pkunk_preprocess; - StarShipPtr->RaceDescPtr->postprocess_func = pkunk_postprocess; - StarShipPtr->RaceDescPtr->init_weapon_func = initialize_bug_missile; - StarShipPtr->RaceDescPtr->ship_info.crew_level = MAX_CREW; - StarShipPtr->RaceDescPtr->ship_info.energy_level = MAX_ENERGY; - /* fix vux impairment */ - StarShipPtr->RaceDescPtr->characteristics.max_thrust = MAX_THRUST; - StarShipPtr->RaceDescPtr->characteristics.thrust_increment = THRUST_INCREMENT; - StarShipPtr->RaceDescPtr->characteristics.turn_wait = TURN_WAIT; - StarShipPtr->RaceDescPtr->characteristics.thrust_wait = THRUST_WAIT; - StarShipPtr->RaceDescPtr->characteristics.special_wait = 0; + ElementPtr->state_flags = APPEARING | PLAYER_SHIP | IGNORE_SIMILAR; + ElementPtr->mass_points = SHIP_MASS; + // Restore the element processing callbacks after the explosion. + // The callbacks were changed for the explosion sequence + ElementPtr->preprocess_func = PkunkData->saved_preprocess_func; + ElementPtr->postprocess_func = PkunkData->saved_postprocess_func; + ElementPtr->death_func = PkunkData->saved_death_func; + // preprocess_func() is called during the phoenix transition and + // then cleared, so we need to restore it + StarShipPtr->RaceDescPtr->preprocess_func = pkunk_preprocess; + StarShipPtr->RaceDescPtr->ship_info.crew_level = MAX_CREW; + StarShipPtr->RaceDescPtr->ship_info.energy_level = MAX_ENERGY; + /* fix vux impairment */ + StarShipPtr->RaceDescPtr->characteristics.max_thrust = MAX_THRUST; + StarShipPtr->RaceDescPtr->characteristics.thrust_increment = THRUST_INCREMENT; + StarShipPtr->RaceDescPtr->characteristics.turn_wait = TURN_WAIT; + StarShipPtr->RaceDescPtr->characteristics.thrust_wait = THRUST_WAIT; + StarShipPtr->RaceDescPtr->characteristics.special_wait = 0; - StarShipPtr->ship_input_state = 0; - StarShipPtr->cur_status_flags = 0; - StarShipPtr->old_status_flags = 0; - StarShipPtr->energy_counter = 0; - StarShipPtr->weapon_counter = 0; - StarShipPtr->special_counter = 0; - ElementPtr->crew_level = 0; - ElementPtr->turn_wait = 0; - ElementPtr->thrust_wait = 0; - ElementPtr->life_span = NORMAL_LIFE; + StarShipPtr->ship_input_state = 0; + // Pkunk wins in a simultaneous destruction if it reincarnates + StarShipPtr->cur_status_flags &= PLAY_VICTORY_DITTY; + StarShipPtr->old_status_flags = 0; + StarShipPtr->energy_counter = 0; + StarShipPtr->weapon_counter = 0; + StarShipPtr->special_counter = 0; + ElementPtr->crew_level = 0; + ElementPtr->turn_wait = 0; + ElementPtr->thrust_wait = 0; + ElementPtr->life_span = NORMAL_LIFE; - StarShipPtr->ShipFacing = NORMALIZE_FACING (TFB_Random ()); - ElementPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; - ElementPtr->current.image.frame = - SetAbsFrameIndex (StarShipPtr->RaceDescPtr->ship_data.ship[0], - StarShipPtr->ShipFacing); - SetPrimType (&(GLOBAL (DisplayArray))[ - ElementPtr->PrimIndex - ], STAMP_PRIM); + StarShipPtr->ShipFacing = NORMALIZE_FACING (TFB_Random ()); + ElementPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; + ElementPtr->current.image.frame = SetAbsFrameIndex ( + StarShipPtr->RaceDescPtr->ship_data.ship[0], + StarShipPtr->ShipFacing); + SetPrimType (&(GLOBAL (DisplayArray))[ElementPtr->PrimIndex], STAMP_PRIM); - do - { - ElementPtr->current.location.x = - WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); - ElementPtr->current.location.y = - WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); - } while (CalculateGravity (ElementPtr) - || TimeSpaceMatterConflict (ElementPtr)); + do + { + ElementPtr->current.location.x = + WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); + ElementPtr->current.location.y = + WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); + } while (CalculateGravity (ElementPtr) + || TimeSpaceMatterConflict (ElementPtr)); - ElementPtr->hTarget = StarShipPtr->hShip; - } + // XXX: Hack: Set hTarget!=0 so that ship_preprocess() does not + // call ship_transition() for us. + ElementPtr->hTarget = StarShipPtr->hShip; } +// This function is called when the ship dies but reincarnates. +// The generic ship_death() function is not called for the ship in this case. static void +pkunk_reincarnation_death (ELEMENT *ShipPtr) +{ + // Simulate ship death + StopAllBattleMusic (); + StartShipExplosion (ShipPtr, true); + // Once the explosion ends, we will get a brand new ship + ShipPtr->death_func = new_pkunk; +} + +static void intercept_pkunk_death (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; + PKUNK_DATA *PkunkData; + ELEMENT *ShipPtr; - ElementPtr->state_flags &= ~DISAPPEARING; - ElementPtr->life_span = 1; + GetElementStarShip (ElementPtr, &StarShipPtr); + PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; + + if (StarShipPtr->RaceDescPtr->ship_info.crew_level != 0) + { // Ship not dead yet. + // Keep the Phoenix element alive. + ElementPtr->state_flags &= ~DISAPPEARING; + ElementPtr->life_span = 1; + return; + } - GetElementStarShip (ElementPtr, &StarShipPtr); - if (StarShipPtr->RaceDescPtr->ship_info.crew_level == 0) + LockElement (StarShipPtr->hShip, &ShipPtr); + // GRAVITY_MASS() indicates a warp-out here. If Pkunk dies while warping + // out, there is no reincarnation. + if (!GRAVITY_MASS (ShipPtr->mass_points + 1)) { - ELEMENT *ShipPtr; + // XXX: Hack: Set mass_points to indicate a reincarnation to + // FindAliveStarShip() + ShipPtr->mass_points = MAX_SHIP_MASS + 1; + // Save the various element processing callbacks before the + // explosion happens, because we were not the ones who set + // these callbacks and they are about to be changed. + PkunkData->saved_preprocess_func = ShipPtr->preprocess_func; + PkunkData->saved_postprocess_func = ShipPtr->postprocess_func; + PkunkData->saved_death_func = ShipPtr->death_func; - LockElement (StarShipPtr->hShip, &ShipPtr); - if (GRAVITY_MASS (ShipPtr->mass_points + 1)) - { - ElementPtr->state_flags |= DISAPPEARING; - ElementPtr->life_span = 0; - } - else - { - ShipPtr->mass_points = MAX_SHIP_MASS + 1; - StarShipPtr->RaceDescPtr->preprocess_func = ShipPtr->preprocess_func; - StarShipPtr->RaceDescPtr->postprocess_func = ShipPtr->postprocess_func; - StarShipPtr->RaceDescPtr->init_weapon_func = - (COUNT (*) (ELEMENT *ElementPtr, HELEMENT Weapon[])) - ShipPtr->death_func; - - ElementPtr->death_func = new_pkunk; - } - UnlockElement (StarShipPtr->hShip); + ShipPtr->death_func = pkunk_reincarnation_death; } + UnlockElement (StarShipPtr->hShip); } #define START_PHOENIX_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) @@ -425,15 +444,22 @@ pkunk_preprocess (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; + PKUNK_DATA *PkunkData; GetElementStarShip (ElementPtr, &StarShipPtr); + PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data; if (ElementPtr->state_flags & APPEARING) { HELEMENT hPhoenix = 0; - if ((BYTE)TFB_Random () & 1) + if (TFB_Random () & 1) hPhoenix = AllocElement (); + // The hPhoenix element is created and placed at the head of the + // queue so that it is preprocessed before any of the ships' elements + // are, and so before death_func() is called for the dead Pkunk. + // hPhoenix detects when the Pkunk ship dies and tweaks the ship, + // starting the death + reincarnation sequence. if (hPhoenix) { ELEMENT *PhoenixPtr; @@ -450,12 +476,17 @@ UnlockElement (hPhoenix); InsertElement (hPhoenix, GetHeadElement ()); } - StarShipPtr->RaceDescPtr->data = (intptr_t) hPhoenix; + PkunkData->hPhoenix = hPhoenix; + // XXX: Hack: new_pkunk() sets hTarget!=0 which indicates a + // reincarnation to us. if (ElementPtr->hTarget == 0) + { + // A brand new ship is preprocessed only once StarShipPtr->RaceDescPtr->preprocess_func = 0; + } else - { + { // Start the reincarnation sequence COUNT angle, facing; ProcessSound (SetAbsSoundIndex ( @@ -538,18 +569,32 @@ } } +static void +uninit_pkunk (RACE_DESC *pRaceDesc) +{ + HFree ((void *)pRaceDesc->data); + pRaceDesc->data = 0; +} + RACE_DESC* init_pkunk (void) { RACE_DESC *RaceDescPtr; + // The caller of this func will copy the struct + static RACE_DESC new_pkunk_desc; + pkunk_desc.uninit_func = uninit_pkunk; pkunk_desc.preprocess_func = pkunk_preprocess; pkunk_desc.postprocess_func = pkunk_postprocess; pkunk_desc.init_weapon_func = initialize_bug_missile; pkunk_desc.cyborg_control.intelligence_func = pkunk_intelligence; - RaceDescPtr = &pkunk_desc; + /* copy initial ship settings to the new descriptor */ + new_pkunk_desc = pkunk_desc; + new_pkunk_desc.data = (intptr_t) HCalloc (sizeof (PKUNK_DATA)); + RaceDescPtr = &new_pkunk_desc; + LastSound = 0; // We need to reinitialise it at least each battle, to ensure // that NetPlay is synchronised if one player played another @@ -557,4 +602,3 @@ return (RaceDescPtr); } - Modified: trunk/sc2/src/uqm/ships/shofixti/shofixti.c =================================================================== --- trunk/sc2/src/uqm/ships/shofixti/shofixti.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ships/shofixti/shofixti.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -21,6 +21,7 @@ #include "resinst.h" #include "uqm/globdata.h" +#include "uqm/tactrans.h" #include "libs/mathlib.h" @@ -212,10 +213,10 @@ PutElement (hDestruct); LockElement (hDestruct, &DestructPtr); SetElementStarShip (DestructPtr, StarShipPtr); - DestructPtr->hit_points = DestructPtr->mass_points = 0; + DestructPtr->hit_points = 0; + DestructPtr->mass_points = 0; DestructPtr->playerNr = NEUTRAL_PLAYER_NUM; DestructPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; - DestructPtr->life_span = (NUM_EXPLOSION_FRAMES - 3) - 1; SetPrimType (&(GLOBAL (DisplayArray))[DestructPtr->PrimIndex], STAMPFILL_PRIM); SetPrimColor (&(GLOBAL (DisplayArray))[DestructPtr->PrimIndex], @@ -224,6 +225,8 @@ StarShipPtr->RaceDescPtr->ship_data.special; DestructPtr->current.image.frame = StarShipPtr->RaceDescPtr->ship_data.special[0]; + DestructPtr->life_span = GetFrameCount ( + DestructPtr->current.image.frame); DestructPtr->current.location = ElementPtr->current.location; DestructPtr->preprocess_func = destruct_preprocess; DestructPtr->postprocess_func = NULL; @@ -240,110 +243,147 @@ #define ORZ_MARINE(ptr) (ptr->preprocess_func == intruder_preprocess && \ ptr->collision_func == marine_collision) -// XXX: This function should be split into two static void -self_destruct (ELEMENT *ElementPtr) +self_destruct_kill_objects (ELEMENT *ElementPtr) { - STARSHIP *StarShipPtr; + // This is called during PostProcessQueue(), close to or at the end, + // for the temporary destruct element to apply the effects of glory + // explosion. The effects are not seen until the next frame. + HELEMENT hElement, hNextElement; - GetElementStarShip (ElementPtr, &StarShipPtr); - if (ElementPtr->state_flags & PLAYER_SHIP) + for (hElement = GetHeadElement (); hElement != 0; hElement = hNextElement) { - HELEMENT hDestruct; - - // Spawn a temporary element, which dies in this same frame, in order - // to defer the effects of the glory explosion. - // It will be the last element (or one of the last) for which the - // death_func will be called from PostProcessQueue() in this frame. - hDestruct = AllocElement (); - if (hDestruct) + ELEMENT *ObjPtr; + SIZE delta_x, delta_y; + DWORD dist; + + LockElement (hElement, &ObjPtr); + hNextElement = GetSuccElement (ObjPtr); + + if (!CollidingElement (ObjPtr) && !ORZ_MARINE (ObjPtr)) { - ELEMENT *DestructPtr; + UnlockElement (hElement); + continue; + } - LockElement (hDestruct, &DestructPtr); - DestructPtr->playerNr = ElementPtr->playerNr; - DestructPtr->state_flags = APPEARING | NONSOLID | FINITE_LIFE; - DestructPtr->next.location = ElementPtr->next.location; - DestructPtr->life_span = 0; - DestructPtr->pParent = ElementPtr->pParent; - DestructPtr->hTarget = 0; +#define DESTRUCT_RANGE 180 + delta_x = ObjPtr->next.location.x - ElementPtr->next.location.x; + if (delta_x < 0) + delta_x = -delta_x; + delta_y = ObjPtr->next.location.y - ElementPtr->next.location.y; + if (delta_y < 0) + delta_y = -delta_y; + delta_x = WORLD_TO_DISPLAY (delta_x); + delta_y = WORLD_TO_DISPLAY (delta_y); + dist = delta_x * delta_x + delta_y * delta_y; + if (delta_x <= DESTRUCT_RANGE && delta_y <= DESTRUCT_RANGE + && dist <= DESTRUCT_RANGE * DESTRUCT_RANGE) + { +#define MAX_DESTRUCTION (DESTRUCT_RANGE / 10) + int destruction = 1 + MAX_DESTRUCTION * + (DESTRUCT_RANGE - square_root (dist)) / DESTRUCT_RANGE; - DestructPtr->death_func = self_destruct; + // XXX: Why not simply call do_damage()? + if (ObjPtr->state_flags & PLAYER_SHIP) + { + if (!DeltaCrew (ObjPtr, -destruction)) + ObjPtr->life_span = 0; + } + else if (!GRAVITY_MASS (ObjPtr->mass_points)) + { + if (destruction < ObjPtr->hit_points) + ObjPtr->hit_points -= destruction; + else + { + ObjPtr->hit_points = 0; + ObjPtr->life_span = 0; + } + } + } - UnlockElement (hDestruct); + UnlockElement (hElement); + } +} - PutElement (hDestruct); +// This function is called when the ship dies via Glory Device. +// The generic ship_death() function is not called for the ship in this case. +static void +shofixti_destruct_death (ELEMENT *ShipPtr) +{ + STARSHIP *StarShip; + STARSHIP *winner; + + GetElementStarShip (ShipPtr, &StarShip); + + StopAllBattleMusic (); + + StartShipExplosion (ShipPtr, false); + // We process the explosion ourselves because it is different + ShipPtr->preprocess_func = destruct_preprocess; + + PlaySound (SetAbsSoundIndex (StarShip->RaceDescPtr->ship_data.ship_sounds, + 1), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); + + winner = GetWinnerStarShip (); + if (winner == NULL) + { // No winner determined yet + winner = FindAliveStarShip (ShipPtr); + if (winner == NULL) + { // No ships left alive after the Glory Device thus Shofixti wins + winner = StarShip; } + SetWinnerStarShip (winner); + } + else if (winner == StarShip) + { // This ship is the winner + // It may have self-destructed before the ditty started playing, + // and in that case, there should be no ditty + StarShip->cur_status_flags &= ~PLAY_VICTORY_DITTY; + } + RecordShipDeath (ShipPtr); +} - ElementPtr->state_flags |= NONSOLID; - // The ship is now dead. It's death_func, i.e. ship_death(), will be - // called the next frame. - ElementPtr->life_span = 0; +static void +self_destruct (ELEMENT *ElementPtr) +{ + STARSHIP *StarShipPtr; + HELEMENT hDestruct; - ElementPtr->preprocess_func = destruct_preprocess; - } - else + GetElementStarShip (ElementPtr, &StarShipPtr); + + // Spawn a temporary element, which dies in this same frame, in order + // to defer the effects of the glory explosion. + // It will be the last element (or one of the last) for which the + // death_func() will be called from PostProcessQueue() in this frame. + // XXX: Why at the end? Why not just do it now? + hDestruct = AllocElement (); + if (hDestruct) { - // This is called during PostProcessQueue(), close to or at the end, - // for the temporary destruct element to apply the effects of glory - // explosion. The effects are not seen until the next frame. - HELEMENT hElement, hNextElement; + ELEMENT *DestructPtr; - for (hElement = GetHeadElement (); - hElement != 0; hElement = hNextElement) - { - ELEMENT *ObjPtr; + LockElement (hDestruct, &DestructPtr); + DestructPtr->playerNr = ElementPtr->playerNr; + DestructPtr->state_flags = APPEARING | NONSOLID | FINITE_LIFE; + DestructPtr->next.location = ElementPtr->next.location; + DestructPtr->life_span = 0; + DestructPtr->pParent = ElementPtr->pParent; + DestructPtr->hTarget = 0; - LockElement (hElement, &ObjPtr); - hNextElement = GetSuccElement (ObjPtr); + DestructPtr->death_func = self_destruct_kill_objects; - if (CollidingElement (ObjPtr) || ORZ_MARINE (ObjPtr)) - { -#define DESTRUCT_RANGE 180 - SIZE delta_x, delta_y; - DWORD dist; + UnlockElement (hDestruct); - if ((delta_x = ObjPtr->next.location.x - - ElementPtr->next.location.x) < 0) - delta_x = -delta_x; - if ((delta_y = ObjPtr->next.location.y - - ElementPtr->next.location.y) < 0) - delta_y = -delta_y; - delta_x = WORLD_TO_DISPLAY (delta_x); - delta_y = WORLD_TO_DISPLAY (delta_y); - if (delta_x <= DESTRUCT_RANGE && delta_y <= DESTRUCT_RANGE - && (dist = (DWORD)(delta_x * delta_x) - + (DWORD)(delta_y * delta_y)) <= - (DWORD)(DESTRUCT_RANGE * DESTRUCT_RANGE)) - { -#define MAX_DESTRUCTION (DESTRUCT_RANGE / 10) - SIZE destruction; + PutElement (hDestruct); + } - destruction = ((MAX_DESTRUCTION - * (DESTRUCT_RANGE - square_root (dist))) - / DESTRUCT_RANGE) + 1; + // Must kill off the remaining crew ourselves + DeltaCrew (ElementPtr, -(int)ElementPtr->crew_level); - if (ObjPtr->state_flags & PLAYER_SHIP) - { - if (!DeltaCrew (ObjPtr, -destruction)) - ObjPtr->life_span = 0; - } - else if (!GRAVITY_MASS (ObjPtr->mass_points)) - { - if ((BYTE)destruction < ObjPtr->hit_points) - ObjPtr->hit_points -= (BYTE)destruction; - else - { - ObjPtr->hit_points = 0; - ObjPtr->life_span = 0; - } - } - } - } - - UnlockElement (hElement); - } - } + ElementPtr->state_flags |= NONSOLID; + ElementPtr->life_span = 0; + // The ship is now dead. It's death_func, i.e. shofixti_destruct_death(), + // will be called the next frame. + ElementPtr->death_func = shofixti_destruct_death; } static void @@ -410,7 +450,7 @@ init_shofixti (void) { RACE_DESC *RaceDescPtr; - + // The caller of this func will copy the struct static RACE_DESC new_shofixti_desc; shofixti_desc.postprocess_func = shofixti_postprocess; Modified: trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c =================================================================== --- trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -848,8 +848,8 @@ init_sis (void) { RACE_DESC *RaceDescPtr; - COUNT i; + // The caller of this func will copy the struct static RACE_DESC new_sis_desc; /* copy initial ship settings to new_sis_desc */ Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/tactrans.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -47,6 +47,8 @@ static BOOLEAN dittyIsPlaying; static STARSHIP *winnerStarShip; + // Indicates which ship is the winner of the current battle. + // The winner will be last to pick the next ship. BOOLEAN @@ -617,38 +619,37 @@ } void -ship_death (ELEMENT *ShipPtr) +StopAllBattleMusic (void) { - STARSHIP *StarShipPtr; - STARSHIP *VictoriousStarShipPtr; - HELEMENT hElement, hNextElement; - ELEMENT *ElementPtr; - StopDitty (); StopMusic (); +} - GetElementStarShip (ShipPtr, &StarShipPtr); +STARSHIP * +FindAliveStarShip (ELEMENT *deadShip) +{ + STARSHIP *aliveShip = NULL; + HELEMENT hElement, hNextElement; - if (ShipPtr->mass_points <= MAX_SHIP_MASS) - { // Not running away and not reincarnating (Pkunk) - // When a ship tries to run away, it is (dis)counted in DoRunAway(), - // so when it dies while running away, we will not count it again - assert (StarShipPtr->playerNr >= 0); - battle_counter[StarShipPtr->playerNr]--; - } - - VictoriousStarShipPtr = NULL; + // Find the remaining ship, if any, and see if it is still alive. for (hElement = GetHeadElement (); hElement; hElement = hNextElement) { + ELEMENT *ElementPtr; + LockElement (hElement, &ElementPtr); if ((ElementPtr->state_flags & PLAYER_SHIP) - && ElementPtr != ShipPtr + && ElementPtr != deadShip /* and not running away */ - && ElementPtr->mass_points <= MAX_SHIP_MASS) + && ElementPtr->mass_points <= MAX_SHIP_MASS + 1) { - GetElementStarShip (ElementPtr, &VictoriousStarShipPtr); - if (VictoriousStarShipPtr->RaceDescPtr->ship_info.crew_level == 0) - VictoriousStarShipPtr = NULL; + GetElementStarShip (ElementPtr, &aliveShip); + assert (aliveShip != NULL); + if (aliveShip->RaceDescPtr->ship_info.crew_level == 0 + /* reincarnating Pkunk is not actually dead */ + && ElementPtr->mass_points != MAX_SHIP_MASS + 1) + { + aliveShip = NULL; + } UnlockElement (hElement); break; @@ -656,52 +657,98 @@ hNextElement = GetSuccElement (ElementPtr); UnlockElement (hElement); } + + return aliveShip; +} - StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY; +STARSHIP * +GetWinnerStarShip (void) +{ + return winnerStarShip; +} +void +SetWinnerStarShip (STARSHIP *winner) +{ + if (winner == NULL) + return; // nothing to do + + winner->cur_status_flags |= PLAY_VICTORY_DITTY; + + // The winner is set once per battle. If both ships die, this function is + // called twice, once for each ship. We need to preserve the winner + // determined on the first call. + if (winnerStarShip == NULL) + winnerStarShip = winner; +} + +void +RecordShipDeath (ELEMENT *deadShip) +{ + STARSHIP *deadStarShip; + + GetElementStarShip (deadShip, &deadStarShip); + assert (deadStarShip != NULL); + + if (deadShip->mass_points <= MAX_SHIP_MASS) + { // Not running away. + // When a ship tries to run away, it is (dis)counted in DoRunAway(), + // so when it dies while running away, we will not count it again + assert (deadStarShip->playerNr >= 0); + battle_counter[deadStarShip->playerNr]--; + } + + if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) + MeleeShipDeath (deadStarShip); +} + +void +StartShipExplosion (ELEMENT *ShipPtr, bool playSound) +{ + STARSHIP *StarShipPtr; + + GetElementStarShip (ShipPtr, &StarShipPtr); + + ZeroVelocityComponents (&ShipPtr->velocity); + DeltaEnergy (ShipPtr, -(SIZE)StarShipPtr->RaceDescPtr->ship_info.energy_level); ShipPtr->life_span = NUM_EXPLOSION_FRAMES * 3; ShipPtr->state_flags &= ~DISAPPEARING; ShipPtr->state_flags |= FINITE_LIFE | NONSOLID; + ShipPtr->preprocess_func = explosion_preprocess; ShipPtr->postprocess_func = PostProcessStatus; ShipPtr->death_func = cleanup_dead_ship; ShipPtr->hTarget = 0; - ZeroVelocityComponents (&ShipPtr->velocity); - if (ShipPtr->crew_level) /* only happens for shofixti self-destruct */ - { - PlaySound (SetAbsSoundIndex ( - StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), - CalcSoundPosition (ShipPtr), ShipPtr, - GAME_SOUND_PRIORITY + 1); - DeltaCrew (ShipPtr, -(SIZE)ShipPtr->crew_level); - if (VictoriousStarShipPtr == NULL) - { // No ships left alive after a Shofixti Glory device, - // thus Shofixti wins - VictoriousStarShipPtr = StarShipPtr; - } - } - else + if (playSound) { - ShipPtr->preprocess_func = explosion_preprocess; - PlaySound (SetAbsSoundIndex (GameSounds, SHIP_EXPLODES), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); } +} - if (VictoriousStarShipPtr != NULL) - VictoriousStarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY; +void +ship_death (ELEMENT *ShipPtr) +{ + STARSHIP *StarShipPtr; + STARSHIP *winner; - // The winner is set once per battle. If both ships die, this function is - // called twice, once for each ship. We need to preserve the winner - // determined on the first call. - if (winnerStarShip == NULL) - winnerStarShip = VictoriousStarShipPtr; + GetElementStarShip (ShipPtr, &StarShipPtr); - if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) - MeleeShipDeath (StarShipPtr); + StopAllBattleMusic (); + + // If the winning ship dies before the ditty starts, do not play it. + // e.g. a ship can die after the opponent begins exploding but + // before the explosion is over. + StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY; + + StartShipExplosion (ShipPtr, true); + + winner = FindAliveStarShip (ShipPtr); + SetWinnerStarShip (winner); + RecordShipDeath (ShipPtr); } #define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) Modified: trunk/sc2/src/uqm/tactrans.h =================================================================== --- trunk/sc2/src/uqm/tactrans.h 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/tactrans.h 2011-07-26 20:30:58 UTC (rev 3664) @@ -43,6 +43,12 @@ extern void StopDitty (void); extern void ResetWinnerStarShip (void); +extern void StopAllBattleMusic (void); +extern STARSHIP* FindAliveStarShip (ELEMENT *deadShip); +extern STARSHIP* GetWinnerStarShip (void); +extern void SetWinnerStarShip (STARSHIP *winner); +extern void RecordShipDeath (ELEMENT *deadShip); +extern void StartShipExplosion (ELEMENT *ShipPtr, bool playSound); #if defined(__cplusplus) } Modified: trunk/sc2/src/uqm/weapon.c =================================================================== --- trunk/sc2/src/uqm/weapon.c 2011-07-24 19:58:25 UTC (rev 3663) +++ trunk/sc2/src/uqm/weapon.c 2011-07-26 20:30:58 UTC (rev 3664) @@ -50,7 +50,7 @@ LaserElementPtr->state_flags = APPEARING | FINITE_LIFE | pLaserBlock->flags; LaserElementPtr->life_span = LASER_LIFE; - LaserElementPtr->collision_func = (CollisionFunc*)weapon_collision; + LaserElementPtr->collision_func = weapon_collision; LaserElementPtr->blast_offset = 1; LaserElementPtr->current.location.x = pLaserBlock->cx @@ -100,7 +100,7 @@ SetAbsFrameIndex (pMissileBlock->farray[0], pMissileBlock->index); MissileElementPtr->preprocess_func = pMissileBlock->preprocess_func; - MissileElementPtr->collision_func = (CollisionFunc*)weapon_collision; + MissileElementPtr->collision_func = weapon_collision; MissileElementPtr->blast_offset = (BYTE)pMissileBlock->blast_offs; angle = FACING_TO_ANGLE (pMissileBlock->face); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-07-24 19:58:35
|
Revision: 3663 http://sc2.svn.sourceforge.net/sc2/?rev=3663&view=rev Author: Meep-Eep Date: 2011-07-24 19:58:25 +0000 (Sun, 24 Jul 2011) Log Message: ----------- Preparing for linking with C++ code, from Scott A. Colcord. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/endian_uqm.h trunk/sc2/src/libs/alarm.h trunk/sc2/src/libs/callback.h trunk/sc2/src/libs/cdplib.h trunk/sc2/src/libs/compiler.h trunk/sc2/src/libs/declib.h trunk/sc2/src/libs/file.h trunk/sc2/src/libs/gfxlib.h trunk/sc2/src/libs/heap.h trunk/sc2/src/libs/inplib.h trunk/sc2/src/libs/list.h trunk/sc2/src/libs/log.h trunk/sc2/src/libs/mathlib.h trunk/sc2/src/libs/md5.h trunk/sc2/src/libs/memlib.h trunk/sc2/src/libs/misc.h trunk/sc2/src/libs/net.h trunk/sc2/src/libs/platform.h trunk/sc2/src/libs/reslib.h trunk/sc2/src/libs/sndlib.h trunk/sc2/src/libs/strlib.h trunk/sc2/src/libs/tasklib.h trunk/sc2/src/libs/threadlib.h trunk/sc2/src/libs/timelib.h trunk/sc2/src/libs/uio.h trunk/sc2/src/libs/uioutils.h trunk/sc2/src/libs/unicode.h trunk/sc2/src/libs/vidlib.h trunk/sc2/src/options.h trunk/sc2/src/port.h trunk/sc2/src/types.h trunk/sc2/src/uqm/battle.h trunk/sc2/src/uqm/battlecontrols.h trunk/sc2/src/uqm/build.h trunk/sc2/src/uqm/clock.h trunk/sc2/src/uqm/cnctdlg.h trunk/sc2/src/uqm/coderes.h trunk/sc2/src/uqm/collide.h trunk/sc2/src/uqm/comm.h trunk/sc2/src/uqm/commanim.h trunk/sc2/src/uqm/commglue.h trunk/sc2/src/uqm/cons_res.h trunk/sc2/src/uqm/controls.h trunk/sc2/src/uqm/credits.h trunk/sc2/src/uqm/demo.h trunk/sc2/src/uqm/displist.h trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/encount.h trunk/sc2/src/uqm/flash.h trunk/sc2/src/uqm/fmv.h trunk/sc2/src/uqm/gameev.h trunk/sc2/src/uqm/gameopt.h trunk/sc2/src/uqm/gamestr.h trunk/sc2/src/uqm/gendef.h trunk/sc2/src/uqm/globdata.h trunk/sc2/src/uqm/grpinfo.h trunk/sc2/src/uqm/hyper.h trunk/sc2/src/uqm/init.h trunk/sc2/src/uqm/intel.h trunk/sc2/src/uqm/ipdisp.h trunk/sc2/src/uqm/load.h trunk/sc2/src/uqm/master.h trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/oscill.h trunk/sc2/src/uqm/pickship.h trunk/sc2/src/uqm/planets/elemdata.h trunk/sc2/src/uqm/planets/generate/gendefault.h trunk/sc2/src/uqm/planets/generate.h trunk/sc2/src/uqm/planets/lander.h trunk/sc2/src/uqm/planets/lifeform.h trunk/sc2/src/uqm/planets/plandata.h trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.h trunk/sc2/src/uqm/planets/sundata.h trunk/sc2/src/uqm/process.h trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/restart.h trunk/sc2/src/uqm/save.h trunk/sc2/src/uqm/settings.h trunk/sc2/src/uqm/setup.h trunk/sc2/src/uqm/setupmenu.h trunk/sc2/src/uqm/ship.h trunk/sc2/src/uqm/shipcont.h trunk/sc2/src/uqm/ships/androsyn/androsyn.h trunk/sc2/src/uqm/ships/arilou/arilou.h trunk/sc2/src/uqm/ships/blackurq/blackurq.h trunk/sc2/src/uqm/ships/chenjesu/chenjesu.h trunk/sc2/src/uqm/ships/chmmr/chmmr.h trunk/sc2/src/uqm/ships/druuge/druuge.h trunk/sc2/src/uqm/ships/human/human.h trunk/sc2/src/uqm/ships/ilwrath/ilwrath.h trunk/sc2/src/uqm/ships/lastbat/lastbat.h trunk/sc2/src/uqm/ships/melnorme/melnorme.h trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.h trunk/sc2/src/uqm/ships/mycon/mycon.h trunk/sc2/src/uqm/ships/orz/orz.h trunk/sc2/src/uqm/ships/pkunk/pkunk.h trunk/sc2/src/uqm/ships/probe/probe.h trunk/sc2/src/uqm/ships/shofixti/shofixti.h trunk/sc2/src/uqm/ships/sis_ship/sis_ship.h trunk/sc2/src/uqm/ships/slylandr/slylandr.h trunk/sc2/src/uqm/ships/spathi/spathi.h trunk/sc2/src/uqm/ships/supox/supox.h trunk/sc2/src/uqm/ships/syreen/syreen.h trunk/sc2/src/uqm/ships/thradd/thradd.h trunk/sc2/src/uqm/ships/umgah/umgah.h trunk/sc2/src/uqm/ships/urquan/urquan.h trunk/sc2/src/uqm/ships/utwig/utwig.h trunk/sc2/src/uqm/ships/vux/vux.h trunk/sc2/src/uqm/ships/yehat/yehat.h trunk/sc2/src/uqm/ships/zoqfot/zoqfot.h trunk/sc2/src/uqm/sis.h trunk/sc2/src/uqm/sounds.h trunk/sc2/src/uqm/starbase.h trunk/sc2/src/uqm/starcon.h trunk/sc2/src/uqm/state.h trunk/sc2/src/uqm/status.h trunk/sc2/src/uqm/supermelee/buildpick.h trunk/sc2/src/uqm/supermelee/loadmele.h trunk/sc2/src/uqm/supermelee/melee.h trunk/sc2/src/uqm/supermelee/meleesetup.h trunk/sc2/src/uqm/supermelee/meleeship.h trunk/sc2/src/uqm/supermelee/netplay/checkbuf.h trunk/sc2/src/uqm/supermelee/netplay/checksum.h trunk/sc2/src/uqm/supermelee/netplay/crc.h trunk/sc2/src/uqm/supermelee/netplay/netconnection.h trunk/sc2/src/uqm/supermelee/netplay/netinput.h trunk/sc2/src/uqm/supermelee/netplay/netmelee.h trunk/sc2/src/uqm/supermelee/netplay/netmisc.h trunk/sc2/src/uqm/supermelee/netplay/netoptions.h trunk/sc2/src/uqm/supermelee/netplay/netrcv.h trunk/sc2/src/uqm/supermelee/netplay/netsend.h trunk/sc2/src/uqm/supermelee/netplay/netstate.h trunk/sc2/src/uqm/supermelee/netplay/notify.h trunk/sc2/src/uqm/supermelee/netplay/notifyall.h trunk/sc2/src/uqm/supermelee/netplay/packet.h trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h trunk/sc2/src/uqm/supermelee/netplay/packetq.h trunk/sc2/src/uqm/supermelee/netplay/packetsenders.h trunk/sc2/src/uqm/supermelee/netplay/proto/npconfirm.h trunk/sc2/src/uqm/supermelee/netplay/proto/ready.h trunk/sc2/src/uqm/supermelee/netplay/proto/reset.h trunk/sc2/src/uqm/supermelee/pickmele.h trunk/sc2/src/uqm/tactrans.h trunk/sc2/src/uqm/units.h trunk/sc2/src/uqm/util.h trunk/sc2/src/uqm/velocity.h trunk/sc2/src/uqm/weapon.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/ChangeLog 2011-07-24 19:58:25 UTC (rev 3663) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Preparing for linking with C++ code, from Scott A. Colcord - Fixed player's phrase leading to Tanaka's response about a solitary vigil (bug #859) - Alex - Added the Ur-Quan to the list of starfaring races on which Commander Modified: trunk/sc2/src/endian_uqm.h =================================================================== --- trunk/sc2/src/endian_uqm.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/endian_uqm.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -61,6 +61,11 @@ #define UQM_Swap32 __arch__swab32 #endif #endif /* linux */ + +#if defined(__cplusplus) +extern "C" { +#endif + /* Use inline functions for compilers that support them, and static functions for those that do not. Because these functions become static for compilers that do not support inline functions, this @@ -124,4 +129,8 @@ #define UQM_SwapBE64(X) (X) #endif +#if defined(__cplusplus) +} +#endif + #endif /* _ENDIAN_H */ Modified: trunk/sc2/src/libs/alarm.h =================================================================== --- trunk/sc2/src/libs/alarm.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/alarm.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -1,2 +1,9 @@ +#if defined(__cplusplus) +extern "C" { +#endif + #include "callback/alarm.h" +#if defined(__cplusplus) +} +#endif Modified: trunk/sc2/src/libs/callback.h =================================================================== --- trunk/sc2/src/libs/callback.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/callback.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -1,2 +1,10 @@ +#if defined(__cplusplus) +extern "C" { +#endif + #include "callback/callback.h" +#if defined(__cplusplus) +} +#endif + Modified: trunk/sc2/src/libs/cdplib.h =================================================================== --- trunk/sc2/src/libs/cdplib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/cdplib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,6 +19,14 @@ #ifndef _CDPLIB_H #define _CDPLIB_H +#if defined(__cplusplus) +extern "C" { +#endif + #include "cdp/cdp.h" +#if defined(__cplusplus) +} +#endif + #endif /* _CDPLIB_H */ Modified: trunk/sc2/src/libs/compiler.h =================================================================== --- trunk/sc2/src/libs/compiler.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/compiler.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "types.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef uint8 BYTE; typedef uint8 UBYTE; typedef sint8 SBYTE; @@ -85,5 +89,9 @@ # define _ALIGNED_ON(bytes) #endif +#if defined(__cplusplus) +} +#endif + #endif /* _COMPILER_H */ Modified: trunk/sc2/src/libs/declib.h =================================================================== --- trunk/sc2/src/libs/declib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/declib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,11 @@ #define _DECLIB_H #include "libs/compiler.h" + +#if defined(__cplusplus) +extern "C" { +#endif + typedef struct _LZHCODE_DESC* DECODE_REF; enum @@ -45,4 +50,8 @@ extern COUNT cwrite (const void *pStr, COUNT size, COUNT count, DECODE_REF DecodeRef); +#if defined(__cplusplus) +} +#endif + #endif /* _DECLIB_H */ Modified: trunk/sc2/src/libs/file.h =================================================================== --- trunk/sc2/src/libs/file.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/file.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -25,6 +25,10 @@ // for bool #include "types.h" +#if defined(__cplusplus) +extern "C" { +#endif + #if 0 // from temp.h void initTempDir (void); @@ -83,5 +87,9 @@ } #endif /* HAVE_DRIVE_LETTERS */ +#if defined(__cplusplus) +} +#endif + #endif /* _FILE_H */ Modified: trunk/sc2/src/libs/gfxlib.h =================================================================== --- trunk/sc2/src/libs/gfxlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/gfxlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -32,6 +32,10 @@ #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef struct context_desc CONTEXT_DESC; typedef struct frame_desc FRAME_DESC; typedef struct font_desc FONT_DESC; @@ -227,8 +231,16 @@ COUNT CharCount; } TEXT; +#if defined(__cplusplus) +} +#endif + #include "libs/strlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef STRING_TABLE COLORMAP_REF; typedef STRING COLORMAP; // COLORMAPPTR is really a pointer to colortable entry structure @@ -237,6 +249,7 @@ #include "graphics/prim.h" + typedef BYTE BATCH_FLAGS; // This flag is currently unused but it might make sense to restore it #define BATCH_BUILD_PAGE (BATCH_FLAGS)(1 << 0) @@ -454,4 +467,8 @@ void SetSystemRect (const RECT *pRect); void ClearSystemRect (void); +#if defined(__cplusplus) +} +#endif + #endif /* _GFXLIB_H */ Modified: trunk/sc2/src/libs/heap.h =================================================================== --- trunk/sc2/src/libs/heap.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/heap.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -1,2 +1,9 @@ +#if defined(__cplusplus) +extern "C" { +#endif + #include "heap/heap.h" +#if defined(__cplusplus) +} +#endif Modified: trunk/sc2/src/libs/inplib.h =================================================================== --- trunk/sc2/src/libs/inplib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/inplib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,7 +24,11 @@ #include "libs/uio.h" #include "libs/unicode.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN AnyButtonPress (BOOLEAN DetectSpecial); extern void TFB_ResetControls (void); @@ -59,5 +63,9 @@ void BeginInputFrame (void); +#if defined(__cplusplus) +} +#endif + #endif /* _INPLIB_H */ Modified: trunk/sc2/src/libs/list.h =================================================================== --- trunk/sc2/src/libs/list.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/list.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -16,5 +16,14 @@ * */ +#if defined(__cplusplus) +extern "C" { +#endif + #include "list/list.h" +#if defined(__cplusplus) +} +#endif + + Modified: trunk/sc2/src/libs/log.h =================================================================== --- trunk/sc2/src/libs/log.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/log.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -14,4 +14,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if defined(__cplusplus) +extern "C" { +#endif + #include "log/uqmlog.h" + +#if defined(__cplusplus) +} +#endif Modified: trunk/sc2/src/libs/mathlib.h =================================================================== --- trunk/sc2/src/libs/mathlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/mathlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,10 +20,19 @@ #define _MATHLIB_H #include "libs/compiler.h" + +#if defined(__cplusplus) +extern "C" { +#endif + #include "math/random.h" extern COUNT square_root (DWORD value); +#if defined(__cplusplus) +} +#endif + #endif /* _MATHLIB_H */ Modified: trunk/sc2/src/libs/md5.h =================================================================== --- trunk/sc2/src/libs/md5.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/md5.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,7 +19,15 @@ #ifndef _LIB_MD5_H #define _LIB_MD5_H +#if defined(__cplusplus) +extern "C" { +#endif + #include "md5/md5.h" +#if defined(__cplusplus) +} +#endif + #endif /* _LIB_MD5_H */ Modified: trunk/sc2/src/libs/memlib.h =================================================================== --- trunk/sc2/src/libs/memlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/memlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "types.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern bool mem_init (void); extern bool mem_uninit (void); @@ -29,5 +33,9 @@ extern void *HCalloc (int size); extern void *HRealloc (void *p, int size); +#if defined(__cplusplus) +} +#endif + #endif /* _MEMLIB_H */ Modified: trunk/sc2/src/libs/misc.h =================================================================== --- trunk/sc2/src/libs/misc.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/misc.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,7 +26,11 @@ #include <stdlib.h> #include "port.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern int TFB_DEBUG_HALT; static inline void explode (void) _NORETURN; @@ -54,5 +58,9 @@ return u.c; } +#if defined(__cplusplus) +} #endif +#endif + Modified: trunk/sc2/src/libs/net.h =================================================================== --- trunk/sc2/src/libs/net.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/net.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,11 +19,19 @@ #ifndef _NET_H #define _NET_H +#if defined(__cplusplus) +extern "C" { +#endif + #include "network/network.h" #include "network/netmanager/netmanager.h" #include "network/connect/connect.h" #include "network/connect/listen.h" #include "network/connect/resolve.h" +#if defined(__cplusplus) +} +#endif + #endif /* _NET_H */ Modified: trunk/sc2/src/libs/platform.h =================================================================== --- trunk/sc2/src/libs/platform.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/platform.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,6 +17,10 @@ #ifndef PLATFORM_H_ #define PLATFORM_H_ +#if defined(__cplusplus) +extern "C" { +#endif + #if defined(USE_PLATFORM_ACCEL) # if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) # define MMX_ASM @@ -46,4 +50,8 @@ extern PLATFORM_TYPE force_platform; +#if defined(__cplusplus) +} +#endif + #endif /* PLATFORM_H_ */ Modified: trunk/sc2/src/libs/reslib.h =================================================================== --- trunk/sc2/src/libs/reslib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/reslib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -25,6 +25,10 @@ #include "libs/memlib.h" #include "libs/uio.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef struct resource_index_desc RESOURCE_INDEX_DESC; typedef RESOURCE_INDEX_DESC *RESOURCE_INDEX; @@ -78,8 +82,16 @@ #define AllocResourceData HMalloc BOOLEAN FreeResourceData (void *); +#if defined(__cplusplus) +} +#endif + #include "libs/strlib.h" #include "libs/gfxlib.h" + +#if defined(__cplusplus) +extern "C" { +#endif // For Color typedef STRING_TABLE DIRENTRY_REF; @@ -120,4 +132,8 @@ BOOLEAN res_Remove (const char *key); +#if defined(__cplusplus) +} +#endif + #endif /* _RESLIB_H */ Modified: trunk/sc2/src/libs/sndlib.h =================================================================== --- trunk/sc2/src/libs/sndlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/sndlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -22,6 +22,10 @@ #include "port.h" #include "libs/strlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef STRING_TABLE SOUND_REF; typedef STRING SOUND; // SOUNDPTR is really a TFB_SoundSample** @@ -95,5 +99,9 @@ extern DWORD FadeMusic (BYTE end_vol, SIZE TimeInterval); +#if defined(__cplusplus) +} +#endif + #endif /* _SNDLIB_H */ Modified: trunk/sc2/src/libs/strlib.h =================================================================== --- trunk/sc2/src/libs/strlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/strlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -36,6 +36,10 @@ /* This has to go here because reslib requires the above typedefs. */ #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN InstallStringTableResType (void); extern STRING_TABLE LoadStringTableInstance (RESOURCE res); extern STRING_TABLE LoadStringTableFile (uio_DirHandle *dir, @@ -67,5 +71,9 @@ #define UNICHAR_BULLET 0x2022 #define STR_BULLET "\xE2\x80\xA2" +#if defined(__cplusplus) +} +#endif + #endif /* _STRLIB_H */ Modified: trunk/sc2/src/libs/tasklib.h =================================================================== --- trunk/sc2/src/libs/tasklib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/tasklib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,6 +26,10 @@ #include "libs/threadlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* Bitmasks for setting task state. */ #define TASK_INUSE 1 #define TASK_EXIT 2 @@ -50,5 +54,9 @@ extern void FinishTask (Task task); extern void ConcludeTask (Task task); +#if defined(__cplusplus) +} #endif +#endif + Modified: trunk/sc2/src/libs/threadlib.h =================================================================== --- trunk/sc2/src/libs/threadlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/threadlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -45,6 +45,10 @@ #include <sys/types.h> #include "libs/timelib.h" +#if defined(__cplusplus) +extern "C" { +#endif + #if defined (PROFILE_THREADS) || defined (DEBUG_THREADS) #define THREAD_NAMES #endif @@ -173,5 +177,9 @@ void SignalCondVar (CondVar); void BroadcastCondVar (CondVar); +#if defined(__cplusplus) +} +#endif + #endif /* _THREADLIB_H */ Modified: trunk/sc2/src/libs/timelib.h =================================================================== --- trunk/sc2/src/libs/timelib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/timelib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* ONE_SECOND is the LCM of all the fractions of a second the game uses. * Battle is 24 FPS, Landers are 35 FPS, most UI-level things are 15 FPS, * The Interplanetary flight is 30 FPS, Comm ambient animation is 40 FPS, @@ -38,5 +42,9 @@ extern void UnInitTimeSystem (void); extern TimeCount GetTimeCounter (void); +#if defined(__cplusplus) +} +#endif + #endif /* _TIMLIB_H */ Modified: trunk/sc2/src/libs/uio.h =================================================================== --- trunk/sc2/src/libs/uio.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/uio.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,7 +21,15 @@ #ifndef _UIO_H #define _UIO_H +#if defined(__cplusplus) +extern "C" { +#endif + #include "uio/io.h" +#if defined(__cplusplus) +} +#endif + #endif /* _UIO_H */ Modified: trunk/sc2/src/libs/uioutils.h =================================================================== --- trunk/sc2/src/libs/uioutils.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/uioutils.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,7 +21,15 @@ #ifndef _UIOUTILS_H #define _UIOUTILS_H +#if defined(__cplusplus) +extern "C" { +#endif + #include "uio/utils.h" +#if defined(__cplusplus) +} +#endif + #endif /* _UIOUTILS_H */ Modified: trunk/sc2/src/libs/unicode.h =================================================================== --- trunk/sc2/src/libs/unicode.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/unicode.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include <sys/types.h> // For size_t +#if defined(__cplusplus) +extern "C" { +#endif + typedef uint32 UniChar; #ifdef UNICODE_INTERNAL @@ -60,5 +64,9 @@ #undef UNICODE_CHAR +#if defined(__cplusplus) +} +#endif + #endif /* UNICODE_H */ Modified: trunk/sc2/src/libs/vidlib.h =================================================================== --- trunk/sc2/src/libs/vidlib.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/libs/vidlib.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "libs/sndlib.h" #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef enum { NO_FMV = 0, @@ -57,4 +61,8 @@ extern void StopLegacyVideo (LEGACY_VIDEO_REF ref); extern BOOLEAN PlayingLegacyVideo (LEGACY_VIDEO_REF ref); +#if defined(__cplusplus) +} +#endif + #endif /* _VIDLIB_H */ Modified: trunk/sc2/src/options.h =================================================================== --- trunk/sc2/src/options.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/options.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,6 +26,10 @@ #include "libs/compiler.h" #include "libs/uio.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define OPT_3DO 0x01 #define OPT_PC 0x02 #define OPT_ALL 0xFF @@ -81,5 +85,9 @@ bool setGammaCorrection (float gamma); +#if defined(__cplusplus) +} #endif +#endif + Modified: trunk/sc2/src/port.h =================================================================== --- trunk/sc2/src/port.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/port.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -79,13 +79,25 @@ #ifndef HAVE_STRUPR +#if defined(__cplusplus) +extern "C" { +#endif char *strupr (char *str); +#if defined(__cplusplus) +} #endif +#endif #if !defined (_MSC_VER) && !defined (HAVE_READDIR_R) # include <dirent.h> +#if defined(__cplusplus) +extern "C" { +#endif int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); +#if defined(__cplusplus) +} #endif +#endif // Directories #ifdef WIN32 @@ -161,10 +173,21 @@ #ifdef _MSC_VER # include <stdarg.h> // Defined in port.c +#if defined(__cplusplus) +extern "C" { +#endif int snprintf(char *str, size_t size, const char *format, ...); int vsnprintf(char *str, size_t size, const char *format, va_list args); +#if defined(__cplusplus) +} +#endif + #endif /* _MSC_VER */ +#if defined(__cplusplus) +extern "C" { +#endif + // setenv() #ifndef HAVE_SETENV int setenv (const char *name, const char *value, int overwrite); @@ -178,6 +201,10 @@ typedef unsigned int wint_t; #endif +#if defined(__cplusplus) +} +#endif + #if defined (_MSC_VER) || defined(__MINGW32__) # define USE_WINSOCK #endif Modified: trunk/sc2/src/types.h =================================================================== --- trunk/sc2/src/types.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/types.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -50,6 +50,10 @@ # endif /* defined(PRIxPTR) */ #endif +#if defined(__cplusplus) +extern "C" { +#endif + #if defined(__arch64__) || defined(__alpha) || defined(__x86_64) \ || defined(_M_IA64) || defined(_M_AMD64) /* 64-bit platforms */ @@ -177,4 +181,8 @@ #define UINT16_MAX 0xffff /* 65535U */ #define UINT32_MAX 0xffffffff /* 4294967295U */ +#if defined(__cplusplus) +} +#endif + #endif /* _TYPES_H */ Modified: trunk/sc2/src/uqm/battle.h =================================================================== --- trunk/sc2/src/uqm/battle.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/battle.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,6 +26,10 @@ #include "init.h" // For NUM_SIDES +#if defined(__cplusplus) +extern "C" { +#endif + // The callback function is called on every battle frame // with GraphicsLock held, just before the display queue // is drawn @@ -56,4 +60,8 @@ extern void BattleSong (BOOLEAN DoPlay); extern void FreeBattleSong (void); +#if defined(__cplusplus) +} +#endif + #endif /* _BATTLE_H */ Modified: trunk/sc2/src/uqm/battlecontrols.h =================================================================== --- trunk/sc2/src/uqm/battlecontrols.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/battlecontrols.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -30,6 +30,10 @@ #include "races.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef BATTLE_INPUT_STATE (*BattleFrameInputFunction) ( InputContext *context, STARSHIP *StarShipPtr); typedef BOOLEAN (*SelectShipFunction) (InputContext *context, @@ -88,6 +92,10 @@ // Call InputContext->handlers->freeContext() to release an // InputContext. +#if defined(__cplusplus) +} +#endif + #endif /* _BATTLECONTROLS_H */ Modified: trunk/sc2/src/uqm/build.h =================================================================== --- trunk/sc2/src/uqm/build.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/build.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "displist.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define NAME_OFFSET 5 #define NUM_CAPTAINS_NAMES 16 @@ -60,5 +64,9 @@ extern void free_ship (RACE_DESC *RaceDescPtr, BOOLEAN FreeIconData, BOOLEAN FreeBattleData); +#if defined(__cplusplus) +} +#endif + #endif /* _BUILD_H */ Modified: trunk/sc2/src/uqm/clock.h =================================================================== --- trunk/sc2/src/uqm/clock.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/clock.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -22,7 +22,11 @@ #include "libs/tasklib.h" #include "displist.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define START_YEAR 2155 #define UPDATE_DAY (1 << 0) @@ -100,5 +104,9 @@ // but not much else extern BOOLEAN GameClockRunning (void); +#if defined(__cplusplus) +} +#endif + #endif /* _CLOCK_H */ Modified: trunk/sc2/src/uqm/cnctdlg.h =================================================================== --- trunk/sc2/src/uqm/cnctdlg.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/cnctdlg.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -16,16 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef NETPLAY - #ifndef _CNCTDLG_H #define _CNCTDLG_H +#ifdef NETPLAY + #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + BOOLEAN MeleeConnectDialog (int side); -#endif /* _CNCTDLG_H */ +#if defined(__cplusplus) +} +#endif #endif /* NETPLAY */ +#endif /* _CNCTDLG_H */ Modified: trunk/sc2/src/uqm/coderes.h =================================================================== --- trunk/sc2/src/uqm/coderes.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/coderes.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN InstallCodeResType (void); extern void *LoadCodeResInstance (RESOURCE res); extern void *CaptureCodeRes (void *hCode, void *pData, void **ppLocData); @@ -32,5 +36,9 @@ UWORD size; } CODE_REF; +#if defined(__cplusplus) +} +#endif + #endif /* _CODERES_H */ Modified: trunk/sc2/src/uqm/collide.h =================================================================== --- trunk/sc2/src/uqm/collide.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/collide.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "element.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define COLLISION_TURN_WAIT 1 #define COLLISION_THRUST_WAIT 3 @@ -59,5 +63,9 @@ extern void collide (ELEMENT *ElementPtr0, ELEMENT *ElementPtr1); +#if defined(__cplusplus) +} +#endif + #endif /* _COLLIDE_H */ Modified: trunk/sc2/src/uqm/comm.h =================================================================== --- trunk/sc2/src/uqm/comm.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/comm.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -31,6 +31,10 @@ #include "commanim.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern LOCDATA CommData; static inline BOOLEAN @@ -131,6 +135,10 @@ extern void EnableTalkingAnim (BOOLEAN enable); +#if defined(__cplusplus) +} +#endif + #endif /* _COMM_H */ Modified: trunk/sc2/src/uqm/commanim.h =================================================================== --- trunk/sc2/src/uqm/commanim.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/commanim.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,10 @@ #include "libs/compiler.h" #include "libs/gfxlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + // Some background: every animation has a neutral frame which returns // the image to the state it was in before the animation began. Which // frame is neutral depends on the animation type. @@ -130,6 +134,10 @@ extern void InitCommAnimations (void); extern BOOLEAN ProcessCommAnimations (BOOLEAN fullRedraw, BOOLEAN paused); +#if defined(__cplusplus) +} +#endif + #endif /* _COMMANIM_H */ Modified: trunk/sc2/src/uqm/commglue.h =================================================================== --- trunk/sc2/src/uqm/commglue.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/commglue.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "resinst.h" #include "libs/sound/trackplayer.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef enum { ARILOU_CONVERSATION, CHMMR_CONVERSATION, @@ -154,5 +158,9 @@ extern LOCDATA* init_umgah_comm (void); +#if defined(__cplusplus) +} +#endif + #endif /* _COMMGLUE_H */ Modified: trunk/sc2/src/uqm/cons_res.h =================================================================== --- trunk/sc2/src/uqm/cons_res.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/cons_res.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,10 @@ #include "libs/gfxlib.h" #include "libs/sndlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + void load_gravity_well (BYTE selector); void free_gravity_well (void); @@ -27,4 +31,8 @@ MUSIC_REF load_orbit_theme (BYTE selector); +#if defined(__cplusplus) +} +#endif + #endif /* CONS_RES_H_ */ Modified: trunk/sc2/src/uqm/controls.h =================================================================== --- trunk/sc2/src/uqm/controls.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/controls.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "libs/strlib.h" #include "libs/timelib.h" +#if defined(__cplusplus) +extern "C" { +#endif + // Enumerated type for controls enum { KEY_UP, @@ -162,6 +166,10 @@ extern BOOLEAN DoTextEntry (TEXTENTRY_STATE *pTES); +#if defined(__cplusplus) +} #endif +#endif + Modified: trunk/sc2/src/uqm/credits.h =================================================================== --- trunk/sc2/src/uqm/credits.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/credits.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,7 +19,15 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void Credits (BOOLEAN WithOuttakes); +#if defined(__cplusplus) +} +#endif + #endif /* _CREDITS_H */ Modified: trunk/sc2/src/uqm/demo.h =================================================================== --- trunk/sc2/src/uqm/demo.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/demo.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,6 +19,10 @@ #ifndef _DEMO_H #define _DEMO_H +#if defined(__cplusplus) +extern "C" { +#endif + #ifndef DEMO_MODE #define DEMO_MODE 0 #endif /* DEMO_MODE */ @@ -44,5 +48,9 @@ #endif +#if defined(__cplusplus) +} +#endif + #endif /* _DEMO_H */ Modified: trunk/sc2/src/uqm/displist.h =================================================================== --- trunk/sc2/src/uqm/displist.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/displist.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,6 +24,10 @@ #include "libs/compiler.h" #include "libs/memlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + // Note that we MUST use the QUEUE_TABLE variant at this time, because // certain gameplay elements depend on it. Namely, the maximum number // of HyperSpace encounter globes chasing the player is defined by the @@ -120,5 +124,9 @@ extern COUNT CountLinks (QUEUE *pq); void ForAllLinks(QUEUE *pq, void (*callback)(LINK *, void *), void *arg); +#if defined(__cplusplus) +} +#endif + #endif /* _DISPLIST_H */ Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/element.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,7 +24,11 @@ #include "velocity.h" #include "libs/gfxlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define NORMAL_LIFE 1 typedef HLINK HELEMENT; @@ -230,5 +234,9 @@ extern BOOLEAN CalculateGravity (ELEMENT *ElementPtr); +#if defined(__cplusplus) +} +#endif + #endif /* _ELEMENT_H */ Modified: trunk/sc2/src/uqm/encount.h =================================================================== --- trunk/sc2/src/uqm/encount.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/encount.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -30,7 +30,11 @@ #include "element.h" #include "races.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef HLINK HENCOUNTER; #define MAX_HYPER_SHIPS 7 @@ -190,5 +194,9 @@ extern SIZE EncounterRace; extern BYTE EncounterGroup; +#if defined(__cplusplus) +} +#endif + #endif /* _ENCOUNT_H */ Modified: trunk/sc2/src/uqm/flash.h =================================================================== --- trunk/sc2/src/uqm/flash.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/flash.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -90,6 +90,10 @@ #include "libs/gfxlib.h" #include "libs/timelib.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef enum { FlashState_fadeIn = 0, // Someway between on and off, going towards on. @@ -211,5 +215,9 @@ COUNT Flash_getCacheSize (const FlashContext *context); +#if defined(__cplusplus) +} +#endif + #endif /* _FLASH_H */ Modified: trunk/sc2/src/uqm/fmv.h =================================================================== --- trunk/sc2/src/uqm/fmv.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/fmv.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,11 @@ #include "libs/compiler.h" #include "libs/sndlib.h" #include "libs/gfxlib.h" + +#if defined(__cplusplus) +extern "C" { +#endif + #define WANT_SHIP_SPINS extern void SplashScreen (void (* DoProcessing)(DWORD TimeOut)); @@ -29,5 +34,9 @@ extern BOOLEAN ShowPresentation (RESOURCE presentation); +#if defined(__cplusplus) +} +#endif + #endif /* _FMV_H */ Modified: trunk/sc2/src/uqm/gameev.h =================================================================== --- trunk/sc2/src/uqm/gameev.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/gameev.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,7 +20,11 @@ #include "libs/compiler.h" #include "libs/gfxlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + enum { ARILOU_ENTRANCE_EVENT = 0, @@ -57,5 +61,9 @@ BYTE func_index); +#if defined(__cplusplus) +} +#endif + #endif /* _GAMEEV_H */ Modified: trunk/sc2/src/uqm/gameopt.h =================================================================== --- trunk/sc2/src/uqm/gameopt.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/gameopt.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,11 +19,19 @@ #include "libs/compiler.h" #include "libs/gfxlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void ConfirmSaveLoad (STAMP *MsgStamp); extern BOOLEAN GameOptions (void); typedef void (NamingCallback) (void); extern void SetNamingCallback (NamingCallback *); +#if defined(__cplusplus) +} +#endif + #endif /* _GAMEOPT_H */ Modified: trunk/sc2/src/uqm/gamestr.h =================================================================== --- trunk/sc2/src/uqm/gamestr.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/gamestr.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -25,6 +25,10 @@ #include "libs/strlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define STAR_STRING_COUNT 133 #define DEVICE_STRING_COUNT 29 #define CARGO_STRING_COUNT 10 @@ -82,5 +86,9 @@ +#if defined(__cplusplus) +} +#endif + #endif /* _GAMESTR_H */ Modified: trunk/sc2/src/uqm/gendef.h =================================================================== --- trunk/sc2/src/uqm/gendef.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/gendef.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -4,7 +4,15 @@ #include "planets/generate.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + const GenerateFunctions *getGenerateFunctions (BYTE Index); +#if defined(__cplusplus) +} +#endif + #endif /* GENDEF_H */ Modified: trunk/sc2/src/uqm/globdata.h =================================================================== --- trunk/sc2/src/uqm/globdata.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/globdata.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -27,7 +27,11 @@ #include "velocity.h" #include "commanim.h" +#if defined(__cplusplus) +extern "C" { +#endif + // general numbers-speech generator info // should accomodate most common base-10 languages // many languages require various plural forms @@ -1010,5 +1014,9 @@ extern BOOLEAN InitGameStructures (void); extern void UninitGameStructures (void); +#if defined(__cplusplus) +} +#endif + #endif /* _GLOBDATA_H */ Modified: trunk/sc2/src/uqm/grpinfo.h =================================================================== --- trunk/sc2/src/uqm/grpinfo.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/grpinfo.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,6 +24,10 @@ // for POINT #include <assert.h> +#if defined(__cplusplus) +extern "C" { +#endif + // XXX: Needed to maintain savegame compatibility #define NUM_SAVED_BATTLE_GROUPS 64 @@ -82,4 +86,8 @@ extern HIPGROUP BuildGroup (QUEUE *pDstQueue, BYTE race_id); +#if defined(__cplusplus) +} +#endif + #endif /* _GRPINFO_H */ Modified: trunk/sc2/src/uqm/hyper.h =================================================================== --- trunk/sc2/src/uqm/hyper.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/hyper.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "units.h" // for UNIT_SCREEN_WIDTH/HEIGHT +#if defined(__cplusplus) +extern "C" { +#endif + #define NUM_RADAR_SCREENS 12 #define RADAR_SCAN_WIDTH (UNIT_SCREEN_WIDTH * NUM_RADAR_SCREENS) @@ -79,5 +83,9 @@ extern void HyperspaceMenu (void); extern void SaveSisHyperState (void); +#if defined(__cplusplus) +} +#endif + #endif /* _HYPER_H */ Modified: trunk/sc2/src/uqm/init.h =================================================================== --- trunk/sc2/src/uqm/init.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/init.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,10 @@ #include "libs/gfxlib.h" #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define NUM_PLAYERS 2 #define NUM_SIDES 2 @@ -35,5 +39,9 @@ RESOURCE med_res, RESOURCE sml_res); extern BOOLEAN free_image (FRAME *pixarray); +#if defined(__cplusplus) +} +#endif + #endif /* _INIT_H */ Modified: trunk/sc2/src/uqm/intel.h =================================================================== --- trunk/sc2/src/uqm/intel.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/intel.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,6 +24,10 @@ #include "element.h" #include "races.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define MANEUVERABILITY(pi) ((pi)->ManeuverabilityIndex) #define WEAPON_RANGE(pi) ((pi)->WeaponRange) @@ -74,6 +78,10 @@ #define AWESOME_RATING (BYTE)(1 << 6) +#if defined(__cplusplus) +} +#endif + #endif /* _INTEL_H */ Modified: trunk/sc2/src/uqm/ipdisp.h =================================================================== --- trunk/sc2/src/uqm/ipdisp.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ipdisp.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,6 +19,10 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void NotifyOthers (COUNT which_race, BYTE target_loc); // Special target locations for NotifyOthers() #define IPNL_INTERCEPT_PLAYER 0 @@ -26,4 +30,8 @@ extern void DoMissions (void); +#if defined(__cplusplus) +} +#endif + #endif /* UQM_IPDISP_H_INCL_ */ Modified: trunk/sc2/src/uqm/load.h =================================================================== --- trunk/sc2/src/uqm/load.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/load.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -22,10 +22,18 @@ #include "libs/compiler.h" #include "globdata.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern ACTIVITY NextActivity; extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc); +#if defined(__cplusplus) +} +#endif + #endif /* _LOAD_H */ Modified: trunk/sc2/src/uqm/master.h =================================================================== --- trunk/sc2/src/uqm/master.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/master.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,10 @@ #include "races.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef HLINK HMASTERSHIP; typedef struct @@ -58,5 +62,9 @@ FRAME GetShipIconsFromIndex (unsigned Index); FRAME GetShipMeleeIconsFromIndex (unsigned Index); +#if defined(__cplusplus) +} +#endif + #endif /* _MASTER_H */ Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/menustat.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "libs/sndlib.h" #include "flash.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef struct menu_state { // Standard field required by DoInput() @@ -120,5 +124,9 @@ extern BOOLEAN DoMenuChooser (MENU_STATE *pMS, BYTE BaseState); extern void DrawMenuStateStrings (BYTE beg_index, SWORD NewState); +#if defined(__cplusplus) +} +#endif + #endif /* _MENUSTAT_H */ Modified: trunk/sc2/src/uqm/oscill.h =================================================================== --- trunk/sc2/src/uqm/oscill.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/oscill.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,6 +20,10 @@ #include "libs/compiler.h" #include "libs/gfxlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN sliderDisabled; extern BOOLEAN oscillDisabled; @@ -32,5 +36,9 @@ extern void SetSliderImage (FRAME f); void DrawSlider (void); +#if defined(__cplusplus) +} +#endif + #endif /* _OSCILL_H */ Modified: trunk/sc2/src/uqm/pickship.h =================================================================== --- trunk/sc2/src/uqm/pickship.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/pickship.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -20,8 +20,16 @@ #include "libs/compiler.h" #include "races.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern HSTARSHIP GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player); extern void DrawArmadaPickShip (BOOLEAN draw_salvage_frame, RECT *pPickRect); +#if defined(__cplusplus) +} +#endif + #endif /* UQM_PICKSHIP_H_INCL_ */ Modified: trunk/sc2/src/uqm/planets/elemdata.h =================================================================== --- trunk/sc2/src/uqm/planets/elemdata.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/elemdata.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,9 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif /*------------------------------ Type Defines ----------------------------- */ enum @@ -205,5 +208,9 @@ extern const BYTE *Elements; +#if defined(__cplusplus) +} +#endif + #endif /* _ELEMDATA_H */ Modified: trunk/sc2/src/uqm/planets/generate/gendefault.h =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "../planets.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + bool GenerateDefault_initNpcs (SOLARSYS_STATE *solarSys); bool GenerateDefault_reinitNpcs (SOLARSYS_STATE *solarSys); bool GenerateDefault_uninitNpcs (SOLARSYS_STATE *solarSys); @@ -52,5 +56,9 @@ extern const GenerateFunctions generateDefaultFunctions; +#if defined(__cplusplus) +} +#endif + #endif /* GENDEFAULT_H */ Modified: trunk/sc2/src/uqm/planets/generate.h =================================================================== --- trunk/sc2/src/uqm/planets/generate.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/generate.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -23,6 +23,10 @@ #include "planets.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* * To do (for further cleanups): * - split off generateOrbital in a calculation and an activation @@ -98,6 +102,9 @@ PickupLifeFunction pickupLife; }; +#if defined(__cplusplus) +} +#endif #endif /* GENERATE_H */ Modified: trunk/sc2/src/uqm/planets/lander.h =================================================================== --- trunk/sc2/src/uqm/planets/lander.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/lander.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,6 +26,9 @@ #include "libs/timelib.h" #include "../element.h" +#if defined(__cplusplus) +extern "C" { +#endif // Surface magnification shift (x4) #define MAG_SHIFT 2 @@ -76,5 +79,9 @@ PS_NON_PLAYER, }; +#if defined(__cplusplus) +} +#endif + #endif /* _LANDER_H */ Modified: trunk/sc2/src/uqm/planets/lifeform.h =================================================================== --- trunk/sc2/src/uqm/planets/lifeform.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/lifeform.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,9 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif #define BEHAVIOR_HUNT (0 << 0) #define BEHAVIOR_FLEE (1 << 0) @@ -65,5 +68,9 @@ extern const LIFEFORM_DESC CreatureData[]; +#if defined(__cplusplus) +} +#endif + #endif /* _LIFEFORM_H */ Modified: trunk/sc2/src/uqm/planets/plandata.h =================================================================== --- trunk/sc2/src/uqm/planets/plandata.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/plandata.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,9 @@ #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif /*------------------------------ Type Defines ----------------------------- */ #define NUMBER_OF_ORBITS 16 @@ -328,5 +331,9 @@ extern const PlanetFrame *PlanData; +#if defined(__cplusplus) +} +#endif + #endif /* _PLANDATA_H */ Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/planets.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -99,6 +99,9 @@ #include "plandata.h" #include "sundata.h" +#if defined(__cplusplus) +extern "C" { +#endif struct planet_desc { @@ -286,5 +289,9 @@ extern void PlanetOrbitMenu (void); extern void SaveSolarSysLocation (void); +#if defined(__cplusplus) +} +#endif + #endif /* _PLANETS_H */ Modified: trunk/sc2/src/uqm/planets/scan.h =================================================================== --- trunk/sc2/src/uqm/planets/scan.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/scan.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -26,6 +26,9 @@ #include "libs/gfxlib.h" #include "planets.h" +#if defined(__cplusplus) +extern "C" { +#endif struct scan_desc { @@ -62,5 +65,9 @@ void setNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr); void setNodeNotRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr); +#if defined(__cplusplus) +} +#endif + #endif /* _SCAN_H */ Modified: trunk/sc2/src/uqm/planets/sundata.h =================================================================== --- trunk/sc2/src/uqm/planets/sundata.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/planets/sundata.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -22,6 +22,9 @@ #include "plandata.h" #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif /*------------------------------ Global Data ------------------------------ */ @@ -58,5 +61,9 @@ extern SYSTEM_INFO CurSysInfo; +#if defined(__cplusplus) +} +#endif + #endif /* _SUNDATA_H */ Modified: trunk/sc2/src/uqm/process.h =================================================================== --- trunk/sc2/src/uqm/process.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/process.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,9 +21,17 @@ #include "libs/gfxlib.h" #include "element.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void RedrawQueue (BOOLEAN clear); extern void InitDisplayList (void); extern void SetUpElement (ELEMENT *ElementPtr); extern void InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI); +#if defined(__cplusplus) +} +#endif + #endif /* UQM_PROCESS_H_INCL_ */ Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/races.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -31,7 +31,11 @@ #include "libs/sndlib.h" #include "libs/reslib.h" +#if defined(__cplusplus) +extern "C" { +#endif + // TODO: remove RACES_PER_PLAYER remnant of SC1 #define RACES_PER_PLAYER 7 #define MAX_SHIPS_PER_SIDE 14 @@ -664,5 +668,9 @@ BUILD_COLOR (MAKE_RGB15_INIT (0x06, 0x06, 0x06), 0x20), /* BLACK_URQUAN_SHIP */ \ BUILD_COLOR (MAKE_RGB15_INIT (0x14, 0x07, 0x1F), 0x39), /* YEHAT_REBEL_SHIP */ +#if defined(__cplusplus) +} +#endif + #endif /* _RACES_H */ Modified: trunk/sc2/src/uqm/restart.h =================================================================== --- trunk/sc2/src/uqm/restart.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/restart.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,8 +19,16 @@ #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN StartGame (void); +#if defined(__cplusplus) +} +#endif + #endif /* _RESTART_H */ Modified: trunk/sc2/src/uqm/save.h =================================================================== --- trunk/sc2/src/uqm/save.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/save.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,8 +21,16 @@ // for SUMMARY_DESC #include "libs/compiler.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void SaveProblem (void); extern BOOLEAN SaveGame (COUNT which_game, SUMMARY_DESC *summary_desc); +#if defined(__cplusplus) +} +#endif + #endif /* _SAVE_H */ Modified: trunk/sc2/src/uqm/settings.h =================================================================== --- trunk/sc2/src/uqm/settings.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/settings.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -19,6 +19,10 @@ #include "libs/sndlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern void ToggleMusic (void); extern void StopMusic (void); extern void ResumeMusic (void); @@ -30,5 +34,9 @@ void *PositionalObject, BYTE Priority); +#if defined(__cplusplus) +} +#endif + #endif /* _SETTINGS_H */ Modified: trunk/sc2/src/uqm/setup.h =================================================================== --- trunk/sc2/src/uqm/setup.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/setup.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -24,6 +24,10 @@ #include "libs/gfxlib.h" #include "libs/threadlib.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern RESOURCE_INDEX hResIndex; extern FRAME Screen; @@ -79,6 +83,10 @@ void ClearPlayerInputAll (void); +#if defined(__cplusplus) +} +#endif + #endif /* _SETUP_H */ Modified: trunk/sc2/src/uqm/setupmenu.h =================================================================== --- trunk/sc2/src/uqm/setupmenu.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/setupmenu.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "controls.h" +#if defined(__cplusplus) +extern "C" { +#endif + typedef enum { OPTVAL_DISABLED, OPTVAL_ENABLED @@ -88,4 +92,8 @@ void GetGlobalOptions (GLOBALOPTS *opts); void SetGlobalOptions (GLOBALOPTS *opts); +#if defined(__cplusplus) +} +#endif + #endif // _SETUPMENU_H Modified: trunk/sc2/src/uqm/ship.h =================================================================== --- trunk/sc2/src/uqm/ship.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ship.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "races.h" #include "element.h" +#if defined(__cplusplus) +extern "C" { +#endif + extern BOOLEAN GetNextStarShip (STARSHIP *LastStarShipPtr, COUNT which_side); extern BOOLEAN GetInitialStarShips (void); @@ -32,4 +36,8 @@ extern STATUS_FLAGS inertial_thrust (ELEMENT *ElementPtr); +#if defined(__cplusplus) +} +#endif + #endif /* UQM_SHIP_H_INCL_ */ Modified: trunk/sc2/src/uqm/shipcont.h =================================================================== --- trunk/sc2/src/uqm/shipcont.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/shipcont.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -21,6 +21,10 @@ #include "menustat.h" +#if defined(__cplusplus) +extern "C" { +#endif + #define FIELD_WIDTH (STATUS_WIDTH - 5) extern void CargoMenu (void); @@ -33,5 +37,9 @@ extern SIZE InventoryDevices (BYTE *pDeviceMap, COUNT Size); +#if defined(__cplusplus) +} +#endif + #endif /* _SHIPCONT_H */ Modified: trunk/sc2/src/uqm/ships/androsyn/androsyn.h =================================================================== --- trunk/sc2/src/uqm/ships/androsyn/androsyn.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/androsyn/androsyn.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef ANDROSYN_H #define ANDROSYN_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_androsynth (void); +#if defined(__cplusplus) +} +#endif + #endif /* ANDROSYN_H */ Modified: trunk/sc2/src/uqm/ships/arilou/arilou.h =================================================================== --- trunk/sc2/src/uqm/ships/arilou/arilou.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/arilou/arilou.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef ARILOU_H #define ARILOU_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_arilou (void); +#if defined(__cplusplus) +} +#endif + #endif /* ARILOU_H */ Modified: trunk/sc2/src/uqm/ships/blackurq/blackurq.h =================================================================== --- trunk/sc2/src/uqm/ships/blackurq/blackurq.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/blackurq/blackurq.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef BLACKURQ_H #define BLACKURQ_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_black_urquan (void); +#if defined(__cplusplus) +} +#endif + #endif /* BLACKURQ_H */ Modified: trunk/sc2/src/uqm/ships/chenjesu/chenjesu.h =================================================================== --- trunk/sc2/src/uqm/ships/chenjesu/chenjesu.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/chenjesu/chenjesu.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef CHENJESU_H #define CHENJESU_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_chenjesu (void); +#if defined(__cplusplus) +} +#endif + #endif /* CHENJESU_H */ Modified: trunk/sc2/src/uqm/ships/chmmr/chmmr.h =================================================================== --- trunk/sc2/src/uqm/ships/chmmr/chmmr.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/chmmr/chmmr.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef CHMMR_H #define CHMMR_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_chmmr (void); +#if defined(__cplusplus) +} +#endif + #endif /* CHMMR_H */ Modified: trunk/sc2/src/uqm/ships/druuge/druuge.h =================================================================== --- trunk/sc2/src/uqm/ships/druuge/druuge.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/druuge/druuge.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef DRUUGE_H #define DRUUGE_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_druuge (void); +#if defined(__cplusplus) +} +#endif + #endif /* DRUUGE_H */ Modified: trunk/sc2/src/uqm/ships/human/human.h =================================================================== --- trunk/sc2/src/uqm/ships/human/human.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/human/human.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef HUMAN_H #define HUMAN_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_human (void); +#if defined(__cplusplus) +} +#endif + #endif /* HUMAN_H */ Modified: trunk/sc2/src/uqm/ships/ilwrath/ilwrath.h =================================================================== --- trunk/sc2/src/uqm/ships/ilwrath/ilwrath.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/ilwrath/ilwrath.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef ILWRATH_H #define ILWRATH_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_ilwrath (void); +#if defined(__cplusplus) +} +#endif + #endif /* ILWRATH_H */ Modified: trunk/sc2/src/uqm/ships/lastbat/lastbat.h =================================================================== --- trunk/sc2/src/uqm/ships/lastbat/lastbat.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/lastbat/lastbat.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef LASTBAT_H #define LASTBAT_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_samatra (void); +#if defined(__cplusplus) +} +#endif + #endif /* LASTBAT_H */ Modified: trunk/sc2/src/uqm/ships/melnorme/melnorme.h =================================================================== --- trunk/sc2/src/uqm/ships/melnorme/melnorme.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/melnorme/melnorme.h 2011-07-24 19:58:25 UTC (rev 3663) @@ -17,7 +17,15 @@ #ifndef MELNORME_H #define MELNORME_H +#if defined(__cplusplus) +extern "C" { +#endif + RACE_DESC *init_melnorme (void); +#if defined(__cplusplus) +} +#endif + #endif /* MELNORME_H */ Modified: trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.h =================================================================== --- trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.h 2011-07-24 19:03:42 UTC (rev 3662) +++ trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.h 2011-07-24 19:58:25 UTC ... [truncated message content] |
From: <Mee...@us...> - 2011-07-24 19:03:48
|
Revision: 3662 http://sc2.svn.sourceforge.net/sc2/?rev=3662&view=rev Author: Meep-Eep Date: 2011-07-24 19:03:42 +0000 (Sun, 24 Jul 2011) Log Message: ----------- Socket functions needed when we switch to UDP. Modified Paths: -------------- trunk/sc2/src/libs/network/socket/socket.h trunk/sc2/src/libs/network/socket/socket_bsd.c trunk/sc2/src/libs/network/socket/socket_win.c Modified: trunk/sc2/src/libs/network/socket/socket.h =================================================================== --- trunk/sc2/src/libs/network/socket/socket.h 2011-07-23 16:55:21 UTC (rev 3661) +++ trunk/sc2/src/libs/network/socket/socket.h 2011-07-24 19:03:42 UTC (rev 3662) @@ -80,7 +80,11 @@ int Socket_listen(Socket *sock, int backlog); Socket *Socket_accept(Socket *sock, struct sockaddr *addr, socklen_t *addrLen); ssize_t Socket_send(Socket *sock, const void *buf, size_t len, int flags); +ssize_t Socket_sendto(Socket *sock, const void *buf, size_t len, int flags, + const struct sockaddr *addr, socklen_t addrLen); ssize_t Socket_recv(Socket *sock, void *buf, size_t len, int flags); +ssize_t Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags, + struct sockaddr *from, socklen_t *fromLen); int Socket_setNonBlocking(Socket *sock); int Socket_setReuseAddr(Socket *sock); Modified: trunk/sc2/src/libs/network/socket/socket_bsd.c =================================================================== --- trunk/sc2/src/libs/network/socket/socket_bsd.c 2011-07-23 16:55:21 UTC (rev 3661) +++ trunk/sc2/src/libs/network/socket/socket_bsd.c 2011-07-24 19:03:42 UTC (rev 3662) @@ -130,10 +130,22 @@ } ssize_t +Socket_sendto(Socket *sock, const void *buf, size_t len, int flags, + const struct sockaddr *addr, socklen_t addrLen) { + return sendto(sock->fd, buf, len, flags, addr, addrLen); +} + +ssize_t Socket_recv(Socket *sock, void *buf, size_t len, int flags) { return recv(sock->fd, buf, len, flags); } +ssize_t +Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags, + struct sockaddr *from, socklen_t *fromLen) { + return recvfrom(sock->fd, buf, len, flags, from, fromLen); +} + int Socket_setNonBlocking(Socket *sock) { int flags; Modified: trunk/sc2/src/libs/network/socket/socket_win.c =================================================================== --- trunk/sc2/src/libs/network/socket/socket_win.c 2011-07-23 16:55:21 UTC (rev 3661) +++ trunk/sc2/src/libs/network/socket/socket_win.c 2011-07-24 19:03:42 UTC (rev 3662) @@ -160,6 +160,20 @@ } ssize_t +Socket_sendto(Socket *sock, const void *buf, size_t len, int flags, + const struct sockaddr *addr, socklen_t addrLen) { + int sendResult; + + sendResult = sendto(sock->sock, buf, len, flags, addr, addrLen); + if (sendResult == SOCKET_ERROR) { + errno = getWinsockErrno(); + return -1; + } + + return sendResult; +} + +ssize_t Socket_recv(Socket *sock, void *buf, size_t len, int flags) { int recvResult; @@ -172,6 +186,20 @@ return recvResult; } +ssize_t +Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags, + struct sockaddr *from, socklen_t *fromLen) { + int recvResult; + + recvResult = recvfrom(sock->sock, buf, len, flags, from, fromLen); + if (recvResult == SOCKET_ERROR) { + errno = getWinsockErrno(); + return -1; + } + + return recvResult; +} + int Socket_setNonBlocking(Socket *sock) { unsigned long flag = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-07-23 16:55:27
|
Revision: 3661 http://sc2.svn.sourceforge.net/sc2/?rev=3661&view=rev Author: avolkov Date: 2011-07-23 16:55:21 +0000 (Sat, 23 Jul 2011) Log Message: ----------- Remove 'uqm-wrapper' script in 'clean' subtarget; small comment fix; bug #1126 Modified Paths: -------------- trunk/sc2/build/unix/build.config trunk/sc2/build/unix/build_functions Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2011-07-23 16:31:20 UTC (rev 3660) +++ trunk/sc2/build/unix/build.config 2011-07-23 16:55:21 UTC (rev 3661) @@ -445,7 +445,7 @@ SUBSTITUTE_FILES="build.vars" substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES . "$BUILD_WORK" - # Make 'uqm' shell script from build.vars.in, substituting variables. + # Make 'uqm' shell script from uqm-wrapper.in, substituting variables. SUBSTITUTE_VARS="INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR uqm_NAME" SUBSTITUTE_FILES="uqm-wrapper" substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES build/unix "$BUILD_WORK" Modified: trunk/sc2/build/unix/build_functions =================================================================== --- trunk/sc2/build/unix/build_functions 2011-07-23 16:31:20 UTC (rev 3660) +++ trunk/sc2/build/unix/build_functions 2011-07-23 16:55:21 UTC (rev 3661) @@ -131,6 +131,7 @@ eval DEPEND_FILE="\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}${DEPEND_NAME}" rm -f "$DEPEND_FILE" "$BUILD_WORK/build.vars" \ + "$BUILD_WORK/uqm-wrapper" \ "$BUILD_WORK/config.state" eval "${TARGET}_clean" } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-07-23 16:31:26
|
Revision: 3660 http://sc2.svn.sourceforge.net/sc2/?rev=3660&view=rev Author: avolkov Date: 2011-07-23 16:31:20 +0000 (Sat, 23 Jul 2011) Log Message: ----------- Removed unused UQM_SVN_REVISION define which evidently confused some people Modified Paths: -------------- trunk/sc2/src/uqmversion.h Modified: trunk/sc2/src/uqmversion.h =================================================================== --- trunk/sc2/src/uqmversion.h 2011-07-20 19:02:32 UTC (rev 3659) +++ trunk/sc2/src/uqmversion.h 2011-07-23 16:31:20 UTC (rev 3660) @@ -33,6 +33,4 @@ UQM_MAJOR_VERSION_S "." UQM_MINOR_VERSION_S "." UQM_PATCH_VERSION_S \ UQM_EXTRA_VERSION -#define UQM_SVN_REVISION "$Revision$" - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-07-20 19:02:39
|
Revision: 3659 http://sc2.svn.sourceforge.net/sc2/?rev=3659&view=rev Author: avolkov Date: 2011-07-20 19:02:32 +0000 (Wed, 20 Jul 2011) Log Message: ----------- Fixed player's phrase leading to Tanaka's solitary vigil response so that the response made sense; the new phrase is a hybrid of DOS and 3DO versions; also some emphasis punctuation changes (tracks DOS and voice actor) Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/content/base/comm/shofixti/shofixti.txt Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-07-20 18:17:42 UTC (rev 3658) +++ trunk/sc2/ChangeLog 2011-07-20 19:02:32 UTC (rev 3659) @@ -1,4 +1,6 @@ Changes towards version 0.8: +- Fixed player's phrase leading to Tanaka's response about a solitary + vigil (bug #859) - Alex - Added the Ur-Quan to the list of starfaring races on which Commander Hayes provides info (bug #865) - Alex - Commander Hayes now advises the player correctly on the number of Modified: trunk/sc2/content/base/comm/shofixti/shofixti.txt =================================================================== --- trunk/sc2/content/base/comm/shofixti/shofixti.txt 2011-07-20 18:17:42 UTC (rev 3658) +++ trunk/sc2/content/base/comm/shofixti/shofixti.txt 2011-07-20 19:02:32 UTC (rev 3659) @@ -215,11 +215,11 @@ What might that be? #(need_you_for_duty) -Shofixti, I am now your new commander. I order you not to kill yourself. You are to remain here and guard your solar system. +Shofixti, I am now your new commander. I order you not to kill yourself. Instead, join our fleet. Fight with us! #(OK_WILL_BE_SENTRY) shofixti-033.ogg -To fight again? Against the Ur-Quan? -Yes. But no +To fight again? Against the UR-QUAN!? +YES!!... But no. I cannot leave my homeworld unguarded. I will remain here and keep a solitary vigil. Goodbye. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-07-20 18:17:49
|
Revision: 3658 http://sc2.svn.sourceforge.net/sc2/?rev=3658&view=rev Author: avolkov Date: 2011-07-20 18:17:42 +0000 (Wed, 20 Jul 2011) Log Message: ----------- Added the Ur-Quan to the Hayes' conversation options on the Hierarchy; the encompassing option changed to 'The Hierarchy and their battle thralls'; bug #865 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/content/addons/3dovoice/starbase/starbase.txt trunk/sc2/content/base/comm/starbase/starbase.txt trunk/sc2/src/uqm/comm/starbas/starbas.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-07-20 17:23:43 UTC (rev 3657) +++ trunk/sc2/ChangeLog 2011-07-20 18:17:42 UTC (rev 3658) @@ -1,4 +1,6 @@ Changes towards version 0.8: +- Added the Ur-Quan to the list of starfaring races on which Commander + Hayes provides info (bug #865) - Alex - Commander Hayes now advises the player correctly on the number of landers one needs (bug #1098) - Alex - All Sound Options are now preserved between visits to the setup menu. Modified: trunk/sc2/content/addons/3dovoice/starbase/starbase.txt =================================================================== --- trunk/sc2/content/addons/3dovoice/starbase/starbase.txt 2011-07-20 17:23:43 UTC (rev 3657) +++ trunk/sc2/content/addons/3dovoice/starbase/starbase.txt 2011-07-20 18:17:42 UTC (rev 3658) @@ -1324,7 +1324,7 @@ The members of the old Alliance. #(what_about_hierarchy) -The battle thralls in the Hierarchy. +The Hierarchy and their battle thralls. #(what_about_other) Were there any alien races who weren't in the War? Modified: trunk/sc2/content/base/comm/starbase/starbase.txt =================================================================== --- trunk/sc2/content/base/comm/starbase/starbase.txt 2011-07-20 17:23:43 UTC (rev 3657) +++ trunk/sc2/content/base/comm/starbase/starbase.txt 2011-07-20 18:17:42 UTC (rev 3658) @@ -1324,7 +1324,7 @@ The members of the old Alliance. #(what_about_hierarchy) -The battle thralls in the Hierarchy. +The Hierarchy and their battle thralls. #(what_about_other) Were there any alien races who weren't in the War? Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2011-07-20 17:23:43 UTC (rev 3657) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2011-07-20 18:17:42 UTC (rev 3658) @@ -302,6 +302,7 @@ #define HIERARCHY_ANDROSYNTH (1 << 3) #define HIERARCHY_ILWRATH (1 << 4) #define HIERARCHY_VUX (1 << 5) +#define HIERARCHY_URQUAN (1 << 6) static BYTE HierarchyMask = 0; if (PLAYER_SAID (R, what_about_hierarchy)) @@ -309,6 +310,11 @@ NPCPhrase (WHICH_HIERARCHY); HierarchyMask = 0; } + else if (PLAYER_SAID (R, urquan)) + { + NPCPhrase (ABOUT_URQUAN); + HierarchyMask |= HIERARCHY_URQUAN; + } else if (PLAYER_SAID (R, mycon)) { NPCPhrase (ABOUT_MYCON); @@ -340,6 +346,8 @@ HierarchyMask |= HIERARCHY_VUX; } + if (!(HierarchyMask & HIERARCHY_URQUAN)) + Response (urquan, HierarchyInfo); if (!(HierarchyMask & HIERARCHY_MYCON)) Response (mycon, HierarchyInfo); if (!(HierarchyMask & HIERARCHY_SPATHI)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |