SetPlayerInput() and SetPlayerInputAll() may fail.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3204 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2009-10-08 19:59:53 +00:00
parent 7237f0bab3
commit c1d112191d
5 changed files with 28 additions and 11 deletions
+5 -1
View File
@@ -36,6 +36,7 @@
#include "setup.h"
#include "sounds.h"
#include "libs/graphics/gfx_common.h"
#include "libs/log.h"
#include "libs/mathlib.h"
#include "libs/inplib.h"
@@ -756,7 +757,10 @@ EncounterBattle (void)
PlayerControl[0] = CYBORG_CONTROL | AWESOME_RATING;
savedPlayerInput = PlayerInput[0];
PlayerInput[0] = NULL;
SetPlayerInput (0);
if (!SetPlayerInput (0)) {
log_add (log_Fatal, "Could not set cyborg player input.");
explode (); // Does not return;
}
}
GameSounds = CaptureSound (LoadSound (GAME_SOUNDS));
+2 -1
View File
@@ -1738,7 +1738,8 @@ StartMelee (MELEE_STATE *pMS)
WaitForSoundEnd (TFBSOUND_WAIT_ALL);
SetPlayerInputAll ();
if (!SetPlayerInputAll ())
break;
load_gravity_well ((BYTE)((COUNT)TFB_Random () %
NUMBER_OF_PLANET_TYPES));
Battle ();
+15 -6
View File
@@ -231,7 +231,7 @@ InitGameKernel (void)
return TRUE;
}
void
bool
SetPlayerInput (COUNT playerI)
{
assert (PlayerInput[playerI] == NULL);
@@ -243,7 +243,7 @@ SetPlayerInput (COUNT playerI)
break;
case COMPUTER_CONTROL:
case CYBORG_CONTROL:
// COMPUTER_CONTROL is used in SuperMelee; the computer choses
// COMPUTER_CONTROL is used in SuperMelee; the computer chooses
// the ships and fights the battles.
// CYBORG_CONTROL is used in the full game; the computer only
// fights the battles. XXX: This will need to be handled
@@ -260,23 +260,32 @@ SetPlayerInput (COUNT playerI)
break;
#endif
default:
fprintf (stderr, "Invalid control method in SetPlayerInput().\n");
log_add (log_Fatal,
"Invalid control method in SetPlayerInput().");
explode (); /* Does not return */
}
return PlayerInput[playerI] != NULL;
}
void
bool
SetPlayerInputAll (void)
{
COUNT playerI;
for (playerI = 0; playerI < NUM_PLAYERS; playerI++)
SetPlayerInput (playerI);
if (!SetPlayerInput (playerI))
return false;
return true;
}
void
ClearPlayerInput (COUNT playerI)
{
assert (PlayerInput[playerI] != NULL);
if (PlayerInput[playerI] == NULL) {
log_add (log_Debug, "ClearPlayerInput(): PlayerInput[%d] was NULL.",
playerI);
return;
}
PlayerInput[playerI]->handlers->deleteContext (PlayerInput[playerI]);
PlayerInput[playerI] = NULL;
+2 -2
View File
@@ -67,8 +67,8 @@ extern void FreeKernel (void);
int initIO (void);
void uninitIO (void);
void SetPlayerInput (COUNT playerI);
void SetPlayerInputAll (void);
bool SetPlayerInput (COUNT playerI);
bool SetPlayerInputAll (void);
void ClearPlayerInput (COUNT playerI);
void ClearPlayerInputAll (void);
+4 -1
View File
@@ -162,7 +162,10 @@ while (--ac > 0)
while (StartGame ())
{
// Initialise a new game
SetPlayerInputAll ();
if (!SetPlayerInputAll ()) {
log_add (log_Fatal, "Could not set player input.");
explode (); // Does not return;
}
InitSIS ();
InitGameClock ();
AddInitialGameEvents();