Corrected abort feedback.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2577 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2006-12-07 04:21:26 +00:00
parent e69613241f
commit ebcf23a5bf
3 changed files with 47 additions and 31 deletions
+17 -11
View File
@@ -3205,12 +3205,12 @@ confirmationCancelled(PMELEE_STATE pMS, COUNT side)
} }
static void static void
connectionFeedback (NetConnection *conn, const char *str) { connectionFeedback (NetConnection *conn, const char *str, bool forcePopup) {
struct battlestate_struct *bs = NetMelee_getBattleState (conn); struct battlestate_struct *bs = NetMelee_getBattleState (conn);
if (bs == NULL) if (bs == NULL && !forcePopup)
{ {
// bs == NULL means the game has started. // bs == NULL means the game has not started yet.
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DrawMeleeStatusMessage (str); DrawMeleeStatusMessage (str);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
@@ -3224,10 +3224,12 @@ connectionFeedback (NetConnection *conn, const char *str) {
void void
connectedFeedback (NetConnection *conn) { connectedFeedback (NetConnection *conn) {
if (NetConnection_getPlayerNr(conn) == 0) if (NetConnection_getPlayerNr(conn) == 0)
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 8)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 8),
false);
// "Bottom player is connected." // "Bottom player is connected."
else else
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 9)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 9),
false);
// "Top player is connected." // "Top player is connected."
PlayMenuSound (MENU_SOUND_INVOKED); PlayMenuSound (MENU_SOUND_INVOKED);
@@ -3261,7 +3263,7 @@ abortFeedback (NetConnection *conn, NetplayAbortReason reason)
msg = abortReasonString (reason); msg = abortReasonString (reason);
if (msg != NULL) if (msg != NULL)
connectionFeedback (conn, msg); connectionFeedback (conn, msg, true);
} }
const char * const char *
@@ -3305,17 +3307,19 @@ resetFeedback (NetConnection *conn, NetplayResetReason reason,
msg = resetReasonString (reason); msg = resetReasonString (reason);
if (msg != NULL) if (msg != NULL)
connectionFeedback (conn, msg); connectionFeedback (conn, msg, false);
} }
void void
errorFeedback (NetConnection *conn) errorFeedback (NetConnection *conn)
{ {
if (NetConnection_getPlayerNr(conn) == 0) if (NetConnection_getPlayerNr(conn) == 0)
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 10)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 10),
false);
// "Bottom player: connection failed." // "Bottom player: connection failed."
else else
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 11)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 11),
false);
// "Top player: connection failed." // "Top player: connection failed."
} }
@@ -3323,10 +3327,12 @@ void
closeFeedback (NetConnection *conn) closeFeedback (NetConnection *conn)
{ {
if (NetConnection_getPlayerNr(conn) == 0) if (NetConnection_getPlayerNr(conn) == 0)
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 12)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 12),
false);
// "Bottom player: connection closed." // "Bottom player: connection closed."
else else
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 13)); connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 13),
false);
// "Top player: connection closed." // "Top player: connection closed."
} }
+19 -15
View File
@@ -120,18 +120,28 @@ NetMelee_getBattleState(NetConnection *conn) {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
static inline
void
netInputAux(uint32 timeoutMs) {
NetManager_process(&timeoutMs);
// This may cause more packets to be queued, hence the
// flushPacketQueues().
Alarm_process();
Callback_process();
flushPacketQueues();
// During the flush, a disconnect may be noticed, which triggers
// another callback. It must be handled immediately, before
// another flushPacketQueue() can occur, which would not know
// that the socket is no longer valid.
// TODO: modify the close handling so this order isn't
// necessary.
Callback_process();
}
// Check the network connections for input. // Check the network connections for input.
void void
netInput(void) { netInput(void) {
uint32 timeoutMs = 0; netInputAux(0);
NetManager_process(&timeoutMs);
// This may cause more packets to be queued, hence the
// flushPacketQueues().
flushPacketQueues();
Alarm_process();
Callback_process();
} }
void void
@@ -142,13 +152,7 @@ netInputBlocking(uint32 timeoutMs) {
if (nextAlarmMs < timeoutMs) if (nextAlarmMs < timeoutMs)
timeoutMs = nextAlarmMs; timeoutMs = nextAlarmMs;
NetManager_process(&timeoutMs); netInputAux(timeoutMs);
// This may cause more packets to be queued, hence the
// flushPacketQueues().
flushPacketQueues();
Alarm_process();
Callback_process();
} }
+11 -5
View File
@@ -75,6 +75,14 @@ static void NetMelee_enterState_inSetup(NetConnection *conn, void *arg);
// Called when a connection has been established. // Called when a connection has been established.
void void
NetMelee_connectCallback(NetConnection *conn) { NetMelee_connectCallback(NetConnection *conn) {
BattleStateData *battleStateData;
struct melee_state *meleeState;
meleeState = (struct melee_state *) NetConnection_getExtra(conn);
battleStateData = BattleStateData_new(meleeState, NULL, NULL);
NetConnection_setStateData(conn, (void *) battleStateData);
NetConnection_setExtra(conn, NULL);
sendInit(conn); sendInit(conn);
Netplay_localReady (conn, NetMelee_enterState_inSetup, NULL, false); Netplay_localReady (conn, NetMelee_enterState_inSetup, NULL, false);
} }
@@ -102,12 +110,10 @@ NetMelee_enterState_inSetup(NetConnection *conn, void *arg) {
int player; int player;
NetConnection_setState(conn, NetState_inSetup); NetConnection_setState(conn, NetState_inSetup);
battleStateData = (BattleStateData *) NetConnection_getStateData(conn);
meleeState = battleStateData->meleeState;
meleeState = (struct melee_state *) NetConnection_getExtra(conn);
battleStateData = BattleStateData_new(meleeState, NULL, NULL);
NetConnection_setStateData(conn, (void *) battleStateData);
NetConnection_setExtra(conn, NULL);
player = NetConnection_getPlayerNr(conn); player = NetConnection_getPlayerNr(conn);
connectedFeedback(conn); connectedFeedback(conn);