64 bits fixes.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2306 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2006-04-10 02:37:16 +00:00
parent 3d92d1f0c7
commit 4ec86728bd
8 changed files with 53 additions and 40 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ typedef struct
EXTENDED_STAR_DESC SD;
long log_x, log_y;
SDWORD log_x, log_y;
} ENCOUNTER;
typedef ENCOUNTER *PENCOUNTER;
+19 -24
View File
@@ -258,9 +258,7 @@ DrawDescriptionString (PMENU_STATE pMS, COUNT which_string, COUNT state)
}
SetContextFont (Font);
// XXX: nasty hack; CurString may not be large enough to
// contain a pointer on some platforms
lf.pStr = ((GAME_DESC *)pMS->CurString)[rel_index];
lf.pStr = ((GAME_DESC *)pMS->Extra)[rel_index];
lf.CharCount = (COUNT)~0;
if (!(state & DDSHS_EDIT))
@@ -382,12 +380,10 @@ DoNaming (PMENU_STATE pMS)
// first_item.x - current cursor position
// first_item.y - must be set to 0; DrawDescriptionString()
// treats it as base index into array of strings
// supplied in CurString
// supplied in Extra
pMS->first_item.x = 0;
pMS->first_item.y = 0;
// XXX: nasty hack; CurString may not be large enough to
// contain a pointer on some platforms
pMS->CurString = (STRING)buf;
pMS->Extra = buf;
DrawDescriptionString (pMS, 0, DDSHS_EDIT);
LockMutex (GraphicsLock);
@@ -586,7 +582,7 @@ DrawCargo (COUNT redraw_state)
if (pLocMenuState->delta_item == SAVE_GAME)
s.frame = DecFrameIndex (s.frame);
DrawStamp (&s);
if (((SUMMARY_DESC *)pLocMenuState->CurString)
if (((SUMMARY_DESC *)pLocMenuState->Extra)
[pLocMenuState->CurState].year_index == 0)
return;
}
@@ -607,7 +603,7 @@ DrawCargo (COUNT redraw_state)
);
if (redraw_state == 2
|| (redraw_state == 1
/*&& !(((SUMMARY_DESC *)pLocMenuState->CurString)
/*&& !(((SUMMARY_DESC *)pLocMenuState->Extra)
[pLocMenuState->CurState].Flags & AFTER_BOMB_INSTALLED)*/))
{
s.origin.x = 7 + SUMMARY_X_OFFS - SUMMARY_SIDE_OFFS + 3;
@@ -945,7 +941,7 @@ DoPickGame (PMENU_STATE pMS)
BatchGraphics ();
Restart:
SetContext (SpaceContext);
LoadGameDescriptions ((SUMMARY_DESC *)pMS->CurString);
LoadGameDescriptions ((SUMMARY_DESC *)pMS->Extra);
DrawCargo (1);
pMS->Initialized = TRUE;
goto ChangeGameSelection;
@@ -973,7 +969,7 @@ Restart:
}
else if (PulsedInputState.key[KEY_MENU_SELECT])
{
pSD = &((SUMMARY_DESC *)pMS->CurString)[pMS->CurState];
pSD = &((SUMMARY_DESC *)pMS->Extra)[pMS->CurState];
prev_save = pMS->CurState;
if (pMS->delta_item == SAVE_GAME || pSD->year_index)
{
@@ -1076,24 +1072,24 @@ Restart:
LockMutex (GraphicsLock);
BatchGraphics ();
if (((SUMMARY_DESC *)pMS->CurString)[NewState].year_index != 0)
if (((SUMMARY_DESC *)pMS->Extra)[NewState].year_index != 0)
{
if (!(((SUMMARY_DESC *)pMS->CurString)[NewState].Flags
if (!(((SUMMARY_DESC *)pMS->Extra)[NewState].Flags
& AFTER_BOMB_INSTALLED))
{
if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].year_index == 0)
if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].year_index == 0)
DrawCargo (1);
else if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].Flags
else if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].Flags
& AFTER_BOMB_INSTALLED)
DrawCargo (2);
}
else if (((SUMMARY_DESC *)pMS->CurString)[pMS->CurState].year_index == 0)
else if (((SUMMARY_DESC *)pMS->Extra)[pMS->CurState].year_index == 0)
DrawCargo (3);
}
ChangeGameSelection:
pMS->CurState = NewState;
ShowSummary (&((SUMMARY_DESC *)pMS->CurString)[pMS->CurState]);
ShowSummary (&((SUMMARY_DESC *)pMS->Extra)[pMS->CurState]);
SetContextFont (TinyFont);
r.extent.width = 240;
@@ -1146,14 +1142,14 @@ ChangeGameSelection:
DrawRectangle (&r);
t.baseline.x = r.corner.x + 3;
if (((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index == 0)
if (((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].year_index == 0)
sprintf (buf, GAME_STRING (SAVEGAME_STRING_BASE + 3)); // "Empty Slot"
else
{
DateToString (buf2, sizeof buf2,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].month_index,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].day_index,
((SUMMARY_DESC *)pMS->CurString)[NewState - SHIFT + i].year_index);
((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].month_index,
((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].day_index,
((SUMMARY_DESC *)pMS->Extra)[NewState - SHIFT + i].year_index);
sprintf (buf, "%s %s", GAME_STRING (SAVEGAME_STRING_BASE + 4), buf2); // "Saved Game - Date:"
}
font_DrawText (&t);
@@ -1214,12 +1210,11 @@ PickGame (PMENU_STATE pMS)
DlgRect.extent.width = SIS_SCREEN_WIDTH;
DlgRect.extent.height = SIS_SCREEN_HEIGHT;
DlgStamp.frame = CaptureDrawable (LoadDisplayPixmap (
&DlgRect, (FRAME)0)
);
&DlgRect, (FRAME)0));
pMS->Initialized = FALSE;
pMS->InputFunc = DoPickGame;
pMS->CurString = (STRING)&desc_array[0];
pMS->Extra = desc_array;
UnlockMutex (GraphicsLock);
DoInput (pMS, TRUE);
+1 -1
View File
@@ -369,7 +369,7 @@ FreeHyperspace (void)
static void
ElementToUniverse (ELEMENTPTR ElementPtr, PPOINT pPt)
{
long log_x, log_y;
SDWORD log_x, log_y;
log_x = GLOBAL_SIS (log_x)
+ (ElementPtr->next.location.x - (LOG_SPACE_WIDTH >> 1));
+1 -1
View File
@@ -595,7 +595,7 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_Tra
sound_sample->callbacks = trackCBs;
sound_sample->num_buffers = 8;
sound_sample->buffer_tag = HCalloc (sizeof (TFB_SoundTag) * sound_sample->num_buffers);
sound_sample->buffer = HMalloc (sizeof (uint32) * sound_sample->num_buffers);
sound_sample->buffer = HMalloc (sizeof (audio_Object) * sound_sample->num_buffers);
audio_GenBuffers (sound_sample->num_buffers, sound_sample->buffer);
decoder = SoundDecoder_Load (contentDir, TrackName, 4096,
startTime, time_stamps[page_counter]);
+18 -2
View File
@@ -163,6 +163,20 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
return TRUE;
}
// Crude check for big-endian/little-endian incompatibilities.
// year_index is suitable as it's a multi-byte value within
// a specific recognisable range.
if (summary_desc->year_index < START_YEAR ||
summary_desc->year_index >= START_YEAR +
YEARS_TO_KOHRAH_VICTORY + 1 /* Utwig intervention */ +
1 /* time to destroy all races, plenty */)
{
fprintf (stderr, "Warning: Savegame corrupt or from an "
"an incompatible platform.\n");
res_CloseResFile (in_fp);
return FALSE;
}
GlobData.SIS_state = summary_desc->SS;
if ((fh = copen (in_fp, FILE_STREAM, STREAM_READ)) == 0)
@@ -187,7 +201,8 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
memset ((PBYTE)&GLOBAL (GameState[0]),
0, sizeof (GLOBAL (GameState)));
Activity = GLOBAL (CurrentActivity);
cread ((PBYTE)&GlobData.Game_state, sizeof (GlobData.Game_state), 1, fh);
cread ((PBYTE)&GlobData.Game_state, sizeof (GlobData.Game_state), 1,
fh);
NextActivity = GLOBAL (CurrentActivity);
GLOBAL (CurrentActivity) = Activity;
@@ -202,7 +217,8 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
// But if it does happen, it needs to be reset to 0, since on load
// the clock semaphore is gauranteed to be 0
if (GLOBAL (GameClock.TimeCounter) != 0)
fprintf (stderr, "Warning: Game clock wasn't stopped during save, Savegame may be corrupt!\n");
fprintf (stderr, "Warning: Game clock wasn't stopped during "
"save, Savegame may be corrupt!\n");
GLOBAL (GameClock.TimeCounter) = 0;
LoadShipQueue (fh, &GLOBAL (avail_race_q), FALSE);
+2
View File
@@ -43,6 +43,8 @@ typedef struct menu_state
FRAME flash_frame0, flash_frame1;
MUSIC_REF hMusic;
void *Extra;
} MENU_STATE;
typedef MENU_STATE *PMENU_STATE;
+1 -1
View File
@@ -198,7 +198,7 @@ enum
typedef struct
{
long log_x, log_y;
SDWORD log_x, log_y;
DWORD ResUnits;
+10 -10
View File
@@ -93,36 +93,36 @@ extern int ScreenHeight;
#define UNIT_SCREEN_HEIGHT 50
static inline COORD
logxToUniverse (long lx)
logxToUniverse (SDWORD lx)
{
return (COORD) ((lx * ((MAX_X_UNIVERSE + 1) >> 4)) * 10
/ ((long) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH));
/ ((SDWORD) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH));
}
#define LOGX_TO_UNIVERSE(lx) \
logxToUniverse (lx)
static inline COORD
logyToUniverse (long ly)
logyToUniverse (SDWORD ly)
{
return (COORD) (MAX_Y_UNIVERSE -
(COORD)(((long) (ly) * ((MAX_Y_UNIVERSE + 1) >> 4))
/ ((long) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT)));
(COORD)(((SDWORD) (ly) * ((MAX_Y_UNIVERSE + 1) >> 4))
/ ((SDWORD) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT)));
}
#define LOGY_TO_UNIVERSE(ly) \
logyToUniverse (ly)
static inline long
static inline SDWORD
universeToLogx (COORD ux)
{
return ((long) ux * ((long) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH)
return ((SDWORD) ux * ((SDWORD) ((LOG_SPACE_WIDTH) >> 4) * SECTOR_WIDTH)
+ ((((MAX_X_UNIVERSE + 1) >> 4) * 10) >> 1))
/ (((MAX_X_UNIVERSE + 1) >> 4) * 10);
}
#define UNIVERSE_TO_LOGX(ux) \
universeToLogx (ux)
static inline long
static inline SDWORD
universeToLogy (COORD uy)
{
return ((long) (MAX_Y_UNIVERSE - uy)
* ((long) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT)
return ((SDWORD) (MAX_Y_UNIVERSE - uy)
* ((SDWORD) ((LOG_SPACE_HEIGHT) >> 4) * SECTOR_HEIGHT)
+ (((MAX_Y_UNIVERSE + 1) >> 4) >> 1))
/ ((MAX_Y_UNIVERSE + 1) >> 4);
}