From 02085a84227e88ffe8f7a704d9cc70a960f77bd0 Mon Sep 17 00:00:00 2001 From: Wanne Date: Thu, 11 Oct 2012 18:20:21 +0000 Subject: [PATCH] - MP Bugfix: Fixed the nasty interrupt bug (endless clock), when playing in COOP and the pure client got interrupted by the enemy AI (by haydent) o As a workaround the server had to press ALT + E to give the turn back to the client. Now this workaround should not be needed (hopefully ) :) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5623 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Multiplayer/client.cpp | 55 +++++++++++++++++++++------------------- Tactical/TeamTurns.cpp | 34 ++++++++++++------------- Utils/_ChineseText.cpp | 2 +- Utils/_DutchText.cpp | 2 +- Utils/_EnglishText.cpp | 2 +- Utils/_FrenchText.cpp | 2 +- Utils/_GermanText.cpp | 2 +- Utils/_ItalianText.cpp | 2 +- Utils/_PolishText.cpp | 2 +- Utils/_RussianText.cpp | 2 +- Utils/_TaiwaneseText.cpp | 2 +- 11 files changed, 55 insertions(+), 52 deletions(-) diff --git a/Multiplayer/client.cpp b/Multiplayer/client.cpp index 212ebd0f..a6d1ce64 100644 --- a/Multiplayer/client.cpp +++ b/Multiplayer/client.cpp @@ -1941,10 +1941,18 @@ void recieveINTERRUPT (RPCParameters *rpcParameters) INT_STRUCT* INT = (INT_STRUCT*)rpcParameters->input; SOLDIERTYPE* pOpponent = MercPtrs[ INT->Interrupted]; - if(INT->bTeam==netbTeam)//for us + if(INT->bTeam == netbTeam || (is_server && INT->bTeam == 1))//its for us or we are server and its for AI which we control { - INT->bTeam=0; - INT->ubID=INT->ubID - ubID_prefix; + + if(INT->bTeam == netbTeam){//for me + INT->bTeam=0; + INT->ubID=INT->ubID - ubID_prefix; + AddTopMessage( PLAYER_INTERRUPT_MESSAGE, TeamTurnString[ INT->bTeam ] ); + }else{//for ai + //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"starting ai" ); + AddTopMessage( COMPUTER_INTERRUPT_MESSAGE, TeamTurnString[ INT->bTeam ] ); + } + for(int i=0; i <= INT->gubOutOfTurnPersons; i++)//this loop translates soldier id's from what they are in someone else's game to what they are locally { @@ -1957,14 +1965,24 @@ void recieveINTERRUPT (RPCParameters *rpcParameters) gubOutOfTurnPersons = INT->gubOutOfTurnPersons; - AddTopMessage( PLAYER_INTERRUPT_MESSAGE, TeamTurnString[ INT->bTeam ] ); - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt of %s awarded to %s.", TeamNameStrings[pOpponent->bTeam], TeamNameStrings[INT->bTeam] ); + //AddTopMessage( PLAYER_INTERRUPT_MESSAGE, TeamTurnString[ INT->bTeam ] ); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Recieved interrupt between %s and %s.", TeamNameStrings[pOpponent->bTeam], TeamNameStrings[INT->bTeam] ); + + + + //start interrupt turn //real interrupt code + SOLDIERTYPE* pSoldier = MercPtrs[ INT->ubID ]; + ManSeesMan(pSoldier,pOpponent,pOpponent->sGridNo,pOpponent->pathing.bLevel,2,1); + StartInterrupt(); + } - - // WANNE - MP: This seems to cause the HANG on AI interrupt where we have to press ALT + E on the server! - if( INT->bTeam != 0)//not for our team - hayden + else//its not for us, make faux interrupt look while it happens { + //this following section starts the interrupt, either with faux interrupt look, or real interrupt code, or nothing if already there + + //if( INT->bTeam != 0)//not for our team - hayden + //{ //stop moving merc who was interrupted and init UI bar SOLDIERTYPE* pMerc = MercPtrs[ INT->ubID ]; @@ -1977,29 +1995,14 @@ void recieveINTERRUPT (RPCParameters *rpcParameters) AddTopMessage( COMPUTER_INTERRUPT_MESSAGE, TeamTurnString[ INT->bTeam ] ); //this needed to add details of who's interrupt it is - hayden - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt with %s awarded to %s.", TeamNameStrings[pOpponent->bTeam], TeamNameStrings[INT->bTeam] );//was MPClientMessage[17], can be reconnected if text updated and translated + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Recieved interrupt with %s and %s.", TeamNameStrings[pOpponent->bTeam], TeamNameStrings[INT->bTeam] );//was MPClientMessage[17], can be reconnected if text updated and translated } - else - { - //it for us ! :) - if(INT->gubOutOfTurnPersons==0)//indicates finished interrupt maybe can just call end interrupt - { - //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"old int finish" ); - } - else //start our interrupt turn - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt of %s awarded to you.", TeamNameStrings[pOpponent->bTeam] );//was MPClientMessage[37], can be reconnected if text updated and translated - SOLDIERTYPE* pSoldier = MercPtrs[ INT->ubID ]; - ManSeesMan(pSoldier,pOpponent,pOpponent->sGridNo,pOpponent->pathing.bLevel,2,1); - StartInterrupt(); - } - } } void intAI (SOLDIERTYPE *pSoldier ) { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"intAI with %s", TeamNameStrings[pSoldier->bTeam] );//was MPClientMessage[17], can be reconnected if text updated and translated + //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"intAI with %s", TeamNameStrings[pSoldier->bTeam] );//was MPClientMessage[17], can be reconnected if text updated and translated AddTopMessage( COMPUTER_INTERRUPT_MESSAGE, TeamTurnString[ pSoldier->bTeam ] ); gTacticalStatus.fInterruptOccurred = TRUE; } @@ -4606,7 +4609,7 @@ void teamwiped ( void ) void recieve_wipe (RPCParameters *rpcParameters) { sc_struct* data = (sc_struct*)rpcParameters->input; - ScreenMsg( FONT_LTGREEN, MSG_INTERFACE, MPClientMessage[75], data->ubStartingTeam ); + ScreenMsg( FONT_LTGREEN, MSG_INTERFACE, MPClientMessage[75], TeamNameStrings[data->ubStartingTeam] ); if(is_server) { if(gTacticalStatus.ubCurrentTeam==data->ubStartingTeam)EndTurn( data->ubStartingTeam+1 ); diff --git a/Tactical/TeamTurns.cpp b/Tactical/TeamTurns.cpp index 9cc8d7b4..f85abf0a 100644 --- a/Tactical/TeamTurns.cpp +++ b/Tactical/TeamTurns.cpp @@ -1162,15 +1162,16 @@ void EndInterrupt( BOOLEAN fMarkInterruptOccurred ) #ifdef BETAVERSION ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"unchecked interrupt call area:(resume interrupted interrupt)..."); #endif - - if ((nbTeam > 0) && (nbTeam <6 ) && is_server) // AI interrupt resume and im server + // INTERRUPT is calculated on the server who controls AI + if (0)//(nbTeam > 0) && (nbTeam <6 ) && is_server) //the AI had interrupted someone //experiment with 0 as with doneaddindtointlist func { send_interrupt( npSoldier ); StartInterrupt(); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Continuing interrupt with %s and AI", TeamNameStrings[npSoldier->bTeam]);//tried to use pSoldier, but its not available. find another way to get correct team } - else if(is_server && gTacticalStatus.ubCurrentTeam == 1)// resume AI interrupted and im server + // INTERRUPT is calculated on the server who controls AI + else if(is_server && gTacticalStatus.ubCurrentTeam == 1)//its AI's turn (it got interrupted) { //hayden send_interrupt( npSoldier ); @@ -1183,7 +1184,7 @@ void EndInterrupt( BOOLEAN fMarkInterruptOccurred ) ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Continuing interrupt of AI by %s", TeamNameStrings[npSoldier->bTeam]); } - else// pure client awarding interrupt resume //suspect it needs to be: else if(gTacticalStatus.ubCurrentTeam == 0)//its our turn (we are moving) + else if(gTacticalStatus.ubCurrentTeam == 0)//its our turn//else// pure client awarding interrupt resume //its our turn { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Continuing interrupt with %s", TeamNameStrings[npSoldier->bTeam]);//this can be simplified if above comment is implemented @@ -2259,10 +2260,10 @@ void DoneAddingToIntList( SOLDIERTYPE * pSoldier, BOOLEAN fChange, UINT8 ubInter //npSoldier is interruptor //hayden - // INTERRUPT is calculated on the server - if ((nbTeam > 0) && (nbTeam <6 ) && is_server) //is for AI and are server - { - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s is interrupt by AI", TeamNameStrings[pSoldier->bTeam]); + // INTERRUPT is calculated on the server who controls AI + if (0)//((nbTeam > 0) && (nbTeam <6 ) && is_server) //the AI has interrupted someone//made this 0 as interrupt should only be calculated by person whos turn it is + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt calculated between %s and AI", TeamNameStrings[pSoldier->bTeam]); // Only display the top message if we (the server) got interrupted if (pSoldier->bTeam == 0) @@ -2272,8 +2273,8 @@ void DoneAddingToIntList( SOLDIERTYPE * pSoldier, BOOLEAN fChange, UINT8 ubInter StartInterrupt(); } - // INTERRUPT is calculated on the server - else if(is_server && gTacticalStatus.ubCurrentTeam == 1)// against ai and are server + // INTERRUPT is calculated on the server who controls AI + else if(is_server && gTacticalStatus.ubCurrentTeam == 1)//the AI has been interrupted { //hayden send_interrupt( npSoldier ); // @@ -2282,16 +2283,15 @@ void DoneAddingToIntList( SOLDIERTYPE * pSoldier, BOOLEAN fChange, UINT8 ubInter else StartInterrupt();// - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"AI is interrupted by %s", TeamNameStrings[npSoldier->bTeam]); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt calculated with AI and %s", TeamNameStrings[npSoldier->bTeam]); } - // INTERRUPT is calculated on the pure client - else if(gTacticalStatus.ubCurrentTeam == 0)//its our turn (we are moving) - { - ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, MPClientMessage[79]); + // INTERRUPT is calculated on the pure client or server + else if(gTacticalStatus.ubCurrentTeam == 0)//its our turn + { + //ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, MPClientMessage[79]); send_interrupt( npSoldier ); - SOLDIERTYPE* pMerc = MercPtrs[ gusSelectedSoldier ]; //AdjustNoAPToFinishMove( pMerc, TRUE ); pMerc->HaultSoldierFromSighting(TRUE); @@ -2302,7 +2302,7 @@ void DoneAddingToIntList( SOLDIERTYPE * pSoldier, BOOLEAN fChange, UINT8 ubInter AddTopMessage( COMPUTER_INTERRUPT_MESSAGE, TeamTurnString[ nbTeam ] ); gTacticalStatus.fInterruptOccurred = TRUE; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"You have interrupted %s", TeamNameStrings[npSoldier->bTeam]); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Interrupt calculated against You by %s", TeamNameStrings[npSoldier->bTeam]); } else { diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index f7f5292f..bd887113 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -6407,7 +6407,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.", diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 7fe32e7a..abe7b733 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -6410,7 +6410,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.", diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 0e627e04..810cc6b7 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -6404,7 +6404,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.", diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index d60953ee..8de7d7a7 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -6390,7 +6390,7 @@ STR16 MPClientMessage[] = L"Mode spectateur désactivé", L"Choisir le numéro du client a kické :", // 75 - L"La team #%d a été anéantie.", + L"La team %s a été anéantie.", L"Le client n'as pas réussi à démarrer. Terminé.", L"Le client s'est déconnecté et s'est fermé.", L"Le client n'est pas démarré.", diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index ba11eb52..e36ff081 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -6229,7 +6229,7 @@ STR16 MPClientMessage[] = L"Überwachungsmodus wurde ausgeschaltet", L"Wählen Sie den Client, der gekickt werden soll. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d wurde vernichtet", + L"Team %s wurde vernichtet", L"Client konnte nicht gestartet werden. Beendigung.", L"Client Verbindung aufgelöst und heruntergefahren.", L"Client läuft nicht.", diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index b4e5b952..1bc3c91f 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -6398,7 +6398,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.", diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 55e964bc..7b6a9fac 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -6407,7 +6407,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.", diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index 0e743e22..e24c8409 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -6381,7 +6381,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Укажите номер клиента, который нужно кикнуть. №1: <Отменить>, №2: %S, №3: %S, №4: %S", // 75 - L"Команда #%d уничтожена.", + L"Команда %s уничтожена.", L"Ошибка при запуске клиента. Завершение операции.", L"Клиент отсоединился и закрыт.", L"Клиент не запущен.", diff --git a/Utils/_TaiwaneseText.cpp b/Utils/_TaiwaneseText.cpp index 3218daa5..031996d6 100644 --- a/Utils/_TaiwaneseText.cpp +++ b/Utils/_TaiwaneseText.cpp @@ -6414,7 +6414,7 @@ STR16 MPClientMessage[] = L"Spectator mode disabled", L"Choose client to kick from game. #1: , #2: %S, #3: %S, #4: %S", // 75 - L"Team #%d is wiped out.", + L"Team %s is wiped out.", L"Client failed to start. Terminating.", L"Client disconnected and shutdown.", L"Client is not running.",