Reworked SuperMelee loading; new files loadmele.[ch].
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2817 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Changes towards version 0.7:
|
||||
- Reworked SuperMelee fleet loading (fixes bug #823) - SvdB
|
||||
- Fixed enemy ships getting recrewed between ecnounters in HyperSpace
|
||||
(bug #996) - Alex
|
||||
- Removed mouse_err.c since DoPopupWindow() is used now - SvdB
|
||||
|
||||
@@ -4112,6 +4112,14 @@ SOURCE=..\sc2code\load.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\loadmele.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\loadmele.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\loadship.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -4,7 +4,7 @@ uqm_CFILES="battle.c border.c build.c cleanup.c clock.c cnctdlg.c collide.c
|
||||
demo.c displist.c dummy.c encount.c flash.c fmv.c galaxy.c gameev.c
|
||||
gameinp.c gameopt.c gendef.c getchar.c globdata.c gravity.c
|
||||
gravwell.c grpinfo.c hyper.c init.c intel.c intro.c ipdisp.c
|
||||
load.c loadship.c master.c melee.c menu.c misc.c
|
||||
load.c loadmele.c loadship.c master.c melee.c menu.c misc.c
|
||||
oscill.c outfit.c pickmele.c pickship.c plandata.c process.c
|
||||
restart.c save.c settings.c setup.c setupmenu.c ship.c
|
||||
shipstat.c shipyard.c sis.c sounds.c starbase.c starcon.c
|
||||
|
||||
@@ -568,9 +568,10 @@ _GetFontData (uio_Stream *fp, DWORD length)
|
||||
goto err;
|
||||
|
||||
fontDir = CaptureDirEntryTable (LoadDirEntryTable (contentDir,
|
||||
_cur_resfile_name, ".", match_MATCH_SUBSTRING, &numDirEntries));
|
||||
_cur_resfile_name, ".", match_MATCH_SUBSTRING));
|
||||
if (fontDir == 0)
|
||||
goto err;
|
||||
numDirEntries = GetDirEntryTableCount (fontDir);
|
||||
|
||||
fontDirHandle = uio_openDirRelative (contentDir, _cur_resfile_name, 0);
|
||||
if (fontDirHandle == NULL)
|
||||
|
||||
@@ -105,8 +105,7 @@ typedef STRINGPTR DIRENTRYPTR;
|
||||
|
||||
|
||||
extern DIRENTRY_REF LoadDirEntryTable (uio_DirHandle *dirHandle,
|
||||
const char *path, const char *pattern, match_MatchType matchType,
|
||||
COUNT *pnum_entries);
|
||||
const char *path, const char *pattern, match_MatchType matchType);
|
||||
#define CaptureDirEntryTable CaptureStringTable
|
||||
#define ReleaseDirEntryTable ReleaseStringTable
|
||||
#define DestroyDirEntryTable DestroyStringTable
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
DIRENTRY_REF
|
||||
LoadDirEntryTable (uio_DirHandle *dirHandle, const char *path,
|
||||
const char *pattern, match_MatchType matchType, COUNT *pnum_entries)
|
||||
const char *pattern, match_MatchType matchType)
|
||||
{
|
||||
uio_DirList *dirList;
|
||||
COUNT num_entries, length;
|
||||
@@ -69,7 +69,6 @@ LoadDirEntryTable (uio_DirHandle *dirHandle, const char *path,
|
||||
|
||||
if (num_entries == 0) {
|
||||
uio_DirList_free(dirList);
|
||||
*pnum_entries = 0;
|
||||
return ((DIRENTRY_REF) 0);
|
||||
}
|
||||
|
||||
@@ -81,7 +80,6 @@ LoadDirEntryTable (uio_DirHandle *dirHandle, const char *path,
|
||||
{
|
||||
FreeStringTable (StringTable);
|
||||
uio_DirList_free(dirList);
|
||||
*pnum_entries = 0;
|
||||
return ((DIRENTRY_REF) 0);
|
||||
}
|
||||
lpST->StringCount = num_entries;
|
||||
@@ -102,7 +100,6 @@ LoadDirEntryTable (uio_DirHandle *dirHandle, const char *path,
|
||||
}
|
||||
|
||||
uio_DirList_free(dirList);
|
||||
*pnum_entries = num_entries;
|
||||
UnlockStringTable (StringTable);
|
||||
return ((DIRENTRY_REF) StringTable);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,834 @@
|
||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This file handles loading of teams, but the UI and the actual loading.
|
||||
|
||||
#include "melee.h"
|
||||
|
||||
#include "controls.h"
|
||||
#include "gameopt.h"
|
||||
#include "gamestr.h"
|
||||
#include "globdata.h"
|
||||
#include "master.h"
|
||||
#include "save.h"
|
||||
#include "setup.h"
|
||||
#include "sounds.h"
|
||||
#include "options.h"
|
||||
#include "libs/log.h"
|
||||
#include "libs/misc.h"
|
||||
|
||||
|
||||
#define LOAD_TEAM_NAME_TEXT_COLOR \
|
||||
BUILD_COLOR (MAKE_RGB15 (0x0F, 0x10, 0x1B), 0x00)
|
||||
#define LOAD_TEAM_NAME_TEXT_COLOR_HILITE \
|
||||
BUILD_COLOR (MAKE_RGB15 (0x17, 0x18, 0x1D), 0x00)
|
||||
|
||||
|
||||
#define LOAD_MELEE_BOX_WIDTH 34
|
||||
#define LOAD_MELEE_BOX_HEIGHT 34
|
||||
#define LOAD_MELEE_BOX_SPACE 1
|
||||
|
||||
|
||||
static void DrawFileStrings (MELEE_STATE *pMS);
|
||||
static bool FillFileView (MELEE_STATE *pMS);
|
||||
|
||||
|
||||
bool
|
||||
ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp)
|
||||
{
|
||||
int status;
|
||||
FleetShipIndex i;
|
||||
|
||||
status = ReadResFile (pTI, sizeof (*pTI), 1, load_fp);
|
||||
if (status != 1)
|
||||
return false;
|
||||
|
||||
// Sanity check on the entries.
|
||||
for (i = 0; i < MELEE_FLEET_SIZE; i++)
|
||||
{
|
||||
BYTE StarShip = pTI->ShipList[i];
|
||||
|
||||
if (StarShip == MELEE_NONE)
|
||||
continue;
|
||||
|
||||
if (StarShip >= NUM_MELEE_SHIPS)
|
||||
{
|
||||
log_add (log_Warning, "Invalid ship type in loaded team (index "
|
||||
"%d, ship type is %d, max valid is %d).",
|
||||
i, StarShip, NUM_MELEE_SHIPS - 1);
|
||||
pTI->ShipList[i] = MELEE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
LoadTeamImage (DIRENTRY DirEntry, TEAM_IMAGE *pTI)
|
||||
{
|
||||
const BYTE *fileName;
|
||||
uio_Stream *load_fp;
|
||||
bool status;
|
||||
|
||||
fileName = GetDirEntryAddress (DirEntry);
|
||||
load_fp = res_OpenResFile (meleeDir, (const char *) fileName, "rb");
|
||||
if (load_fp == 0)
|
||||
return false;
|
||||
|
||||
if (LengthResFile (load_fp) != sizeof (*pTI))
|
||||
status = false;
|
||||
else
|
||||
status = ReadTeamImage (pTI, load_fp);
|
||||
res_CloseResFile (load_fp);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#if 0 /* Not used */
|
||||
static void
|
||||
UnindexFleet (MELEE_STATE *pMS, COUNT index)
|
||||
{
|
||||
assert (index < pMS->load.numIndices);
|
||||
pMS->load.numIndices--;
|
||||
memmove (&pMS->load.entryIndices[index],
|
||||
&pMS->load.entryIndices[index + 1],
|
||||
(pMS->load.numIndices - index) * sizeof pMS->load.entryIndices[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
UnindexFleets (MELEE_STATE *pMS, COUNT index, COUNT count)
|
||||
{
|
||||
assert (index + count <= pMS->load.numIndices);
|
||||
|
||||
pMS->load.numIndices -= count;
|
||||
memmove (&pMS->load.entryIndices[index],
|
||||
&pMS->load.entryIndices[index + count],
|
||||
(pMS->load.numIndices - index) * sizeof pMS->load.entryIndices[0]);
|
||||
}
|
||||
|
||||
static bool
|
||||
GetFleetByIndex (MELEE_STATE *pMS, COUNT index, TEAM_IMAGE *result)
|
||||
{
|
||||
COUNT firstIndex;
|
||||
|
||||
if (index < pMS->load.preBuiltCount)
|
||||
{
|
||||
*result = pMS->load.preBuiltList[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
index -= pMS->load.preBuiltCount;
|
||||
firstIndex = index;
|
||||
|
||||
for ( ; index < pMS->load.numIndices; index++)
|
||||
{
|
||||
DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries,
|
||||
pMS->load.entryIndices[index]);
|
||||
if (LoadTeamImage (entry, result))
|
||||
break; // Success
|
||||
|
||||
{
|
||||
const BYTE *fileName;
|
||||
fileName = GetDirEntryAddress (entry);
|
||||
log_add (log_Warning, "Warning: File '%s' is not a valid "
|
||||
"SuperMelee team.", fileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (index != firstIndex)
|
||||
UnindexFleets (pMS, firstIndex, index - firstIndex);
|
||||
|
||||
return index < pMS->load.numIndices;
|
||||
}
|
||||
|
||||
// returns (COUNT) -1 if not found
|
||||
static COUNT
|
||||
GetFleetIndexByFileName (MELEE_STATE *pMS, const char *fileName)
|
||||
{
|
||||
COUNT index;
|
||||
|
||||
for (index = 0; index < pMS->load.numIndices; index++)
|
||||
{
|
||||
DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries,
|
||||
pMS->load.entryIndices[index]);
|
||||
const BYTE *entryName = GetDirEntryAddress (entry);
|
||||
|
||||
if (stricmp ((const char *) entryName, fileName) == 0)
|
||||
return pMS->load.preBuiltCount + index;
|
||||
}
|
||||
|
||||
return (COUNT) -1;
|
||||
}
|
||||
|
||||
// Auxiliary function for DrawFileStrings
|
||||
// If drawShips is set the ships themselves are drawn, in addition to the
|
||||
// fleet name and value; if not, only the fleet name and value are drawn.
|
||||
// If highlite is set the text is drawn in the color used for highlighting.
|
||||
static void
|
||||
DrawFileString (TEAM_IMAGE *pTI, POINT *origin, BOOLEAN drawShips,
|
||||
BOOLEAN highlite)
|
||||
{
|
||||
SetContextForeGroundColor (highlite ?
|
||||
LOAD_TEAM_NAME_TEXT_COLOR_HILITE : LOAD_TEAM_NAME_TEXT_COLOR);
|
||||
|
||||
// Print the name of the fleet
|
||||
{
|
||||
TEXT Text;
|
||||
|
||||
Text.baseline = *origin;
|
||||
Text.align = ALIGN_LEFT;
|
||||
Text.pStr = pTI->TeamName;
|
||||
Text.CharCount = (COUNT)~0;
|
||||
font_DrawText (&Text);
|
||||
}
|
||||
|
||||
// Print the value of the fleet
|
||||
{
|
||||
TEXT Text;
|
||||
UNICODE buf[60];
|
||||
|
||||
sprintf (buf, "%u", GetTeamValue (pTI));
|
||||
Text.baseline = *origin;
|
||||
Text.baseline.x += NUM_MELEE_COLUMNS *
|
||||
(LOAD_MELEE_BOX_WIDTH + LOAD_MELEE_BOX_SPACE) - 1;
|
||||
Text.align = ALIGN_RIGHT;
|
||||
Text.pStr = buf;
|
||||
Text.CharCount = (COUNT)~0;
|
||||
font_DrawText (&Text);
|
||||
}
|
||||
|
||||
// Draw the ships for the fleet
|
||||
if (drawShips)
|
||||
{
|
||||
STAMP s;
|
||||
FleetShipIndex index;
|
||||
|
||||
s.origin.x = origin->x + 1;
|
||||
s.origin.y = origin->y + 4;
|
||||
for (index = 0; index < MELEE_FLEET_SIZE; index++)
|
||||
{
|
||||
BYTE StarShip;
|
||||
|
||||
StarShip = pTI->ShipList[index];
|
||||
if (StarShip != MELEE_NONE)
|
||||
{
|
||||
s.frame = GetShipIconsFromIndex (StarShip);
|
||||
DrawStamp (&s);
|
||||
s.origin.x += 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if there are any entries in the view, in which case
|
||||
// pMS->load.bot gets set to the index of the bottom entry in the view.
|
||||
// returns false if not, in which case, the entire view remains unchanged.
|
||||
static bool
|
||||
FillFileView (MELEE_STATE *pMS)
|
||||
{
|
||||
COUNT viewI;
|
||||
|
||||
for (viewI = 0; viewI < LOAD_TEAM_VIEW_SIZE; viewI++)
|
||||
{
|
||||
bool success = GetFleetByIndex (pMS, pMS->load.top + viewI,
|
||||
&pMS->load.view[viewI]);
|
||||
if (!success)
|
||||
break;
|
||||
}
|
||||
|
||||
if (viewI == 0)
|
||||
return false;
|
||||
|
||||
pMS->load.bot = pMS->load.top + viewI;
|
||||
return true;
|
||||
}
|
||||
|
||||
#define FILE_STRING_ORIGIN_X 5
|
||||
#define FILE_STRING_ORIGIN_Y 34
|
||||
#define ENTRY_HEIGHT 32
|
||||
|
||||
void
|
||||
SelectFileString (MELEE_STATE *pMS, bool hilite)
|
||||
{
|
||||
CONTEXT OldContext;
|
||||
POINT origin;
|
||||
COUNT viewI;
|
||||
|
||||
viewI = pMS->load.cur - pMS->load.top;
|
||||
|
||||
OldContext = SetContext (SpaceContext);
|
||||
SetContextFont (MicroFont);
|
||||
BatchGraphics ();
|
||||
|
||||
origin.x = FILE_STRING_ORIGIN_X;
|
||||
origin.y = FILE_STRING_ORIGIN_Y + viewI * ENTRY_HEIGHT;
|
||||
DrawFileString (&pMS->load.view[viewI], &origin, FALSE, hilite);
|
||||
|
||||
UnbatchGraphics ();
|
||||
SetContext (OldContext);
|
||||
}
|
||||
|
||||
static void
|
||||
DrawFileStrings (MELEE_STATE *pMS)
|
||||
{
|
||||
POINT origin;
|
||||
CONTEXT OldContext;
|
||||
|
||||
origin.x = FILE_STRING_ORIGIN_X;
|
||||
origin.y = FILE_STRING_ORIGIN_Y;
|
||||
|
||||
OldContext = SetContext (SpaceContext);
|
||||
SetContextFont (MicroFont);
|
||||
BatchGraphics ();
|
||||
|
||||
DrawMeleeIcon (28); /* The load team frame */
|
||||
|
||||
if (FillFileView (pMS))
|
||||
{
|
||||
COUNT i;
|
||||
for (i = pMS->load.top; i < pMS->load.bot; i++) {
|
||||
DrawFileString (&pMS->load.view[i - pMS->load.top], &origin,
|
||||
TRUE, FALSE);
|
||||
origin.y += ENTRY_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
UnbatchGraphics ();
|
||||
SetContext (OldContext);
|
||||
}
|
||||
|
||||
static void
|
||||
RefocusView (MELEE_STATE *pMS, COUNT index)
|
||||
{
|
||||
assert (index < pMS->load.preBuiltCount + pMS->load.numIndices);
|
||||
|
||||
pMS->load.cur = index;
|
||||
if (index <= LOAD_TEAM_VIEW_SIZE / 2)
|
||||
pMS->load.top = 0;
|
||||
else
|
||||
pMS->load.top = index - LOAD_TEAM_VIEW_SIZE / 2;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DoLoadTeam (MELEE_STATE *pMS)
|
||||
{
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
return FALSE;
|
||||
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP |
|
||||
MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT);
|
||||
|
||||
if (!pMS->Initialized)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
DrawFileStrings (pMS);
|
||||
SelectFileString (pMS, true);
|
||||
pMS->Initialized = TRUE;
|
||||
pMS->InputFunc = DoLoadTeam;
|
||||
UnlockMutex (GraphicsLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (PulsedInputState.menu[KEY_MENU_SELECT] ||
|
||||
PulsedInputState.menu[KEY_MENU_CANCEL])
|
||||
{
|
||||
if (PulsedInputState.menu[KEY_MENU_SELECT])
|
||||
{
|
||||
// Copy the selected fleet to the player.
|
||||
pMS->SideState[pMS->side].TeamImage =
|
||||
pMS->load.view[pMS->load.cur - pMS->load.top];
|
||||
pMS->SideState[pMS->side].star_bucks =
|
||||
GetTeamValue (&pMS->SideState[pMS->side].TeamImage);
|
||||
entireFleetChanged (pMS, pMS->side);
|
||||
teamStringChanged (pMS, pMS->side);
|
||||
}
|
||||
|
||||
pMS->InputFunc = DoMelee;
|
||||
{
|
||||
RECT r;
|
||||
|
||||
GetFrameRect (SetAbsFrameIndex (MeleeFrame, 28), &r);
|
||||
LockMutex (GraphicsLock);
|
||||
RepairMeleeFrame (&r);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
COUNT newTop = pMS->load.top;
|
||||
COUNT newIndex = pMS->load.cur;
|
||||
|
||||
if (PulsedInputState.menu[KEY_MENU_UP])
|
||||
{
|
||||
if (newIndex > 0)
|
||||
{
|
||||
newIndex--;
|
||||
if (newIndex < newTop)
|
||||
newTop = (newTop < LOAD_TEAM_VIEW_SIZE) ?
|
||||
0 : newTop - LOAD_TEAM_VIEW_SIZE;
|
||||
}
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_DOWN])
|
||||
{
|
||||
COUNT numEntries = pMS->load.numIndices + pMS->load.preBuiltCount;
|
||||
if (newIndex + 1 < numEntries)
|
||||
{
|
||||
newIndex++;
|
||||
if (newIndex >= pMS->load.bot)
|
||||
newTop = pMS->load.bot;
|
||||
}
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_PAGE_UP])
|
||||
{
|
||||
newIndex = (newIndex < LOAD_TEAM_VIEW_SIZE) ?
|
||||
0 : newIndex - LOAD_TEAM_VIEW_SIZE;
|
||||
newTop = (newTop < LOAD_TEAM_VIEW_SIZE) ?
|
||||
0 : newTop - LOAD_TEAM_VIEW_SIZE;
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_PAGE_DOWN])
|
||||
{
|
||||
COUNT numEntries = pMS->load.numIndices + pMS->load.preBuiltCount;
|
||||
if (newIndex + LOAD_TEAM_VIEW_SIZE < numEntries)
|
||||
{
|
||||
newIndex += LOAD_TEAM_VIEW_SIZE;
|
||||
newTop += LOAD_TEAM_VIEW_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
newIndex = numEntries - 1;
|
||||
if (newTop + LOAD_TEAM_VIEW_SIZE < numEntries &&
|
||||
numEntries > LOAD_TEAM_VIEW_SIZE)
|
||||
newTop = numEntries - LOAD_TEAM_VIEW_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if (newIndex != pMS->load.cur)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
if (newTop == pMS->load.top)
|
||||
SelectFileString (pMS, false);
|
||||
else
|
||||
{
|
||||
pMS->load.top = newTop;
|
||||
DrawFileStrings (pMS);
|
||||
}
|
||||
pMS->load.cur = newIndex;
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp)
|
||||
{
|
||||
return WriteResFile (pTI, sizeof (*pTI), 1, save_fp);
|
||||
}
|
||||
|
||||
void
|
||||
SelectTeamByFileName (MELEE_STATE *pMS, const char *fileName)
|
||||
{
|
||||
COUNT index = GetFleetIndexByFileName (pMS, fileName);
|
||||
if (index == (COUNT) -1)
|
||||
return;
|
||||
|
||||
RefocusView (pMS, index);
|
||||
}
|
||||
|
||||
void
|
||||
LoadTeamList (MELEE_STATE *pMS)
|
||||
{
|
||||
COUNT i;
|
||||
|
||||
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->load.dirEntries));
|
||||
pMS->load.dirEntries = CaptureDirEntryTable (
|
||||
LoadDirEntryTable (meleeDir, "", ".mle", match_MATCH_SUFFIX));
|
||||
|
||||
if (pMS->load.entryIndices != NULL)
|
||||
HFree (pMS->load.entryIndices);
|
||||
pMS->load.numIndices = GetDirEntryTableCount (pMS->load.dirEntries);
|
||||
pMS->load.entryIndices = HMalloc (pMS->load.numIndices *
|
||||
sizeof pMS->load.entryIndices[0]);
|
||||
for (i = 0; i < pMS->load.numIndices; i++)
|
||||
pMS->load.entryIndices[i] = i;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DoSaveTeam (MELEE_STATE *pMS)
|
||||
{
|
||||
STAMP MsgStamp;
|
||||
char file[NAME_MAX];
|
||||
uio_Stream *save_fp;
|
||||
CONTEXT OldContext;
|
||||
|
||||
sprintf (file, "%s.mle", pMS->SideState[pMS->side].TeamImage.TeamName);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
OldContext = SetContext (ScreenContext);
|
||||
ConfirmSaveLoad (&MsgStamp);
|
||||
save_fp = res_OpenResFile (meleeDir, file, "wb");
|
||||
if (save_fp)
|
||||
{
|
||||
BOOLEAN err;
|
||||
|
||||
err = (BOOLEAN)(WriteTeamImage (
|
||||
&pMS->SideState[pMS->side].TeamImage, save_fp) == 0);
|
||||
if (res_CloseResFile (save_fp) == 0)
|
||||
err = TRUE;
|
||||
if (err)
|
||||
save_fp = 0;
|
||||
}
|
||||
|
||||
pMS->load.top = 0;
|
||||
pMS->load.cur = 0;
|
||||
|
||||
if (save_fp == 0)
|
||||
{
|
||||
DrawStamp (&MsgStamp);
|
||||
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
|
||||
SetContext (OldContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
DeleteResFile (meleeDir, file);
|
||||
SaveProblem ();
|
||||
}
|
||||
|
||||
LoadTeamList (pMS);
|
||||
SelectTeamByFileName (pMS, file);
|
||||
|
||||
if (save_fp != 0)
|
||||
{
|
||||
DrawStamp (&MsgStamp);
|
||||
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
|
||||
SetContext (OldContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
return (save_fp != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
InitPreBuilt (MELEE_STATE *pMS)
|
||||
{
|
||||
TEAM_IMAGE *list;
|
||||
|
||||
#define PREBUILT_COUNT 15
|
||||
pMS->load.preBuiltList =
|
||||
HMalloc (PREBUILT_COUNT * sizeof pMS->load.preBuiltList[0]);
|
||||
pMS->load.preBuiltCount = PREBUILT_COUNT;
|
||||
#undef PREBUILT_COUNT
|
||||
|
||||
{
|
||||
FleetShipIndex shipI = 0;
|
||||
int fleetI;
|
||||
|
||||
for (fleetI = 0; fleetI < pMS->load.preBuiltCount; fleetI++)
|
||||
for (shipI = 0; shipI < MELEE_FLEET_SIZE; shipI++)
|
||||
pMS->load.preBuiltList[fleetI].ShipList[shipI] = MELEE_NONE;
|
||||
}
|
||||
|
||||
list = pMS->load.preBuiltList;
|
||||
|
||||
{
|
||||
/* "Balanced Team 1" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 4));
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list->ShipList[i++] = MELEE_SYREEN;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
/* "Balanced Team 2" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 5));
|
||||
list->ShipList[i++] = MELEE_ARILOU;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_YEHAT;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_THRADDASH;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
/* "200 points" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 6));
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list->ShipList[i++] = MELEE_ILWRATH;
|
||||
list->ShipList[i++] = MELEE_VUX;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
/* "Behemoth Zenith" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 7));
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
/* "The Peeled Eyes" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 8));
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_SYREEN;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Ford's Fighters");
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list->ShipList[i++] = MELEE_UMGAH;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Leyland's Lashers");
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"The Gregorizers 200");
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"300 point Armada!");
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_YEHAT;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Little Dudes with Attitudes");
|
||||
list->ShipList[i++] = MELEE_UMGAH;
|
||||
list->ShipList[i++] = MELEE_THRADDASH;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_VUX;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"New Alliance Ships");
|
||||
list->ShipList[i++] = MELEE_ARILOU;
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_SYREEN;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_YEHAT;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_THRADDASH;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Old Alliance Ships");
|
||||
list->ShipList[i++] = MELEE_ARILOU;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_MMRNMHRM;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list->ShipList[i++] = MELEE_SYREEN;
|
||||
list->ShipList[i++] = MELEE_YEHAT;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Old Hierarchy Ships");
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_ILWRATH;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list->ShipList[i++] = MELEE_UMGAH;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_VUX;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Star Control 1");
|
||||
list->ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
list->ShipList[i++] = MELEE_ARILOU;
|
||||
list->ShipList[i++] = MELEE_CHENJESU;
|
||||
list->ShipList[i++] = MELEE_EARTHLING;
|
||||
list->ShipList[i++] = MELEE_ILWRATH;
|
||||
list->ShipList[i++] = MELEE_MMRNMHRM;
|
||||
list->ShipList[i++] = MELEE_MYCON;
|
||||
list->ShipList[i++] = MELEE_SHOFIXTI;
|
||||
list->ShipList[i++] = MELEE_SPATHI;
|
||||
list->ShipList[i++] = MELEE_SYREEN;
|
||||
list->ShipList[i++] = MELEE_UMGAH;
|
||||
list->ShipList[i++] = MELEE_URQUAN;
|
||||
list->ShipList[i++] = MELEE_VUX;
|
||||
list->ShipList[i++] = MELEE_YEHAT;
|
||||
list++;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (list->TeamName, sizeof (list->TeamName),
|
||||
"Star Control 2");
|
||||
list->ShipList[i++] = MELEE_CHMMR;
|
||||
list->ShipList[i++] = MELEE_DRUUGE;
|
||||
list->ShipList[i++] = MELEE_KOHR_AH;
|
||||
list->ShipList[i++] = MELEE_MELNORME;
|
||||
list->ShipList[i++] = MELEE_ORZ;
|
||||
list->ShipList[i++] = MELEE_PKUNK;
|
||||
list->ShipList[i++] = MELEE_SLYLANDRO;
|
||||
list->ShipList[i++] = MELEE_SUPOX;
|
||||
list->ShipList[i++] = MELEE_THRADDASH;
|
||||
list->ShipList[i++] = MELEE_UTWIG;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list->ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
list++;
|
||||
}
|
||||
|
||||
assert (list == pMS->load.preBuiltList + pMS->load.preBuiltCount);
|
||||
}
|
||||
|
||||
static void
|
||||
UninitPreBuilt (MELEE_STATE *pMS) {
|
||||
HFree (pMS->load.preBuiltList);
|
||||
pMS->load.preBuiltCount = 0;
|
||||
}
|
||||
|
||||
void
|
||||
InitMeleeLoadState (MELEE_STATE *pMS)
|
||||
{
|
||||
pMS->load.entryIndices = NULL;
|
||||
InitPreBuilt (pMS);
|
||||
}
|
||||
|
||||
void
|
||||
UninitMeleeLoadState (MELEE_STATE *pMS)
|
||||
{
|
||||
UninitPreBuilt (pMS);
|
||||
if (pMS->load.entryIndices != NULL)
|
||||
HFree (pMS->load.entryIndices);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
||||
|
||||
/*
|
||||
* 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 _LOADMELE_H
|
||||
#define _LOADMELE_H
|
||||
|
||||
#define LOAD_TEAM_VIEW_SIZE 5
|
||||
|
||||
struct melee_load_state;
|
||||
|
||||
#include "melee.h"
|
||||
|
||||
struct melee_load_state
|
||||
{
|
||||
TEAM_IMAGE *preBuiltList;
|
||||
COUNT preBuiltCount;
|
||||
|
||||
DIRENTRY dirEntries;
|
||||
COUNT *entryIndices;
|
||||
COUNT numIndices;
|
||||
|
||||
TEAM_IMAGE view[LOAD_TEAM_VIEW_SIZE];
|
||||
COUNT top;
|
||||
// Index of the first entry for the view.
|
||||
COUNT bot;
|
||||
// Index of the first entry past the end of the view.
|
||||
|
||||
COUNT cur;
|
||||
// Index of the current position in the view.
|
||||
COUNT viewSize;
|
||||
// Number of entries in the view.
|
||||
};
|
||||
|
||||
void InitMeleeLoadState (MELEE_STATE *pMS);
|
||||
void UninitMeleeLoadState (MELEE_STATE *pMS);
|
||||
|
||||
BOOLEAN DoLoadTeam (MELEE_STATE *pMS);
|
||||
BOOLEAN DoSaveTeam (MELEE_STATE *pMS);
|
||||
bool ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp);
|
||||
int WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp);
|
||||
void SelectFileString (MELEE_STATE *pMS, bool hilite);
|
||||
void LoadTeamList (MELEE_STATE *pMS);
|
||||
|
||||
#endif /* _LOADMELE_H */
|
||||
|
||||
|
||||
@@ -167,3 +167,59 @@ FindMasterShipIndex (DWORD ship_ref)
|
||||
|
||||
return hStarShip ? index : -1;
|
||||
}
|
||||
|
||||
COUNT
|
||||
GetShipCostFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
COUNT val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.ship_cost;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
FRAME
|
||||
GetShipIconsFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
FRAME val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.icons;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
FRAME
|
||||
GetShipMeleeIconsFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
FRAME val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.melee_icon;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ extern void LoadMasterShipList (void (* YieldProcessing)(void));
|
||||
extern void FreeMasterShipList (void);
|
||||
extern HMASTERSHIP FindMasterShip (DWORD ship_ref);
|
||||
extern int FindMasterShipIndex (DWORD ship_ref);
|
||||
|
||||
COUNT GetShipCostFromIndex (unsigned Index);
|
||||
FRAME GetShipIconsFromIndex (unsigned Index);
|
||||
FRAME GetShipMeleeIconsFromIndex (unsigned Index);
|
||||
|
||||
#endif /* _MASTER_H */
|
||||
|
||||
|
||||
+24
-786
@@ -28,6 +28,7 @@
|
||||
#include "gamestr.h"
|
||||
#include "globdata.h"
|
||||
#include "intel.h"
|
||||
#include "master.h"
|
||||
#include "nameref.h"
|
||||
#ifdef NETPLAY
|
||||
# include "netplay/netconnection.h"
|
||||
@@ -38,11 +39,8 @@
|
||||
#endif
|
||||
#include "options.h"
|
||||
#include "races.h"
|
||||
#include "master.h"
|
||||
#include "resinst.h"
|
||||
#include "save.h"
|
||||
#include "settings.h"
|
||||
#include "gameopt.h"
|
||||
#include "setup.h"
|
||||
#include "sounds.h"
|
||||
#include "util.h"
|
||||
@@ -161,9 +159,6 @@ enum
|
||||
#define TEAM_NAME_EDIT_CURS_COLOR \
|
||||
WHITE_COLOR
|
||||
|
||||
#define LOAD_TEAM_NAME_TEXT_COLOR TEAM_NAME_TEXT_COLOR
|
||||
#define LOAD_TEAM_NAME_TEXT_COLOR_HILITE TEAM_NAME_EDIT_TEXT_COLOR
|
||||
|
||||
#define PICKSHIP_TEAM_NAME_TEXT_COLOR \
|
||||
BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)
|
||||
#define PICKSHIP_TEAM_START_VALUE_COLOR \
|
||||
@@ -188,14 +183,14 @@ enum
|
||||
|
||||
|
||||
FRAME PickMeleeFrame;
|
||||
static FRAME MeleeFrame;
|
||||
FRAME MeleeFrame;
|
||||
// Loaded from melee/melebkgd.ani
|
||||
static FRAME BuildPickFrame;
|
||||
// Constructed.
|
||||
DWORD InTime;
|
||||
MELEE_STATE *pMeleeState;
|
||||
|
||||
static BOOLEAN DoMelee (MELEE_STATE *pMS);
|
||||
BOOLEAN DoMelee (MELEE_STATE *pMS);
|
||||
static BOOLEAN DoEdit (MELEE_STATE *pMS);
|
||||
static BOOLEAN DoPickShip (MELEE_STATE *pMS);
|
||||
static BOOLEAN DoConfirmSettings (MELEE_STATE *pMS);
|
||||
@@ -209,12 +204,9 @@ static BOOLEAN DoConfirmSettings (MELEE_STATE *pMS);
|
||||
static BOOLEAN DrawTeamString (MELEE_STATE *pMS, COUNT side,
|
||||
COUNT HiLiteState);
|
||||
|
||||
static BOOLEAN DoLoadTeam (MELEE_STATE *pMS);
|
||||
static void DrawFileStrings (MELEE_STATE *pMS, int HiLiteState);
|
||||
|
||||
|
||||
// These icons come from melee/melebkgd.ani
|
||||
static void
|
||||
void
|
||||
DrawMeleeIcon (COUNT which_icon)
|
||||
{
|
||||
STAMP s;
|
||||
@@ -256,63 +248,6 @@ GetShipColumn (int index)
|
||||
return index % NUM_MELEE_COLUMNS;
|
||||
}
|
||||
|
||||
// XXX: Perhaps move this to master.c
|
||||
static COUNT
|
||||
GetShipCostFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
COUNT val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.ship_cost;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
// XXX: Perhaps move this to master.c
|
||||
static FRAME
|
||||
GetShipIconsFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
FRAME val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.icons;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
// XXX: Perhaps move this to master.c
|
||||
static FRAME
|
||||
GetShipMeleeIconsFromIndex (unsigned Index)
|
||||
{
|
||||
HMASTERSHIP hMasterShip;
|
||||
MASTER_SHIP_INFO *MasterPtr;
|
||||
FRAME val;
|
||||
|
||||
hMasterShip = GetStarShipFromIndex (&master_q, Index);
|
||||
if (!hMasterShip)
|
||||
return 0;
|
||||
|
||||
MasterPtr = LockMasterShip (&master_q, hMasterShip);
|
||||
val = MasterPtr->ShipInfo.melee_icon;
|
||||
UnlockMasterShip (&master_q, hMasterShip);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
DrawShipBox (COUNT side, COUNT row, COUNT col, BYTE ship, BOOLEAN HiLite)
|
||||
{
|
||||
@@ -422,7 +357,7 @@ DrawPickFrame (MELEE_STATE *pMS)
|
||||
LockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
RepairMeleeFrame (RECT *pRect)
|
||||
{
|
||||
RECT r;
|
||||
@@ -488,7 +423,8 @@ RedrawMeleeFrame (void)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.corner.x = r.corner.y = 0;
|
||||
r.corner.x = 0;
|
||||
r.corner.y = 0;
|
||||
r.extent.width = SCREEN_WIDTH;
|
||||
r.extent.height = SCREEN_HEIGHT;
|
||||
|
||||
@@ -527,7 +463,7 @@ DrawTeamString (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState)
|
||||
TEXT rtText;
|
||||
UNICODE buf[30];
|
||||
|
||||
sprintf (buf, "%d", pMS->SideState[side].star_bucks);
|
||||
sprintf (buf, "%u", pMS->SideState[side].star_bucks);
|
||||
rtText.pStr = buf;
|
||||
rtText.align = ALIGN_RIGHT;
|
||||
rtText.CharCount = (COUNT)~0;
|
||||
@@ -768,13 +704,12 @@ Deselect (BYTE opt)
|
||||
break;
|
||||
case LOAD_TOP:
|
||||
case LOAD_BOT:
|
||||
if (pMeleeState->InputFunc != DoLoadTeam) {
|
||||
if (pMeleeState->InputFunc != DoLoadTeam)
|
||||
DrawMeleeIcon (opt == LOAD_TOP ? 17 : 22);
|
||||
/* 17: "Load" (top, not highlighted) */
|
||||
/* 22: "Load" (bottom, not highlighted) */
|
||||
}
|
||||
else
|
||||
DrawFileStrings (pMeleeState, 0);
|
||||
SelectFileString (pMeleeState, false);
|
||||
break;
|
||||
case SAVE_TOP:
|
||||
DrawMeleeIcon (18); /* "Save" (top, not highlighted) */
|
||||
@@ -832,13 +767,11 @@ Select (BYTE opt)
|
||||
case LOAD_TOP:
|
||||
case LOAD_BOT:
|
||||
if (pMeleeState->InputFunc != DoLoadTeam)
|
||||
{
|
||||
DrawMeleeIcon (opt == LOAD_TOP ? 19 : 24);
|
||||
/* 19: "Load" (top, highlighted) */
|
||||
/* 24: "Load" (bottom, highlighted) */
|
||||
}
|
||||
else
|
||||
DrawFileStrings (pMeleeState, 1);
|
||||
SelectFileString (pMeleeState, true);
|
||||
break;
|
||||
case SAVE_TOP:
|
||||
DrawMeleeIcon (20); /* "Save" (top; highlighted) */
|
||||
@@ -876,9 +809,7 @@ Select (BYTE opt)
|
||||
DTSHS_SELECTED);
|
||||
}
|
||||
else if (pMeleeState->InputFunc == DoPickShip)
|
||||
{
|
||||
DrawPickIcon (pMeleeState->CurIndex, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1040,7 +971,7 @@ GetShipValue (BYTE StarShip)
|
||||
return val;
|
||||
}
|
||||
|
||||
static COUNT
|
||||
COUNT
|
||||
GetTeamValue (TEAM_IMAGE *pTI)
|
||||
{
|
||||
FleetShipIndex index;
|
||||
@@ -1059,427 +990,6 @@ GetTeamValue (TEAM_IMAGE *pTI)
|
||||
return val;
|
||||
}
|
||||
|
||||
static int
|
||||
ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp)
|
||||
{
|
||||
int status;
|
||||
FleetShipIndex i;
|
||||
|
||||
status = ReadResFile (pTI, sizeof (*pTI), 1, load_fp);
|
||||
if (status != 1)
|
||||
return -1;
|
||||
|
||||
// Sanity check on the entries.
|
||||
for (i = 0; i < MELEE_FLEET_SIZE; i++)
|
||||
{
|
||||
BYTE StarShip = pTI->ShipList[i];
|
||||
|
||||
if (StarShip == MELEE_NONE)
|
||||
continue;
|
||||
|
||||
if (StarShip >= NUM_MELEE_SHIPS)
|
||||
{
|
||||
log_add(log_Warning, "Invalid ship type in loaded team (index "
|
||||
"%d, ship type is %d, max valid is %d).",
|
||||
i, StarShip, NUM_MELEE_SHIPS - 1);
|
||||
pTI->ShipList[i] = MELEE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
LoadTeamImage (DIRENTRY DirEntry, TEAM_IMAGE* pTI, UNICODE* pFilePath)
|
||||
{
|
||||
UNICODE file[NAME_MAX]; // local buf if needed
|
||||
UNICODE *pfile;
|
||||
uio_Stream *load_fp;
|
||||
int status;
|
||||
|
||||
pfile = pFilePath != NULL ? pFilePath : file;
|
||||
|
||||
GetDirEntryContents (DirEntry, (STRINGPTR)pfile, FALSE);
|
||||
load_fp = res_OpenResFile (meleeDir, pfile, "rb");
|
||||
if (load_fp == 0)
|
||||
status = -1;
|
||||
else
|
||||
{
|
||||
if (LengthResFile (load_fp) != sizeof (*pTI))
|
||||
status = -1;
|
||||
else
|
||||
status = ReadTeamImage (pTI, load_fp);
|
||||
res_CloseResFile (load_fp);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// Auxiliary function for DrawFileStrings
|
||||
// If drawShips is set the ships themselves are drawn, in addition to the
|
||||
// fleet name and value; if not, only the fleet name and value are drawn.
|
||||
// If highlite is set the text is drawn in the color used for highlighting.
|
||||
static void
|
||||
DrawFileListFleet(TEAM_IMAGE *pTI, POINT *origin, BOOLEAN drawShips,
|
||||
BOOLEAN highlite) {
|
||||
SetContextForeGroundColor (highlite ?
|
||||
LOAD_TEAM_NAME_TEXT_COLOR_HILITE : LOAD_TEAM_NAME_TEXT_COLOR);
|
||||
|
||||
// Print the name of the fleet
|
||||
{
|
||||
TEXT Text;
|
||||
|
||||
Text.baseline = *origin;
|
||||
Text.align = ALIGN_LEFT;
|
||||
Text.pStr = pTI->TeamName;
|
||||
Text.CharCount = (COUNT)~0;
|
||||
font_DrawText (&Text);
|
||||
}
|
||||
|
||||
// Print the value of the fleet
|
||||
{
|
||||
TEXT Text;
|
||||
UNICODE buf[60];
|
||||
|
||||
sprintf (buf, "%d", GetTeamValue (pTI));
|
||||
Text.baseline = *origin;
|
||||
Text.baseline.x +=
|
||||
NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE) - 1;
|
||||
Text.align = ALIGN_RIGHT;
|
||||
Text.pStr = buf;
|
||||
Text.CharCount = (COUNT)~0;
|
||||
font_DrawText (&Text);
|
||||
}
|
||||
|
||||
// Draw the ships for the fleet
|
||||
if (drawShips)
|
||||
{
|
||||
STAMP s;
|
||||
FleetShipIndex index;
|
||||
|
||||
s.origin.x = origin->x + 1;
|
||||
s.origin.y = origin->y + 4;
|
||||
for (index = 0; index < MELEE_FLEET_SIZE; index++)
|
||||
{
|
||||
BYTE StarShip;
|
||||
|
||||
StarShip = pTI->ShipList[index];
|
||||
if (StarShip != MELEE_NONE)
|
||||
{
|
||||
s.frame = GetShipIconsFromIndex (StarShip);
|
||||
DrawStamp (&s);
|
||||
s.origin.x += 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DrawFileStrings (MELEE_STATE *pMS, int HiLiteState)
|
||||
{
|
||||
#define ENTRY_HEIGHT 32
|
||||
POINT origin;
|
||||
COUNT top, bot;
|
||||
CONTEXT OldContext;
|
||||
|
||||
origin.x = 5;
|
||||
origin.y = 34;
|
||||
|
||||
top = pMS->TopTeamIndex;
|
||||
|
||||
if (HiLiteState == 1)
|
||||
{
|
||||
COUNT new_;
|
||||
|
||||
new_ = pMS->CurIndex;
|
||||
bot = pMS->BotTeamIndex;
|
||||
|
||||
if (new_ < top || new_ > bot)
|
||||
{
|
||||
if (new_ < top)
|
||||
top = new_;
|
||||
else
|
||||
top += new_ - bot;
|
||||
pMS->TopTeamIndex = top;
|
||||
|
||||
HiLiteState = -1;
|
||||
}
|
||||
}
|
||||
|
||||
OldContext = SetContext (SpaceContext);
|
||||
SetContextFont (MicroFont);
|
||||
BatchGraphics ();
|
||||
if (HiLiteState != -1)
|
||||
{
|
||||
bot = pMS->CurIndex - top;
|
||||
|
||||
origin.y += bot * ENTRY_HEIGHT;
|
||||
DrawFileListFleet(&pMS->FileList[bot], &origin, FALSE,
|
||||
HiLiteState == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
COUNT teams_left;
|
||||
|
||||
DrawMeleeIcon (28); /* The load team frame */
|
||||
|
||||
teams_left = (COUNT)(
|
||||
GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - top);
|
||||
if (teams_left)
|
||||
{
|
||||
bot = top - 1;
|
||||
do
|
||||
{
|
||||
if (++bot < NUM_PREBUILT)
|
||||
pMS->FileList[bot - top] = pMS->PreBuiltList[bot];
|
||||
else
|
||||
{
|
||||
pMS->TeamDE = SetAbsDirEntryTableIndex (
|
||||
pMS->TeamDE, bot - NUM_PREBUILT);
|
||||
if (-1 == LoadTeamImage (pMS->TeamDE,
|
||||
&pMS->FileList[bot - top], NULL))
|
||||
pMS->FileList[bot - top] = pMS->PreBuiltList[0];
|
||||
}
|
||||
|
||||
DrawFileListFleet(&pMS->FileList[bot - top], &origin,
|
||||
TRUE, FALSE);
|
||||
|
||||
origin.y += ENTRY_HEIGHT;
|
||||
} while (--teams_left && bot - top < MAX_VIS_TEAMS - 1);
|
||||
pMS->BotTeamIndex = bot;
|
||||
}
|
||||
}
|
||||
UnbatchGraphics ();
|
||||
SetContext (OldContext);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
DoLoadTeam (MELEE_STATE *pMS)
|
||||
{
|
||||
SIZE index;
|
||||
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
return (FALSE);
|
||||
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN | MENU_SOUND_PAGEUP |
|
||||
MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT);
|
||||
|
||||
if (!pMS->Initialized)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
Select (pMS->MeleeOption);
|
||||
pMS->TopTeamIndex = pMS->CurIndex;
|
||||
if (pMS->TopTeamIndex == (COUNT)~0)
|
||||
{
|
||||
pMS->TopTeamIndex = 0;
|
||||
pMS->CurIndex = 0;
|
||||
}
|
||||
else if (pMS->TopTeamIndex <= MAX_VIS_TEAMS / 2)
|
||||
pMS->TopTeamIndex = 0;
|
||||
else
|
||||
pMS->TopTeamIndex -= MAX_VIS_TEAMS / 2;
|
||||
|
||||
DrawFileStrings (pMS, -1);
|
||||
pMS->Initialized = TRUE;
|
||||
pMS->InputFunc = DoLoadTeam;
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_SELECT] ||
|
||||
PulsedInputState.menu[KEY_MENU_CANCEL])
|
||||
{
|
||||
if (!PulsedInputState.menu[KEY_MENU_CANCEL])
|
||||
{
|
||||
pMS->SideState[pMS->side].TeamImage =
|
||||
pMS->FileList[pMS->CurIndex - pMS->TopTeamIndex];
|
||||
pMS->SideState[pMS->side].star_bucks =
|
||||
GetTeamValue (&pMS->SideState[pMS->side].TeamImage);
|
||||
entireFleetChanged (pMS, pMS->side);
|
||||
teamStringChanged (pMS, pMS->side);
|
||||
}
|
||||
|
||||
pMS->InputFunc = DoMelee;
|
||||
{
|
||||
RECT r;
|
||||
|
||||
GetFrameRect (SetAbsFrameIndex (MeleeFrame, 28), &r);
|
||||
LockMutex (GraphicsLock);
|
||||
RepairMeleeFrame (&r);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
InTime = GetTimeCounter ();
|
||||
}
|
||||
else
|
||||
{
|
||||
SIZE old_index, NewTop;
|
||||
|
||||
NewTop = pMS->TopTeamIndex;
|
||||
index = old_index = pMS->CurIndex;
|
||||
if (PulsedInputState.menu[KEY_MENU_UP])
|
||||
{
|
||||
if (index-- == 0)
|
||||
index = 0;
|
||||
|
||||
if (index < NewTop && (NewTop -= MAX_VIS_TEAMS) < 0)
|
||||
NewTop = 0;
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_DOWN])
|
||||
{
|
||||
if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) +
|
||||
NUM_PREBUILT - 1)
|
||||
++index;
|
||||
|
||||
if ((int)index > (int)pMS->BotTeamIndex)
|
||||
NewTop = index;
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_PAGE_UP])
|
||||
{
|
||||
index -= MAX_VIS_TEAMS;
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
NewTop = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTop -= MAX_VIS_TEAMS;
|
||||
if (NewTop < 0)
|
||||
NewTop = 0;
|
||||
}
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_PAGE_DOWN])
|
||||
{
|
||||
index += MAX_VIS_TEAMS;
|
||||
if ((int) index <
|
||||
(int)(GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT))
|
||||
NewTop += MAX_VIS_TEAMS;
|
||||
else
|
||||
{
|
||||
index = GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1;
|
||||
if (index - (MAX_VIS_TEAMS - 1) > NewTop)
|
||||
{
|
||||
NewTop = index - (MAX_VIS_TEAMS - 1);
|
||||
if (NewTop < 0)
|
||||
NewTop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index != old_index)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
if ((int)NewTop == (int)pMS->TopTeamIndex)
|
||||
Deselect (pMS->MeleeOption);
|
||||
else
|
||||
{
|
||||
pMS->TopTeamIndex = NewTop;
|
||||
DrawFileStrings (pMS, -1);
|
||||
}
|
||||
pMS->CurIndex = index;
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static int
|
||||
WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp)
|
||||
{
|
||||
return (WriteResFile (pTI, sizeof (*pTI), 1, save_fp));
|
||||
}
|
||||
|
||||
static void
|
||||
LoadTeamList (MELEE_STATE *pMS, UNICODE *pbuf)
|
||||
{
|
||||
COUNT num_entries;
|
||||
char file[NAME_MAX];
|
||||
|
||||
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->TeamDE));
|
||||
pMS->TeamDE = CaptureDirEntryTable (
|
||||
LoadDirEntryTable (meleeDir, "", ".mle", match_MATCH_SUFFIX,
|
||||
&num_entries));
|
||||
|
||||
pMS->CurIndex = 0;
|
||||
while (num_entries--)
|
||||
{
|
||||
int status;
|
||||
TEAM_IMAGE TI;
|
||||
|
||||
status = LoadTeamImage (pMS->TeamDE, &TI, file);
|
||||
if (status == -1)
|
||||
{
|
||||
// It isn't possible to delete entries from a STRING_TABLE,
|
||||
// so we just overwrite the string itself by a '\0' char.
|
||||
STRINGPTR str = GetDirEntryAddress(pMS->TeamDE);
|
||||
log_add(log_Warning, "Warning: File '%s' is not a valid "
|
||||
"SuperMelee team.", str);
|
||||
*str = '\0';
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (pbuf && stricmp (file, pbuf) == 0)
|
||||
{
|
||||
pMS->CurIndex = GetDirEntryTableIndex (pMS->TeamDE) + NUM_PREBUILT;
|
||||
pbuf = 0;
|
||||
}
|
||||
|
||||
next:
|
||||
pMS->TeamDE = SetRelDirEntryTableIndex (pMS->TeamDE, 1);
|
||||
}
|
||||
pMS->TeamDE = SetAbsDirEntryTableIndex (pMS->TeamDE, 0);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
DoSaveTeam (MELEE_STATE *pMS)
|
||||
{
|
||||
STAMP MsgStamp;
|
||||
char file[NAME_MAX];
|
||||
uio_Stream *save_fp;
|
||||
CONTEXT OldContext;
|
||||
|
||||
sprintf (file, "%s.mle", pMS->SideState[pMS->side].TeamImage.TeamName);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
OldContext = SetContext (ScreenContext);
|
||||
ConfirmSaveLoad (&MsgStamp);
|
||||
save_fp = res_OpenResFile (meleeDir, file, "wb");
|
||||
if (save_fp)
|
||||
{
|
||||
BOOLEAN err;
|
||||
|
||||
err = (BOOLEAN)(WriteTeamImage (
|
||||
&pMS->SideState[pMS->side].TeamImage, save_fp) == 0);
|
||||
if (res_CloseResFile (save_fp) == 0)
|
||||
err = TRUE;
|
||||
if (err)
|
||||
save_fp = 0;
|
||||
}
|
||||
|
||||
pMS->CurIndex = 0;
|
||||
if (save_fp == 0)
|
||||
{
|
||||
DrawStamp (&MsgStamp);
|
||||
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
|
||||
SetContext (OldContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
DeleteResFile (meleeDir, file);
|
||||
SaveProblem ();
|
||||
}
|
||||
|
||||
LoadTeamList (pMS, file);
|
||||
|
||||
if (save_fp)
|
||||
{
|
||||
DrawStamp (&MsgStamp);
|
||||
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
|
||||
SetContext (OldContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
return (save_fp != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
DeleteCurrentShip (MELEE_STATE *pMS)
|
||||
{
|
||||
@@ -2026,7 +1536,7 @@ LoadMeleeInfo (MELEE_STATE *pMS)
|
||||
|
||||
InitSpace ();
|
||||
|
||||
LoadTeamList (pMS, 0);
|
||||
LoadTeamList (pMS);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2037,8 +1547,8 @@ FreeMeleeInfo (MELEE_STATE *pMS)
|
||||
ConcludeTask (pMS->flash_task);
|
||||
pMS->flash_task = 0;
|
||||
}
|
||||
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->TeamDE));
|
||||
pMS->TeamDE = 0;
|
||||
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->load.dirEntries));
|
||||
pMS->load.dirEntries = 0;
|
||||
|
||||
if (pMS->hMusic)
|
||||
{
|
||||
@@ -2106,7 +1616,7 @@ BuildAndDrawShipList (MELEE_STATE *pMS)
|
||||
font_DrawText (&t);
|
||||
|
||||
// Total team value of the starting team:
|
||||
sprintf (buf, "%d", pMS->SideState[i].star_bucks);
|
||||
sprintf (buf, "%u", pMS->SideState[i].star_bucks);
|
||||
t.baseline.x = 4;
|
||||
t.baseline.y = 7;
|
||||
t.align = ALIGN_LEFT;
|
||||
@@ -2475,8 +1985,7 @@ check_for_disconnections (MELEE_STATE *pMS)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static BOOLEAN
|
||||
BOOLEAN
|
||||
DoMelee (MELEE_STATE *pMS)
|
||||
{
|
||||
BOOLEAN force_select = FALSE;
|
||||
@@ -2601,6 +2110,7 @@ DoMelee (MELEE_STATE *pMS)
|
||||
pMS->Initialized = FALSE;
|
||||
pMS->side = pMS->MeleeOption == LOAD_TOP ? 0 : 1;
|
||||
DoLoadTeam (pMS);
|
||||
InTime = GetTimeCounter ();
|
||||
break;
|
||||
case SAVE_TOP:
|
||||
case SAVE_BOT:
|
||||
@@ -2693,279 +2203,6 @@ DoMelee (MELEE_STATE *pMS)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
InitPreBuilt (MELEE_STATE *pMS)
|
||||
{
|
||||
{
|
||||
FleetShipIndex shipI = 0;
|
||||
int fleetI;
|
||||
|
||||
for (fleetI = 0; fleetI < NUM_PREBUILT; fleetI++)
|
||||
for (shipI = 0; shipI < MELEE_FLEET_SIZE; shipI++)
|
||||
pMS->PreBuiltList[fleetI].ShipList[shipI] = MELEE_NONE;
|
||||
}
|
||||
|
||||
{
|
||||
/* "Balanced Team 1" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[0].TeamName,
|
||||
sizeof (pMS->PreBuiltList[0].TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 4));
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_SPATHI;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_SYREEN;
|
||||
pMS->PreBuiltList[0].ShipList[i++] = MELEE_UTWIG;
|
||||
}
|
||||
|
||||
{
|
||||
/* "Balanced Team 2" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[1].TeamName,
|
||||
sizeof (pMS->PreBuiltList[1].TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 5));
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_ARILOU;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_YEHAT;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_THRADDASH;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[1].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
}
|
||||
|
||||
{
|
||||
/* "200 points" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[2].TeamName,
|
||||
sizeof (pMS->PreBuiltList[2].TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 6));
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_SPATHI;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_ILWRATH;
|
||||
pMS->PreBuiltList[2].ShipList[i++] = MELEE_VUX;
|
||||
}
|
||||
|
||||
{
|
||||
/* "Behemoth Zenith" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[3].TeamName,
|
||||
sizeof (pMS->PreBuiltList[3].TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 7));
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_UTWIG;
|
||||
pMS->PreBuiltList[3].ShipList[i++] = MELEE_UTWIG;
|
||||
}
|
||||
|
||||
{
|
||||
/* "The Peeled Eyes" */
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[4].TeamName,
|
||||
sizeof (pMS->PreBuiltList[4].TeamName),
|
||||
GAME_STRING (MELEE_STRING_BASE + 8));
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_SYREEN;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[4].ShipList[i++] = MELEE_ORZ;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[5].TeamName,
|
||||
sizeof (pMS->PreBuiltList[5].TeamName),
|
||||
"Ford's Fighters");
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_UTWIG;
|
||||
pMS->PreBuiltList[5].ShipList[i++] = MELEE_UMGAH;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[6].TeamName,
|
||||
sizeof (pMS->PreBuiltList[6].TeamName),
|
||||
"Leyland's Lashers");
|
||||
pMS->PreBuiltList[6].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[6].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[6].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[6].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[6].ShipList[i++] = MELEE_URQUAN;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[7].TeamName,
|
||||
sizeof (pMS->PreBuiltList[7].TeamName),
|
||||
"The Gregorizers 200");
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[7].ShipList[i++] = MELEE_SPATHI;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[8].TeamName,
|
||||
sizeof (pMS->PreBuiltList[8].TeamName),
|
||||
"300 point Armada!");
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_SPATHI;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[8].ShipList[i++] = MELEE_YEHAT;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[9].TeamName,
|
||||
sizeof (pMS->PreBuiltList[9].TeamName),
|
||||
"Little Dudes with Attitudes");
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_UMGAH;
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_THRADDASH;
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_VUX;
|
||||
pMS->PreBuiltList[9].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[10].TeamName,
|
||||
sizeof (pMS->PreBuiltList[10].TeamName),
|
||||
"New Alliance Ships");
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_ARILOU;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_SYREEN;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_UTWIG;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_YEHAT;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_THRADDASH;
|
||||
pMS->PreBuiltList[10].ShipList[i++] = MELEE_SPATHI;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[11].TeamName,
|
||||
sizeof (pMS->PreBuiltList[11].TeamName),
|
||||
"Old Alliance Ships");
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_ARILOU;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_MMRNMHRM;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_SYREEN;
|
||||
pMS->PreBuiltList[11].ShipList[i++] = MELEE_YEHAT;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[12].TeamName,
|
||||
sizeof (pMS->PreBuiltList[12].TeamName),
|
||||
"Old Hierarchy Ships");
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_ILWRATH;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_SPATHI;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_UMGAH;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[12].ShipList[i++] = MELEE_VUX;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[13].TeamName,
|
||||
sizeof (pMS->PreBuiltList[13].TeamName),
|
||||
"Star Control 1");
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_ANDROSYNTH;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_ARILOU;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_CHENJESU;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_EARTHLING;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_ILWRATH;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_MMRNMHRM;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_MYCON;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_SHOFIXTI;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_SPATHI;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_SYREEN;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_UMGAH;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_URQUAN;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_VUX;
|
||||
pMS->PreBuiltList[13].ShipList[i++] = MELEE_YEHAT;
|
||||
}
|
||||
|
||||
{
|
||||
FleetShipIndex i = 0;
|
||||
utf8StringCopy (pMS->PreBuiltList[14].TeamName,
|
||||
sizeof (pMS->PreBuiltList[14].TeamName),
|
||||
"Star Control 2");
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_CHMMR;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_DRUUGE;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_KOHR_AH;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_MELNORME;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_ORZ;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_PKUNK;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_SLYLANDRO;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_SUPOX;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_THRADDASH;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_UTWIG;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
pMS->PreBuiltList[14].ShipList[i++] = MELEE_ZOQFOTPIK;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
LoadMeleeConfig (MELEE_STATE *pMS)
|
||||
{
|
||||
@@ -2987,8 +2224,7 @@ LoadMeleeConfig (MELEE_STATE *pMS)
|
||||
goto err;
|
||||
PlayerControl[side] = (BYTE)status;
|
||||
|
||||
status = ReadTeamImage (&pMS->SideState[side].TeamImage, load_fp);
|
||||
if (status == -1)
|
||||
if (!ReadTeamImage (&pMS->SideState[side].TeamImage, load_fp))
|
||||
goto err;
|
||||
|
||||
/* Do not allow netplay mode at the start. */
|
||||
@@ -3066,7 +2302,7 @@ Melee (void)
|
||||
#endif
|
||||
|
||||
MenuState.CurIndex = (COUNT)~0;
|
||||
InitPreBuilt (&MenuState);
|
||||
InitMeleeLoadState (&MenuState);
|
||||
|
||||
GLOBAL (CurrentActivity) = SUPER_MELEE;
|
||||
|
||||
@@ -3075,9 +2311,9 @@ Melee (void)
|
||||
if (LoadMeleeConfig (&MenuState) == -1)
|
||||
{
|
||||
PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING;
|
||||
MenuState.SideState[0].TeamImage = MenuState.PreBuiltList[0];
|
||||
MenuState.SideState[0].TeamImage = MenuState.load.preBuiltList[0];
|
||||
PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING;
|
||||
MenuState.SideState[1].TeamImage = MenuState.PreBuiltList[1];
|
||||
MenuState.SideState[1].TeamImage = MenuState.load.preBuiltList[1];
|
||||
}
|
||||
SetPlayerInput ();
|
||||
teamStringChanged (&MenuState, 0);
|
||||
@@ -3104,6 +2340,8 @@ Melee (void)
|
||||
DestroyDrawable (ReleaseDrawable (PickMeleeFrame));
|
||||
PickMeleeFrame = 0;
|
||||
|
||||
UninitMeleeLoadState (&MenuState);
|
||||
|
||||
RandomContext_Delete (MenuState.randomContext);
|
||||
|
||||
FlushInput ();
|
||||
|
||||
+10
-6
@@ -78,8 +78,6 @@ extern FRAME PickMeleeFrame;
|
||||
// in SuperMelee.
|
||||
|
||||
#define MAX_TEAM_CHARS 30
|
||||
#define MAX_VIS_TEAMS 5
|
||||
#define NUM_PREBUILT 15
|
||||
#define NUM_PICK_COLS 5
|
||||
#define NUM_PICK_ROWS 5
|
||||
|
||||
@@ -94,6 +92,8 @@ typedef struct
|
||||
* default name in starcon.txt is unknowingly mangled. */
|
||||
} TEAM_IMAGE;
|
||||
|
||||
#include "loadmele.h"
|
||||
|
||||
struct melee_side_state
|
||||
{
|
||||
TEAM_IMAGE TeamImage;
|
||||
@@ -107,14 +107,11 @@ struct melee_state
|
||||
|
||||
BOOLEAN Initialized;
|
||||
MELEE_OPTIONS MeleeOption;
|
||||
DIRENTRY TeamDE;
|
||||
COUNT TopTeamIndex, BotTeamIndex;
|
||||
COUNT side, row, col;
|
||||
struct melee_side_state SideState[NUM_SIDES];
|
||||
struct melee_load_state load;
|
||||
COUNT CurIndex;
|
||||
Task flash_task;
|
||||
TEAM_IMAGE FileList[MAX_VIS_TEAMS];
|
||||
TEAM_IMAGE PreBuiltList[NUM_PREBUILT];
|
||||
RandomContext *randomContext;
|
||||
/* RNG state for all local random decisions, i.e. those
|
||||
* decisions that are not shared among network parties. */
|
||||
@@ -124,6 +121,13 @@ struct melee_state
|
||||
|
||||
extern void Melee (void);
|
||||
|
||||
// Some prototypes for use by loadmele.c:
|
||||
BOOLEAN DoMelee (MELEE_STATE *pMS);
|
||||
void DrawMeleeIcon (COUNT which_icon);
|
||||
COUNT GetTeamValue (TEAM_IMAGE *pTI);
|
||||
void RepairMeleeFrame (RECT *pRect);
|
||||
extern FRAME MeleeFrame;
|
||||
|
||||
void teamStringChanged (MELEE_STATE *pMS, int player);
|
||||
void entireFleetChanged (MELEE_STATE *pMS, int player);
|
||||
void fleetShipChanged (MELEE_STATE *pMS, int player, size_t index);
|
||||
|
||||
Reference in New Issue
Block a user