Package: hedgewars Version: 0.9.0-4 Severity: normal Tags: patch incorrect team select widget state after adding new team with 'New team' button at network game and multiplayer game
Steps to reproduce: 1. Press multiplayer game 2. Add some existing teams 3. Press 'New team' button 4. Edit new team and press Save Now we have cleared playing teams widget instead of expected adding a new team. Patch to fix this problem (also some fixes due to remove warnings in hedgewars engine at compilation and more correct way of finding and using Qt4 in CMake) included.
Index: QTfrontend/hwform.cpp =================================================================== --- QTfrontend/hwform.cpp (revision 506) +++ QTfrontend/hwform.cpp (revision 510) @@ -156,20 +156,27 @@ GoToPage(ID_PAGE_NET); } -void HWForm::OnPageShown(quint8 id) +void HWForm::OnPageShown(quint8 id, quint8 lastid) { if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) { QStringList tmNames=config->GetTeamsList(); TeamSelWidget* curTeamSelWidget; - id == ID_PAGE_MULTIPLAYER ? curTeamSelWidget=ui.pageMultiplayer->teamsSelect : + if(id == ID_PAGE_MULTIPLAYER) { + curTeamSelWidget=ui.pageMultiplayer->teamsSelect; + } else { curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; + } QList<HWTeam> teamsList; for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { HWTeam team(*it); team.LoadFromFile(); teamsList.push_back(team); } - curTeamSelWidget->resetPlayingTeams(teamsList); + if(lastid==ID_PAGE_SETUP_TEAM) { + if (editedTeam) curTeamSelWidget->addTeam(*editedTeam); + } else { + curTeamSelWidget->resetPlayingTeams(teamsList); + } } } @@ -186,7 +193,7 @@ if(hwnet || pnetserver) NetDisconnect(); } quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); - OnPageShown(id); + OnPageShown(id, ui.Pages->currentIndex()); ui.Pages->setCurrentIndex(id); } @@ -209,14 +216,16 @@ { editedTeam->GetFromPage(this); editedTeam->SaveToFile(); - delete editedTeam; UpdateTeamsLists(); GoBack(); + delete editedTeam; + editedTeam=0; } void HWForm::TeamDiscard() { delete editedTeam; + editedTeam=0; GoBack(); } Index: QTfrontend/CMakeLists.txt =================================================================== --- QTfrontend/CMakeLists.txt (revision 506) +++ QTfrontend/CMakeLists.txt (revision 510) @@ -1,8 +1,14 @@ set(QT_MIN_VERSION "4.2.0") +set(QT_USE_QTNETWORK TRUE) +set(QT_USE_QTSVG TRUE) +set(QT_USE_QTXML TRUE) +set(QT_USE_QTMAIN TRUE) + find_package(Qt4 REQUIRED) +include(${QT_USE_FILE}) -include_directories(${QT_INCLUDES} .) +include_directories(.) if(WIN32 AND NOT UNIX) set(HEDGEWARS_BINDIR ".") @@ -99,26 +105,18 @@ ${hwfr_moc_srcs} ${hwfr_hdrs} ${hwfr_rez_src}) + +set(HW_LINK_LIBS ${QT_LIBRARIES}) +if(WIN32 AND NOT UNIX) + set(HW_LINK_LIBS + ${HW_LINK_LIBS} + ole32 + winspool + uuid) +endif(WIN32 AND NOT UNIX) + target_link_libraries(hedgewars - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTSVG_LIBRARY} - ${QT_QTMAIN_LIBRARY}) + ${HW_LINK_LIBS}) install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) - - -if(WIN32 AND NOT UNIX) - string(REPLACE "\\" "/" QT_BIN_DIR $ENV{QTDIR}/bin) - - install(FILES - "${QT_BIN_DIR}/QtNetwork4.dll" - "${QT_BIN_DIR}/QtGui4.dll" - "${QT_BIN_DIR}/QtCore4.dll" - "${QT_BIN_DIR}/QtSvg4.dll" - "${QT_BIN_DIR}/QtXml4.dll" - "${QT_BIN_DIR}/mingwm10.dll" - DESTINATION bin) -endif(WIN32 AND NOT UNIX) Index: QTfrontend/hwform.h =================================================================== --- QTfrontend/hwform.h (revision 506) +++ QTfrontend/hwform.h (revision 510) @@ -94,7 +94,7 @@ HWNetServer* pnetserver; HWNetUdpServer* pUdpServer; void AddStatText(const QString & msg); - void OnPageShown(quint8 id); + void OnPageShown(quint8 id, quint8 lastid=0); }; #endif Index: hedgewars/uLand.pas =================================================================== --- hedgewars/uLand.pas (revision 506) +++ hedgewars/uLand.pas (revision 510) @@ -212,7 +212,7 @@ end; procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat); -var x, y, i, StartLoop: LongInt; +var i, StartLoop: LongInt; opa: TPixAr; begin opa:= pa; Index: hedgewars/uMisc.pas =================================================================== --- hedgewars/uMisc.pas (revision 506) +++ hedgewars/uMisc.pas (revision 510) @@ -167,16 +167,6 @@ FloatToStr:= cstr(n) end; -{$IFNDEF FPC} -function arctan2(const Y, X: hwFloat): hwFloat; -asm - fld Y - fld X - fpatan - fwait -end; -{$ENDIF} - function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; const _16divPI: Extended = 16/pi; var dY, dX: Extended; Index: hedgewars/GSHandlers.inc =================================================================== --- hedgewars/GSHandlers.inc (revision 506) +++ hedgewars/GSHandlers.inc (revision 510) @@ -1035,7 +1035,6 @@ end; procedure doStepAirAttack(Gear: PGear); -var t: LongInt; begin AllInactive:= false; if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 Index: hedgewars/options.inc =================================================================== --- hedgewars/options.inc (revision 506) +++ hedgewars/options.inc (revision 510) @@ -18,7 +18,7 @@ {$J+} -{ $DEFINE DEBUGFILE} +{$DEFINE DEBUGFILE} { $DEFINE COUNTTICKS} { $DEFINE DUMP} { $DEFINE TRACEAIACTIONS} Index: hedgewars/uLandGraphics.pas =================================================================== --- hedgewars/uLandGraphics.pas (revision 506) +++ hedgewars/uLandGraphics.pas (revision 510) @@ -269,13 +269,11 @@ end; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): boolean; -var Result: boolean; - X, Y, sY, bpp, h, w: LongInt; +var X, Y, bpp, h, w: LongInt; p: PByteArray; r, rr: TSDL_Rect; Image: PSDL_Surface; begin -Result:= true; Image:= SpritesData[Obj].Surface; w:= SpritesData[Obj].Width; h:= SpritesData[Obj].Height; Index: hedgewars/uConsts.pas =================================================================== --- hedgewars/uConsts.pas (revision 506) +++ hedgewars/uConsts.pas (revision 510) @@ -357,7 +357,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidClusterBomb; Probability: 100; NumberInCase: 3; @@ -372,7 +373,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidBazooka; Probability: 0; NumberInCase: 1; @@ -386,7 +388,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidUFO; Probability: 100; NumberInCase: 1; @@ -401,7 +404,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidShotgun; Probability: 0; NumberInCase: 1; @@ -415,7 +419,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidPickHammer; Probability: 0; NumberInCase: 1; @@ -432,7 +437,8 @@ TimeAfterTurn: 0; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidSkip; Probability: 0; NumberInCase: 1; @@ -446,7 +452,8 @@ TimeAfterTurn: 0; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidRope; Probability: 100; NumberInCase: 3; @@ -462,7 +469,8 @@ TimeAfterTurn: 0; minAngle: 0; maxAngle: cMaxAngle div 2; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidMine; Probability: 100; NumberInCase: 1; @@ -476,7 +484,8 @@ TimeAfterTurn: 5000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidDEagle; Probability: 100; NumberInCase: 2; @@ -490,7 +499,8 @@ TimeAfterTurn: 3000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidDynamite; Probability: 100; NumberInCase: 1; @@ -506,7 +516,8 @@ TimeAfterTurn: 5000; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidFirePunch; Probability: 0; NumberInCase: 1; @@ -523,7 +534,8 @@ TimeAfterTurn: 3000; MinAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidBaseballBat; Probability: 100; NumberInCase: 1; @@ -537,7 +549,8 @@ TimeAfterTurn: 5000; minAngle: 0; maxAngle: cMaxAngle div 2; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidParachute; Probability: 100; NumberInCase: 1; @@ -554,7 +567,8 @@ TimeAfterTurn: 0; minAngle: 0; maxAngle: 0; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidAirAttack; Probability: 100; NumberInCase: 1; @@ -602,7 +616,8 @@ TimeAfterTurn: 3000; minAngle: 768; maxAngle: 1280; - PosCount: 1), + PosCount: 1; + PosSprite: sprWater), (NameId: sidGirder; Probability: 400; NumberInCase: 3; Index: hedgewars/uStore.pas =================================================================== --- hedgewars/uStore.pas (revision 506) +++ hedgewars/uStore.pas (revision 510) @@ -248,6 +248,7 @@ TryDo(IOResult = 0, msgFailed, true); WriteLnToConsole(msgOK); val(s, cExplosionBorderColor, c); + TryDo(c = 0, 'Theme data corrupted', true); AdjustColor(cExplosionBorderColor); end; Index: hedgewars/uGears.pas =================================================================== --- hedgewars/uGears.pas (revision 506) +++ hedgewars/uGears.pas (revision 510) @@ -842,7 +842,7 @@ CountNonZeroz:= Result end; -var fx, x: LongInt; +var x: LongInt; y, sy: LongInt; ar: array[0..511] of TPoint; ar2: array[0..1023] of TPoint; Index: hedgewars/uConsole.pas =================================================================== --- hedgewars/uConsole.pas (revision 506) +++ hedgewars/uConsole.pas (revision 510) @@ -156,7 +156,7 @@ procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); type PhwFloat = ^hwFloat; -var i, ii: LongInt; +var ii: LongInt; s: shortstring; t: PVariable; c: char; @@ -183,8 +183,8 @@ begin str(PLongInt(t^.Handler)^, s); WriteLnToConsole('$' + CmdStr + ' is "' + s + '"'); - end else val(s, PLongInt(t^.Handler)^, i); - vthwFloat: if c='$' then + end else val(s, PLongInt(t^.Handler)^); + vthwFloat: if c='$' then if s[0]=#0 then begin //str(PhwFloat(t^.Handler)^:4:6, s); @@ -197,7 +197,7 @@ WriteLnToConsole('$' + CmdStr + ' is "' + s + '"'); end else begin - val(s, ii, i); + val(s, ii); boolean(t^.Handler^):= not (ii = 0) end; end; Index: hedgewars/CCHandlers.inc =================================================================== --- hedgewars/CCHandlers.inc (revision 506) +++ hedgewars/CCHandlers.inc (revision 510) @@ -99,27 +99,25 @@ end; procedure chColor(var id: shortstring); -var c: LongInt; begin if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true); -val(id, CurrentTeam^.Color, c); +val(id, CurrentTeam^.Color); CurrentTeam^.AdjColor:= CurrentTeam^.Color; AdjustColor(CurrentTeam^.AdjColor) end; procedure chAddHH(var id: shortstring); var s: shortstring; - c: LongInt; Gear: PGear; begin if (not isDeveloperMode) or (CurrentTeam = nil) then exit; with CurrentTeam^ do begin SplitBySpace(id, s); - val(id, Hedgehogs[HedgehogsNumber].BotLevel, c); + val(id, Hedgehogs[HedgehogsNumber].BotLevel); Gear:= AddGear(0, 0, gtHedgehog, 0, 0, 0, 0); Gear^.Hedgehog:= @Hedgehogs[HedgehogsNumber]; - val(s, Gear^.Health, c); + val(s, Gear^.Health); TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1;