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:
+17
-11
@@ -3205,12 +3205,12 @@ confirmationCancelled(PMELEE_STATE pMS, COUNT side)
|
||||
}
|
||||
|
||||
static void
|
||||
connectionFeedback (NetConnection *conn, const char *str) {
|
||||
connectionFeedback (NetConnection *conn, const char *str, bool forcePopup) {
|
||||
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);
|
||||
DrawMeleeStatusMessage (str);
|
||||
UnlockMutex (GraphicsLock);
|
||||
@@ -3224,10 +3224,12 @@ connectionFeedback (NetConnection *conn, const char *str) {
|
||||
void
|
||||
connectedFeedback (NetConnection *conn) {
|
||||
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."
|
||||
else
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 9));
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 9),
|
||||
false);
|
||||
// "Top player is connected."
|
||||
|
||||
PlayMenuSound (MENU_SOUND_INVOKED);
|
||||
@@ -3261,7 +3263,7 @@ abortFeedback (NetConnection *conn, NetplayAbortReason reason)
|
||||
|
||||
msg = abortReasonString (reason);
|
||||
if (msg != NULL)
|
||||
connectionFeedback (conn, msg);
|
||||
connectionFeedback (conn, msg, true);
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -3305,17 +3307,19 @@ resetFeedback (NetConnection *conn, NetplayResetReason reason,
|
||||
|
||||
msg = resetReasonString (reason);
|
||||
if (msg != NULL)
|
||||
connectionFeedback (conn, msg);
|
||||
connectionFeedback (conn, msg, false);
|
||||
}
|
||||
|
||||
void
|
||||
errorFeedback (NetConnection *conn)
|
||||
{
|
||||
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."
|
||||
else
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 11));
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 11),
|
||||
false);
|
||||
// "Top player: connection failed."
|
||||
}
|
||||
|
||||
@@ -3323,10 +3327,12 @@ void
|
||||
closeFeedback (NetConnection *conn)
|
||||
{
|
||||
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."
|
||||
else
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 13));
|
||||
connectionFeedback (conn, GAME_STRING (NETMELEE_STRING_BASE + 13),
|
||||
false);
|
||||
// "Top player: connection closed."
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
void
|
||||
netInput(void) {
|
||||
uint32 timeoutMs = 0;
|
||||
NetManager_process(&timeoutMs);
|
||||
// This may cause more packets to be queued, hence the
|
||||
// flushPacketQueues().
|
||||
flushPacketQueues();
|
||||
|
||||
Alarm_process();
|
||||
Callback_process();
|
||||
netInputAux(0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -142,13 +152,7 @@ netInputBlocking(uint32 timeoutMs) {
|
||||
if (nextAlarmMs < timeoutMs)
|
||||
timeoutMs = nextAlarmMs;
|
||||
|
||||
NetManager_process(&timeoutMs);
|
||||
// This may cause more packets to be queued, hence the
|
||||
// flushPacketQueues().
|
||||
flushPacketQueues();
|
||||
|
||||
Alarm_process();
|
||||
Callback_process();
|
||||
netInputAux(timeoutMs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,14 @@ static void NetMelee_enterState_inSetup(NetConnection *conn, void *arg);
|
||||
// Called when a connection has been established.
|
||||
void
|
||||
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);
|
||||
Netplay_localReady (conn, NetMelee_enterState_inSetup, NULL, false);
|
||||
}
|
||||
@@ -103,10 +111,8 @@ NetMelee_enterState_inSetup(NetConnection *conn, void *arg) {
|
||||
|
||||
NetConnection_setState(conn, NetState_inSetup);
|
||||
|
||||
meleeState = (struct melee_state *) NetConnection_getExtra(conn);
|
||||
battleStateData = BattleStateData_new(meleeState, NULL, NULL);
|
||||
NetConnection_setStateData(conn, (void *) battleStateData);
|
||||
NetConnection_setExtra(conn, NULL);
|
||||
battleStateData = (BattleStateData *) NetConnection_getStateData(conn);
|
||||
meleeState = battleStateData->meleeState;
|
||||
|
||||
player = NetConnection_getPlayerNr(conn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user