From: <av...@us...> - 2010-01-16 21:56:52
|
Revision: 3499 http://sc2.svn.sourceforge.net/sc2/?rev=3499&view=rev Author: avolkov Date: 2010-01-16 21:56:46 +0000 (Sat, 16 Jan 2010) Log Message: ----------- Fixed concurrent fades regression; bug #1079 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/graphics/cmap.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-01-01 21:49:56 UTC (rev 3498) +++ trunk/sc2/ChangeLog 2010-01-16 21:56:46 UTC (rev 3499) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed concurrent screen fades regression (bug #1079) - Alex - Removed some legacy source code files related to resources - SvdB - Put SuperMelee source files in separate subdirectory - SvdB - Added additive and alpha drawing modes to graphics lib - Alex Modified: trunk/sc2/src/libs/graphics/cmap.c =================================================================== --- trunk/sc2/src/libs/graphics/cmap.c 2010-01-01 21:49:56 UTC (rev 3498) +++ trunk/sc2/src/libs/graphics/cmap.c 2010-01-16 21:56:46 UTC (rev 3499) @@ -347,14 +347,20 @@ } static void -FlushFadeXForms (void) +finishPendingFade (void) { - LockMutex (XFormControl.Lock); if (fadeInterval) { // end the fade immediately fadeAmount += fadeDelta; fadeInterval = 0; } +} + +static void +FlushFadeXForms (void) +{ + LockMutex (XFormControl.Lock); + finishPendingFade (); UnlockMutex (XFormControl.Lock); } @@ -388,6 +394,8 @@ LockMutex (XFormControl.Lock); + finishPendingFade (); + if (TimeInterval <= 0) { // end the fade immediately fadeAmount = FadeEnd; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-23 00:59:28
|
Revision: 3502 http://sc2.svn.sourceforge.net/sc2/?rev=3502&view=rev Author: Meep-Eep Date: 2010-01-23 00:34:27 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Cleanups and some refactoring of the SuperMelee code. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/netplay/Makeinfo trunk/sc2/src/uqm/netplay/netmelee.c trunk/sc2/src/uqm/netplay/netmelee.h trunk/sc2/src/uqm/netplay/netmisc.c trunk/sc2/src/uqm/netplay/notify.c trunk/sc2/src/uqm/netplay/notify.h trunk/sc2/src/uqm/netplay/packet.h trunk/sc2/src/uqm/netplay/packethandlers.c trunk/sc2/src/uqm/netplay/packetsenders.c trunk/sc2/src/uqm/netplay/packetsenders.h trunk/sc2/src/uqm/supermelee/Makeinfo trunk/sc2/src/uqm/supermelee/loadmele.c trunk/sc2/src/uqm/supermelee/loadmele.h trunk/sc2/src/uqm/supermelee/melee.c trunk/sc2/src/uqm/supermelee/melee.h trunk/sc2/src/uqm/supermelee/pickmele.c trunk/sc2/src/uqm/supermelee/pickmele.h trunk/sc2/src/uqm/tactrans.c Added Paths: ----------- trunk/sc2/src/uqm/netplay/notifyall.c trunk/sc2/src/uqm/netplay/notifyall.h trunk/sc2/src/uqm/supermelee/buildpick.c trunk/sc2/src/uqm/supermelee/buildpick.h trunk/sc2/src/uqm/supermelee/meleesetup.c trunk/sc2/src/uqm/supermelee/meleesetup.h trunk/sc2/src/uqm/supermelee/meleeship.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/ChangeLog 2010-01-23 00:34:27 UTC (rev 3502) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Clean up and some refactoring of the SuperMelee code - SvdB - Fixed concurrent screen fades regression (bug #1079) - Alex - Removed some legacy source code files related to resources - SvdB - Put SuperMelee source files in separate subdirectory - SvdB Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 00:34:27 UTC (rev 3502) @@ -2973,6 +2973,14 @@ # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\src\uqm\supermelee\buildpick.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\buildpick.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\supermelee\loadmele.c # End Source File # Begin Source File @@ -2989,6 +2997,14 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\supermelee\meleesetup.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\meleesetup.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\supermelee\pickmele.c # End Source File # Begin Source File Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/battle.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -32,6 +32,7 @@ # ifdef NETPLAY_CHECKSUM # include "netplay/checksum.h" # endif +# include "netplay/notifyall.h" #endif #include "supermelee/pickmele.h" #include "resinst.h" @@ -187,7 +188,7 @@ if (!(PlayerControl[cur_player] & NETWORK_CONTROL)) { BattleInputBuffer *bib = getBattleInputBuffer(cur_player); - sendBattleInputConnections (InputState); + Netplay_NotifyAll_battleInput (InputState); flushPacketQueues (); BattleInputBuffer_push (bib, InputState); @@ -279,7 +280,7 @@ crc_processState (&state); checksum = (Checksum) crc_finish (&state); - sendChecksumConnections ((uint32) battleFrameCount, + Netplay_NotifyAll_checksum ((uint32) battleFrameCount, (uint32) checksum); flushPacketQueues (); addLocalChecksum (battleFrameCount, checksum); Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/gameopt.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -66,8 +66,10 @@ t.CharCount = (COUNT)~0; if (MsgStamp) t.pStr = GAME_STRING (SAVEGAME_STRING_BASE + 0); + // "Saving . . ." else t.pStr = GAME_STRING (SAVEGAME_STRING_BASE + 1); + // "Loading . . ." TextRect (&t, &r, NULL); r.corner.x -= 4; r.corner.y -= 4; Modified: trunk/sc2/src/uqm/netplay/Makeinfo =================================================================== --- trunk/sc2/src/uqm/netplay/Makeinfo 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/Makeinfo 2010-01-23 00:34:27 UTC (rev 3502) @@ -1,3 +1,3 @@ uqm_SUBDIRS="proto" -uqm_CFILES="checkbuf.c checksum.c crc.c netconnection.c netinput.c netmelee.c netmisc.c netoptions.c netrcv.c netsend.c netstate.c notify.c packet.c packethandlers.c packetsenders.c packetq.c" +uqm_CFILES="checkbuf.c checksum.c crc.c netconnection.c netinput.c netmelee.c netmisc.c netoptions.c netrcv.c netsend.c netstate.c notify.c notifyall.c packet.c packethandlers.c packetsenders.c packetq.c" Modified: trunk/sc2/src/uqm/netplay/netmelee.c =================================================================== --- trunk/sc2/src/uqm/netplay/netmelee.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/netmelee.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -61,6 +61,33 @@ numNetConnections--; } +size_t +getNumNetConnections(void) { + return numNetConnections; +} + +// If the callback function returns 'false', the function will immediately +// return with 'false'. Otherwise it will return 'true' after calling +// the callback function for each connected player. +bool +forEachConnectedPlayer(ForEachConnectionCallback callback, void *arg) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + if (!(*callback)(conn, arg)) + return false; + } + return true; +} + void closeAllConnections(void) { COUNT player; @@ -87,12 +114,6 @@ } } -size_t -getNumNetConnections(void) { - return numNetConnections; -} - - //////////////////////////////////////////////////////////////////////////// @@ -120,8 +141,7 @@ //////////////////////////////////////////////////////////////////////////// -static inline -void +static inline void netInputAux(uint32 timeoutMs) { NetManager_process(&timeoutMs); // This may cause more packets to be queued, hence the @@ -250,42 +270,6 @@ } void -sendBattleInputConnections(BATTLE_INPUT_STATE input) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_battleInput(conn, input); - } -} - -#ifdef NETPLAY_CHECKSUM -void -sendChecksumConnections(uint32 frameNr, uint32 checksum) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_sendChecksum(conn, frameNr, checksum); - } -} -#endif /* NETPLAY_CHECKSUM */ - -void initBattleStateDataConnections(void) { COUNT player; @@ -415,29 +399,7 @@ NetConnection_close(netConnections[player]); } -// If the callback function returns 'false', the function will immediately -// return with 'false'. Otherwise it will return 'true' after calling -// the callback function for each connected player. bool -forAllConnectedPlayers(ForAllCallback callback, void *arg) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - if (!(*callback)(conn, arg)) - return false; - } - return true; -} - -bool setupInputDelay(size_t localInputDelay) { COUNT player; bool haveNetworkPlayer = false; @@ -466,51 +428,39 @@ } static bool -sendInputDelayConnection(NetConnection *conn, const size_t *delay) { - Netplay_sendInputDelay(conn, *delay); - return true; -} - -bool -sendInputDelayConnections(size_t delay) { - return forAllConnectedPlayers( - (ForAllCallback) sendInputDelayConnection, &delay); -} - -static bool -setStateConnection(NetConnection *conn, const NetState *state) { +setStateConnection(NetConnection *conn, void *arg) { + const NetState *state = (NetState *) arg; NetConnection_setState(conn, *state); return true; } bool setStateConnections(NetState state) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) setStateConnection, &state); + return forEachConnectedPlayer(setStateConnection, &state); } static bool -sendAbortConnection(NetConnection *conn, const NetplayAbortReason *reason) { +sendAbortConnection(NetConnection *conn, void *arg) { + const NetplayAbortReason *reason = (NetplayAbortReason *) arg; sendAbort(conn, *reason); return true; } bool sendAbortConnections(NetplayAbortReason reason) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) sendAbortConnection, &reason); + return forEachConnectedPlayer(sendAbortConnection, &reason); } static bool -resetConnection(NetConnection *conn, const NetplayResetReason *reason) { +resetConnection(NetConnection *conn, void *arg) { + const NetplayResetReason *reason = (NetplayResetReason *) arg; Netplay_localReset(conn, *reason); return true; } bool resetConnections(NetplayResetReason reason) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) resetConnection, &reason); + return forEachConnectedPlayer(resetConnection, &reason); } ///////////////////////////////////////////////////////////////////////////// @@ -522,9 +472,10 @@ } LocalReadyConnectionArg; static bool -localReadyConnection(NetConnection *conn, LocalReadyConnectionArg *arg) { - Netplay_localReady(conn, arg->readyCallback, arg->readyCallbackArg, - arg->notifyRemote); +localReadyConnection(NetConnection *conn, void *arg) { + LocalReadyConnectionArg *readyArg = (LocalReadyConnectionArg *) arg; + Netplay_localReady(conn, readyArg->readyCallback, + readyArg->readyCallbackArg, readyArg->notifyRemote); return true; } @@ -536,8 +487,7 @@ arg.readyCallbackArg = readyArg; arg.notifyRemote = notifyRemote; - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) localReadyConnection, &arg); + return forEachConnectedPlayer(localReadyConnection, &arg); } @@ -636,7 +586,7 @@ struct WaitReadyState { // Common fields of INPUT_STATE_DESC, from which this structure // "inherits". - BOOLEAN(*InputFunc)(void *pInputState); + BOOLEAN (*InputFunc)(void *pInputState); NetConnection *conn; NetConnection_ReadyCallback readyCallback; @@ -760,7 +710,7 @@ return NetConnection_isConnected(conn); } -// Wait until we have received a reset packet to all connections. If we +// Wait until we have received a reset packet from all connections. If we // ourselves have not sent a reset packet, one is sent, with reason // 'manualReset'. // XXX: Right now all connections are handled one by one. Handling them all Modified: trunk/sc2/src/uqm/netplay/netmelee.h =================================================================== --- trunk/sc2/src/uqm/netplay/netmelee.h 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/netmelee.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -40,6 +40,8 @@ void closeAllConnections(void); void closeDisconnectedConnections(void); size_t getNumNetConnections(void); +typedef bool(*ForEachConnectionCallback)(NetConnection *conn, void *arg); +bool forEachConnectedPlayer(ForEachConnectionCallback callback, void *arg); struct melee_state *NetMelee_getMeleeState(NetConnection *conn); struct battlestate_struct *NetMelee_getBattleState(NetConnection *conn); @@ -54,8 +56,6 @@ bool allConnected(void); -void sendBattleInputConnections(BATTLE_INPUT_STATE input); -void sendChecksumConnections(uint32 frameNr, uint32 checksum); void initBattleStateDataConnections(void); void setBattleStateConnections(struct battlestate_struct *bs); @@ -65,11 +65,7 @@ NetConnection *openPlayerNetworkConnection(COUNT player, void *extra); void closePlayerNetworkConnection(COUNT player); -typedef bool(*ForAllCallback)(NetConnection *conn, void *arg); -bool forAllConnectedPlayers(ForAllCallback callback, void *arg); - bool setupInputDelay(size_t localInputDelay); -bool sendInputDelayConnections(size_t delay); bool setStateConnections(NetState state); bool sendAbortConnections(NetplayAbortReason reason); bool resetConnections(NetplayResetReason reason); Modified: trunk/sc2/src/uqm/netplay/netmisc.c =================================================================== --- trunk/sc2/src/uqm/netplay/netmisc.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/netmisc.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -20,6 +20,7 @@ #include "netmisc.h" #include "netmelee.h" +#include "notifyall.h" #include "packetsenders.h" #include "proto/ready.h" @@ -118,8 +119,8 @@ connectedFeedback(conn); - entireFleetChanged(meleeState, player); - teamStringChanged(meleeState, player); + Netplay_NotifyAll_setFleet(meleeState, player); + Netplay_NotifyAll_setTeamName(meleeState, player); flushPacketQueues(); @@ -151,13 +152,10 @@ for (side = 0; side < NUM_SIDES; side++) { - entireFleetChanged(meleeState, side); - teamStringChanged(meleeState, side); + Netplay_NotifyAll_setFleet(meleeState, side); + Netplay_NotifyAll_setTeamName(meleeState, side); } flushPacketQueues(); } } - - - Modified: trunk/sc2/src/uqm/netplay/notify.c =================================================================== --- trunk/sc2/src/uqm/netplay/notify.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/notify.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -37,14 +37,14 @@ } void -Netplay_selectShip(NetConnection *conn, uint16 index) { +Netplay_Notify_shipSelected(NetConnection *conn, FleetShipIndex index) { assert(NetConnection_getState(conn) == NetState_selectShip); sendSelectShip(conn, index); } void -Netplay_battleInput(NetConnection *conn, BATTLE_INPUT_STATE input) { +Netplay_Notify_battleInput(NetConnection *conn, BATTLE_INPUT_STATE input) { assert(NetConnection_getState(conn) == NetState_inBattle || NetConnection_getState(conn) == NetState_endingBattle || NetConnection_getState(conn) == NetState_endingBattle2); @@ -53,18 +53,18 @@ } void -Netplay_teamStringChanged(NetConnection *conn, int player, +Netplay_Notify_setTeamName(NetConnection *conn, int player, const char *name, size_t len) { assert(NetConnection_getState(conn) == NetState_inSetup); assert(!conn->stateFlags.handshake.localOk); - sendTeamString(conn, netSide(conn, player), name, len); + sendTeamName(conn, netSide(conn, player), name, len); } // On initialisation, or load. void -Netplay_entireFleetChanged(NetConnection *conn, int player, - const BYTE *fleet, size_t fleetSize) { +Netplay_Notify_setFleet(NetConnection *conn, int player, + const MeleeShip *fleet, size_t fleetSize) { assert(NetConnection_getState(conn) == NetState_inSetup); assert(!conn->stateFlags.handshake.localOk); @@ -72,8 +72,8 @@ } void -Netplay_fleetShipChanged(NetConnection *conn, int player, - size_t index, BYTE ship) { +Netplay_Notify_setShip(NetConnection *conn, int player, + FleetShipIndex index, MeleeShip ship) { assert(NetConnection_getState(conn) == NetState_inSetup); assert(!conn->stateFlags.handshake.localOk); @@ -81,7 +81,7 @@ } void -Netplay_seedRandom(NetConnection *conn, uint32 seed) { +Netplay_Notify_seedRandom(NetConnection *conn, uint32 seed) { assert(NetConnection_getState(conn) == NetState_preBattle); sendSeedRandom(conn, seed); @@ -89,14 +89,15 @@ } void -Netplay_sendInputDelay(NetConnection *conn, uint32 delay) { +Netplay_Notify_inputDelay(NetConnection *conn, uint32 delay) { assert(NetConnection_getState(conn) == NetState_preBattle); sendInputDelay(conn, delay); } void -Netplay_sendFrameCount(NetConnection *conn, BattleFrameCounter frameCount) { +Netplay_Notify_frameCount(NetConnection *conn, + BattleFrameCounter frameCount) { assert(NetConnection_getState(conn) == NetState_endingBattle); sendFrameCount(conn, frameCount); @@ -104,7 +105,7 @@ #ifdef NETPLAY_CHECKSUM void -Netplay_sendChecksum(NetConnection *conn, BattleFrameCounter frameNr, +Netplay_Notify_checksum(NetConnection *conn, BattleFrameCounter frameNr, Checksum checksum) { assert(NetState_battleActive(NetConnection_getState(conn))); Modified: trunk/sc2/src/uqm/netplay/notify.h =================================================================== --- trunk/sc2/src/uqm/netplay/notify.h 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/notify.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -27,21 +27,26 @@ #ifdef NETPLAY_CHECKSUM # include "checksum.h" #endif +#include "../supermelee/meleeship.h" + // for MeleeShip +#include "../supermelee/meleesetup.h" + // for FleetShipIndex -void Netplay_selectShip(NetConnection *conn, uint16 index); -void Netplay_battleInput(NetConnection *conn, BATTLE_INPUT_STATE input); -void Netplay_teamStringChanged(NetConnection *conn, int player, +void Netplay_Notify_shipSelected(NetConnection *conn, FleetShipIndex index); +void Netplay_Notify_battleInput(NetConnection *conn, + BATTLE_INPUT_STATE input); +void Netplay_Notify_setTeamName(NetConnection *conn, int player, const char *name, size_t len); -void Netplay_entireFleetChanged(NetConnection *conn, int player, - const BYTE *fleet, size_t fleetSize); -void Netplay_fleetShipChanged(NetConnection *conn, int player, - size_t index, BYTE ship); -void Netplay_seedRandom(NetConnection *conn, uint32 seed); -void Netplay_sendInputDelay(NetConnection *conn, uint32 delay); -void Netplay_sendFrameCount(NetConnection *conn, +void Netplay_Notify_setFleet(NetConnection *conn, int player, + const MeleeShip *fleet, size_t fleetSize); +void Netplay_Notify_setShip(NetConnection *conn, int player, + FleetShipIndex index, MeleeShip ship); +void Netplay_Notify_seedRandom(NetConnection *conn, uint32 seed); +void Netplay_Notify_inputDelay(NetConnection *conn, uint32 delay); +void Netplay_Notify_frameCount(NetConnection *conn, BattleFrameCounter frameCount); #ifdef NETPLAY_CHECKSUM -void Netplay_sendChecksum(NetConnection *conn, +void Netplay_Notify_checksum(NetConnection *conn, BattleFrameCounter frameCount, Checksum checksum); #endif Added: trunk/sc2/src/uqm/netplay/notifyall.c =================================================================== --- trunk/sc2/src/uqm/netplay/notifyall.c (rev 0) +++ trunk/sc2/src/uqm/netplay/notifyall.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -0,0 +1,146 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "notifyall.h" + +#include "netmelee.h" +#include "notify.h" + +// Notify the network connections of a team name change. +void +Netplay_NotifyAll_setTeamName (MELEE_STATE *pMS, size_t playerNr) +{ + const char *name; + size_t len; + size_t playerI; + + name = MeleeSetup_getTeamName (pMS->meleeSetup, playerNr); + len = strlen (name); + for (playerI = 0; playerI < NUM_PLAYERS; playerI++) + { + NetConnection *conn = netConnections[playerI]; + + if (conn == NULL) + continue; + + if (!NetConnection_isConnected (conn)) + continue; + + if (NetConnection_getState (conn) != NetState_inSetup) + continue; + + Netplay_Notify_setTeamName (conn, playerNr, name, len); + } +} + +// Notify the network connections of the configuration of a fleet. +void +Netplay_NotifyAll_setFleet (MELEE_STATE *pMS, size_t playerNr) +{ + MeleeSetup *setup = pMS->meleeSetup; + const MeleeShip *ships = MeleeSetup_getFleet (setup, playerNr); + size_t playerI; + + for (playerI = 0; playerI < NUM_PLAYERS; playerI++) { + NetConnection *conn = netConnections[playerI]; + + if (conn == NULL) + continue; + + if (!NetConnection_isConnected (conn)) + continue; + + if (NetConnection_getState (conn) != NetState_inSetup) + continue; + + Netplay_Notify_setFleet (conn, playerNr, ships, MELEE_FLEET_SIZE); + } +} + +// Notify the network of a change in the configuration of a fleet. +void +Netplay_NotifyAll_setShip (MELEE_STATE *pMS, size_t playerNr, size_t index) +{ + MeleeSetup *setup = pMS->meleeSetup; + MeleeShip ship = MeleeSetup_getShip (setup, playerNr, index); + + size_t playerI; + for (playerI = 0; playerI < NUM_PLAYERS; playerI++) + { + NetConnection *conn = netConnections[playerI]; + + if (conn == NULL) + continue; + + if (!NetConnection_isConnected (conn)) + continue; + + if (NetConnection_getState (conn) != NetState_inSetup) + continue; + + Netplay_Notify_setShip (conn, playerNr, index, ship); + } +} + +static bool +Netplay_NotifyAll_inputDelayCallback(NetConnection *conn, void *arg) { + const size_t *delay = (size_t *) arg; + Netplay_Notify_inputDelay(conn, *delay); + return true; +} + +bool +Netplay_NotifyAll_inputDelay(size_t delay) { + return forEachConnectedPlayer(Netplay_NotifyAll_inputDelayCallback, + &delay); +} + +#ifdef NETPLAY_CHECKSUM +void +Netplay_NotifyAll_checksum(BattleFrameCounter frameNr, Checksum checksum) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + Netplay_Notify_checksum(conn, frameNr, checksum); + } +} +#endif /* NETPLAY_CHECKSUM */ + +void +Netplay_NotifyAll_battleInput(BATTLE_INPUT_STATE input) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + Netplay_Notify_battleInput(conn, input); + } +} + Added: trunk/sc2/src/uqm/netplay/notifyall.h =================================================================== --- trunk/sc2/src/uqm/netplay/notifyall.h (rev 0) +++ trunk/sc2/src/uqm/netplay/notifyall.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef NOTIFYALL_H +#define NOTIFYALL_H + +#include "../battle.h" +#include "../battlecontrols.h" +#include "../supermelee/melee.h" +#ifdef NETPLAY_CHECKSUM +# include "checksum.h" +#endif /* NETPLAY_CHECKSUM */ + +void Netplay_NotifyAll_setTeamName (MELEE_STATE *pMS, size_t playerNr); +void Netplay_NotifyAll_setFleet (MELEE_STATE *pMS, size_t playerNr); +void Netplay_NotifyAll_setShip (MELEE_STATE *pMS, size_t playerNr, + size_t index); + +bool Netplay_NotifyAll_inputDelay(size_t delay); +#ifdef NETPLAY_CHECKSUM +void Netplay_NotifyAll_checksum(BattleFrameCounter frameNr, + Checksum checksum); +#endif /* NETPLAY_CHECKSUM */ +void Netplay_NotifyAll_battleInput(BATTLE_INPUT_STATE input); + + +#endif /* NOTIFYALL_H */ + Modified: trunk/sc2/src/uqm/netplay/packet.h =================================================================== --- trunk/sc2/src/uqm/netplay/packet.h 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/packet.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -174,7 +174,7 @@ typedef struct { uint8 index; /* Position in the fleet */ - uint8 ship; /* Ship type index */ + uint8 ship; /* Ship type index; actually MeleeShip */ } FleetEntry; // Structure describing an update to a player's fleet. // TODO: use strings as ship identifiers, instead of numbers, Modified: trunk/sc2/src/uqm/netplay/packethandlers.c =================================================================== --- trunk/sc2/src/uqm/netplay/packethandlers.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/packethandlers.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -39,6 +39,8 @@ // for GLOBAL #include "../supermelee/melee.h" // for various update functions. +#include "../supermelee/meleeship.h" + // for MeleeShip #include "../supermelee/pickmele.h" // for various update functions. #include "libs/mathlib.h" @@ -263,16 +265,26 @@ } for (i = 0; i < numShips; i++) { - int ship = packet->ships[i].ship; - int index = packet->ships[i].index; + MeleeShip ship = (MeleeShip) packet->ships[i].ship; + FleetShipIndex index = (FleetShipIndex) packet->ships[i].index; - bool updateResult = updateFleetShip( - battleStateData->meleeState, player, index, ship); - if (!updateResult) + if (!MeleeShip_valid(ship)) { + log_add (log_Warning, "Invalid ship type number %d (max = %d).\n", + ship, NUM_MELEE_SHIPS - 1); + errno = EBADMSG; + return -1; + } + + if (index >= MELEE_FLEET_SIZE) { + log_add (log_Warning, "Invalid ship position number %d " + "(max = %d).\n", index, MELEE_FLEET_SIZE - 1); errno = EBADMSG; return -1; } + + Melee_RemoteChange_ship (battleStateData->meleeState, conn, + player, index, ship); } // Padding data may follow; it is ignored. @@ -312,9 +324,18 @@ - sizeof (Packet_TeamName) - 1; // The -1 is for not counting the terminating '\0'. - updateTeamName(battleStateData->meleeState, side, - (const char *) packet->name, nameLen); + { + char buf[MAX_TEAM_CHARS + 1]; + if (nameLen > MAX_TEAM_CHARS) + nameLen = MAX_TEAM_CHARS; + memcpy (buf, (const char *) packet->name, nameLen); + buf[nameLen] = '\0'; + + Melee_RemoteChange_teamName(battleStateData->meleeState, conn, + side, buf); + } + // Padding data may follow; it is ignored. return 0; } Modified: trunk/sc2/src/uqm/netplay/packetsenders.c =================================================================== --- trunk/sc2/src/uqm/netplay/packetsenders.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/packetsenders.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -107,7 +107,7 @@ } void -sendTeamString(NetConnection *conn, NetplaySide side, const char *name, +sendTeamName(NetConnection *conn, NetplaySide side, const char *name, size_t len) { Packet_TeamName *packet; @@ -116,30 +116,30 @@ } void -sendFleet(NetConnection *conn, NetplaySide side, const BYTE *ships, - size_t numShips) { +sendFleet(NetConnection *conn, NetplaySide side, const MeleeShip *ships, + size_t shipCount) { size_t i; Packet_Fleet *packet; - packet = Packet_Fleet_create(side, numShips); + packet = Packet_Fleet_create(side, shipCount); - for (i = 0; i < numShips; i++) { + for (i = 0; i < shipCount; i++) { packet->ships[i].index = (uint8) i; - packet->ships[i].ship = ships[i]; + packet->ships[i].ship = (uint8) ships[i]; } queuePacket(conn, (Packet *) packet, false); } void -sendFleetShip(NetConnection *conn, NetplaySide side, size_t shipIndex, - BYTE ship) { +sendFleetShip(NetConnection *conn, NetplaySide side, + FleetShipIndex shipIndex, MeleeShip ship) { Packet_Fleet *packet; packet = Packet_Fleet_create(side, 1); - packet->ships[0].index = shipIndex; - packet->ships[0].ship = ship; + packet->ships[0].index = (uint8) shipIndex; + packet->ships[0].ship = (uint8) ship; queuePacket(conn, (Packet *) packet, false); } @@ -161,10 +161,10 @@ } void -sendSelectShip(NetConnection *conn, COUNT ship) { +sendSelectShip(NetConnection *conn, FleetShipIndex index) { Packet_SelectShip *packet; - packet = Packet_SelectShip_create(ship); + packet = Packet_SelectShip_create((uint16) index); queuePacket(conn, (Packet *) packet, false); } Modified: trunk/sc2/src/uqm/netplay/packetsenders.h =================================================================== --- trunk/sc2/src/uqm/netplay/packetsenders.h 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/netplay/packetsenders.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -26,6 +26,10 @@ #include "../controls.h" // for BATTLE_INPUT_STATE +#include "../supermelee/meleeship.h" + // for MeleeShip +#include "../supermelee/meleesetup.h" + // for FleetShipIndex void sendInit(NetConnection *conn); void sendPing(NetConnection *conn, uint32 id); @@ -37,18 +41,19 @@ void sendHandshake1(NetConnection *conn); void sendHandshakeCancel(NetConnection *conn); void sendHandshakeCancelAck(NetConnection *conn); -void sendTeamString(NetConnection *conn, NetplaySide side, +void sendTeamName(NetConnection *conn, NetplaySide side, const char *name, size_t len); -void sendFleet(NetConnection *conn, NetplaySide side, const BYTE *ships, - size_t numShips); +void sendFleet(NetConnection *conn, NetplaySide side, + const MeleeShip *ships, size_t numShips); void sendFleetShip(NetConnection *conn, NetplaySide player, - size_t shipIndex, BYTE ship); + FleetShipIndex shipIndex, MeleeShip ship); void sendSeedRandom(NetConnection *conn, uint32 seed); void sendInputDelay(NetConnection *conn, uint32 delay); -void sendSelectShip(NetConnection *conn, COUNT ship); +void sendSelectShip(NetConnection *conn, FleetShipIndex index); void sendBattleInput(NetConnection *conn, BATTLE_INPUT_STATE input); -void sendFrameCount(NetConnection *conn, uint32 frameCount); -void sendChecksum(NetConnection *conn, uint32 frameNr, uint32 checksum); +void sendFrameCount(NetConnection *conn, BattleFrameCounter frameCount); +void sendChecksum(NetConnection *conn, BattleFrameCounter frameNr, + Checksum checksum); void sendAbort(NetConnection *conn, NetplayAbortReason reason); void sendReset(NetConnection *conn, NetplayResetReason reason); Modified: trunk/sc2/src/uqm/supermelee/Makeinfo =================================================================== --- trunk/sc2/src/uqm/supermelee/Makeinfo 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/supermelee/Makeinfo 2010-01-23 00:34:27 UTC (rev 3502) @@ -1 +1 @@ -uqm_CFILES="loadmele.c melee.c pickmele.c" +uqm_CFILES="buildpick.c loadmele.c melee.c meleesetup.c pickmele.c" Added: trunk/sc2/src/uqm/supermelee/buildpick.c =================================================================== --- trunk/sc2/src/uqm/supermelee/buildpick.c (rev 0) +++ trunk/sc2/src/uqm/supermelee/buildpick.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -0,0 +1,226 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "buildpick.h" + +#include "../controls.h" +#include "../colors.h" +#include "../fmv.h" +#include "../master.h" +#include "../setup.h" +#include "../sounds.h" +#include "libs/gfxlib.h" + +static FRAME BuildPickFrame; + +void +BuildBuildPickFrame (void) +{ + STAMP s; + RECT r; + COUNT i; + CONTEXT OldContext = SetContext (OffScreenContext); + + // create team building ship selection box + s.origin.x = 0; + s.origin.y = 0; + s.frame = SetAbsFrameIndex (MeleeFrame, 27); + // 5x5 grid of ships to pick from + GetFrameRect (s.frame, &r); + + BuildPickFrame = CaptureDrawable (CreateDrawable ( + WANT_PIXMAP, r.extent.width, r.extent.height, 1)); + SetContextFGFrame (BuildPickFrame); + SetFrameHot (s.frame, MAKE_HOT_SPOT (0, 0)); + DrawStamp (&s); + + for (i = 0; i < NUM_PICK_COLS * NUM_PICK_ROWS; ++i) + DrawPickIcon (i, true); + + SetContext (OldContext); +} + +void +DestroyBuildPickFrame (void) +{ + DestroyDrawable (ReleaseDrawable (BuildPickFrame)); + BuildPickFrame = 0; +} + +// Draw a ship icon in the ship selection popup. +void +DrawPickIcon (MeleeShip ship, bool DrawErase) +{ + STAMP s; + RECT r; + + GetFrameRect (BuildPickFrame, &r); + + s.origin.x = r.corner.x + 20 + (ship % NUM_PICK_COLS) * 18; + s.origin.y = r.corner.y + 5 + (ship / NUM_PICK_COLS) * 18; + s.frame = GetShipIconsFromIndex (ship); + if (DrawErase) + { // draw icon + DrawStamp (&s); + } + else + { // erase icon + Color OldColor; + + OldColor = SetContextForeGroundColor (BLACK_COLOR); + DrawFilledStamp (&s); + SetContextForeGroundColor (OldColor); + } +} + +// Pre: the called holds the GraphicsLock +void +DrawPickFrame (MELEE_STATE *pMS) +{ + RECT r, r0, r1, ship_r; + STAMP s; + + GetShipBox (&r0, 0, 0, 0), + GetShipBox (&r1, 1, NUM_MELEE_ROWS - 1, NUM_MELEE_COLUMNS - 1), + BoxUnion (&r0, &r1, &ship_r); + + s.frame = SetAbsFrameIndex (BuildPickFrame, 0); + GetFrameRect (s.frame, &r); + r.corner.x = -(ship_r.corner.x + + ((ship_r.extent.width - r.extent.width) >> 1)); + if (pMS->side) + r.corner.y = -ship_r.corner.y; + else + r.corner.y = -(ship_r.corner.y + + (ship_r.extent.height - r.extent.height)); + SetFrameHot (s.frame, MAKE_HOT_SPOT (r.corner.x, r.corner.y)); + s.origin.x = 0; + s.origin.y = 0; + DrawStamp (&s); + DrawMeleeShipStrings (pMS, pMS->currentShip); +} + +void +GetBuildPickFrameRect (RECT *r) +{ + GetFrameRect (BuildPickFrame, r); +} + +static BOOLEAN +DoPickShip (MELEE_STATE *pMS) +{ + DWORD TimeIn = GetTimeCounter (); + + /* Cancel any presses of the Pause key. */ + GamePaused = FALSE; + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + { + pMS->buildPickConfirmed = false; + return FALSE; + } + + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + + if (PulsedInputState.menu[KEY_MENU_SELECT] || + PulsedInputState.menu[KEY_MENU_CANCEL]) + { + // Confirm selection or cancel. + pMS->buildPickConfirmed = !PulsedInputState.menu[KEY_MENU_CANCEL]; + return FALSE; + } + + if (PulsedInputState.menu[KEY_MENU_SPECIAL] + && (pMS->currentShip != MELEE_NONE)) + { + // Show ship spin video. + DoShipSpin (pMS->currentShip, (MUSIC_REF) 0); + return TRUE; + } + + { + MeleeShip newSelectedShip; + + newSelectedShip = pMS->currentShip; + + if (PulsedInputState.menu[KEY_MENU_LEFT]) + { + if (newSelectedShip % NUM_PICK_COLS == 0) + newSelectedShip += NUM_PICK_COLS; + --newSelectedShip; + } + else if (PulsedInputState.menu[KEY_MENU_RIGHT]) + { + ++newSelectedShip; + if (newSelectedShip % NUM_PICK_COLS == 0) + newSelectedShip -= NUM_PICK_COLS; + } + + if (PulsedInputState.menu[KEY_MENU_UP]) + { + if (newSelectedShip >= NUM_PICK_COLS) + newSelectedShip -= NUM_PICK_COLS; + else + newSelectedShip += NUM_PICK_COLS * (NUM_PICK_ROWS - 1); + } + else if (PulsedInputState.menu[KEY_MENU_DOWN]) + { + if (newSelectedShip < NUM_PICK_COLS * (NUM_PICK_ROWS - 1)) + newSelectedShip += NUM_PICK_COLS; + else + newSelectedShip -= NUM_PICK_COLS * (NUM_PICK_ROWS - 1); + } + + if (newSelectedShip != pMS->currentShip) + { + // A new ship has been selected. + LockMutex (GraphicsLock); + DrawPickIcon (pMS->currentShip, true); + pMS->currentShip = newSelectedShip; + DrawMeleeShipStrings (pMS, newSelectedShip); + UnlockMutex (GraphicsLock); + } + } + + Melee_flashSelection (pMS); + + SleepThreadUntil (TimeIn + ONE_SECOND / 30); + + return TRUE; +} + +// Returns true if a ship has been selected, or false if the operation has +// been cancelled or if the general abort key was pressed (in which case +// 'GLOBAL (CurrentActivity) & CHECK_ABORT' is true as usual. +// If a ship was selected, pMS->currentShip is set to the selected ship. +bool +BuildPickShip (MELEE_STATE *pMS) +{ + FlushInput (); + + if (pMS->currentShip == MELEE_NONE) + pMS->currentShip = 0; + + LockMutex (GraphicsLock); + DrawPickFrame (pMS); + UnlockMutex (GraphicsLock); + + pMS->InputFunc = DoPickShip; + DoInput (pMS, FALSE); + + return pMS->buildPickConfirmed; +} + Added: trunk/sc2/src/uqm/supermelee/buildpick.h =================================================================== --- trunk/sc2/src/uqm/supermelee/buildpick.h (rev 0) +++ trunk/sc2/src/uqm/supermelee/buildpick.h 2010-01-23 00:34:27 UTC (rev 3502) @@ -0,0 +1,17 @@ +#ifndef BUILDPICK_H +#define BUILDPICK_H + +#include <stdbool.h> +#include "melee.h" + +void BuildBuildPickFrame (void); +void DestroyBuildPickFrame (void); +bool BuildPickShip (MELEE_STATE *pMS); +void GetBuildPickFrameRect (RECT *r); + +void DrawPickFrame (MELEE_STATE *pMS); +void DrawPickIcon (MeleeShip ship, bool DrawErase); + + +#endif /* BUILDPICK_H */ + Modified: trunk/sc2/src/uqm/supermelee/loadmele.c =================================================================== --- trunk/sc2/src/uqm/supermelee/loadmele.c 2010-01-23 00:15:44 UTC (rev 3501) +++ trunk/sc2/src/uqm/supermelee/loadmele.c 2010-01-23 00:34:27 UTC (rev 3502) @@ -18,6 +18,7 @@ // This file handles loading of teams, but the UI and the actual loading. +#define MELEESETUP_INTERNAL #include "melee.h" #include "../controls.h" @@ -25,10 +26,11 @@ #include "../gamestr.h" #include "../globdata.h" #include "../master.h" +#include "meleesetup.h" #include "../save.h" #include "../setup.h" #include "../sounds.h" -#include "../../options.h" +#include "options.h" #include "libs/log.h" #include "libs/memlib.h" @@ -48,54 +50,24 @@ static bool FillFileView (MELEE_STATE *pMS); -bool -ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp) -{ - int status; - FleetShipIndex i; - - status = ReadResFile (pTI, sizeof (*pTI), 1, load_fp); - if (status != 1) - return false; - - // Sanity check on the entries. - for (i = 0; i < MELEE_FLEET_SIZE; i++) - { - BYTE StarShip = pTI->ShipList[i]; - - if (StarShip == MELEE_NONE) - continue; - - if (StarShip >= NUM_MELEE_SHIPS) - { - log_add (log_Warning, "Invalid ship type in loaded team (index " - "%d, ship type is %d, max valid is %d).", - i, StarShip, NUM_MELEE_SHIPS - 1); - pTI->ShipList[i] = MELEE_NONE; - } - } - - return true; -} - static bool -LoadTeamImage (DIRENTRY DirEntry, TEAM_IMAGE *pTI) +LoadTeamImage (DIRENTRY DirEntry, MeleeTeam *team) { - const BYTE *fileName; - uio_Stream *load_fp; + const char *fileName; + uio_Stream *stream; bool status; fileName = GetDirEntryAddress (DirEntry); - load_fp = res_OpenResFile (meleeDir, (const char *) fileName, "rb"); - if (load_fp == 0) + + stream = uio_fopen (meleeDir, fileName, "rb"); + if (stream == NULL) return false; - if (LengthResFile (load_fp) != sizeof (*pTI)) - status = false; - else - status = ReadTeamImage (pTI, load_fp); - res_CloseResFile (load_fp); + if (MeleeTeam_deserialize (team, stream) == -1) + return false; + uio_fclose (stream); + return status; } @@ -123,13 +95,13 @@ } static bool -GetFleetByIndex (MELEE_STATE *pMS, COUNT index, TEAM_IMAGE *result) +GetFleetByIndex (MELEE_STATE *pMS, COUNT index, MeleeTeam *result) { COUNT firstIndex; if (index < pMS->load.preBuiltCount) { - *result = pMS->load.preBuiltList[index]; + MeleeTeam_copy (result, pMS->load.preBuiltList[index]); return true; } @@ -144,7 +116,7 @@ break; // Success { - const BYTE *fileName; + const char *fileName; fileName = GetDirEntryAddress (entry); log_add (log_Warning, "Warning: File '%s' is not a valid " "SuperMelee team.", fileName); @@ -167,7 +139,7 @@ { DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries, pMS->load.entryIndices[index]); - const BYTE *entryName = GetDirEntryAddress (entry); + const char *entryName = GetDirEntryAddress (entry); if (strcasecmp ((const char *) entryName, fileName) == 0) return pMS->load.preBuiltCount + index; @@ -181,8 +153,8 @@ // fleet name and value; if not, only the fleet name and value are drawn. // If highlite is set the text is drawn in the color used for highlighting. static void -DrawFileString (TEAM_IMAGE *pTI, POINT *origin, BOOLEAN drawShips, - BOOLEAN highlite) +DrawFileString (const MeleeTeam *team, const POINT *origin, + BOOLEAN drawShips, BOOLEAN highlite) { SetContextForeGroundColor (highlite ? LOAD_TEAM_NAME_TEXT_COLOR_HILITE : LOAD_TEAM_NAME_TEXT_COLOR); @@ -193,7 +165,7 @@ Text.baseline = *origin; Text.align = ALIGN_LEFT; - Text.pStr = pTI->TeamName; + Text.pStr = MeleeTeam_getTeamName(team); Text.CharCount = (COUNT)~0; font_DrawText (&Text); } @@ -203,7 +175,7 @@ TEXT Text; UNICODE buf[60]; - sprintf (buf, "%u", GetTeamValue (pTI)); + sprintf (buf, "%u", MeleeTeam_getValue (team)); Text.baseline = *origin; Text.baseline.x += NUM_MELEE_COLUMNS * (LOAD_MELEE_BOX_WIDTH + LOAD_MELEE_BOX_SPACE) - 1; @@ -217,15 +189,15 @@ if (drawShips) { STAMP s; - FleetShipIndex index; + FleetShipIndex slotI; s.origin.x = origin->x + 1; s.origin.y = origin->y + 4; - for (index = 0; index < MELEE_FLEET_SIZE; index++) + for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) { BYTE StarShip; - StarShip = pTI->ShipList[index]; + StarShip = team->ships[slotI]; if (StarShip != MELEE_NONE) { s.frame = GetShipIconsFromIndex (StarShip); @@ -247,7 +219,7 @@ for (viewI = 0; viewI < LOAD_TEAM_VIEW_SIZE; viewI++) { bool success = GetFleetByIndex (pMS, pMS->load.top + viewI, - &pMS->load.view[viewI]); + pMS->load.view[viewI]); if (!success) break; } @@ -278,7 +250,7 @@ origin.x = FILE_STRING_ORIGIN_X; origin.y = FILE_STRING_ORIGIN_Y + viewI * ENTRY_HEIGHT; - DrawFileString (&pMS->load.view[viewI], &origin, FALSE, hilite); + DrawFileString (pMS->load.view[viewI], &origin, FALSE, hilite); UnbatchGraphics (); SetContext (OldContext); @@ -303,7 +275,7 @@ { COUNT i; for (i = pMS->load.top; i < pMS->load.bot; i++) { - DrawFileString (&pMS->load.view[i - pMS->load.top], &origin, + DrawFileString (pMS->load.view[i - pMS->load.top], &origin, TRUE, FALSE); origin.y += ENTRY_HEIGHT; } @@ -379,12 +351,8 @@ if (PulsedInputState.menu[KEY_MENU_SELECT]) { // Copy the selected fleet to the player. - pMS->SideState[pMS->side].TeamImage = - pMS->load.view[pMS->load.cur - pMS->load.top]; - pMS->SideState[pMS->side].star_bucks = - GetTeamValue (&pMS->SideState[pMS->side].TeamImage); - entireFleetChanged (pMS, pMS->side); - teamStringChanged (pMS, pMS->side); + Melee_Change_team (pMS, pMS->side, + pMS->load.view[pMS->load.cur - pMS->load.top]); } pMS->InputFunc = DoMelee; @@ -470,12 +438,6 @@ return TRUE; } -int -WriteTeamImage (TEAM_IMAGE *pTI, uio_Stream *save_fp) -{ - return WriteResFile (pTI, sizeof (*pTI), 1, save_fp); -} - void SelectTeamByFileName (MELEE_STATE *pMS, const char *fileName) { @@ -509,73 +471,67 @@ { STAMP MsgStamp; char file[NAME_MAX]; - uio_Stream *save_fp; + uio_Stream *stream; CONTEXT OldContext; + bool saveOk = false; - sprintf (file, "%s.mle", pMS->SideState[pMS->side].TeamImage.TeamName); + snprintf (file, sizeof file, "%s.mle", + MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side)); LockMutex (GraphicsLock); OldContext = SetContext (ScreenContext); ConfirmSaveLoad (&MsgStamp); - save_fp = res_OpenResFile (meleeDir, file, "wb"); - if (save_fp) + // Show the "Saving . . ." message. + UnlockMutex (GraphicsLock); + + stream = uio_fopen (meleeDir, file, "wb"); + if (stream != NULL) { - BOOLEAN err; + saveOk = (MeleeTeam_serialize (&pMS->meleeSetup->teams[pMS->side], + stream) == 0); + uio_fclose (stream); - err = (BOOLEAN)(WriteTeamImage ( - &pMS->SideState[pMS->side].TeamImage, save_fp) == 0); - if (res_CloseResFile (save_fp) == 0) - err = TRUE; - if (err) - save_fp = 0; + if (!saveOk) + uio_unlink (meleeDir, file); } pMS->load.top = 0; pMS->load.cur = 0; - if (save_fp == 0) - { - DrawStamp (&MsgStamp); - DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); - SetContext (OldContext); - UnlockMutex (GraphicsLock); + // Undo the screen damage done by the "Saving . . ." message. + LockMutex (GraphicsLock); + DrawStamp (&MsgStamp); + DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); + SetContext (OldContext); + UnlockMutex (GraphicsLock); - DeleteResFile (meleeDir, file); + if (!saveOk) SaveProblem (); - } + // Update the team list; a previously existing team may have been + // deleted when save failed. LoadTeamList (pMS); SelectTeamByFileName (pMS, file); - - if (save_fp != 0) - { - DrawStamp (&MsgStamp); - DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); - SetContext (OldContext); - UnlockMutex (GraphicsLock); - } - return (save_fp != 0); + return (stream != 0); } static void InitPreBuilt (MELEE_STATE *pMS) { - TEAM_IMAGE *list; + MeleeTeam **list; #define PREBUILT_COUNT 15 pMS->load.preBuiltList = - HMalloc (PREBUILT_COUNT * sizeof pMS->load.preBuiltList[0]); + HMalloc (PREBUILT_COUNT * sizeof (MeleeTeam *)); pMS->load.preBuiltCount = PREBUILT_COUNT; #undef PREBUILT_COUNT { - FleetShipIndex shipI = 0; - int fleetI; + size_t fleetI; for (fleetI = 0; fleetI < pMS->load.preBuiltCount; fleetI++) - for (shipI = 0; shipI < MELEE_FLEET_SIZE; shipI++) - pMS->load.preBuiltList[fleetI].ShipList[shipI] = MELEE_NONE; + pMS->load.preBuiltList[fleetI] = MeleeTeam_new (); } list = pMS->load.preBuiltList; @@ -583,260 +539,245 @@ { /* "Balanced Team 1" */ FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 4)); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_UTWIG; + MeleeTeam_setName (*list, GAME_STRING (MELEE_STRING_BASE + 4)); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); + MeleeTeam_setShip (*list, i++, MELEE_SYREEN); + MeleeTeam_setShip (*list, i++, MELEE_UTWIG); list++; } { /* "Balanced Team 2" */ FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 5)); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_YEHAT; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_SHOFIXTI; + MeleeTeam_setName (*list, GAME_STRING (MELEE_STRING_BASE + 5)); + MeleeTeam_setShip (*list, i++, MELEE_ARILOU); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_MYCON); + MeleeTeam_setShip (*list, i++, MELEE_YEHAT); + MeleeTeam_setShip (*list, i++, MELEE_PKUNK); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_THRADDASH); + MeleeTeam_setShip (*list, i++, MELEE_ZOQFOTPIK); + MeleeTeam_setShip (*list, i++, MELEE_SHOFIXTI); list++; } { /* "200 points" */ FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 6)); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_ILWRATH; - list->ShipList[i++] = MELEE_VUX; + MeleeTeam_setName (*list, GAME_STRING (MELEE_STRING_BASE + 6)); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); + MeleeTeam_setShip (*list, i++, MELEE_ILWRATH); + MeleeTeam_setShip (*list, i++, MELEE_VUX); list++; } { /* "Behemoth Zenith" */ FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 7)); - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_UTWIG; + MeleeTeam_setName (*list, GAME_STRING (MELEE_STRING_BASE + 7)); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_UTWIG); + MeleeTeam_setShip (*list, i++, MELEE_UTWIG); list++; } { /* "The Peeled Eyes" */ FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - GAME_STRING (MELEE_STRING_BASE + 8)); - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_ORZ; + MeleeTeam_setName (*list, GAME_STRING (MELEE_STRING_BASE + 8)); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_MYCON); + MeleeTeam_setShip (*list, i++, MELEE_SYREEN); + MeleeTeam_setShip (*list, i++, MELEE_ZOQFOTPIK); + MeleeTeam_setShip (*list, i++, MELEE_SHOFIXTI); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_PKUNK); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Ford's Fighters"); - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_UMGAH; + MeleeTeam_setName (*list, "Ford's Fighters"); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_ZOQFOTPIK); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_UTWIG); + MeleeTeam_setShip (*list, i++, MELEE_UMGAH); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Leyland's Lashers"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_URQUAN; + MeleeTeam_setName (*list, "Leyland's Lashers"); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_MYCON); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "The Gregorizers 200"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SPATHI; + MeleeTeam_setName (*list, "The Gregorizers 200"); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_PKUNK); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "300 point Armada!"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_KOHR_AH; - list->ShipList[i++] = MELEE_MELNORME; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_YEHAT; + MeleeTeam_setName (*list, "300 point Armada!"); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_KOHR_AH); + MeleeTeam_setShip (*list, i++, MELEE_MELNORME); + MeleeTeam_setShip (*list, i++, MELEE_MYCON); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_PKUNK); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_YEHAT); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Little Dudes with Attitudes"); - list->ShipList[i++] = MELEE_UMGAH; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_VUX; - list->ShipList[i++] = MELEE_ZOQFOTPIK; + MeleeTeam_setName (*list, "Little Dudes with Attitudes"); + MeleeTeam_setShip (*list, i++, MELEE_UMGAH); + MeleeTeam_setShip (*list, i++, MELEE_THRADDASH); + MeleeTeam_setShip (*list, i++, MELEE_SHOFIXTI); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_VUX); + MeleeTeam_setShip (*list, i++, MELEE_ZOQFOTPIK); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "New Alliance Ships"); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHMMR; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_ORZ; - list->ShipList[i++] = MELEE_PKUNK; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_SUPOX; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_UTWIG; - list->ShipList[i++] = MELEE_ZOQFOTPIK; - list->ShipList[i++] = MELEE_YEHAT; - list->ShipList[i++] = MELEE_DRUUGE; - list->ShipList[i++] = MELEE_THRADDASH; - list->ShipList[i++] = MELEE_SPATHI; + MeleeTeam_setName (*list, "New Alliance Ships"); + MeleeTeam_setShip (*list, i++, MELEE_ARILOU); + MeleeTeam_setShip (*list, i++, MELEE_CHMMR); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_ORZ); + MeleeTeam_setShip (*list, i++, MELEE_PKUNK); + MeleeTeam_setShip (*list, i++, MELEE_SHOFIXTI); + MeleeTeam_setShip (*list, i++, MELEE_SUPOX); + MeleeTeam_setShip (*list, i++, MELEE_SYREEN); + MeleeTeam_setShip (*list, i++, MELEE_UTWIG); + MeleeTeam_setShip (*list, i++, MELEE_ZOQFOTPIK); + MeleeTeam_setShip (*list, i++, MELEE_YEHAT); + MeleeTeam_setShip (*list, i++, MELEE_DRUUGE); + MeleeTeam_setShip (*list, i++, MELEE_THRADDASH); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Old Alliance Ships"); - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EARTHLING; - list->ShipList[i++] = MELEE_MMRNMHRM; - list->ShipList[i++] = MELEE_SHOFIXTI; - list->ShipList[i++] = MELEE_SYREEN; - list->ShipList[i++] = MELEE_YEHAT; + MeleeTeam_setName (*list, "Old Alliance Ships"); + MeleeTeam_setShip (*list, i++, MELEE_ARILOU); + MeleeTeam_setShip (*list, i++, MELEE_CHENJESU); + MeleeTeam_setShip (*list, i++, MELEE_EARTHLING); + MeleeTeam_setShip (*list, i++, MELEE_MMRNMHRM); + MeleeTeam_setShip (*list, i++, MELEE_SHOFIXTI); + MeleeTeam_setShip (*list, i++, MELEE_SYREEN); + MeleeTeam_setShip (*list, i++, MELEE_YEHAT); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Old Hierarchy Ships"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_ILWRATH; - list->ShipList[i++] = MELEE_MYCON; - list->ShipList[i++] = MELEE_SPATHI; - list->ShipList[i++] = MELEE_UMGAH; - list->ShipList[i++] = MELEE_URQUAN; - list->ShipList[i++] = MELEE_VUX; + MeleeTeam_setName (*list, "Old Hierarchy Ships"); + MeleeTeam_setShip (*list, i++, MELEE_ANDROSYNTH); + MeleeTeam_setShip (*list, i++, MELEE_ILWRATH); + MeleeTeam_setShip (*list, i++, MELEE_MYCON); + MeleeTeam_setShip (*list, i++, MELEE_SPATHI); + MeleeTeam_setShip (*list, i++, MELEE_UMGAH); + MeleeTeam_setShip (*list, i++, MELEE_URQUAN); + MeleeTeam_setShip (*list, i++, MELEE_VUX); list++; } { FleetShipIndex i = 0; - utf8StringCopy (list->TeamName, sizeof (list->TeamName), - "Star Control 1"); - list->ShipList[i++] = MELEE_ANDROSYNTH; - list->ShipList[i++] = MELEE_ARILOU; - list->ShipList[i++] = MELEE_CHENJESU; - list->ShipList[i++] = MELEE_EAR... [truncated message content] |
From: <Mee...@us...> - 2010-01-23 01:33:17
|
Revision: 3507 http://sc2.svn.sourceforge.net/sc2/?rev=3507&view=rev Author: Meep-Eep Date: 2010-01-23 01:33:10 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Some cleanups. Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/dummy.c Added Paths: ----------- trunk/sc2/src/uqm/dummy.h Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 01:11:35 UTC (rev 3506) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 01:33:10 UTC (rev 3507) @@ -3146,6 +3146,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\dummy.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\element.h # End Source File # Begin Source File Modified: trunk/sc2/src/uqm/dummy.c =================================================================== --- trunk/sc2/src/uqm/dummy.c 2010-01-23 01:11:35 UTC (rev 3506) +++ trunk/sc2/src/uqm/dummy.c 2010-01-23 01:33:10 UTC (rev 3507) @@ -21,6 +21,8 @@ * much. */ +#include "dummy.h" + #include "coderes.h" #include "globdata.h" #include "races.h" @@ -38,11 +40,8 @@ RACE_DESC data _ALIGNED_ANY; } CODERES_STRUCT; -static void -GetCodeResData (const char *ship_id, RESOURCE_DATA *resdata) +typedef enum { -enum -{ ANDROSYN_CODE_RES, ARILOU_CODE_RES, BLACKURQ_CODE_RES, @@ -72,8 +71,54 @@ SAMATRA_CODE_RES, SIS_CODE_RES, PROBE_CODE_RES -}; +} ShipCodeRes; +typedef RACE_DESC *(*RaceDescInitFunc)(void); + +static RaceDescInitFunc +CodeResToInitFunc(ShipCodeRes res) +{ + switch (res) + { + case ANDROSYN_CODE_RES: return init_androsynth; + case ARILOU_CODE_RES: return init_arilou; + case BLACKURQ_CODE_RES: return init_black_urquan; + case CHENJESU_CODE_RES: return init_chenjesu; + case CHMMR_CODE_RES: return init_chmmr; + case DRUUGE_CODE_RES: return init_druuge; + case HUMAN_CODE_RES: return init_human; + case ILWRATH_CODE_RES: return init_ilwrath; + case MELNORME_CODE_RES: return init_melnorme; + case MMRNMHRM_CODE_RES: return init_mmrnmhrm; + case MYCON_CODE_RES: return init_mycon; + case ORZ_CODE_RES: return init_orz; + case PKUNK_CODE_RES: return init_pkunk; + case SHOFIXTI_CODE_RES: return init_shofixti; + case SLYLANDR_CODE_RES: return init_slylandro; + case SPATHI_CODE_RES: return init_spathi; + case SUPOX_CODE_RES: return init_supox; + case SYREEN_CODE_RES: return init_syreen; + case THRADD_CODE_RES: return init_thraddash; + case UMGAH_CODE_RES: return init_umgah; + case URQUAN_CODE_RES: return init_urquan; + case UTWIG_CODE_RES: return init_utwig; + case VUX_CODE_RES: return init_vux; + case YEHAT_CODE_RES: return init_yehat; + case ZOQFOT_CODE_RES: return init_zoqfotpik; + case SAMATRA_CODE_RES: return init_samatra; + case SIS_CODE_RES: return init_sis; + case PROBE_CODE_RES: return init_probe; + default: + { + log_add (log_Warning, "Unknown SHIP identifier '%d'", res); + return NULL; + } + } +} + +static void +GetCodeResData (const char *ship_id, RESOURCE_DATA *resdata) +{ BYTE which_res; void *hData; @@ -81,218 +126,8 @@ hData = HMalloc (sizeof (CODERES_STRUCT)); if (hData) { - RACE_DESC *RDPtr; - - RDPtr = NULL; - switch (which_res) - { - case ANDROSYN_CODE_RES: - { - extern RACE_DESC* init_androsynth (void); - - RDPtr = init_androsynth (); - break; - } - case ARILOU_CODE_RES: - { - extern RACE_DESC* init_arilou (void); - - RDPtr = init_arilou (); - break; - } - case BLACKURQ_CODE_RES: - { - extern RACE_DESC* init_black_urquan (void); - - RDPtr = init_black_urquan (); - break; - } - case CHENJESU_CODE_RES: - { - extern RACE_DESC* init_chenjesu (void); - - RDPtr = init_chenjesu (); - break; - } - case CHMMR_CODE_RES: - { - extern RACE_DESC* init_chmmr (void); - - RDPtr = init_chmmr (); - break; - } - case DRUUGE_CODE_RES: - { - extern RACE_DESC* init_druuge (void); - - RDPtr = init_druuge (); - break; - } - case HUMAN_CODE_RES: - { - extern RACE_DESC* init_human (void); - - RDPtr = init_human (); - break; - } - case ILWRATH_CODE_RES: - { - - extern RACE_DESC* init_ilwrath (void); - - RDPtr = init_ilwrath (); - break; - } - case MELNORME_CODE_RES: - { - extern RACE_DESC* init_melnorme (void); - - RDPtr = init_melnorme (); - break; - } - case MMRNMHRM_CODE_RES: - { - extern RACE_DESC* init_mmrnmhrm (void); - - RDPtr = init_mmrnmhrm (); - break; - } - case MYCON_CODE_RES: - { - extern RACE_DESC* init_mycon (void); - - RDPtr = init_mycon (); - break; - } - case ORZ_CODE_RES: - { - extern RACE_DESC* init_orz (void); - - RDPtr = init_orz (); - break; - } - case PKUNK_CODE_RES: - { - extern RACE_DESC* init_pkunk (void); - - RDPtr = init_pkunk (); - break; - } - case SHOFIXTI_CODE_RES: - { - extern RACE_DESC* init_shofixti (void); - - RDPtr = init_shofixti (); - break; - } - case SLYLANDR_CODE_RES: - { - - extern RACE_DESC* init_slylandro (void); - - RDPtr = init_slylandro (); - break; - } - case SPATHI_CODE_RES: - { - extern RACE_DESC* init_spathi (void); - - RDPtr = init_spathi (); - break; - } - case SUPOX_CODE_RES: - { - extern RACE_DESC* init_supox (void); - - RDPtr = init_supox (); - break; - } - case SYREEN_CODE_RES: - { - extern RACE_DESC* init_syreen (void); - - RDPtr = init_syreen (); - break; - } - case THRADD_CODE_RES: - { - extern RACE_DESC* init_thraddash (void); - - RDPtr = init_thraddash (); - break; - } - case UMGAH_CODE_RES: - { - extern RACE_DESC* init_umgah (void); - - RDPtr = init_umgah (); - break; - } - case URQUAN_CODE_RES: - { - extern RACE_DESC* init_urquan (void); - - RDPtr = init_urquan (); - break; - } - case UTWIG_CODE_RES: - { - extern RACE_DESC* init_utwig (void); - - RDPtr = init_utwig (); - break; - } - case VUX_CODE_RES: - { - - extern RACE_DESC* init_vux (void); - - RDPtr = init_vux (); - break; - } - case YEHAT_CODE_RES: - { - extern RACE_DESC* init_yehat (void); - - RDPtr = init_yehat (); - break; - } - case ZOQFOT_CODE_RES: - { - extern RACE_DESC* init_zoqfotpik (void); - - RDPtr = init_zoqfotpik (); - break; - } - case SAMATRA_CODE_RES: - { - extern RACE_DESC* init_samatra (void); - - RDPtr = init_samatra (); - break; - } - case SIS_CODE_RES: - { - extern RACE_DESC* init_sis (void); - - RDPtr = init_sis (); - break; - } - case PROBE_CODE_RES: - { - extern RACE_DESC* init_probe (void); - - RDPtr = init_probe (); - break; - } - default: - { - log_add (log_Warning, "Unknown SHIP identifier '%d'", which_res); - RDPtr = NULL; - break; - } - } - + RaceDescInitFunc initFunc = CodeResToInitFunc (which_res); + RACE_DESC *RDPtr = (initFunc == NULL) ? NULL : (*initFunc)(); if (RDPtr == 0) { HFree (hData); @@ -306,10 +141,10 @@ cs->data = *RDPtr; // Structure assignment. } } - resdata->ptr = (hData); + resdata->ptr = hData; } -BOOLEAN +static BOOLEAN _ReleaseCodeResData (void *data) { HFree (data); @@ -333,7 +168,7 @@ if (hData) res_DetachResource (res); - return (hData); + return hData; } @@ -341,7 +176,7 @@ DestroyCodeRes (void *hCode) { HFree (hCode); - return (TRUE); + return TRUE; } Added: trunk/sc2/src/uqm/dummy.h =================================================================== --- trunk/sc2/src/uqm/dummy.h (rev 0) +++ trunk/sc2/src/uqm/dummy.h 2010-01-23 01:33:10 UTC (rev 3507) @@ -0,0 +1,52 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DUMMY_H +#define DUMMY_H + +#include "races.h" + +RACE_DESC *init_androsynth (void); +RACE_DESC *init_arilou (void); +RACE_DESC *init_black_urquan (void); +RACE_DESC *init_chenjesu (void); +RACE_DESC *init_chmmr (void); +RACE_DESC *init_druuge (void); +RACE_DESC *init_human (void); +RACE_DESC *init_ilwrath (void); +RACE_DESC *init_melnorme (void); +RACE_DESC *init_mmrnmhrm (void); +RACE_DESC *init_mycon (void); +RACE_DESC *init_orz (void); +RACE_DESC *init_pkunk (void); +RACE_DESC *init_shofixti (void); +RACE_DESC *init_slylandro (void); +RACE_DESC *init_spathi (void); +RACE_DESC *init_supox (void); +RACE_DESC *init_syreen (void); +RACE_DESC *init_thraddash (void); +RACE_DESC *init_umgah (void); +RACE_DESC *init_urquan (void); +RACE_DESC *init_utwig (void); +RACE_DESC *init_vux (void); +RACE_DESC *init_yehat (void); +RACE_DESC *init_zoqfotpik (void); +RACE_DESC *init_samatra (void); +RACE_DESC *init_sis (void); +RACE_DESC *init_probe (void); + +#endif /* DUMMY_H */ + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-23 20:30:39
|
Revision: 3509 http://sc2.svn.sourceforge.net/sc2/?rev=3509&view=rev Author: Meep-Eep Date: 2010-01-23 20:30:31 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Move netplay/ to supermelee/. Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/Makeinfo trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/battlecontrols.c trunk/sc2/src/uqm/cnctdlg.c trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/setup.c trunk/sc2/src/uqm/supermelee/Makeinfo trunk/sc2/src/uqm/supermelee/melee.c trunk/sc2/src/uqm/supermelee/melee.h trunk/sc2/src/uqm/supermelee/netplay/checkbuf.c trunk/sc2/src/uqm/supermelee/netplay/checkbuf.h trunk/sc2/src/uqm/supermelee/netplay/checksum.h trunk/sc2/src/uqm/supermelee/netplay/netinput.c trunk/sc2/src/uqm/supermelee/netplay/netinput.h trunk/sc2/src/uqm/supermelee/netplay/netmisc.h trunk/sc2/src/uqm/supermelee/netplay/proto/reset.c trunk/sc2/src/uqm/supermelee/pickmele.c trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqm.c Added Paths: ----------- trunk/sc2/src/uqm/supermelee/netplay/ trunk/sc2/src/uqm/supermelee/netplay/Makeinfo trunk/sc2/src/uqm/supermelee/netplay/netmelee.c trunk/sc2/src/uqm/supermelee/netplay/netmelee.h trunk/sc2/src/uqm/supermelee/netplay/netmisc.c trunk/sc2/src/uqm/supermelee/netplay/notify.c trunk/sc2/src/uqm/supermelee/netplay/notify.h trunk/sc2/src/uqm/supermelee/netplay/notifyall.c trunk/sc2/src/uqm/supermelee/netplay/notifyall.h trunk/sc2/src/uqm/supermelee/netplay/packet.h trunk/sc2/src/uqm/supermelee/netplay/packethandlers.c trunk/sc2/src/uqm/supermelee/netplay/packetsenders.c trunk/sc2/src/uqm/supermelee/netplay/packetsenders.h Removed Paths: ------------- trunk/sc2/src/uqm/netplay/ trunk/sc2/src/uqm/supermelee/netplay/Makeinfo trunk/sc2/src/uqm/supermelee/netplay/netmelee.c trunk/sc2/src/uqm/supermelee/netplay/netmelee.h trunk/sc2/src/uqm/supermelee/netplay/netmisc.c trunk/sc2/src/uqm/supermelee/netplay/notify.c trunk/sc2/src/uqm/supermelee/netplay/notify.h trunk/sc2/src/uqm/supermelee/netplay/packet.h trunk/sc2/src/uqm/supermelee/netplay/packethandlers.c trunk/sc2/src/uqm/supermelee/netplay/packetsenders.c trunk/sc2/src/uqm/supermelee/netplay/packetsenders.h Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 20:30:31 UTC (rev 3509) @@ -2096,174 +2096,6 @@ SOURCE=..\..\src\uqm\comm\commall.h # End Source File # End Group -# Begin Group "netplay" - -# PROP Default_Filter "" -# Begin Group "proto" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\npconfirm.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\npconfirm.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\ready.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\ready.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\reset.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\proto\reset.h -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\checkbuf.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\checkbuf.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\checksum.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\checksum.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\crc.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\crc.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\nc_connect.ci -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netconnection.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netconnection.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netinput.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netinput.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netmelee.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netmelee.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netmisc.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netmisc.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netoptions.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netoptions.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netplay.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netrcv.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netrcv.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netsend.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netsend.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netstate.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\netstate.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\notify.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\notify.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packet.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packet.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packethandlers.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packethandlers.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packetq.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packetq.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packetsenders.c -# End Source File -# Begin Source File - -SOURCE=..\..\src\uqm\netplay\packetsenders.h -# End Source File -# End Group # Begin Group "planets" # PROP Default_Filter "" @@ -2971,8 +2803,176 @@ # Begin Group "supermelee" # PROP Default_Filter "" +# Begin Group "netplay" + +# PROP Default_Filter "" +# Begin Group "proto" + +# PROP Default_Filter "" # Begin Source File +SOURCE=..\..\src\uqm\supermelee\netplay\proto\npconfirm.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\proto\npconfirm.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\proto\ready.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\proto\ready.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\proto\reset.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\proto\reset.h +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\checkbuf.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\checkbuf.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\checksum.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\checksum.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\crc.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\crc.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\nc_connect.ci +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netconnection.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netconnection.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netinput.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netinput.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netmelee.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netmelee.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netmisc.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netmisc.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netoptions.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netoptions.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netplay.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netrcv.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netrcv.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netsend.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netsend.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netstate.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\netstate.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\notify.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\notify.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packet.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packet.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packethandlers.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packethandlers.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packetq.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packetq.h +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packetsenders.c +# End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\supermelee\netplay\packetsenders.h +# End Source File +# End Group +# Begin Source File + SOURCE=..\..\src\uqm\supermelee\buildpick.c # End Source File # Begin Source File Modified: trunk/sc2/src/uqm/Makeinfo =================================================================== --- trunk/sc2/src/uqm/Makeinfo 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/Makeinfo 2010-01-23 20:30:31 UTC (rev 3509) @@ -9,7 +9,4 @@ ship.c shipstat.c shipyard.c sis.c sounds.c starbase.c starcon.c starmap.c state.c status.c tactrans.c trans.c uqmdebug.c util.c velocity.c weapon.c" -if [ -n "$uqm_NETPLAY" ]; then - uqm_SUBDIRS="$uqm_SUBDIRS netplay" -fi Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/battle.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -28,11 +28,11 @@ // for flee_preprocess() #include "intel.h" #ifdef NETPLAY -# include "netplay/netmelee.h" +# include "supermelee/netplay/netmelee.h" # ifdef NETPLAY_CHECKSUM -# include "netplay/checksum.h" +# include "supermelee/netplay/checksum.h" # endif -# include "netplay/notifyall.h" +# include "supermelee/netplay/notifyall.h" #endif #include "supermelee/pickmele.h" #include "resinst.h" Modified: trunk/sc2/src/uqm/battlecontrols.c =================================================================== --- trunk/sc2/src/uqm/battlecontrols.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/battlecontrols.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -25,7 +25,7 @@ #include "libs/memlib.h" // For HMalloc(), HFree() #ifdef NETPLAY -# include "netplay/netmelee.h" +# include "supermelee/netplay/netmelee.h" #endif /* NETPLAY */ InputContext *PlayerInput[NUM_PLAYERS]; Modified: trunk/sc2/src/uqm/cnctdlg.c =================================================================== --- trunk/sc2/src/uqm/cnctdlg.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/cnctdlg.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -27,7 +27,7 @@ #include "resinst.h" #include "nameref.h" #include "libs/graphics/widgets.h" -#include "netplay/netoptions.h" +#include "supermelee/netplay/netoptions.h" #define MCD_WIDTH 260 #define MCD_HEIGHT 110 Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/gameinp.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -22,7 +22,7 @@ #include "intel.h" // For computer_intelligence #ifdef NETPLAY -# include "netplay/netmelee.h" +# include "supermelee/netplay/netmelee.h" #endif #include "settings.h" #include "sounds.h" Modified: trunk/sc2/src/uqm/setup.c =================================================================== --- trunk/sc2/src/uqm/setup.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/setup.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -23,7 +23,7 @@ #include "options.h" #include "nameref.h" #ifdef NETPLAY -# include "netplay/netmelee.h" +# include "supermelee/netplay/netmelee.h" #endif #include "init.h" #include "intel.h" Modified: trunk/sc2/src/uqm/supermelee/Makeinfo =================================================================== --- trunk/sc2/src/uqm/supermelee/Makeinfo 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/supermelee/Makeinfo 2010-01-23 20:30:31 UTC (rev 3509) @@ -1 +1,4 @@ uqm_CFILES="buildpick.c loadmele.c melee.c meleesetup.c pickmele.c" +if [ -n "$uqm_NETPLAY" ]; then + uqm_SUBDIRS="$uqm_SUBDIRS netplay" +fi Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/supermelee/melee.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -36,10 +36,10 @@ #include "../master.h" #include "../nameref.h" #ifdef NETPLAY -# include "../netplay/netconnection.h" -# include "../netplay/netmelee.h" -# include "../netplay/notify.h" -# include "../netplay/notifyall.h" +# include "netplay/netconnection.h" +# include "netplay/netmelee.h" +# include "netplay/notify.h" +# include "netplay/notifyall.h" # include "libs/graphics/widgets.h" // for DrawShadowedBox() # include "../cnctdlg.h" Modified: trunk/sc2/src/uqm/supermelee/melee.h =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.h 2010-01-23 20:13:26 UTC (rev 3508) +++ trunk/sc2/src/uqm/supermelee/melee.h 2010-01-23 20:30:31 UTC (rev 3509) @@ -25,7 +25,7 @@ #include "libs/sndlib.h" #include "libs/timelib.h" #include "libs/reslib.h" -#include "../netplay/packet.h" +#include "netplay/packet.h" // for NetplayAbortReason and NetplayResetReason. typedef struct melee_state MELEE_STATE; Deleted: trunk/sc2/src/uqm/supermelee/netplay/Makeinfo =================================================================== --- trunk/sc2/src/uqm/netplay/Makeinfo 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/Makeinfo 2010-01-23 20:30:31 UTC (rev 3509) @@ -1,3 +0,0 @@ -uqm_SUBDIRS="proto" -uqm_CFILES="checkbuf.c checksum.c crc.c netconnection.c netinput.c netmelee.c netmisc.c netoptions.c netrcv.c netsend.c netstate.c notify.c packet.c packethandlers.c packetsenders.c packetq.c" - Copied: trunk/sc2/src/uqm/supermelee/netplay/Makeinfo (from rev 3502, trunk/sc2/src/uqm/netplay/Makeinfo) =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/Makeinfo (rev 0) +++ trunk/sc2/src/uqm/supermelee/netplay/Makeinfo 2010-01-23 20:30:31 UTC (rev 3509) @@ -0,0 +1,3 @@ +uqm_SUBDIRS="proto" +uqm_CFILES="checkbuf.c checksum.c crc.c netconnection.c netinput.c netmelee.c netmisc.c netoptions.c netrcv.c netsend.c netstate.c notify.c notifyall.c packet.c packethandlers.c packetsenders.c packetq.c" + Modified: trunk/sc2/src/uqm/supermelee/netplay/checkbuf.c =================================================================== --- trunk/sc2/src/uqm/netplay/checkbuf.c 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/checkbuf.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -23,7 +23,7 @@ #include "checkbuf.h" #include "libs/log.h" -#include "../battle.h" +#include "../../battle.h" // for battleFrameCount Modified: trunk/sc2/src/uqm/supermelee/netplay/checkbuf.h =================================================================== --- trunk/sc2/src/uqm/netplay/checkbuf.h 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/checkbuf.h 2010-01-23 20:30:31 UTC (rev 3509) @@ -22,7 +22,7 @@ typedef struct ChecksumEntry ChecksumEntry; typedef struct ChecksumBuffer ChecksumBuffer; -#include "../battle.h" +#include "../../battle.h" // for BattleFrameCounter #include "checksum.h" Modified: trunk/sc2/src/uqm/supermelee/netplay/checksum.h =================================================================== --- trunk/sc2/src/uqm/netplay/checksum.h 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/checksum.h 2010-01-23 20:30:31 UTC (rev 3509) @@ -28,7 +28,7 @@ #include "netplay.h" #include "crc.h" -#include "../element.h" +#include "../../element.h" #include "libs/gfxlib.h" #include "netconnection.h" Modified: trunk/sc2/src/uqm/supermelee/netplay/netinput.c =================================================================== --- trunk/sc2/src/uqm/netplay/netinput.c 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/netinput.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -22,9 +22,9 @@ #include "netplay.h" #include "netinput.h" -#include "../intel.h" +#include "../../intel.h" // for NETWORK_CONTROL -#include "../setup.h" +#include "../../setup.h" // For PlayerControl #include "libs/log.h" Modified: trunk/sc2/src/uqm/supermelee/netplay/netinput.h =================================================================== --- trunk/sc2/src/uqm/netplay/netinput.h 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/netinput.h 2010-01-23 20:30:31 UTC (rev 3509) @@ -19,9 +19,9 @@ #ifndef _NETINPUT_H #define _NETINPUT_H -#include "../controls.h" +#include "../../controls.h" // for BATTLE_INPUT_STATE -#include "../init.h" +#include "../../init.h" // for NUM_PLAYERS typedef struct BattleInputBuffer { Deleted: trunk/sc2/src/uqm/supermelee/netplay/netmelee.c =================================================================== --- trunk/sc2/src/uqm/netplay/netmelee.c 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/netmelee.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -1,794 +0,0 @@ -/* - * Copyright 2006 Serge van den Boom <sv...@st...> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "netmelee.h" -#include "libs/alarm.h" -#include "libs/callback.h" -#include "libs/log.h" -#include "libs/net.h" -#include "netinput.h" -#include "netmisc.h" -#include "netsend.h" -#include "notify.h" -#include "packetq.h" -#include "proto/npconfirm.h" -#include "proto/ready.h" -#include "proto/reset.h" - -#include "../battlecontrols.h" - // for NetworkInputContext -#include "../controls.h" - // for BATTLE_INPUT_STATE -#include "../init.h" - // for NUM_PLAYERS -#include "../globdata.h" - // for GLOBAL - -#include <errno.h> -#include <stdlib.h> - - -//////////////////////////////////////////////////////////////////////////// - - -NetConnection *netConnections[NUM_PLAYERS]; -size_t numNetConnections; - -void -addNetConnection(NetConnection *conn, int playerNr) { - netConnections[playerNr] = conn; - numNetConnections++; -} - -void -removeNetConnection(int playerNr) { - netConnections[playerNr] = NULL; - numNetConnections--; -} - -void -closeAllConnections(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - - if (conn != NULL) - closePlayerNetworkConnection(player); - } -} - -void -closeDisconnectedConnections(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - - if (conn != NULL && !NetConnection_isConnected(conn)) - closePlayerNetworkConnection(player); - } -} - -size_t -getNumNetConnections(void) { - return numNetConnections; -} - - -//////////////////////////////////////////////////////////////////////////// - - -struct melee_state * -NetMelee_getMeleeState(NetConnection *conn) { - if (NetConnection_getState(conn) > NetState_connecting) { - BattleStateData *battleStateData = - (BattleStateData *) NetConnection_getStateData(conn); - return battleStateData->meleeState; - } else { - return (struct melee_state *) NetConnection_getExtra(conn); - } -} - -struct battlestate_struct * -NetMelee_getBattleState(NetConnection *conn) { - if (NetConnection_getState(conn) > NetState_connecting) { - BattleStateData *battleStateData = - (BattleStateData *) NetConnection_getStateData(conn); - return battleStateData->battleState; - } else { - return NULL; - } -} - -//////////////////////////////////////////////////////////////////////////// - -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) { - netInputAux(0); -} - -void -netInputBlocking(uint32 timeoutMs) { - uint32 nextAlarmMs; - - nextAlarmMs = Alarm_timeBeforeNextMs(); - if (nextAlarmMs < timeoutMs) - timeoutMs = nextAlarmMs; - - netInputAux(timeoutMs); -} - - -//////////////////////////////////////////////////////////////////////////// - - -// Send along all pending network packets. -void -flushPacketQueues(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn; - int flushStatus; - - conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - flushStatus = flushPacketQueue(conn); - if (flushStatus == -1 && errno != EAGAIN) - closePlayerNetworkConnection(player); - } -} - -void -confirmConnections(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_confirm(conn); - } -} - -void -cancelConfirmations(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_cancelConfirmation(conn); - } -} - -void -connectionsLocalReady(NetConnection_ReadyCallback callback, void *arg) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_localReady(conn, callback, arg, true); - } -} - -bool -allConnected(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - return false; - } - return true; -} - -void -sendBattleInputConnections(BATTLE_INPUT_STATE input) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_battleInput(conn, input); - } -} - -#ifdef NETPLAY_CHECKSUM -void -sendChecksumConnections(uint32 frameNr, uint32 checksum) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - Netplay_sendChecksum(conn, frameNr, checksum); - } -} -#endif /* NETPLAY_CHECKSUM */ - -void -initBattleStateDataConnections(void) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - BattleStateData *battleStateData; - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - battleStateData = - (BattleStateData *) NetConnection_getStateData(conn); - battleStateData->endFrameCount = 0; - } -} - -void -setBattleStateConnections(struct battlestate_struct *bs) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - BattleStateData *battleStateData; - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - battleStateData = - (BattleStateData *) NetConnection_getStateData(conn); - battleStateData->battleState = bs; - } -} - -BATTLE_INPUT_STATE -networkBattleInput(NetworkInputContext *context, STARSHIP *StarShipPtr) { - BattleInputBuffer *bib = getBattleInputBuffer(context->playerNr); - BATTLE_INPUT_STATE result; - - for (;;) { - bool ok; - -#if 0 - // This is a useful debugging trick. By enabling this #if - // block, this side will always lag the maximum number of frames - // behind the other side. When the remote side stops on some event - // (a breakpoint or so), this side will stop too, waiting for input - // in the loop below, but it won't have processed the frame that - // triggered the event yet. If you then jump over this 'if' - // statement here, you can walk through the decisive frames - // manually. Works best with no input delay. - if (bib->size <= getBattleInputDelay() + 1) { - ok = false; - } else -#endif - ok = BattleInputBuffer_pop(bib, &result); - // Get the input from the front of the - // buffer. - if (ok) - break; - - { - NetConnection *conn = netConnections[context->playerNr]; - - // First try whether there is incoming data, without blocking. - // If there isn't any, only then give a warning, and then - // block after all. - netInput(); - if (!NetConnection_isConnected(conn)) - { - // Connection aborted. - GLOBAL(CurrentActivity) |= CHECK_ABORT; - return (BATTLE_INPUT_STATE) 0; - } - - if (GLOBAL(CurrentActivity) & CHECK_ABORT) - return (BATTLE_INPUT_STATE) 0; - -#if 0 - log_add(log_Warning, "NETPLAY: [%d] stalling for " - "network input. Increase the input delay if this " - "happens a lot.\n", context->playerNr); -#endif -#define MAX_BLOCK_TIME 500 - netInputBlocking(MAX_BLOCK_TIME); - if (!NetConnection_isConnected(conn)) - { - // Connection aborted. - GLOBAL(CurrentActivity) |= CHECK_ABORT; - return (BATTLE_INPUT_STATE) 0; - } - } - } - - (void) StarShipPtr; - return result; -} - -static void -deleteConnectionCallback(NetConnection *conn) { - removeNetConnection(NetConnection_getPlayerNr(conn)); -} - -NetConnection * -openPlayerNetworkConnection(COUNT player, void *extra) { - NetConnection *conn; - - assert(netConnections[player] == NULL); - - conn = NetConnection_open(player, - &netplayOptions.peer[player], NetMelee_connectCallback, - NetMelee_closeCallback, NetMelee_errorCallback, - deleteConnectionCallback, extra); - - addNetConnection(conn, player); - return conn; -} - -void -shutdownPlayerNetworkConnection(COUNT player) { - NetConnection_close(netConnections[player]); -} - -void -closePlayerNetworkConnection(COUNT player) { - assert(netConnections[player] != NULL); - - NetConnection_close(netConnections[player]); -} - -// If the callback function returns 'false', the function will immediately -// return with 'false'. Otherwise it will return 'true' after calling -// the callback function for each connected player. -bool -forAllConnectedPlayers(ForAllCallback callback, void *arg) { - COUNT player; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - if (!(*callback)(conn, arg)) - return false; - } - return true; -} - -bool -setupInputDelay(size_t localInputDelay) { - COUNT player; - bool haveNetworkPlayer = false; - // We have at least one network controlled player. - size_t inputDelay = 0; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) - continue; - - haveNetworkPlayer = true; - if (NetConnection_getInputDelay(conn) > inputDelay) - inputDelay = NetConnection_getInputDelay(conn); - } - - if (haveNetworkPlayer && inputDelay < localInputDelay) - inputDelay = localInputDelay; - - setBattleInputDelay(inputDelay); - return true; -} - -static bool -sendInputDelayConnection(NetConnection *conn, const size_t *delay) { - Netplay_sendInputDelay(conn, *delay); - return true; -} - -bool -sendInputDelayConnections(size_t delay) { - return forAllConnectedPlayers( - (ForAllCallback) sendInputDelayConnection, &delay); -} - -static bool -setStateConnection(NetConnection *conn, const NetState *state) { - NetConnection_setState(conn, *state); - return true; -} - -bool -setStateConnections(NetState state) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) setStateConnection, &state); -} - -static bool -sendAbortConnection(NetConnection *conn, const NetplayAbortReason *reason) { - sendAbort(conn, *reason); - return true; -} - -bool -sendAbortConnections(NetplayAbortReason reason) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) sendAbortConnection, &reason); -} - -static bool -resetConnection(NetConnection *conn, const NetplayResetReason *reason) { - Netplay_localReset(conn, *reason); - return true; -} - -bool -resetConnections(NetplayResetReason reason) { - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) resetConnection, &reason); -} - -///////////////////////////////////////////////////////////////////////////// - -typedef struct { - NetConnection_ReadyCallback readyCallback; - void *readyCallbackArg; - bool notifyRemote; -} LocalReadyConnectionArg; - -static bool -localReadyConnection(NetConnection *conn, LocalReadyConnectionArg *arg) { - Netplay_localReady(conn, arg->readyCallback, arg->readyCallbackArg, - arg->notifyRemote); - return true; -} - -bool -localReadyConnections(NetConnection_ReadyCallback readyCallback, - void *readyArg, bool notifyRemote) { - LocalReadyConnectionArg arg; - arg.readyCallback = readyCallback; - arg.readyCallbackArg = readyArg; - arg.notifyRemote = notifyRemote; - - return forAllConnectedPlayers( - (bool(*)(NetConnection *, void *)) localReadyConnection, &arg); -} - - -///////////////////////////////////////////////////////////////////////////// - -#define NETWORK_POLL_DELAY (ONE_SECOND / 24) - -typedef struct NegotiateReadyState NegotiateReadyState; -struct NegotiateReadyState { - // Common fields of INPUT_STATE_DESC, from which this structure - // "inherits". - BOOLEAN(*InputFunc)(void *pInputState); - - NetConnection *conn; - NetState nextState; - bool done; -}; - -static BOOLEAN -negotiateReadyInputFunc(NegotiateReadyState *state) { - netInputBlocking(NETWORK_POLL_DELAY); - // The timing out is necessary so that immediate key presses get - // handled while we wait. If we could do without the timeout, - // we wouldn't even need negotiateReadyInputFunc() and the - // DoInput() call. - - // No need to call flushPacketQueues(); nothing needs to be sent - // right now. - - if (!NetConnection_isConnected(state->conn)) - return FALSE; - - return !state->done; -} - -// Called when both sides are ready -static void -negotiateReadyBothReadyCallback(NetConnection *conn, void *arg) { - NegotiateReadyState *state =(NegotiateReadyState *) arg; - - NetConnection_setState(conn, state->nextState); - // This has to be done immediately, as more packets in the - // receive queue may be handled by the netInput() call that - // triggered this callback. - // This is the reason for the nextState argument to - // negotiateReady(); setting the state after the call to - // negotiateReady() would be too late. - state->done = true; -} - -bool -negotiateReady(NetConnection *conn, bool notifyRemote, NetState nextState) { - NegotiateReadyState state; - state.InputFunc = (BOOLEAN(*)(void *)) negotiateReadyInputFunc; - state.conn = conn; - state.nextState = nextState; - state.done = false; - - Netplay_localReady(conn, negotiateReadyBothReadyCallback, - (void *) &state, notifyRemote); - flushPacketQueue(conn); - if (!state.done) - DoInput(&state, FALSE); - - return NetConnection_isConnected(conn); -} - -// Wait for all connections to get ready. -// XXX: Right now all connections are handled one by one. Handling them all -// at once would be faster but would require more work, which is -// not worth it as the time is minimal and this function is not -// time critical. -bool -negotiateReadyConnections(bool notifyRemote, NetState nextState) { - COUNT player; - size_t numDisconnected = 0; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) { - numDisconnected++; - continue; - } - - negotiateReady(conn, notifyRemote, nextState); - } - - return numDisconnected == 0; -} - -typedef struct WaitReadyState WaitReadyState; -struct WaitReadyState { - // Common fields of INPUT_STATE_DESC, from which this structure - // "inherits". - BOOLEAN(*InputFunc)(void *pInputState); - - NetConnection *conn; - NetConnection_ReadyCallback readyCallback; - void *readyCallbackArg; - bool done; -}; - -static void -waitReadyCallback(NetConnection *conn, void *arg) { - WaitReadyState *state =(WaitReadyState *) arg; - state->done = true; - - // Call the original callback. - state->readyCallback(conn, state->readyCallbackArg); -} - -static BOOLEAN -waitReadyInputFunc(WaitReadyState *state) { - netInputBlocking(NETWORK_POLL_DELAY); - // The timing out is necessary so that immediate key presses get - // handled while we wait. If we could do without the timeout, - // we wouldn't even need negotiateReadyInputFunc() and the - // DoInput() call. - - // No need to call flushPacketQueues(); nothing needs to be sent - // right now. - - if (!NetConnection_isConnected(state->conn)) - return FALSE; - - return !state->done; -} - -bool -waitReady(NetConnection *conn) { - WaitReadyState state; - state.InputFunc =(BOOLEAN(*)(void *)) waitReadyInputFunc; - state.conn = conn; - state.readyCallback = NetConnection_getReadyCallback(conn); - state.readyCallbackArg = NetConnection_getReadyCallbackArg(conn); - state.done = false; - - NetConnection_setReadyCallback(conn, waitReadyCallback, (void *) &state); - - DoInput(&state, FALSE); - - return NetConnection_isConnected(conn); -} - - -//////////////////////////////////////////////////////////////////////////// - -typedef struct WaitResetState WaitResetState; -struct WaitResetState { - // Common fields of INPUT_STATE_DESC, from which this structure - // "inherits". - BOOLEAN(*InputFunc)(void *pInputState); - - NetConnection *conn; - NetState nextState; - bool done; -}; - -static BOOLEAN -waitResetInputFunc(WaitResetState *state) { - netInputBlocking(NETWORK_POLL_DELAY); - // The timing out is necessary so that immediate key presses get - // handled while we wait. If we could do without the timeout, - // we wouldn't even need waitResetInputFunc() and the - // DoInput() call. - - // No need to call flushPacketQueues(); nothing needs to be sent - // right now. - - if (!NetConnection_isConnected(state->conn)) - return FALSE; - - return !state->done; -} - -// Called when both sides are reset. -static void -waitResetBothResetCallback(NetConnection *conn, void *arg) { - WaitResetState *state = (WaitResetState *) arg; - - if (state->nextState != (NetState) -1) { - NetConnection_setState(conn, state->nextState); - // This has to be done immediately, as more packets in the - // receive queue may be handled by the netInput() call that - // triggered this callback. - // This is the reason for the nextState argument to - // waitReset(); setting the state after the call to - // waitReset() would be too late. - } - state->done = true; -} - -bool -waitReset(NetConnection *conn, NetState nextState) { - WaitResetState state; - state.InputFunc = (BOOLEAN(*)(void *)) waitResetInputFunc; - state.conn = conn; - state.nextState = nextState; - state.done = false; - - Netplay_setResetCallback(conn, waitResetBothResetCallback, - (void *) &state); - if (state.done) - goto out; - - - if (!Netplay_isLocalReset(conn)) { - Netplay_localReset(conn, ResetReason_manualReset); - flushPacketQueue(conn); - } - - if (!state.done) - DoInput(&state, FALSE); - -out: - return NetConnection_isConnected(conn); -} - -// Wait until we have received a reset packet to all connections. If we -// ourselves have not sent a reset packet, one is sent, with reason -// 'manualReset'. -// XXX: Right now all connections are handled one by one. Handling them all -// at once would be faster but would require more work, which is -// not worth it as the time is minimal and this function is not -// time critical. -// Use '(NetState) -1' for nextState to keep the current state. -bool -waitResetConnections(NetState nextState) { - COUNT player; - size_t numDisconnected = 0; - - for (player = 0; player < NUM_PLAYERS; player++) - { - NetConnection *conn = netConnections[player]; - if (conn == NULL) - continue; - - if (!NetConnection_isConnected(conn)) { - numDisconnected++; - continue; - } - - waitReset(conn, nextState); - } - - return numDisconnected == 0; -} - -//////////////////////////////////////////////////////////////////////////// - Copied: trunk/sc2/src/uqm/supermelee/netplay/netmelee.c (from rev 3502, trunk/sc2/src/uqm/netplay/netmelee.c) =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/netmelee.c (rev 0) +++ trunk/sc2/src/uqm/supermelee/netplay/netmelee.c 2010-01-23 20:30:31 UTC (rev 3509) @@ -0,0 +1,744 @@ +/* + * Copyright 2006 Serge van den Boom <sv...@st...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "netmelee.h" +#include "libs/alarm.h" +#include "libs/callback.h" +#include "libs/log.h" +#include "libs/net.h" +#include "netinput.h" +#include "netmisc.h" +#include "netsend.h" +#include "notify.h" +#include "packetq.h" +#include "proto/npconfirm.h" +#include "proto/ready.h" +#include "proto/reset.h" + +#include "../../battlecontrols.h" + // for NetworkInputContext +#include "../../controls.h" + // for BATTLE_INPUT_STATE +#include "../../init.h" + // for NUM_PLAYERS +#include "../../globdata.h" + // for GLOBAL + +#include <errno.h> +#include <stdlib.h> + + +//////////////////////////////////////////////////////////////////////////// + + +NetConnection *netConnections[NUM_PLAYERS]; +size_t numNetConnections; + +void +addNetConnection(NetConnection *conn, int playerNr) { + netConnections[playerNr] = conn; + numNetConnections++; +} + +void +removeNetConnection(int playerNr) { + netConnections[playerNr] = NULL; + numNetConnections--; +} + +size_t +getNumNetConnections(void) { + return numNetConnections; +} + +// If the callback function returns 'false', the function will immediately +// return with 'false'. Otherwise it will return 'true' after calling +// the callback function for each connected player. +bool +forEachConnectedPlayer(ForEachConnectionCallback callback, void *arg) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + if (!(*callback)(conn, arg)) + return false; + } + return true; +} + +void +closeAllConnections(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + + if (conn != NULL) + closePlayerNetworkConnection(player); + } +} + +void +closeDisconnectedConnections(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + + if (conn != NULL && !NetConnection_isConnected(conn)) + closePlayerNetworkConnection(player); + } +} + +//////////////////////////////////////////////////////////////////////////// + + +struct melee_state * +NetMelee_getMeleeState(NetConnection *conn) { + if (NetConnection_getState(conn) > NetState_connecting) { + BattleStateData *battleStateData = + (BattleStateData *) NetConnection_getStateData(conn); + return battleStateData->meleeState; + } else { + return (struct melee_state *) NetConnection_getExtra(conn); + } +} + +struct battlestate_struct * +NetMelee_getBattleState(NetConnection *conn) { + if (NetConnection_getState(conn) > NetState_connecting) { + BattleStateData *battleStateData = + (BattleStateData *) NetConnection_getStateData(conn); + return battleStateData->battleState; + } else { + return NULL; + } +} + +//////////////////////////////////////////////////////////////////////////// + +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) { + netInputAux(0); +} + +void +netInputBlocking(uint32 timeoutMs) { + uint32 nextAlarmMs; + + nextAlarmMs = Alarm_timeBeforeNextMs(); + if (nextAlarmMs < timeoutMs) + timeoutMs = nextAlarmMs; + + netInputAux(timeoutMs); +} + + +//////////////////////////////////////////////////////////////////////////// + + +// Send along all pending network packets. +void +flushPacketQueues(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn; + int flushStatus; + + conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + flushStatus = flushPacketQueue(conn); + if (flushStatus == -1 && errno != EAGAIN) + closePlayerNetworkConnection(player); + } +} + +void +confirmConnections(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + Netplay_confirm(conn); + } +} + +void +cancelConfirmations(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + Netplay_cancelConfirmation(conn); + } +} + +void +connectionsLocalReady(NetConnection_ReadyCallback callback, void *arg) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + Netplay_localReady(conn, callback, arg, true); + } +} + +bool +allConnected(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + return false; + } + return true; +} + +void +initBattleStateDataConnections(void) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + BattleStateData *battleStateData; + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + battleStateData = + (BattleStateData *) NetConnection_getStateData(conn); + battleStateData->endFrameCount = 0; + } +} + +void +setBattleStateConnections(struct battlestate_struct *bs) { + COUNT player; + + for (player = 0; player < NUM_PLAYERS; player++) + { + BattleStateData *battleStateData; + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + battleStateData = + (BattleStateData *) NetConnection_getStateData(conn); + battleStateData->battleState = bs; + } +} + +BATTLE_INPUT_STATE +networkBattleInput(NetworkInputContext *context, STARSHIP *StarShipPtr) { + BattleInputBuffer *bib = getBattleInputBuffer(context->playerNr); + BATTLE_INPUT_STATE result; + + for (;;) { + bool ok; + +#if 0 + // This is a useful debugging trick. By enabling this #if + // block, this side will always lag the maximum number of frames + // behind the other side. When the remote side stops on some event + // (a breakpoint or so), this side will stop too, waiting for input + // in the loop below, but it won't have processed the frame that + // triggered the event yet. If you then jump over this 'if' + // statement here, you can walk through the decisive frames + // manually. Works best with no input delay. + if (bib->size <= getBattleInputDelay() + 1) { + ok = false; + } else +#endif + ok = BattleInputBuffer_pop(bib, &result); + // Get the input from the front of the + // buffer. + if (ok) + break; + + { + NetConnection *conn = netConnections[context->playerNr]; + + // First try whether there is incoming data, without blocking. + // If there isn't any, only then give a warning, and then + // block after all. + netInput(); + if (!NetConnection_isConnected(conn)) + { + // Connection aborted. + GLOBAL(CurrentActivity) |= CHECK_ABORT; + return (BATTLE_INPUT_STATE) 0; + } + + if (GLOBAL(CurrentActivity) & CHECK_ABORT) + return (BATTLE_INPUT_STATE) 0; + +#if 0 + log_add(log_Warning, "NETPLAY: [%d] stalling for " + "network input. Increase the input delay if this " + "happens a lot.\n", context->playerNr); +#endif +#define MAX_BLOCK_TIME 500 + netInputBlocking(MAX_BLOCK_TIME); + if (!NetConnection_isConnected(conn)) + { + // Connection aborted. + GLOBAL(CurrentActivity) |= CHECK_ABORT; + return (BATTLE_INPUT_STATE) 0; + } + } + } + + (void) StarShipPtr; + return result; +} + +static void +deleteConnectionCallback(NetConnection *conn) { + removeNetConnection(NetConnection_getPlayerNr(conn)); +} + +NetConnection * +openPlayerNetworkConnection(COUNT player, void *extra) { + NetConnection *conn; + + assert(netConnections[player] == NULL); + + conn = NetConnection_open(player, + &netplayOptions.peer[player], NetMelee_connectCallback, + NetMelee_closeCallback, NetMelee_errorCallback, + deleteConnectionCallback, extra); + + addNetConnection(conn, player); + return conn; +} + +void +shutdownPlayerNetworkConnection(COUNT player) { + NetConnection_close(netConnections[player]); +} + +void +closePlayerNetworkConnection(COUNT player) { + assert(netConnections[player] != NULL); + + NetConnection_close(netConnections[player]); +} + +bool +setupInputDelay(size_t localInputDelay) { + COUNT player; + bool haveNetworkPlayer = false; + // We have at least one network controlled player. + size_t inputDelay = 0; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) + continue; + + haveNetworkPlayer = true; + if (NetConnection_getInputDelay(conn) > inputDelay) + inputDelay = NetConnection_getInputDelay(conn); + } + + if (haveNetworkPlayer && inputDelay < localInputDelay) + inputDelay = localInputDelay; + + setBattleInputDelay(inputDelay); + return true; +} + +static bool +setStateConnection(NetConnection *conn, void *arg) { + const NetState *state = (NetState *) arg; + NetConnection_setState(conn, *state); + return true; +} + +bool +setStateConnections(NetState state) { + return forEachConnectedPlayer(setStateConnection, &state); +} + +static bool +sendAbortConnection(NetConnection *conn, void *arg) { + const NetplayAbortReason *reason = (NetplayAbortReason *) arg; + sendAbort(conn, *reason); + return true; +} + +bool +sendAbortConnections(NetplayAbortReason reason) { + return forEachConnectedPlayer(sendAbortConnection, &reason); +} + +static bool +resetConnection(NetConnection *conn, void *arg) { + const NetplayResetReason *reason = (NetplayResetReason *) arg; + Netplay_localReset(conn, *reason); + return true; +} + +bool +resetConnections(NetplayResetReason reason) { + return forEachConnectedPlayer(resetConnection, &reason); +} + +///////////////////////////////////////////////////////////////////////////// + +typedef struct { + NetConnection_ReadyCallback readyCallback; + void *readyCallbackArg; + bool notifyRemote; +} LocalReadyConnectionArg; + +static bool +localReadyConnection(NetConnection *conn, void *arg) { + LocalReadyConnectionArg *readyArg = (LocalReadyConnectionArg *) arg; + Netplay_localReady(conn, readyArg->readyCallback, + readyArg->readyCallbackArg, readyArg->notifyRemote); + return true; +} + +bool +localReadyConnections(NetConnection_ReadyCallback readyCallback, + void *readyArg, bool notifyRemote) { + LocalReadyConnectionArg arg; + arg.readyCallback = readyCallback; + arg.readyCallbackArg = readyArg; + arg.notifyRemote = notifyRemote; + + return forEachConnectedPlayer(localReadyConnection, &arg); +} + + +///////////////////////////////////////////////////////////////////////////// + +#define NETWORK_POLL_DELAY (ONE_SECOND / 24) + +typedef struct NegotiateReadyState NegotiateReadyState; +struct NegotiateReadyState { + // Common fields of INPUT_STATE_DESC, from which this structure + // "inherits". + BOOLEAN(*InputFunc)(void *pInputState); + + NetConnection *conn; + NetState nextState; + bool done; +}; + +static BOOLEAN +negotiateReadyInputFunc(NegotiateReadyState *state) { + netInputBlocking(NETWORK_POLL_DELAY); + // The timing out is necessary so that immediate key presses get + // handled while we wait. If we could do without the timeout, + // we wouldn't even need negotiateReadyInputFunc() and the + // DoInput() call. + + // No need to call flushPacketQueues(); nothing needs to be sent + // right now. + + if (!NetConnection_isConnected(state->conn)) + return FALSE; + + return !state->done; +} + +// Called when both sides are ready +static void +negotiateReadyBothReadyCallback(NetConnection *conn, void *arg) { + NegotiateReadyState *state =(NegotiateReadyState *) arg; + + NetConnection_setState(conn, state->nextState); + // This has to be done immediately, as more packets in the + // receive queue may be handled by the netInput() call that + // triggered this callback. + // This is the reason for the nextState argument to + // negotiateReady(); setting the state after the call to + // negotiateReady() would be too late. + state->done = true; +} + +bool +negotiateReady(NetConnection *conn, bool notifyRemote, NetState nextState) { + NegotiateReadyState state; + state.InputFunc = (BOOLEAN(*)(void *)) negotiateReadyInputFunc; + state.conn = conn; + state.nextState = nextState; + state.done = false; + + Netplay_localReady(conn, negotiateReadyBothReadyCallback, + (void *) &state, notifyRemote); + flushPacketQueue(conn); + if (!state.done) + DoInput(&state, FALSE); + + return NetConnection_isConnected(conn); +} + +// Wait for all connections to get ready. +// XXX: Right now all connections are handled one by one. Handling them all +// at once would be faster but would require more work, which is +// not worth it as the time is minimal and this function is not +// time critical. +bool +negotiateReadyConnections(bool notifyRemote, NetState nextState) { + COUNT player; + size_t numDisconnected = 0; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) { + numDisconnected++; + continue; + } + + negotiateReady(conn, notifyRemote, nextState); + } + + return numDisconnected == 0; +} + +typedef struct WaitReadyState WaitReadyState; +struct WaitReadyState { + // Common fields of INPUT_STATE_DESC, from which this structure + // "inherits". + BOOLEAN (*InputFunc)(void *pInputState); + + NetConnection *conn; + NetConnection_ReadyCallback readyCallback; + void *readyCallbackArg; + bool done; +}; + +static void +waitReadyCallback(NetConnection *conn, void *arg) { + WaitReadyState *state =(WaitReadyState *) arg; + state->done = true; + + // Call the original callback. + state->readyCallback(conn, state->readyCallbackArg); +} + +static BOOLEAN +waitReadyInputFunc(WaitReadyState *state) { + netInputBlocking(NETWORK_POLL_DELAY); + // The timing out is necessary so that immediate key presses get + // handled while we wait. If we could do without the timeout, + // we wouldn't even need negotiateReadyInputFunc() and the + // DoInput() call. + + // No need to call flushPacketQueues(); nothing needs to be sent + // right now. + + if (!NetConnection_isConnected(state->conn)) + return FALSE; + + return !state->done; +} + +bool +waitReady(NetConnection *conn) { + WaitReadyState state; + state.InputFunc =(BOOLEAN(*)(void *)) waitReadyInputFunc; + state.conn = conn; + state.readyCallback = NetConnection_getReadyCallback(conn); + state.readyCallbackArg = NetConnection_getReadyCallbackArg(conn); + state.done = false; + + NetConnection_setReadyCallback(conn, waitReadyCallback, (void *) &state); + + DoInput(&state, FALSE); + + return NetConnection_isConnected(conn); +} + + +//////////////////////////////////////////////////////////////////////////// + +typedef struct WaitResetState WaitResetState; +struct WaitResetState { + // Common fields of INPUT_STATE_DESC, from which this structure + // "inherits". + BOOLEAN(*InputFunc)(void *pInputState); + + NetConnection *conn; + NetState nextState; + bool done; +}; + +static BOOLEAN +waitResetInputFunc(WaitResetState *state) { + netInputBlocking(NETWORK_POLL_DELAY); + // The timing out is necessary so that immediate key presses get + // handled while we wait. If we could do without the timeout, + // we wouldn't even need waitResetInputFunc() and the + // DoInput() call. + + // No need to call flushPacketQueues(); nothing needs to be sent + // right now. + + if (!NetConnection_isConnected(state->conn)) + return FALSE; + + return !state->done; +} + +// Called when both sides are reset. +static void +waitResetBothResetCallback(NetConnection *conn, void *arg) { + WaitResetState *state = (WaitResetState *) arg; + + if (state->nextState != (NetState) -1) { + NetConnection_setState(conn, state->nextState); + // This has to be done immediately, as more packets in the + // receive queue may be handled by the netInput() call that + // triggered this callback. + // This is the reason for the nextState argument to + // waitReset(); setting the state after the call to + // waitReset() would be too late. + } + state->done = true; +} + +bool +waitReset(NetConnection *conn, NetState nextState) { + WaitResetState state; + state.InputFunc = (BOOLEAN(*)(void *)) waitResetInputFunc; + state.conn = conn; + state.nextState = nextState; + state.done = false; + + Netplay_setResetCallback(conn, waitResetBothResetCallback, + (void *) &state); + if (state.done) + goto out; + + + if (!Netplay_isLocalReset(conn)) { + Netplay_localReset(conn, ResetReason_manualReset); + flushPacketQueue(conn); + } + + if (!state.done) + DoInput(&state, FALSE); + +out: + return NetConnection_isConnected(conn); +} + +// Wait until we have received a reset packet from all connections. If we +// ourselves have not sent a reset packet, one is sent, with reason +// 'manualReset'. +// XXX: Right now all connections are handled one by one. Handling them all +// at once would be faster but would require more work, which is +// not worth it as the time is minimal and this function is not +// time critical. +// Use '(NetState) -1' for nextState to keep the current state. +bool +waitResetConnections(NetState nextState) { + COUNT player; + size_t numDisconnected = 0; + + for (player = 0; player < NUM_PLAYERS; player++) + { + NetConnection *conn = netConnections[player]; + if (conn == NULL) + continue; + + if (!NetConnection_isConnected(conn)) { + numDisconnected++; + continue; + } + + waitReset(conn, nextState); + } + + return numDisconnected == 0; +} + +//////////////////////////////////////////////////////////////////////////// + Deleted: trunk/sc2/src/uqm/supermelee/netplay/netmelee.h =================================================================== --- trunk/sc2/src/uqm/netplay/netmelee.h 2010-01-16 22:04:03 UTC (rev 3500) +++ trunk/sc2/src/uqm/supermelee/netplay/netmelee.h 2010-01-23 20:30:31 UTC (rev 3509) @@ -1,89 +0,0 @@ -/* - * Copyright 2006 Serge van den Boom <sv...@st...> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#if !defined(_NETMELEE_H) && defined(NETPLAY) -#define _NETMELEE_H - -#include "netplay.h" -#include "netinput.h" -#include "netconnection.h" -#include "packetsenders.h" - -#include "../battlecontrols.h" - // for NetworkInputContext -#include "../controls.h" - // for BATTLE_INPUT_STATE -#include "../races.h" - // for STARSHIP - - -extern struct NetConnection *netConnections[]; - - -void addNetConnection(NetConnection *conn, int playerNr); -void removeNetConnection(int playerNr); -void closeAllConnections(void); -void closeDisconnectedConnections(void); -size_t getNumNetConnections(void); - -struct melee_state *NetMelee_getMeleeState(NetConnection *conn); -struct battlestate_struct *NetMelee_getBattleState(NetConnection *conn); - -void ne... [truncated message content] |
From: <Mee...@us...> - 2010-01-23 22:07:06
|
Revision: 3511 http://sc2.svn.sourceforge.net/sc2/?rev=3511&view=rev Author: Meep-Eep Date: 2010-01-23 22:06:59 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Warnings fix. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/file/dirs.c trunk/sc2/src/libs/graphics/context.h trunk/sc2/src/libs/graphics/font.c trunk/sc2/src/libs/graphics/gfxload.c trunk/sc2/src/libs/graphics/sdl/3do_getbody.c trunk/sc2/src/libs/graphics/sdl/canvas.c trunk/sc2/src/libs/graphics/sdl/primitives.c trunk/sc2/src/libs/graphics/sdl/pure.h trunk/sc2/src/libs/graphics/sdl/sdl_common.c trunk/sc2/src/libs/input/sdl/vcontrol.c trunk/sc2/src/libs/misc.h trunk/sc2/src/libs/network/socket/socket.h trunk/sc2/src/libs/network/socket/socket_bsd.c trunk/sc2/src/libs/reslib.h trunk/sc2/src/libs/sound/stream.c trunk/sc2/src/libs/sound/trackplayer.c trunk/sc2/src/libs/strings/unicode.c trunk/sc2/src/libs/uio/io.h trunk/sc2/src/uqm/cnctdlg.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/gameinp.c trunk/sc2/src/uqm/gendef.c trunk/sc2/src/uqm/init.c trunk/sc2/src/uqm/intro.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/plangen.c trunk/sc2/src/uqm/planets/roster.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/sis.h trunk/sc2/src/uqm/supermelee/melee.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/ChangeLog 2010-01-23 22:06:59 UTC (rev 3511) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Got rid of many warnings - SvdB - Clean up and some refactoring of the SuperMelee code - SvdB - Fixed concurrent screen fades regression (bug #1079) - Alex - Removed some legacy source code files related to resources - SvdB Modified: trunk/sc2/src/libs/file/dirs.c =================================================================== --- trunk/sc2/src/libs/file/dirs.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/file/dirs.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -27,6 +27,7 @@ #include "filintrn.h" #include "libs/compiler.h" #include "libs/memlib.h" +#include "libs/misc.h" #include "libs/log.h" #ifdef HAVE_DRIVE_LETTERS @@ -788,7 +789,7 @@ if (end < start) return (char *) NULL; if (*end == c) - return (char *) end; + return (char *) unconst(end); } } Modified: trunk/sc2/src/libs/graphics/context.h =================================================================== --- trunk/sc2/src/libs/graphics/context.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/context.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -141,6 +141,7 @@ // pValidRect or origin may be NULL BOOLEAN GetContextValidRect (RECT *pValidRect, POINT *origin); +extern void FixContextFontEffect (void); #endif /* _CONTEXT_H */ Modified: trunk/sc2/src/libs/graphics/font.c =================================================================== --- trunk/sc2/src/libs/graphics/font.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/font.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -20,7 +20,6 @@ #include "tfb_prim.h" #include "libs/log.h" -extern void FixContextFontEffect (void); static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, UniChar ch); Modified: trunk/sc2/src/libs/graphics/gfxload.c =================================================================== --- trunk/sc2/src/libs/graphics/gfxload.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/gfxload.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -356,9 +356,12 @@ UniChar index; } BuildCharDesc; -int -compareBCDIndex (const BuildCharDesc *bcd1, const BuildCharDesc *bcd2) +static int +compareBCDIndex (const void *arg1, const void *arg2) { + const BuildCharDesc *bcd1 = (const BuildCharDesc *) arg1; + const BuildCharDesc *bcd2 = (const BuildCharDesc *) arg2; + return (int) bcd1->index - (int) bcd2->index; } @@ -466,8 +469,7 @@ #endif // sort on the character index - qsort (bcds, numBCDs, sizeof (BuildCharDesc), - (int (*)(const void *, const void *)) compareBCDIndex); + qsort (bcds, numBCDs, sizeof (BuildCharDesc), compareBCDIndex); fontPtr = AllocFont (0); if (fontPtr == NULL) Modified: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -24,7 +24,8 @@ #include "sdl_common.h" #include "primitives.h" - +#if 0 +/* Unused */ void process_rgb_bmp (FRAME FramePtr, Uint32 *rgba, int maxx, int maxy) { int x, y; @@ -45,7 +46,10 @@ SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif +#if 0 +/* Unused */ void fill_frame_rgb (FRAME FramePtr, Uint32 color, int x0, int y0, int x, int y) { @@ -70,8 +74,12 @@ SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif -void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, +#if 0 +/* Unused */ +void +arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, const RECT *rdst, int num, int denom) { TFB_Image *srcImg, *dstImg; @@ -120,7 +128,10 @@ UnlockMutex (srcImg->mutex); UnlockMutex (dstImg->mutex); } +#endif +#if 0 +/* Unused */ // Generate an array of all pixels in FramePtr // The 32bpp pixel format is : // bits 24-31 : red @@ -128,8 +139,8 @@ // bits 8-15 : blue // bits 0-7 : alpha // The 8bpp pixel format is 1 index per pixel -void getpixelarray (void *map, int Bpp, FRAME FramePtr, - int width, int height) +void +getpixelarray (void *map, int Bpp, FRAME FramePtr, int width, int height) { Uint8 r,g,b,a; Uint32 p, pos, row; @@ -179,8 +190,10 @@ SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif - +#if 0 +/* Unused */ // Generate a pixel (in the correct format to be applied to FramePtr) from the // r,g,b,a values supplied Uint32 frame_mapRGBA (FRAME FramePtr,Uint8 r, Uint8 g, Uint8 b, Uint8 a) @@ -188,5 +201,7 @@ SDL_Surface *img= (SDL_Surface *)FramePtr->image->NormalImg; return (SDL_MapRGBA (img->format, r, g, b, a)); } +#endif #endif + Modified: trunk/sc2/src/libs/graphics/sdl/canvas.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/canvas.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/sdl/canvas.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -56,7 +56,7 @@ return err; } -void +static void checkPrimitiveMode (SDL_Surface *surf, Color *color, DrawMode *mode) { const SDL_PixelFormat *fmt = surf->format; Modified: trunk/sc2/src/libs/graphics/sdl/primitives.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -25,42 +25,48 @@ // Pixel drawing routines -Uint32 getpixel_8(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_8(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x; return *p; } -void putpixel_8(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_8(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 1; *p = pixel; } -Uint32 getpixel_16(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_16(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 2; return *(Uint16 *)p; } -void putpixel_16(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_16(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 2; *(Uint16 *)p = pixel; } -Uint32 getpixel_24_be(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_24_be(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; return p[0] << 16 | p[1] << 8 | p[2]; } -void putpixel_24_be(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_24_be(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; @@ -69,14 +75,16 @@ p[2] = pixel & 0xff; } -Uint32 getpixel_24_le(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_24_le(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; return p[0] | p[1] << 8 | p[2] << 16; } -void putpixel_24_le(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_24_le(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; @@ -85,21 +93,24 @@ p[2] = (pixel >> 16) & 0xff; } -Uint32 getpixel_32(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_32(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 4; return *(Uint32 *)p; } -void putpixel_32(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_32(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 4; *(Uint32 *)p = pixel; } -GetPixelFn getpixel_for(SDL_Surface *surface) +GetPixelFn +getpixel_for(SDL_Surface *surface) { int bpp = surface->format->BytesPerPixel; switch (bpp) { @@ -119,7 +130,8 @@ return NULL; } -PutPixelFn putpixel_for(SDL_Surface *surface) +PutPixelFn +putpixel_for(SDL_Surface *surface) { int bpp = surface->format->BytesPerPixel; switch (bpp) { @@ -139,14 +151,16 @@ return NULL; } -static void renderpixel_replace(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_replace(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { (void) factor; // ignored putpixel_32(surface, x, y, pixel); } -static inline Uint8 clip_channel(int c) +static inline Uint8 +clip_channel(int c) { if (c < 0) c = 0; @@ -155,7 +169,8 @@ return c; } -static inline Uint8 modulated_sum(Uint8 dc, Uint8 sc, int factor) +static inline Uint8 +modulated_sum(Uint8 dc, Uint8 sc, int factor) { // We use >> 8 instead of / 255 because it is faster, but it does // not work 100% correctly. It should be safe because this should @@ -164,7 +179,8 @@ return clip_channel(b); } -static inline Uint8 alpha_blend(Uint8 dc, Uint8 sc, int alpha) +static inline Uint8 +alpha_blend(Uint8 dc, Uint8 sc, int alpha) { // We use >> 8 instead of / 255 because it is faster, but it does // not work 100% correctly. It should be safe because this should @@ -183,15 +199,17 @@ } while (0) // Assumes the channels already clipped to 8 bits -static inline Uint32 PACK_PIXEL_32(const SDL_PixelFormat *fmt, +static inline Uint32 +PACK_PIXEL_32(const SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b) { return ((Uint32)r << fmt->Rshift) | ((Uint32)g << fmt->Gshift) | ((Uint32)b << fmt->Bshift); } -static void renderpixel_additive(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_additive(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { const SDL_PixelFormat *fmt = surface->format; Uint32 *p; @@ -223,8 +241,9 @@ *p = PACK_PIXEL_32(fmt, sr, sg, sb); } -static void renderpixel_alpha(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_alpha(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { const SDL_PixelFormat *fmt = surface->format; Uint32 *p; @@ -249,7 +268,8 @@ *p = PACK_PIXEL_32(fmt, sr, sg, sb); } -RenderPixelFn renderpixel_for(SDL_Surface *surface, RenderKind kind) +RenderPixelFn +renderpixel_for(SDL_Surface *surface, RenderKind kind) { const SDL_PixelFormat *fmt = surface->format; @@ -278,8 +298,9 @@ * Adapted from Paul Heckbert's implementation of Bresenham's algorithm, * 3 Sep 85; taken from Graphics Gems I */ -void line_prim(int x1, int y1, int x2, int y2, Uint32 color, - RenderPixelFn plot, int factor, SDL_Surface *dst) +void +line_prim(int x1, int y1, int x2, int y2, Uint32 color, RenderPixelFn plot, + int factor, SDL_Surface *dst) { int d, x, y, ax, ay, sx, sy, dx, dy; SDL_Rect clip_r; @@ -417,8 +438,9 @@ } } -void fillrect_prim(SDL_Rect r, Uint32 color, - RenderPixelFn plot, int factor, SDL_Surface *dst) +void +fillrect_prim(SDL_Rect r, Uint32 color, RenderPixelFn plot, int factor, + SDL_Surface *dst) { int x, y; int x1, y1; @@ -440,7 +462,8 @@ } // clip the rectangle against the clip rectangle -int clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) +int +clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) { // NOTE: the following clipping code is copied in part // from SDL-1.2.4 sources @@ -475,7 +498,8 @@ return 1; } -void blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, +void +blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, SDL_Surface *dst, SDL_Rect dst_r) { SDL_PixelFormat *srcfmt = src->format; @@ -544,7 +568,8 @@ } // clip the source and destination rectangles against the clip rectangle -int clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r) +int +clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r) { // NOTE: the following clipping code is copied in part // from SDL-1.2.4 sources Modified: trunk/sc2/src/libs/graphics/sdl/pure.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/pure.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/sdl/pure.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -23,5 +23,6 @@ int TFB_Pure_InitGraphics (int driver, int flags, int width, int height); int TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen); +void Scale_PerfTest (void); #endif Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -338,8 +338,9 @@ return SDL_Screens[screen]; } -void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, - SDL_Rect *dstrect, int blend_numer, int blend_denom) +void +TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, + SDL_Rect *dstrect, int blend_numer, int blend_denom) { BOOLEAN has_colorkey; int x, y, x1, y1, x2, y2, dst_x2, dst_y2, nr, ng, nb; @@ -369,7 +370,7 @@ } // clip the source rectangle to the source surface - if (srcrect) + if (srcrect) { int maxw, maxh; @@ -452,6 +453,7 @@ else { has_colorkey = FALSE; + colorkey = 0; /* Satisfying compiler */ } src_getpix = getpixel_for (src); Modified: trunk/sc2/src/libs/input/sdl/vcontrol.c =================================================================== --- trunk/sc2/src/libs/input/sdl/vcontrol.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/input/sdl/vcontrol.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -1076,7 +1076,7 @@ } static void -expected_error (parse_state *state, char *expected) +expected_error (parse_state *state, const char *expected) { log_add (log_Warning, "VControl: Expected '%s' on config file line %d", expected, state->linenum); @@ -1084,7 +1084,7 @@ } static void -consume (parse_state *state, char *expected) +consume (parse_state *state, const char *expected) { if (strcasecmp (expected, state->token)) { Modified: trunk/sc2/src/libs/misc.h =================================================================== --- trunk/sc2/src/libs/misc.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/misc.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -41,5 +41,18 @@ #endif } +/* Sometimes you just have to remove a 'const'. + * (for instance, when implementing a function like strchr) + */ +static inline void * +unconst(const void *arg) { + union { + char *c; + const char *cc; + } u; + u.cc = arg; + return u.c; +} + #endif Modified: trunk/sc2/src/libs/network/socket/socket.h =================================================================== --- trunk/sc2/src/libs/network/socket/socket.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/network/socket/socket.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -84,6 +84,8 @@ int Socket_setNonBlocking(Socket *sock); int Socket_setReuseAddr(Socket *sock); +int Socket_setNodelay(Socket *sock); +int Socket_setTOS(Socket *sock, int tos); int Socket_setInteractive(Socket *sock); int Socket_setInlineOOB(Socket *sock); int Socket_setKeepAlive(Socket *sock); Modified: trunk/sc2/src/libs/network/socket/socket_bsd.c =================================================================== --- trunk/sc2/src/libs/network/socket/socket_bsd.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/network/socket/socket_bsd.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -40,12 +40,12 @@ #include <fcntl.h> -Socket * +static Socket * Socket_alloc(void) { return malloc(sizeof (Socket)); } -void +static void Socket_free(Socket *sock) { free(sock); } Modified: trunk/sc2/src/libs/reslib.h =================================================================== --- trunk/sc2/src/libs/reslib.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/reslib.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -64,7 +64,7 @@ BOOLEAN InstallResTypeVectors (const char *res_type, ResourceLoadFun *loadFun, ResourceFreeFun *freeFun, ResourceStringFun *stringFun); void *res_GetResource (RESOURCE res); void *res_DetachResource (RESOURCE res); -BOOLEAN FreeResource (RESOURCE res); +void res_FreeResource (RESOURCE res); COUNT CountResourceTypes (void); DWORD res_GetIntResource (RESOURCE res); BOOLEAN res_GetBooleanResource (RESOURCE res); Modified: trunk/sc2/src/libs/sound/stream.c =================================================================== --- trunk/sc2/src/libs/sound/stream.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/sound/stream.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -578,7 +578,7 @@ return 0; } -inline sint32 +static inline sint32 readSoundSample (void *ptr, int sample_size) { if (sample_size == sizeof (uint8)) Modified: trunk/sc2/src/libs/sound/trackplayer.c =================================================================== --- trunk/sc2/src/libs/sound/trackplayer.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/sound/trackplayer.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -314,8 +314,8 @@ } #define TEXT_SPEED 80 -// Returns number of parsed pages -int +// Returns number of parsed pages +static int SplitSubPages (UNICODE *text, UNICODE *pages[], sint32 timestamp[], int size) { int lead_ellips = 0; Modified: trunk/sc2/src/libs/strings/unicode.c =================================================================== --- trunk/sc2/src/libs/strings/unicode.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/strings/unicode.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -24,6 +24,7 @@ #include <stdio.h> #include <string.h> #include "libs/log.h" +#include "libs/misc.h" // Resynchronise (skip everything starting with 0x10xxxxxx): @@ -176,7 +177,7 @@ if (*ptr == '\0') { *end = ptr; *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } lastPtr = ptr; ch = getCharFromString(&ptr); @@ -191,7 +192,7 @@ if (*ptr == '\0'){ // LF at the end of the string. *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } ch = getCharFromString(&ptr); if (ch == '\0') { @@ -205,11 +206,11 @@ // LF *startNext = *end; } - return (unsigned char *) start; + return (unsigned char *) unconst(start); } else if (ch == '\r') { *end = lastPtr; *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } // else: a normal character } } @@ -271,7 +272,7 @@ if (size == 0) return 0; - strncpy ((char *) dst, (char *) src, size); + strncpy ((char *) dst, (const char *) src, size); dst[size - 1] = '\0'; return dst; @@ -319,7 +320,7 @@ return 0; #else // this will do for now - return strcmp ((char *) str1, (char *) str2); + return strcmp ((const char *) str1, (const char *) str2); #endif } @@ -332,9 +333,9 @@ oldPtr = ptr; ch = getCharFromString(&ptr); if (ch == '\0') - return (unsigned char *) oldPtr; + return (unsigned char *) unconst(oldPtr); } - return (unsigned char *) ptr; + return (unsigned char *) unconst(ptr); } // Decodes a UTF-8 string (start) into a unicode character string (wstr) Modified: trunk/sc2/src/libs/uio/io.h =================================================================== --- trunk/sc2/src/libs/uio/io.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/libs/uio/io.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -102,6 +102,9 @@ int uio_rename(uio_DirHandle *oldDir, const char *oldPath, uio_DirHandle *newDir, const char *newPath); +// Test permissions on a file or directory. +int uio_access(uio_DirHandle *dir, const char *path, int mode); + // Fstat a file descriptor int uio_fstat(uio_Handle *handle, struct stat *statBuf); Modified: trunk/sc2/src/uqm/cnctdlg.c =================================================================== --- trunk/sc2/src/uqm/cnctdlg.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/cnctdlg.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -172,7 +172,7 @@ SetContextForeGroundColor (oldtext); } -void +static void MCD_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -227,10 +227,10 @@ static void TellHistory (RESPONSE_REF R); static void AlienRaces (RESPONSE_REF R); -static BYTE stack0, - stack1, - stack2, - stack3; +static BYTE stack0; +static BYTE stack1; +static BYTE stack2; +static BYTE stack3; static void AllianceInfo (RESPONSE_REF R) @@ -492,7 +492,9 @@ if (PLAYER_SAID (R, history)) { NPCPhrase (WHICH_HISTORY); - stack0 = stack1 = stack2 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; } else if (PLAYER_SAID (R, enough_aliens)) { @@ -518,7 +520,7 @@ case 0: pstack[0] = alien_races; break; - case 1: + default: pstack[0] = 0; break; } @@ -527,7 +529,7 @@ case 0: pstack[1] = the_war; break; - case 1: + default: pstack[1] = 0; break; } @@ -536,7 +538,7 @@ case 0: pstack[2] = ancient_history; break; - case 1: + default: pstack[2] = 0; break; } @@ -782,7 +784,10 @@ if (PLAYER_SAID (R, our_mission)) { NPCPhrase (WHICH_MISSION); - stack0 = stack1 = stack2 = stack3 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; + stack3 = 0; } else if (PLAYER_SAID (R, where_get_minerals)) { @@ -881,7 +886,10 @@ if (PLAYER_SAID (R, starbase_functions)) { NPCPhrase (WHICH_FUNCTION); - stack0 = stack1 = stack2 = stack3 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; + stack3 = 0; } else if (PLAYER_SAID (R, tell_me_about_fuel0)) { Modified: trunk/sc2/src/uqm/gameinp.c =================================================================== --- trunk/sc2/src/uqm/gameinp.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/gameinp.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -318,7 +318,7 @@ _clear_menu_state (); } -MENU_SOUND_FLAGS +static MENU_SOUND_FLAGS MenuKeysToSoundFlags (const CONTROLLER_INPUT_STATE *state) { MENU_SOUND_FLAGS soundFlags; Modified: trunk/sc2/src/uqm/gendef.c =================================================================== --- trunk/sc2/src/uqm/gendef.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/gendef.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "gendef.h" #include "encount.h" #include "planets/generate.h" Modified: trunk/sc2/src/uqm/init.c =================================================================== --- trunk/sc2/src/uqm/init.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/init.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -156,7 +156,7 @@ } } -HSTARSHIP +static HSTARSHIP BuildSIS (void) { HSTARSHIP hStarShip; Modified: trunk/sc2/src/uqm/intro.c =================================================================== --- trunk/sc2/src/uqm/intro.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/intro.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -282,7 +282,7 @@ UnlockMutex (GraphicsLock); } -BOOLEAN +static BOOLEAN ShowPresentationFile (const char *name) { STRING pres = CaptureStringTable (LoadStringTableFile (contentDir, name)); Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/planets/planets.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -199,7 +199,7 @@ BYTE max_ship_speed; STRING XlatRef; - void *XlatPtr; + const void *XlatPtr; COLORMAP OrbitalCMap; SYSTEM_INFO SysInfo; Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/planets/plangen.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -105,12 +105,13 @@ COUNT i; BYTE AlgoType; SIZE base, d; + const XLAT_DESC *xlatDesc; POINT pt; const PlanetFrame *PlanDataPtr; PRIMITIVE BatchArray[NUM_BATCH_POINTS]; PRIMITIVE *pBatch; SBYTE *pSrc; - BYTE *xlat_tab; + const BYTE *xlat_tab; BYTE *cbase; POINT oldOrigin; RECT ClipRect; @@ -132,7 +133,8 @@ ]; AlgoType = PLANALGO (PlanDataPtr->Type); base = PlanDataPtr->base_elevation; - xlat_tab = (BYTE*)((XLAT_DESC*)pSolarSysState->XlatPtr)->xlat_tab; + xlatDesc = (const XLAT_DESC *) pSolarSysState->XlatPtr; + xlat_tab = (const BYTE *) xlatDesc->xlat_tab; cbase = GetColorMapAddress (pSolarSysState->OrbitalCMap); i = NUM_BATCH_POINTS; Modified: trunk/sc2/src/uqm/planets/roster.c =================================================================== --- trunk/sc2/src/uqm/planets/roster.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/planets/roster.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -375,8 +375,8 @@ static int compShipPos (const void *ptr1, const void *ptr2) { - POINT *pt1 = (POINT *) ptr1; - POINT *pt2 = (POINT *) ptr2; + const POINT *pt1 = (const POINT *) ptr1; + const POINT *pt2 = (const POINT *) ptr2; // Ships on the left in the lower half if (pt1->x < pt2->x) Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/sis.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -1274,7 +1274,7 @@ //////////////////////////////////////////////////////////////////////////// // Get the total amount of minerals aboard the SIS. -COUNT +static COUNT GetElementMass (void) { return GLOBAL_SIS (TotalElementMass); @@ -1379,7 +1379,7 @@ //////////////////////////////////////////////////////////////////////////// // Get the total amount of fuel aboard the SIS. -DWORD +static DWORD GetFuelTotal (void) { return GLOBAL_SIS (FuelOnBoard); Modified: trunk/sc2/src/uqm/sis.h =================================================================== --- trunk/sc2/src/uqm/sis.h 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/sis.h 2010-01-23 22:06:59 UTC (rev 3511) @@ -231,9 +231,11 @@ extern COUNT GetCrewPodCapacity (void); extern COUNT GetCPodCapacity (POINT *ppt); +extern COUNT GetModuleStorageCapacity (BYTE moduleType); extern COUNT GetStorageBayCapacity (void); extern COUNT GetSBayCapacity (POINT *ppt); +extern DWORD GetModuleFuelCapacity (BYTE moduleType); extern DWORD GetFuelTankCapacity (void); extern DWORD GetFTankCapacity (POINT *ppt); Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2010-01-23 20:36:00 UTC (rev 3510) +++ trunk/sc2/src/uqm/supermelee/melee.c 2010-01-23 22:06:59 UTC (rev 3511) @@ -1923,7 +1923,7 @@ return TRUE; } -int +static int LoadMeleeConfig (MELEE_STATE *pMS) { uio_Stream *stream; @@ -1968,7 +1968,7 @@ return -1; } -int +static int WriteMeleeConfig (MELEE_STATE *pMS) { uio_Stream *stream; @@ -2125,7 +2125,7 @@ PlayMenuSound (MENU_SOUND_INVOKED); } -const char * +static const char * abortReasonString (NetplayAbortReason reason) { switch (reason) @@ -2160,7 +2160,7 @@ connectionFeedback (conn, msg, true); } -const char * +static const char * resetReasonString (NetplayResetReason reason) { switch (reason) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-23 22:53:26
|
Revision: 3514 http://sc2.svn.sourceforge.net/sc2/?rev=3514&view=rev Author: Meep-Eep Date: 2010-01-23 22:53:19 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Fix warnings. Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/uqm/dummy.h trunk/sc2/src/uqm/ships/androsyn/androsyn.c trunk/sc2/src/uqm/ships/arilou/arilou.c trunk/sc2/src/uqm/ships/blackurq/blackurq.c trunk/sc2/src/uqm/ships/chenjesu/chenjesu.c trunk/sc2/src/uqm/ships/chmmr/chmmr.c trunk/sc2/src/uqm/ships/druuge/druuge.c trunk/sc2/src/uqm/ships/human/human.c trunk/sc2/src/uqm/ships/ilwrath/ilwrath.c trunk/sc2/src/uqm/ships/lastbat/lastbat.c trunk/sc2/src/uqm/ships/melnorme/melnorme.c trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c trunk/sc2/src/uqm/ships/mycon/mycon.c trunk/sc2/src/uqm/ships/orz/orz.c trunk/sc2/src/uqm/ships/pkunk/pkunk.c trunk/sc2/src/uqm/ships/probe/probe.c trunk/sc2/src/uqm/ships/shofixti/shofixti.c trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c trunk/sc2/src/uqm/ships/slylandr/slylandr.c trunk/sc2/src/uqm/ships/spathi/spathi.c trunk/sc2/src/uqm/ships/supox/supox.c trunk/sc2/src/uqm/ships/syreen/syreen.c trunk/sc2/src/uqm/ships/thradd/thradd.c trunk/sc2/src/uqm/ships/umgah/umgah.c trunk/sc2/src/uqm/ships/urquan/urquan.c trunk/sc2/src/uqm/ships/utwig/utwig.c trunk/sc2/src/uqm/ships/vux/vux.c trunk/sc2/src/uqm/ships/yehat/yehat.c trunk/sc2/src/uqm/ships/zoqfot/zoqfot.c trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-23 22:53:19 UTC (rev 3514) @@ -2336,6 +2336,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\androsyn\androsyn.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\androsyn\icode.h # End Source File # Begin Source File @@ -2352,6 +2356,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\arilou\arilou.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\arilou\icode.h # End Source File # Begin Source File @@ -2368,6 +2376,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\blackurq\blackurq.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\blackurq\icode.h # End Source File # Begin Source File @@ -2384,6 +2396,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\chenjesu\chenjesu.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\chenjesu\icode.h # End Source File # Begin Source File @@ -2400,6 +2416,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\chmmr\chmmr.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\chmmr\icode.h # End Source File # Begin Source File @@ -2416,6 +2436,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\druuge\druuge.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\druuge\icode.h # End Source File # Begin Source File @@ -2432,6 +2456,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\human\human.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\human\icode.h # End Source File # Begin Source File @@ -2452,6 +2480,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\ilwrath\ilwrath.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\ilwrath\resinst.h # End Source File # End Group @@ -2468,6 +2500,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\lastbat\lastbat.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\lastbat\resinst.h # End Source File # End Group @@ -2484,6 +2520,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\melnorme\melnorme.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\melnorme\resinst.h # End Source File # End Group @@ -2500,6 +2540,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\mmrnmhrm\mmrnmhrm.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\mmrnmhrm\resinst.h # End Source File # End Group @@ -2516,6 +2560,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\mycon\mycon.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\mycon\resinst.h # End Source File # End Group @@ -2532,6 +2580,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\orz\orz.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\orz\resinst.h # End Source File # End Group @@ -2548,6 +2600,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\pkunk\pkunk.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\pkunk\resinst.h # End Source File # End Group @@ -2564,6 +2620,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\ships\probe\probe.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\ships\probe\resinst.h # End Source File # End Group @@ -2582,6 +2642,10 @@ SOURCE=..\..\src\uqm\ships\shofixti\shofixti.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\shofixti\shofixti.h +# End Source File # End Group # Begin Group "sis_ship" @@ -2618,6 +2682,10 @@ SOURCE=..\..\src\uqm\ships\sis_ship\sis_ship.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\sis_ship\sis_ship.h +# End Source File # End Group # Begin Group "slylandr" @@ -2634,6 +2702,10 @@ SOURCE=..\..\src\uqm\ships\slylandr\slylandr.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\slylandr\slylandr.h +# End Source File # End Group # Begin Group "spathi" @@ -2650,6 +2722,10 @@ SOURCE=..\..\src\uqm\ships\spathi\spathi.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\spathi\spathi.h +# End Source File # End Group # Begin Group "supox" @@ -2666,6 +2742,10 @@ SOURCE=..\..\src\uqm\ships\supox\supox.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\supox\supox.h +# End Source File # End Group # Begin Group "syreen" @@ -2682,6 +2762,10 @@ SOURCE=..\..\src\uqm\ships\syreen\syreen.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\syreen\syreen.h +# End Source File # End Group # Begin Group "thradd" @@ -2698,6 +2782,10 @@ SOURCE=..\..\src\uqm\ships\thradd\thradd.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\thradd\thradd.h +# End Source File # End Group # Begin Group "umgah" @@ -2714,6 +2802,10 @@ SOURCE=..\..\src\uqm\ships\umgah\umgah.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\umgah\umgah.h +# End Source File # End Group # Begin Group "urquan" @@ -2730,6 +2822,10 @@ SOURCE=..\..\src\uqm\ships\urquan\urquan.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\urquan\urquan.h +# End Source File # End Group # Begin Group "utwig" @@ -2746,6 +2842,10 @@ SOURCE=..\..\src\uqm\ships\utwig\utwig.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\utwig\utwig.h +# End Source File # End Group # Begin Group "vux" @@ -2762,6 +2862,10 @@ SOURCE=..\..\src\uqm\ships\vux\vux.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\vux\vux.h +# End Source File # End Group # Begin Group "yehat" @@ -2778,6 +2882,10 @@ SOURCE=..\..\src\uqm\ships\yehat\yehat.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\yehat\yehat.h +# End Source File # End Group # Begin Group "zoqfot" @@ -2794,6 +2902,10 @@ SOURCE=..\..\src\uqm\ships\zoqfot\zoqfot.c # End Source File +# Begin Source File + +SOURCE=..\..\src\uqm\ships\zoqfot\zoqfot.h +# End Source File # End Group # Begin Source File Modified: trunk/sc2/src/uqm/dummy.h =================================================================== --- trunk/sc2/src/uqm/dummy.h 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/dummy.h 2010-01-23 22:53:19 UTC (rev 3514) @@ -19,34 +19,34 @@ #include "races.h" -RACE_DESC *init_androsynth (void); -RACE_DESC *init_arilou (void); -RACE_DESC *init_black_urquan (void); -RACE_DESC *init_chenjesu (void); -RACE_DESC *init_chmmr (void); -RACE_DESC *init_druuge (void); -RACE_DESC *init_human (void); -RACE_DESC *init_ilwrath (void); -RACE_DESC *init_melnorme (void); -RACE_DESC *init_mmrnmhrm (void); -RACE_DESC *init_mycon (void); -RACE_DESC *init_orz (void); -RACE_DESC *init_pkunk (void); -RACE_DESC *init_shofixti (void); -RACE_DESC *init_slylandro (void); -RACE_DESC *init_spathi (void); -RACE_DESC *init_supox (void); -RACE_DESC *init_syreen (void); -RACE_DESC *init_thraddash (void); -RACE_DESC *init_umgah (void); -RACE_DESC *init_urquan (void); -RACE_DESC *init_utwig (void); -RACE_DESC *init_vux (void); -RACE_DESC *init_yehat (void); -RACE_DESC *init_zoqfotpik (void); -RACE_DESC *init_samatra (void); -RACE_DESC *init_sis (void); -RACE_DESC *init_probe (void); +#include "ships/androsyn/androsyn.h" +#include "ships/arilou/arilou.h" +#include "ships/blackurq/blackurq.h" +#include "ships/chenjesu/chenjesu.h" +#include "ships/chmmr/chmmr.h" +#include "ships/druuge/druuge.h" +#include "ships/human/human.h" +#include "ships/ilwrath/ilwrath.h" +#include "ships/melnorme/melnorme.h" +#include "ships/mmrnmhrm/mmrnmhrm.h" +#include "ships/mycon/mycon.h" +#include "ships/orz/orz.h" +#include "ships/pkunk/pkunk.h" +#include "ships/shofixti/shofixti.h" +#include "ships/slylandr/slylandr.h" +#include "ships/spathi/spathi.h" +#include "ships/supox/supox.h" +#include "ships/syreen/syreen.h" +#include "ships/thradd/thradd.h" +#include "ships/umgah/umgah.h" +#include "ships/urquan/urquan.h" +#include "ships/utwig/utwig.h" +#include "ships/vux/vux.h" +#include "ships/yehat/yehat.h" +#include "ships/zoqfot/zoqfot.h" +#include "ships/lastbat/lastbat.h" +#include "ships/sis_ship/sis_ship.h" +#include "ships/probe/probe.h" #endif /* DUMMY_H */ Modified: trunk/sc2/src/uqm/ships/androsyn/androsyn.c =================================================================== --- trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/androsyn/androsyn.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "androsyn.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/arilou/arilou.c =================================================================== --- trunk/sc2/src/uqm/ships/arilou/arilou.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/arilou/arilou.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "arilou.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/blackurq/blackurq.c =================================================================== --- trunk/sc2/src/uqm/ships/blackurq/blackurq.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/blackurq/blackurq.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "blackurq.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/chenjesu/chenjesu.c =================================================================== --- trunk/sc2/src/uqm/ships/chenjesu/chenjesu.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/chenjesu/chenjesu.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "chenjesu.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/chmmr/chmmr.c =================================================================== --- trunk/sc2/src/uqm/ships/chmmr/chmmr.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/chmmr/chmmr.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "chmmr.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/druuge/druuge.c =================================================================== --- trunk/sc2/src/uqm/ships/druuge/druuge.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/druuge/druuge.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "druuge.h" #include "resinst.h" #define MAX_CREW 14 Modified: trunk/sc2/src/uqm/ships/human/human.c =================================================================== --- trunk/sc2/src/uqm/ships/human/human.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/human/human.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "human.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/ilwrath/ilwrath.c =================================================================== --- trunk/sc2/src/uqm/ships/ilwrath/ilwrath.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/ilwrath/ilwrath.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "ilwrath.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/lastbat/lastbat.c =================================================================== --- trunk/sc2/src/uqm/ships/lastbat/lastbat.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/lastbat/lastbat.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "lastbat.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/melnorme/melnorme.c =================================================================== --- trunk/sc2/src/uqm/ships/melnorme/melnorme.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/melnorme/melnorme.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "melnorme.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c =================================================================== --- trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/mmrnmhrm/mmrnmhrm.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "mmrnmhrm.h" #include "resinst.h" Modified: trunk/sc2/src/uqm/ships/mycon/mycon.c =================================================================== --- trunk/sc2/src/uqm/ships/mycon/mycon.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/mycon/mycon.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "mycon.h" #include "resinst.h" #define MAX_CREW 20 Modified: trunk/sc2/src/uqm/ships/orz/orz.c =================================================================== --- trunk/sc2/src/uqm/ships/orz/orz.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/orz/orz.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "orz.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/pkunk/pkunk.c =================================================================== --- trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "pkunk.h" #include "resinst.h" #include "uqm/globdata.h" @@ -314,7 +315,7 @@ #define START_PHOENIX_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) #define TRANSITION_LIFE 1 -void +static void spawn_phoenix_trail (ELEMENT *ElementPtr) { static const Color colorTable[] = @@ -349,7 +350,7 @@ #define PHOENIX_LIFE 12 -void +static void phoenix_transition (ELEMENT *ElementPtr) { HELEMENT hShipImage; Modified: trunk/sc2/src/uqm/ships/probe/probe.c =================================================================== --- trunk/sc2/src/uqm/ships/probe/probe.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/probe/probe.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "probe.h" #include "resinst.h" #define MAX_CREW 1 Modified: trunk/sc2/src/uqm/ships/shofixti/shofixti.c =================================================================== --- trunk/sc2/src/uqm/ships/shofixti/shofixti.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/shofixti/shofixti.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "shofixti.h" #include "resinst.h" #include "uqm/globdata.h" @@ -222,9 +223,8 @@ } /* In order to detect any Orz Marines that have boarded the ship - when it self-destructs, we'll need to see these Orz functions */ -extern void intruder_preprocess (ELEMENT*); -extern void marine_collision (ELEMENT*, POINT*, ELEMENT*, POINT*); + when it self-destructs, we'll need to see some Orz functions */ +#include "../orz/orz.h" #define ORZ_MARINE(ptr) (ptr->preprocess_func == intruder_preprocess && \ ptr->collision_func == marine_collision) Modified: trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c =================================================================== --- trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "sis_ship.h" #include "resinst.h" #include "uqm/colors.h" Modified: trunk/sc2/src/uqm/ships/slylandr/slylandr.c =================================================================== --- trunk/sc2/src/uqm/ships/slylandr/slylandr.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/slylandr/slylandr.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "slylandr.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/spathi/spathi.c =================================================================== --- trunk/sc2/src/uqm/ships/spathi/spathi.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/spathi/spathi.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "spathi.h" #include "resinst.h" #define MAX_CREW 30 Modified: trunk/sc2/src/uqm/ships/supox/supox.c =================================================================== --- trunk/sc2/src/uqm/ships/supox/supox.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/supox/supox.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "supox.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/syreen/syreen.c =================================================================== --- trunk/sc2/src/uqm/ships/syreen/syreen.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/syreen/syreen.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "syreen.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/thradd/thradd.c =================================================================== --- trunk/sc2/src/uqm/ships/thradd/thradd.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/thradd/thradd.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "thradd.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/umgah/umgah.c =================================================================== --- trunk/sc2/src/uqm/ships/umgah/umgah.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/umgah/umgah.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "umgah.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/urquan/urquan.c =================================================================== --- trunk/sc2/src/uqm/ships/urquan/urquan.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/urquan/urquan.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "urquan.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/utwig/utwig.c =================================================================== --- trunk/sc2/src/uqm/ships/utwig/utwig.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/utwig/utwig.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "utwig.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/vux/vux.c =================================================================== --- trunk/sc2/src/uqm/ships/vux/vux.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/vux/vux.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "vux.h" #include "resinst.h" #include "uqm/globdata.h" Modified: trunk/sc2/src/uqm/ships/yehat/yehat.c =================================================================== --- trunk/sc2/src/uqm/ships/yehat/yehat.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/yehat/yehat.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "yehat.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/ships/zoqfot/zoqfot.c =================================================================== --- trunk/sc2/src/uqm/ships/zoqfot/zoqfot.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/ships/zoqfot/zoqfot.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -17,6 +17,7 @@ */ #include "../ship.h" +#include "zoqfot.h" #include "resinst.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2010-01-23 22:17:08 UTC (rev 3513) +++ trunk/sc2/src/uqm/tactrans.c 2010-01-23 22:53:19 UTC (rev 3514) @@ -425,7 +425,7 @@ } } -void +static void explosion_preprocess (ELEMENT *ShipPtr) { BYTE i; @@ -580,7 +580,7 @@ // Called from the death_func of an element for an ion trail pixel, or a // ship shadow (when warping in/out). -void +static void cycle_ion_trail (ELEMENT *ElementPtr) { static const Color colorTab[] = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-25 18:58:20
|
Revision: 3519 http://sc2.svn.sourceforge.net/sc2/?rev=3519&view=rev Author: Meep-Eep Date: 2010-01-25 18:58:13 +0000 (Mon, 25 Jan 2010) Log Message: ----------- Removed obsolete functions/file. Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/graphics/sdl/Makeinfo trunk/sc2/src/libs/graphics/sdl/sdl_common.h Removed Paths: ------------- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-24 20:36:02 UTC (rev 3518) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2010-01-25 18:58:13 UTC (rev 3519) @@ -290,10 +290,6 @@ # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\3do_getbody.c -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\biadv2x.c # End Source File # Begin Source File Deleted: trunk/sc2/src/libs/graphics/sdl/3do_getbody.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2010-01-24 20:36:02 UTC (rev 3518) +++ trunk/sc2/src/libs/graphics/sdl/3do_getbody.c 2010-01-25 18:58:13 UTC (rev 3519) @@ -1,207 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef GFXMODULE_SDL - -#include "port.h" -#include "libs/gfxlib.h" -#include "libs/graphics/tfb_draw.h" -#include "sdl_common.h" -#include "primitives.h" - -#if 0 -/* Unused */ -void process_rgb_bmp (FRAME FramePtr, Uint32 *rgba, int maxx, int maxy) -{ - int x, y; - TFB_Image *tfbImg; - SDL_Surface *img; - PutPixelFn putpix; - - tfbImg = FramePtr->image; - LockMutex (tfbImg->mutex); - img = (SDL_Surface *)tfbImg->NormalImg; - SDL_LockSurface (img); - - putpix = putpixel_for (img); - - for (y = 0; y < maxy; ++y) - for (x = 0; x < maxx; ++x) - putpix (img, x, y, *rgba++); - SDL_UnlockSurface (img); - UnlockMutex (tfbImg->mutex); -} -#endif - -#if 0 -/* Unused */ -void fill_frame_rgb (FRAME FramePtr, Uint32 color, int x0, int y0, - int x, int y) -{ - SDL_Surface *img; - TFB_Image *tfbImg; - SDL_Rect rect; - - tfbImg = FramePtr->image; - LockMutex (tfbImg->mutex); - img = (SDL_Surface *)tfbImg->NormalImg; - SDL_LockSurface (img); - if (x0 == 0 && y0 == 0 && x == 0 && y == 0) - SDL_FillRect(img, NULL, color); - else - { - rect.x = x0; - rect.y = y0; - rect.w = x - x0; - rect.h = y - y0; - SDL_FillRect(img, &rect, color); - } - SDL_UnlockSurface (img); - UnlockMutex (tfbImg->mutex); -} -#endif - -#if 0 -/* Unused */ -void -arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, - const RECT *rdst, int num, int denom) -{ - TFB_Image *srcImg, *dstImg; - SDL_Surface *src, *dst; - SDL_Rect srcRect, dstRect, *srp = NULL, *drp = NULL; - srcImg = srcFrame->image; - dstImg = dstFrame->image; - LockMutex (srcImg->mutex); - LockMutex (dstImg->mutex); - src = (SDL_Surface *)srcImg->NormalImg; - dst = (SDL_Surface *)dstImg->NormalImg; - if (rdst) - { - dstRect.x = rdst->corner.x; - dstRect.y = rdst->corner.y; - dstRect.w = rdst->extent.width; - dstRect.h = rdst->extent.height; - drp = &dstRect; - } - if (rsrc) - { - srcRect.x = rsrc->corner.x; - srcRect.y = rsrc->corner.y; - srcRect.w = rsrc->extent.width; - srcRect.h = rsrc->extent.height; - srp = &srcRect; - } - else if (srcFrame->HotSpot.x || srcFrame->HotSpot.y) - { - if (rdst) - { - dstRect.x -= srcFrame->HotSpot.x; - dstRect.y -= srcFrame->HotSpot.y; - } - else - { - dstRect.x = -srcFrame->HotSpot.x; - dstRect.y = -srcFrame->HotSpot.y; - dstRect.w = GetFrameWidth (srcFrame); - dstRect.h = GetFrameHeight (srcFrame); - drp = &dstRect; - } - - } - TFB_BlitSurface (src, srp, dst, drp, num, denom); - UnlockMutex (srcImg->mutex); - UnlockMutex (dstImg->mutex); -} -#endif - -#if 0 -/* Unused */ -// Generate an array of all pixels in FramePtr -// The 32bpp pixel format is : -// bits 24-31 : red -// bits 16-23 : green -// bits 8-15 : blue -// bits 0-7 : alpha -// The 8bpp pixel format is 1 index per pixel -void -getpixelarray (void *map, int Bpp, FRAME FramePtr, int width, int height) -{ - Uint8 r,g,b,a; - Uint32 p, pos, row; - TFB_Image *tfbImg; - SDL_Surface *img; - GetPixelFn getpix; - int x, y, w, h; - - tfbImg = FramePtr->image; - LockMutex (tfbImg->mutex); - img = (SDL_Surface *)tfbImg->NormalImg; - getpix = getpixel_for (img); - - w = width < img->w ? width : img->w; - h = height < img->h ? height : img->h; - - SDL_LockSurface (img); - - if (Bpp == 4) - { - Uint32 *dp = (Uint32 *)map; - - for (y = 0, row = 0; y < h; y++, row += width) - { - for (x = 0, pos = row; x < w; x++, pos++) - { - p = getpix (img, x, y); - SDL_GetRGBA (p, img->format, &r, &g, &b, &a); - dp[pos] = r << 24 | g << 16 | b << 8 | a; - } - } - } - else if (Bpp == 1) - { - Uint8 *dp = (Uint8 *)map; - - for (y = 0, row = 0; y < h; y++, row += width) - { - for (x = 0, pos = row; x < w; x++, pos++) - { - p = getpix (img, x, y); - dp[pos] = p; - } - } - } - - SDL_UnlockSurface (img); - UnlockMutex (tfbImg->mutex); -} -#endif - -#if 0 -/* Unused */ -// Generate a pixel (in the correct format to be applied to FramePtr) from the -// r,g,b,a values supplied -Uint32 frame_mapRGBA (FRAME FramePtr,Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - SDL_Surface *img= (SDL_Surface *)FramePtr->image->NormalImg; - return (SDL_MapRGBA (img->format, r, g, b, a)); -} -#endif - -#endif - Modified: trunk/sc2/src/libs/graphics/sdl/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/sdl/Makeinfo 2010-01-24 20:36:02 UTC (rev 3518) +++ trunk/sc2/src/libs/graphics/sdl/Makeinfo 2010-01-25 18:58:13 UTC (rev 3519) @@ -1,6 +1,4 @@ -uqm_CFILES="3do_getbody.c opengl.c - palette.c - primitives.c pure.c sdl_common.c +uqm_CFILES="opengl.c palette.c primitives.c pure.c sdl_common.c scalers.c 2xscalers.c 2xscalers_mmx.c 2xscalers_sse.c 2xscalers_3dnow.c nearest2x.c bilinear2x.c biadv2x.c triscan2x.c hq2x.c Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.h =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2010-01-24 20:36:02 UTC (rev 3518) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.h 2010-01-25 18:58:13 UTC (rev 3519) @@ -47,7 +47,5 @@ extern SDL_Surface *format_conv_surf; SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface); -void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, - SDL_Rect *dstrect, int blend_numer, int blend_denom); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-25 21:21:14
|
Revision: 3521 http://sc2.svn.sourceforge.net/sc2/?rev=3521&view=rev Author: Meep-Eep Date: 2010-01-25 21:20:59 +0000 (Mon, 25 Jan 2010) Log Message: ----------- If SDL is not used, just don't compile those files, instead of compiling (after preprocessing) empty files. Modified Paths: -------------- trunk/sc2/build/unix/build.config trunk/sc2/src/libs/graphics/Makeinfo trunk/sc2/src/libs/graphics/sdl/2xscalers.c trunk/sc2/src/libs/graphics/sdl/2xscalers_3dnow.c trunk/sc2/src/libs/graphics/sdl/2xscalers_mmx.c trunk/sc2/src/libs/graphics/sdl/2xscalers_sse.c trunk/sc2/src/libs/graphics/sdl/biadv2x.c trunk/sc2/src/libs/graphics/sdl/bilinear2x.c trunk/sc2/src/libs/graphics/sdl/hq2x.c trunk/sc2/src/libs/graphics/sdl/nearest2x.c trunk/sc2/src/libs/graphics/sdl/opengl.c trunk/sc2/src/libs/graphics/sdl/primitives.c trunk/sc2/src/libs/graphics/sdl/pure.c trunk/sc2/src/libs/graphics/sdl/rotozoom.c trunk/sc2/src/libs/graphics/sdl/scalers.c trunk/sc2/src/libs/graphics/sdl/sdl_common.c trunk/sc2/src/libs/graphics/sdl/triscan2x.c Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/build/unix/build.config 2010-01-25 21:20:59 UTC (rev 3521) @@ -199,6 +199,7 @@ CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action' graphics_pure_action() { CFLAGS="$CFLAGS -DGFXMODULE_SDL" + GFXMODULE_SDL=1 HAVE_OPENGL=0 } CHOICE_graphics_OPTION_opengl_TITLE="Include OpenGL graphics support" @@ -206,6 +207,7 @@ CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl" graphics_opengl_action() { CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL" + GFXMODULE_SDL=1 HAVE_OPENGL=1 use_library opengl } @@ -435,7 +437,8 @@ PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC \ MAKE ECHON SED DEBUG JOYSTICK NETPLAY \ OGGVORBIS SOUNDMODULE USE_INTERNAL_MIKMOD \ - HAVE_OPENGL HAVE_GETOPT_LONG HAVE_REGEX_H_FLAG \ + GFXMODULE_SDL HAVE_OPENGL \ + HAVE_GETOPT_LONG HAVE_REGEX_H_FLAG \ USE_ZIP_IO USE_PLATFORM_ACCEL THREADLIB USE_WINSOCK \ INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR \ REZ WINDRES $HAVE_SYMBOLS" Modified: trunk/sc2/src/libs/graphics/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/Makeinfo 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/Makeinfo 2010-01-25 21:20:59 UTC (rev 3521) @@ -1,5 +1,10 @@ -uqm_SUBDIRS="sdl" +uqm_SUBDIRS= uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c bbox.c dcqueue.c gfxload.c font.c frame.c gfx_common.c intersec.c loaddisp.c pixmap.c resgfx.c tfb_draw.c tfb_prim.c widgets.c" + +if [ -n "$uqm_GFXMODULE_SDL" ]; then + uqm_SUBDIRS="$uqm_SUBDIRS sdl" +fi + Modified: trunk/sc2/src/libs/graphics/sdl/2xscalers.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/2xscalers.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/2xscalers.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -14,8 +14,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -260,4 +258,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ Modified: trunk/sc2/src/libs/graphics/sdl/2xscalers_3dnow.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/2xscalers_3dnow.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/2xscalers_3dnow.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -14,8 +14,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "port.h" #include "libs/platform.h" @@ -101,4 +99,4 @@ #endif /* NO_IMPROVEMENT */ #endif /* MMX_ASM */ -#endif /* GFXMODULE_SDL */ + Modified: trunk/sc2/src/libs/graphics/sdl/2xscalers_mmx.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/2xscalers_mmx.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/2xscalers_mmx.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -14,8 +14,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "port.h" #include "libs/platform.h" @@ -135,4 +133,4 @@ #endif /* MMX_ASM */ -#endif /* GFXMODULE_SDL */ + Modified: trunk/sc2/src/libs/graphics/sdl/2xscalers_sse.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/2xscalers_sse.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/2xscalers_sse.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -14,8 +14,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "port.h" #include "libs/platform.h" @@ -99,4 +97,4 @@ #endif #endif /* MMX_ASM */ -#endif /* GFXMODULE_SDL */ + Modified: trunk/sc2/src/libs/graphics/sdl/biadv2x.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/biadv2x.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/biadv2x.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -21,8 +21,6 @@ // When this file is built standalone is produces a plain C version // Also #included by 2xscalers_mmx.c for an MMX version -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -532,4 +530,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ Modified: trunk/sc2/src/libs/graphics/sdl/bilinear2x.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/bilinear2x.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/bilinear2x.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -19,8 +19,6 @@ // When this file is built standalone is produces a plain C version // Also #included by 2xscalers_mmx.c for an MMX version -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -112,4 +110,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ Modified: trunk/sc2/src/libs/graphics/sdl/hq2x.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/hq2x.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/hq2x.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -27,8 +27,6 @@ // When this file is built standalone is produces a plain C version // Also #included by 2xscalers_mmx.c for an MMX version -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -2888,4 +2886,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ Modified: trunk/sc2/src/libs/graphics/sdl/nearest2x.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/nearest2x.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/nearest2x.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -19,8 +19,6 @@ // When this file is built standalone is produces a plain C version // Also #included by 2xscalers_mmx.c for an MMX version -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -207,4 +205,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ Modified: trunk/sc2/src/libs/graphics/sdl/opengl.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/opengl.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/opengl.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if defined (GFXMODULE_SDL) && defined (HAVE_OPENGL) +#ifdef HAVE_OPENGL #include "libs/graphics/sdl/opengl.h" #include "libs/graphics/bbox.h" Modified: trunk/sc2/src/libs/graphics/sdl/primitives.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -16,8 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "port.h" #include "sdl_common.h" #include "primitives.h" @@ -629,4 +627,3 @@ return 1; } -#endif Modified: trunk/sc2/src/libs/graphics/sdl/pure.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/pure.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/pure.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -15,8 +15,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "pure.h" #include "libs/graphics/bbox.h" #include "scalers.h" @@ -475,4 +473,3 @@ SDL_UnlockSurface (SDL_Screen); } -#endif Modified: trunk/sc2/src/libs/graphics/sdl/rotozoom.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -9,8 +9,6 @@ */ -#ifdef GFXMODULE_SDL - #include <stdlib.h> #include <string.h> #include "libs/memlib.h" @@ -1025,4 +1023,3 @@ return (rz_dst); } -#endif Modified: trunk/sc2/src/libs/graphics/sdl/scalers.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/scalers.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/scalers.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -14,8 +14,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "types.h" #include "libs/graphics/sdl/sdl_common.h" #include "libs/platform.h" @@ -286,4 +284,3 @@ return fdef->func; } -#endif Modified: trunk/sc2/src/libs/graphics/sdl/sdl_common.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/sdl_common.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -16,8 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include "sdl_common.h" #include "opengl.h" #include "pure.h" @@ -607,5 +605,3 @@ } } -#endif - Modified: trunk/sc2/src/libs/graphics/sdl/triscan2x.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/triscan2x.c 2010-01-25 19:16:57 UTC (rev 3520) +++ trunk/sc2/src/libs/graphics/sdl/triscan2x.c 2010-01-25 21:20:59 UTC (rev 3521) @@ -20,8 +20,6 @@ // When this file is built standalone is produces a plain C version // Also #included by 2xscalers_mmx.c for an MMX version -#ifdef GFXMODULE_SDL - #include "libs/graphics/sdl/sdl_common.h" #include "types.h" #include "scalers.h" @@ -155,4 +153,3 @@ SCALE_(PlatDone) (); } -#endif /* GFXMODULE_SDL */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-01-25 22:06:13
|
Revision: 3526 http://sc2.svn.sourceforge.net/sc2/?rev=3526&view=rev Author: Meep-Eep Date: 2010-01-25 22:06:07 +0000 (Mon, 25 Jan 2010) Log Message: ----------- Fixing the problems caused by the previous commits. Note to self: don't commit in a hurry nor while half-asleep. Modified Paths: -------------- trunk/sc2/build/unix/build.config trunk/sc2/build.vars.in trunk/sc2/src/libs/graphics/Makeinfo trunk/sc2/src/libs/input/Makeinfo trunk/sc2/src/libs/input/sdl/input.c Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2010-01-25 21:49:52 UTC (rev 3525) +++ trunk/sc2/build/unix/build.config 2010-01-25 22:06:07 UTC (rev 3526) @@ -198,15 +198,16 @@ CHOICE_graphics_OPTION_pure_TITLE="Don't include OpenGL graphics support" CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action' graphics_pure_action() { - GFXMODULE_SDL=1 + CFLAGS="$CFLAGS -DGFXMODULE_SDL" + GFXMODULE=sdl HAVE_OPENGL=0 } CHOICE_graphics_OPTION_opengl_TITLE="Include OpenGL graphics support" CHOICE_graphics_OPTION_opengl_ACTION='graphics_opengl_action' CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl" graphics_opengl_action() { - CFLAGS="$CFLAGS -DHAVE_OPENGL" - GFXMODULE_SDL=1 + CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL" + GFXMODULE=sdl HAVE_OPENGL=1 use_library opengl } @@ -435,7 +436,7 @@ PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC \ MAKE ECHON SED DEBUG JOYSTICK NETPLAY \ OGGVORBIS SOUNDMODULE USE_INTERNAL_MIKMOD \ - GFXMODULE_SDL HAVE_OPENGL \ + GFXMODULE HAVE_OPENGL \ HAVE_GETOPT_LONG HAVE_REGEX_H_FLAG \ USE_ZIP_IO USE_PLATFORM_ACCEL THREADLIB USE_WINSOCK \ INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR \ Modified: trunk/sc2/build.vars.in =================================================================== --- trunk/sc2/build.vars.in 2010-01-25 21:49:52 UTC (rev 3525) +++ trunk/sc2/build.vars.in 2010-01-25 22:06:07 UTC (rev 3526) @@ -42,7 +42,7 @@ uqm_USE_INTERNAL_MIKMOD='@USE_INTERNAL_MIKMOD@' uqm_HAVE_GETOPT_LONG='@HAVE_GETOPT_LONG@' uqm_HAVE_REGEX='@HAVE_REGEX_H_FLAG@' -uqm_GFXMODULE_SDL='@GFXMODULE_SDL@' +uqm_GFXMODULE='@GFXMODULE@' uqm_HAVE_OPENGL='@HAVE_OPENGL@' uqm_USE_ZIP_IO='@USE_ZIP_IO@' uqm_USE_PLATFORM_ACCEL='@USE_PLATFORM_ACCEL@' @@ -55,6 +55,6 @@ export BUILD_SYSTEM HOST_SYSTEM DEBUG export MACRO_WIN32 MACRO___MINGW32__ export uqm_SOUNDMODULE uqm_USE_INTERNAL_MIKMOD uqm_HAVE_GETOPT_LONG -export uqm_HAVE_REGEX uqm_USE_WINSOCK uqm_GFXMODULE_SDL uqm_HAVE_OPENGL +export uqm_HAVE_REGEX uqm_USE_WINSOCK uqm_GFXMODULE uqm_HAVE_OPENGL export uqm_USE_ZIP_IO uqm_USE_PLATFORM_ACCEL uqm_THREADLIB uqm_NETPLAY Modified: trunk/sc2/src/libs/graphics/Makeinfo =================================================================== --- trunk/sc2/src/libs/graphics/Makeinfo 2010-01-25 21:49:52 UTC (rev 3525) +++ trunk/sc2/src/libs/graphics/Makeinfo 2010-01-25 22:06:07 UTC (rev 3526) @@ -1,10 +1,9 @@ -uqm_SUBDIRS= +if [ "$uqm_GFXMODULE" = "sdl" ]; then + uqm_SUBDIRS="sdl" +fi + uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c bbox.c dcqueue.c gfxload.c font.c frame.c gfx_common.c intersec.c loaddisp.c pixmap.c resgfx.c tfb_draw.c tfb_prim.c widgets.c" -if [ -n "$uqm_GFXMODULE_SDL" ]; then - uqm_SUBDIRS="$uqm_SUBDIRS sdl" -fi - Modified: trunk/sc2/src/libs/input/Makeinfo =================================================================== --- trunk/sc2/src/libs/input/Makeinfo 2010-01-25 21:49:52 UTC (rev 3525) +++ trunk/sc2/src/libs/input/Makeinfo 2010-01-25 22:06:07 UTC (rev 3526) @@ -1,2 +1,5 @@ -uqm_SUBDIRS="sdl" +if [ "$uqm_GFXMODULE" = "sdl" ]; then + uqm_SUBDIRS="sdl" +fi + uqm_CFILES="input_common.c" Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2010-01-25 21:49:52 UTC (rev 3525) +++ trunk/sc2/src/libs/input/sdl/input.c 2010-01-25 22:06:07 UTC (rev 3526) @@ -16,8 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef GFXMODULE_SDL - #include <assert.h> #include <errno.h> #include "../inpintrn.h" @@ -511,4 +509,3 @@ VControl_BeginFrame (); } -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-02-12 01:09:20
|
Revision: 3529 http://sc2.svn.sourceforge.net/sc2/?rev=3529&view=rev Author: avolkov Date: 2010-02-12 00:20:25 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Properly signed math in SDL fillrect clipping; fixes a crash when filling fuel tanks over 10; bug #1082 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/graphics/sdl/primitives.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-01-26 21:30:13 UTC (rev 3528) +++ trunk/sc2/ChangeLog 2010-02-12 00:20:25 UTC (rev 3529) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed a crash when filling fuel tanks over 10 (bug #1082) - Alex - Got rid of many warnings - SvdB - Clean up and some refactoring of the SuperMelee code - SvdB - Fixed concurrent screen fades regression (bug #1079) - Alex Modified: trunk/sc2/src/libs/graphics/sdl/primitives.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-01-26 21:30:13 UTC (rev 3528) +++ trunk/sc2/src/libs/graphics/sdl/primitives.c 2010-02-12 00:20:25 UTC (rev 3529) @@ -466,33 +466,39 @@ // NOTE: the following clipping code is copied in part // from SDL-1.2.4 sources int dx, dy; + int w = r->w; + int h = r->h; + // SDL_Rect.w and .h are unsigned, we need signed dx = clip_r->x - r->x; if (dx > 0) { - r->w -= dx; + w -= dx; r->x += dx; } - dx = r->x + r->w - clip_r->x - clip_r->w; + dx = r->x + w - clip_r->x - clip_r->w; if (dx > 0) - r->w -= dx; + w -= dx; dy = clip_r->y - r->y; if (dy > 0) { - r->h -= dy; + h -= dy; r->y += dy; } - dy = r->y + r->h - clip_r->y - clip_r->h; + dy = r->y + h - clip_r->y - clip_r->h; if (dy > 0) - r->h -= dy; + h -= dy; - if (r->w <= 0 || r->h <= 0) + if (w <= 0 || h <= 0) { r->w = 0; r->h = 0; return 0; } + + r->w = w; + r->h = h; return 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2010-04-24 20:59:14
|
Revision: 3537 http://sc2.svn.sourceforge.net/sc2/?rev=3537&view=rev Author: Meep-Eep Date: 2010-04-24 20:59:07 +0000 (Sat, 24 Apr 2010) Log Message: ----------- Replaced the 'Turn' protocol by the Update' protocol. Bumped the UQM and netplay protocol versions. Some cleanups. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/doc/devel/netplay/protocol trunk/sc2/doc/devel/netplay/states trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/ship.c trunk/sc2/src/uqm/supermelee/loadmele.c trunk/sc2/src/uqm/supermelee/melee.c trunk/sc2/src/uqm/supermelee/melee.h trunk/sc2/src/uqm/supermelee/meleesetup.c trunk/sc2/src/uqm/supermelee/meleesetup.h trunk/sc2/src/uqm/supermelee/meleeship.h trunk/sc2/src/uqm/supermelee/netplay/nc_connect.ci trunk/sc2/src/uqm/supermelee/netplay/netconnection.c trunk/sc2/src/uqm/supermelee/netplay/netconnection.h trunk/sc2/src/uqm/supermelee/netplay/netmisc.c trunk/sc2/src/uqm/supermelee/netplay/netmisc.h trunk/sc2/src/uqm/supermelee/netplay/netplay.h trunk/sc2/src/uqm/supermelee/netplay/netsend.c trunk/sc2/src/uqm/supermelee/netplay/netstate.c trunk/sc2/src/uqm/supermelee/netplay/netstate.h trunk/sc2/src/uqm/supermelee/netplay/packet.c trunk/sc2/src/uqm/supermelee/netplay/packet.h trunk/sc2/src/uqm/supermelee/netplay/packethandlers.c trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h trunk/sc2/src/uqm/supermelee/netplay/packetq.c trunk/sc2/src/uqm/supermelee/netplay/packetq.h trunk/sc2/src/uqm/supermelee/netplay/packetsenders.c trunk/sc2/src/uqm/supermelee/netplay/packetsenders.h trunk/sc2/src/uqm/supermelee/netplay/proto/reset.c trunk/sc2/src/uqm/supermelee/pickmele.c trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqmversion.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/ChangeLog 2010-04-24 20:59:07 UTC (rev 3537) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed the network SuperMelee team configuration protocol - SvdB - Fixed fuel reserve bounds checks - SvdB - Fixed a crash when filling fuel tanks over 10 (bug #1082) - Alex - Got rid of many warnings - SvdB Modified: trunk/sc2/doc/devel/netplay/protocol =================================================================== --- trunk/sc2/doc/devel/netplay/protocol 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/doc/devel/netplay/protocol 2010-04-24 20:59:07 UTC (rev 3537) @@ -5,7 +5,7 @@ This is used when both parties need to sending information to the other side, but what each party is doing does not interfere with what the other party is doing. -- Only speak in your own turn ("Turn") +- Agree on changes ("Update") This is used when the parties have changes to make to common data. - Mutual agreement on an action ("Confirm") This is used to end a state where both parties are modifying @@ -49,45 +49,150 @@ ============================================================================ -"Turn" negotiation. +"Update" negotiation. -For some actions (like changing a shared configuration option), it is -important that both sides don't just send changes at once. -To handle this, only one party may send these packets at any moment. -If the party whose turn it isn't wants to speak, or if the party whose -turn it is doesn't have anything further to say, he can send an ENDTURN -packet. The other party should confirm this by sending another ENDTURN -packet back. +During configuration, both sides may change the same properties. So that the +two sides don't have to take turns, the changes are made locally, and then +the changes are synchronised. -States: -0. myTurn - I may speak - myTurn && !endTurn -1. endMyTurn - I've given up speaking, waiting for confirmation - myTurn && endTurn -2. yourTurn - You may speak - !myTurn && !endTurn -3. endYourTurn - I want to speak, waiting for confirmation - !myTurn && endTurn +To this end, each side has a state containing two copies of each property: + 1. The value of the property as it is locally + 2. The last value which it sent to the other side (until it is no longer + relevant for the protocol) -Messages: -- ENDTURN - "this party ready to change turns" +The basic idea of the Update protocol is: +- both sides each send and receive one packet before being allowed to + send another one (we'll call this a "turn" here) +- when a packet has been sent and one has been received in a turn, + and the sent and received values are the same, then that value is the + agreed upon value. If the sent and received values differ, then a + tie breaker determines which one prevails. +- when the first local change of a turn is made, the change is sent to + the other side +- when a local change has been made while a packet has already been + sent this turn, the change will be made locally, but communicating the + change will be postponed +- when a turn ends while a change has been postponed, and this change isn't + negated by a remote change, then the change will be sent +- when a remote change arrives, and a packet has not been sent this turn, + the local state is updated with the change, and the same packet is sent + to the other side to confirm the change +The tie breaker is required to always let one side win, and the other +side lose, given the same property. +Any function satisfying this requirement is usable, but the currently +used one will return true for the side which 'owns' the property, and +false on the other side. +Another tie breaker could be one which always lets the same side win, +regardless of the property. -From state 0 (myTurn): -local decision -> Send ENDTURN, goto 1 -received ENDTURN -> Send ENDTURN, goto 2 -From state 1 (endMyTurn): -received ENDTURN -> Send ENDTURN, goto 2 +The protocol: -From state 2 (yourTurn): -local decision -> Send ENDTURN, goto 3 -received ENDTURN -> Send ENDTURN, goto 0 +From state 1, {own=x0, sent=--}: +1a Local change x1 -> send(x1); state=2:{own=x1,sent=x1} +1b Received UPDATE(x1) -> send(x1); state=1:{own=x1,sent=--} -From state 3 (endYourTurn): -received ENDTURN -> Send ENDTURN, goto 0 +From state 2, {own=x0, sent=x0}: +2a Local change x1 -> state=3:{own=x1,sent=x0} +2b Received UPDATE(x0) -> state=1:{own=x0,sent=--} +2c+ Received UPDATE(x1) -> state=1:{own=x0,sent=--} if winTieBreak +2c- Received UPDATE(x1) -> state=1:{own=x1,sent=--} if !winTieBreak +From state 3, {own=x1, sent=x0}: +3a Local change x0 -> state=2:{own=x0,sent=x0} +3b Local change !x0 -> state=3:{own=xN,sent=x0} +3c Received UPDATE(x0) -> send(x1); state=2:{own=x1,sent=x1} +3d+ Received UPDATE(!x0) -> send(x1); state=2:{own=x1,sent=x1} if winTieBreak +3d- Received UPDATE(!x0) -> state=1:{own=x?,sent=--} if !winTieBreak + +Explanation: +We keep track of the local value ('own'), and whether or not we sent a packet +in this turn ('sent' != '--'), and if we did, the last packet which we sent +('sent'). When we proceed to the next turn, 'sent' is set to '--'. + +State 1: We have not yet sent a packet this turn (which implies that we +haven't made a local change this turn). +1a. A local change is made. We update our local value, and send this to + the remote side. +1b. A remote change arrives. We don't have any local change ourselves, + so we accept the remote change, and sent it back to confirm. + With both a packet sent and one received, the turn ends, and 'sent' + is set back to '--'. + +State 2: We have sent a packet this turn (after making a local change), and +have not changed our local value since (or we have changed it and changed +it back). +2a. A local change is made. We update our local value, but we have already + sent a packet this turn, so we can't report it until the next turn. +2b. A remote change arrives, and it is equal to both our local value and + the value which we sent to the other side this turn. + This remote notification may be a confirmation of our update, or a + coincidental identical remote change. + Either way, the packet acts as a confirmation, and we do not need + to change anything. With both a packet sent and received, the turn ends + and so 'sent' is set back to '--'. +2c. A remote change arrives, and it is not equal to our local value (which + is the same as the value which we sent). + The tie breaker decides which value prevails. The same value will + prevail on the remote side, so there is no need to send any confirmation + packets. The turn ends, and 'sent' is set back to '--'. + +State 3: We have sent a packet this turn, and have made a local change since. +3a. A local change is made back to the value which we sent. No action + is required. +3b. A local change is made. We update our local value, but we have already + sent a packet this turn, so we can't report it until the next turn. +3c. A remote change arrives, and it is equal to the value which we sent + (which isn't equal to the current local value). + The sent/received value is the accepted value and the turn ends. + But we have changed our value since already, so as the next turn + starts, we immediately send an update. +3d. A remote change arrives, and it is not equal to the value which we sent + this turn. + + We win the tie break, so the value which we sent prevails. + But we have changed our value since already, so as the next turn + starts, we immediately send an update. + - We lose the tie break, so the value which the remote value sent + prevails. We accept the value and the turn ends. + (An alternative would be to consider the local change(s) which + we made after our change was sent as made in the following turn, + in which case we would send our current local value in the next turn. + The advantage would be that 3d- would become equal to 3d+, + so these could be joined (with 3c too), which saves a few + if-statements in the code, but this requires another packet to be sent + and replied to in what currently is 3d-.) + + +Proof outline that this works: +- The states can never get out of sync: + After both a packet has been sent and received, both sides (temporarilly) + have accepted the same value +- There can be no indefinite loop without ongoing local changes. + Once there are no more local changes: + from state 3 we always go to state 2 or 1, + from state 2 we always go to state 1 + from state 1 we can only go back to state 1, and only when a packet + has been received. + So eventually, both sides are in states 1. With both sides in state 1, + no packets have been sent in the current turn, so no more packets are + there to be received. +- Both sides can make changes, as long as the side which wins the tie breaks + stops making changes now and then: + Without making local changes, a side will go to state 1 eventually. + If a side makes a local change, and this is received by the other side + while it is in state 1, then that other side will accept the change. + + +The Confirm negatiation is used to finish the Update negotiation. +This works because local changes triggered by the reception of remote changes +are treated as local modifications for the purpose of the Confirm negotiation. +And this can be done because whenever the Confirm negotiation is in a state +where remote changes may be expected, local modifications are still allowed +(possily after sending a CANCEL packet). + + ============================================================================ "Confirm" negotiation. @@ -130,7 +235,7 @@ Handshake messages: -- CONFIRM1 - "the current local configuration OK for me" +- CONFIRM1 - "the current local configuration is OK for me" - CONFIRM2 - "acknowledging your CONFIRM1; my own configuration is unchanged since I sent CONFIRM1 (after the last CANCEL)" - CANCEL - "forget about my earlier CONFIRM1" @@ -148,7 +253,7 @@ local cancel -> Send CANCEL, goto 4 received CONFIRM1 -> Send CONFIRM2, goto 3 received CONFIRM2 -> Send CONFIRM2, goto 8 -received MESSAGE(changes) -> Process(changes), Send CANCEL, goto 4 +received MESSAGE(changes) -> Send CANCEL, Process(changes), goto 4 From state 2: (remoteOk) local confirmation -> Send CONFIRM2, goto 3 @@ -204,7 +309,7 @@ "Reset" negotiation. -See src/sc2code/netplay/proto.c +See src/sc2code/netplay/proto/reset.c ============================================================================ Modified: trunk/sc2/doc/devel/netplay/states =================================================================== --- trunk/sc2/doc/devel/netplay/states 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/doc/devel/netplay/states 2010-04-24 20:59:07 UTC (rev 3537) @@ -1,63 +1,178 @@ -NetState_unconnected is the initial state. When a connection attempt is made, -the state is set to NetState_connecting. -The state field of a NetConnection is NULL. +== Any connected state == +Some packets may be sent and received in any state except +NetState_unconnected. +These are: PING, ACK, ABORT, RESET +These are not listed below at each individual state. -NetState_connecting indicates a connection is in progress. -When the connection is established, an INIT packet is sent, the state -is changed to NetState_init and InputFunc is set to DoNetworkInit. -The state field of a NetConnection is a ConnectStateData structure. +Whenever a connection is aborted, the state is returned to +NetState_unconnected. This state transition is not listed below at each +individual state. + +== NetState_unconnected == +NetState_unconnected is the initial state. + +NetConnection.state: NULL + +Packets ok to send: none +Packets ok to receive: none + +Next state: + NetState_connecting -- connection attempt in progress + + +== NetState_connecting == +NetState_connecting indicates that a connection is in progress. + +When the connection is established, the state is changed to NetState_init +and InputFunc is set to DoNetworkInit. + +NetConnection.state: instance of ConnectStateData + +Packets ok to send: none +Packets ok to receive: none + +Next state: + NetState_init -- connection established + + +== NetState_init == NetState_init is for initialising the connection before actual game -information is sent. When an INIT packet is received, the state is set -to NetState_inSetup and InputFunc is set to DoMelee. -The state field of a NetConnection is a BattleStateData structure. +information is sent. +As this state is entered, an INIT packet is sent. When an INIT packet +has also been received, the state is set to NetState_inSetup and +InputFunc is set to DoMelee. + +NetConnection.state: instance of BattleStateData + +Packets ok to send: INIT +Packets ok to receive: INIT + +Next state: + NetState_inSetup -- received an INIT packet + + +== NetState_inSetup == NetState_inSetup is the state in which the fleet configuration is negotiated. -Only the side who has myTurn set may send this ship information, by means -of FLEET and TEAMNAME packets. -The Turn negotiation is used to change myTurn. + +This does not necessarilly mean that the fleet setup screen is visible; +this state is also held after a battle when the battle outcome is still +displayed. + +Each side may send fleet configuration changes to the other side, by means of +FLEET and TEAMNAME packets. Agreement on configuration settings is provided +through the Update negotiation. The Confirm negotiation is used to end this state and go to NetState_preBattle. At this time InputFunc is set to DoPreMelee. -The state field of a NetConnection is a BattleStateData structure. +NetConnection.state: instance of BattleStateData + +Packets ok to send: FLEET, TEAMNAME, HANDSHAKE0, HANDSHAKE1, + HANDSHAKECANCEL, HANDSHAKECANCELACK +Packets ok to receive: FLEET, TEAMNAME, HANDSHAKE0, HANDSHAKE1, + HANDSHAKECANCEL, HANDSHAKECANCELACK + +Next state: + NetState_preBattle -- configuration has been confirmed + + +== NetState_preBattle == NetState_preBattle is used for non-interactive battle negotiations. + One side sends the random seed; the other receives it. +Both sides send their input delay value. The Ready negotiation is used to end this state and go to NetState_interBattle. -The state field of a NetConnection is a BattleStateData structure. -NetState_interBattle is used to allow either side to do some local +NetConnection.state: instance of BattleStateData + +Packets ok to send: SEEDRANDOM, INPUTDELAY, READY +Packets ok to receive: SEEDRANDOM, INPUTDELAY, READY + +Next state: + NetState_interBattle -- ready to continue + + +== NetState_interBattle == +NetState_interBattle is used to allow each side to do some local initialisations before moving on. The Ready negotiation is used to end this state and go to -NetState_selectShip, or if there are no more ships to be selected, -to NetState_inBattle. -The state field of a NetConnection is a BattleStateData structure. +NetState_selectShip, or if all sides have selected a ship, to +NetState_inBattle, or if there are no more ships in a fleet, +to NetState_inSetup. -NetState_selectShip is where a side may select his ship. The other +If there are no more ships, the the Ready negotiation is used to +enter NetState_inSetup. + +NetConnection.state: instance of BattleStateData + +Packets ok to send: READY +Packets ok to receive: READY + +Next state: + NetState_selectShip -- ready to select the next ship + NetState_inBattle -- ready to start the battle + NetState_inSetup -- no more ships; game over + + +== NetState_selectShip == +NetState_selectShip is where a side may select their ship. The other side is waiting for notice of this selection. As soon as the selection has been sent or received, the state is changed back to NetState_interBattle. -The state field of a NetConnection is a BattleStateData structure. +NetConnection.state: instance of BattleStateData + +Packets ok to send: SELECTSHIP +Packets ok to receive: SELECTSHIP + +Next state: + NetState_interBattle -- a selection has been made + + +== NetState_inBattle == NetState_inBattle is where the actual melee takes place. Both sides send their input until the game is over, at which point the Ready negotiation is used to end this state and go to the NetState_endingBattle state. Until the Ready negotiation has been completed, the simulation is continuing. -The state field of a NetConnection is a BattleStateData structure. +NetConnection.state: instance of BattleStateData + +Packets ok to send: BATTLEINPUT, READY +Packets ok to receive: BATTLEINPUT, READY + +Next state: + NetState_endingBattle -- ready to end the battle + + +== NetState_endingBattle == NetState_endingBattle is where the local side waits for the remote battle frame count, after it has sent its own. When it arrives, the state changes to NetState_endingBattle2. -The state field of a NetConnection is a BattleStateData structure. +NetConnection.state: instance of BattleStateData + +Packets ok to send: BATTLEINPUT, FRAMECOUNT +Packets ok to receive: BATTLEINPUT, FRAMECOUNT + +Next state: + NetState_endingBattle2 -- we know when to end the battle + + +== NetState_endingBattle2 == NetState_endingBattle2 is where the side with the lowest battle frame count catches up with the other other side, while the other side waits. The Ready negotiation is used to signal that each side is ready, -and the state changes back to NetState_interBattle. -The state field of a NetConnection is a BattleStateData structure. +and the state changes to NetState_interBattle. +NetConnection.state: instance of BattleStateData -When a connection is aborted, the state is returned to NetState_unconnected. +Packets ok to send: BATTLEINPUT, READY +Packets ok to receive: BATTLEINPUT, READY +Next state: + NetState_interBattle -- get ready for the next ship + Modified: trunk/sc2/src/uqm/pickship.c =================================================================== --- trunk/sc2/src/uqm/pickship.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/pickship.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -302,17 +302,29 @@ return (hBattleShip); } +static QUEUE * +GetShipQueueForSide (COUNT sideNr) +{ + if (sideNr == 0) + return &GLOBAL (built_ship_q); + else + return &GLOBAL (npc_built_ship_q); +} + +// Get the next ship to use. HSTARSHIP GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player) { HSTARSHIP hBattleShip; if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) + { // Get the next ship from the battle group. hBattleShip = GetHeadLink (&race_q[which_player]); + } else if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) { - // Let the player chose his own ship. (May be a computer player). + // Let the player chose their own ship. (May be a computer player). if (!(GLOBAL (CurrentActivity) & IN_BATTLE)) { @@ -367,10 +379,7 @@ QUEUE *pQueue; HSHIPFRAG hNextShip; - if (which_player == 0) - pQueue = &GLOBAL (built_ship_q); - else - pQueue = &GLOBAL (npc_built_ship_q); + pQueue = GetShipQueueForSide (which_player); hBattleShip = GetHeadLink (&race_q[which_player]); for (hStarShip = GetHeadLink (pQueue); Modified: trunk/sc2/src/uqm/ship.c =================================================================== --- trunk/sc2/src/uqm/ship.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/ship.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -493,6 +493,7 @@ return (hShip != 0); } +// Select a new ship and spawn it. BOOLEAN GetNextStarShip (STARSHIP *LastStarShipPtr, COUNT which_side) { Modified: trunk/sc2/src/uqm/supermelee/loadmele.c =================================================================== --- trunk/sc2/src/uqm/supermelee/loadmele.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/loadmele.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -208,7 +208,7 @@ } // returns true if there are any entries in the view, in which case -// pMS->load.bot gets set to the index of the bottom entry in the view. +// pMS->load.bot gets set to the index just past the bottom entry in the view. // returns false if not, in which case, the entire view remains unchanged. static bool FillFileView (MELEE_STATE *pMS) @@ -350,7 +350,7 @@ if (PulsedInputState.menu[KEY_MENU_SELECT]) { // Copy the selected fleet to the player. - Melee_Change_team (pMS, pMS->side, + Melee_LocalChange_team (pMS, pMS->side, pMS->load.view[pMS->load.cur - pMS->load.top]); } @@ -417,11 +417,16 @@ if (newIndex != pMS->load.cur) { + // The cursor has been moved. LockMutex (GraphicsLock); if (newTop == pMS->load.top) + { + // The view itself hasn't changed. SelectFileString (pMS, false); + } else { + // The view is changed. pMS->load.top = newTop; DrawFileStrings (pMS); } Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/melee.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -197,6 +197,7 @@ #define DTSHS_BLOCKCUR 8 static BOOLEAN DrawTeamString (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState, const char *str); +static void DrawFleetValue (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState); static void Melee_UpdateView_fleetValue (MELEE_STATE *pMS, COUNT side); static void Melee_UpdateView_ship (MELEE_STATE *pMS, COUNT side, @@ -363,6 +364,7 @@ } DrawTeamString (pMeleeState, side, DTSHS_NORMAL, NULL); + DrawFleetValue (pMeleeState, side, DTSHS_NORMAL); } } @@ -422,6 +424,59 @@ RepairMeleeFrame (&r); } +static void +GetTeamStringRect (COUNT side, RECT *r) +{ + r->corner.x = MELEE_X_OFFS - 1; + r->corner.y = (side + 1) * (MELEE_Y_OFFS + + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) * NUM_MELEE_ROWS + 2)); + r->extent.width = NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE) + - 29; + r->extent.height = 13; +} + +static void +GetFleetValueRect (COUNT side, RECT *r) +{ + r->corner.x = MELEE_X_OFFS + + NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE) - 30; + r->corner.y = (side + 1) * (MELEE_Y_OFFS + + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) * NUM_MELEE_ROWS + 2)); + r->extent.width = 29; + r->extent.height = 13; +} + +static void +DrawFleetValue (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState) +{ + RECT r; + TEXT rtText; + UNICODE buf[30]; + COUNT fleetValue; + + GetFleetValueRect (side ,&r); + + if (HiLiteState == DTSHS_REPAIR) + { + RepairMeleeFrame (&r); + return; + } + + SetContextFont (MicroFont); + + fleetValue = MeleeSetup_getFleetValue (pMS->meleeSetup, side); + sprintf (buf, "%u", fleetValue); + rtText.pStr = buf; + rtText.align = ALIGN_RIGHT; + rtText.CharCount = (COUNT)~0; + rtText.baseline.y = r.corner.y + r.extent.height - 3; + rtText.baseline.x = r.corner.x + r.extent.width; + + SetContextForeGroundColor (!(HiLiteState & DTSHS_SELECTED) + ? TEAM_NAME_TEXT_COLOR : TEAM_NAME_EDIT_TEXT_COLOR); + font_DrawText (&rtText); +} + // If teamName == NULL, the team name is taken from pMS->meleeSetup static BOOLEAN DrawTeamString (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState, @@ -430,11 +485,7 @@ RECT r; TEXT lfText; - r.corner.x = MELEE_X_OFFS - 1; - r.corner.y = (side + 1) * (MELEE_Y_OFFS - + ((MELEE_BOX_HEIGHT + MELEE_BOX_SPACE) * NUM_MELEE_ROWS + 2)); - r.extent.width = NUM_MELEE_COLUMNS * (MELEE_BOX_WIDTH + MELEE_BOX_SPACE); - r.extent.height = 13; + GetTeamStringRect (side, &r); if (HiLiteState == DTSHS_REPAIR) { RepairMeleeFrame (&r); @@ -446,7 +497,6 @@ lfText.pStr = (teamName != NULL) ? teamName : MeleeSetup_getTeamName (pMS->meleeSetup, side); lfText.baseline.y = r.corner.y + r.extent.height - 3; - lfText.baseline.x = r.corner.x + 1; lfText.align = ALIGN_LEFT; lfText.CharCount = strlen (lfText.pStr); @@ -454,20 +504,9 @@ BatchGraphics (); if (!(HiLiteState & DTSHS_EDIT)) { // normal or selected state - TEXT rtText; - UNICODE buf[30]; - - sprintf (buf, "%u", MeleeSetup_getFleetValue (pMS->meleeSetup, side)); - rtText.pStr = buf; - rtText.align = ALIGN_RIGHT; - rtText.CharCount = (COUNT)~0; - rtText.baseline.y = lfText.baseline.y; - rtText.baseline.x = lfText.baseline.x + r.extent.width - 1; - SetContextForeGroundColor (!(HiLiteState & DTSHS_SELECTED) ? TEAM_NAME_TEXT_COLOR : TEAM_NAME_EDIT_TEXT_COLOR); font_DrawText (&lfText); - font_DrawText (&rtText); } else { // editing state @@ -476,9 +515,6 @@ BYTE char_deltas[MAX_TEAM_CHARS]; BYTE *pchar_deltas; - // not drawing team bucks - r.extent.width -= 29; - TextRect (&lfText, &text_r, char_deltas); if ((text_r.extent.width + 2) >= r.extent.width) { // the text does not fit the input box size and so @@ -712,6 +748,8 @@ // Not currently editing the team name. DrawTeamString (pMeleeState, pMeleeState->side, DTSHS_NORMAL, NULL); + DrawFleetValue (pMeleeState, pMeleeState->side, + DTSHS_NORMAL); } } break; @@ -773,6 +811,8 @@ // Not currently editing the team name. DrawTeamString (pMeleeState, pMeleeState->side, DTSHS_SELECTED, NULL); + DrawFleetValue (pMeleeState, pMeleeState->side, + DTSHS_SELECTED); } } break; @@ -942,7 +982,7 @@ DeleteCurrentShip (MELEE_STATE *pMS) { FleetShipIndex slotI = GetShipIndex (pMS->row, pMS->col); - Melee_Change_ship (pMS, pMS->side, slotI, MELEE_NONE); + Melee_LocalChange_ship (pMS, pMS->side, slotI, MELEE_NONE); } static bool @@ -992,6 +1032,23 @@ return ret; } +static BOOLEAN +TeamNameFrameCallback (TEXTENTRY_STATE *pTES) +{ +#ifdef NETPLAY + // Process incoming packets, so that remote changes are displayed + // while we are editing the team name. + // The team name itself isn't modified visually due to remote changes + // while it is being edited. + netInput (); +#endif + + (void) pTES; + + return TRUE; + // Keep editing +} + static void BuildPickShipPopup (MELEE_STATE *pMS) { @@ -1005,7 +1062,7 @@ // A ship has been selected. // Add the currently selected ship to the fleet. FleetShipIndex index = GetShipIndex (pMS->row, pMS->col); - Melee_Change_ship (pMS, pMS->side, index, pMS->currentShip); + Melee_LocalChange_ship (pMS, pMS->side, index, pMS->currentShip); AdvanceCursor (pMS); } @@ -1122,12 +1179,13 @@ tes.MaxSize = MAX_TEAM_CHARS + 1; tes.CbParam = pMS; tes.ChangeCallback = OnTeamNameChange; - tes.FrameCallback = 0; + tes.FrameCallback = TeamNameFrameCallback; DoTextEntry (&tes); - + // done entering pMS->CurIndex = MELEE_STATE_INDEX_DONE; - if (!Melee_Change_teamName (pMS, pMS->side, buf)) { + if (!tes.Success || + !Melee_LocalChange_teamName (pMS, pMS->side, buf)) { // The team name was not changed, so it was not redrawn. // However, because we now leave edit mode, we still // need to redraw. @@ -1253,6 +1311,7 @@ if (PulsedInputState.menu[KEY_MENU_CANCEL]) { + // The connection is explicitely cancelled, locally. pMS->InputFunc = DoMelee; #ifdef NETPLAY cancelConfirmations (); @@ -1266,6 +1325,7 @@ PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]) { + // The player moves the cursor; cancel the confirmation. pMS->InputFunc = DoMelee; #ifdef NETPLAY cancelConfirmations (); @@ -1278,7 +1338,9 @@ #ifndef NETPLAY pMS->InputFunc = DoMelee; SeedRandomNumbers (); + pMS->meleeStarted = TRUE; StartMelee (pMS); + pMS->meleeStarted = FALSE; if (GLOBAL (CurrentActivity) & CHECK_ABORT) return FALSE; return TRUE; @@ -2041,9 +2103,11 @@ if (LoadMeleeConfig (&MenuState) == -1) { PlayerControl[0] = HUMAN_CONTROL | STANDARD_RATING; - Melee_Change_team (&MenuState, 0, MenuState.load.preBuiltList[0]); + Melee_LocalChange_team (&MenuState, 0, + MenuState.load.preBuiltList[0]); PlayerControl[1] = COMPUTER_CONTROL | STANDARD_RATING; - Melee_Change_team (&MenuState, 1, MenuState.load.preBuiltList[1]); + Melee_LocalChange_team (&MenuState, 1, + MenuState.load.preBuiltList[1]); } MenuState.side = 0; @@ -2186,7 +2250,6 @@ { const char *msg; - GLOBAL (CurrentActivity) |= CHECK_ABORT; flushPacketQueues (); // If the local side queued a reset packet as a result of a // remote reset, that packet will not have been sent yet. @@ -2202,6 +2265,10 @@ msg = resetReasonString (reason); if (msg != NULL) connectionFeedback (conn, msg, false); + + // End supermelee. This must not be done before connectionFeedback(), + // otherwise the message will immediately disappear. + GLOBAL (CurrentActivity) |= CHECK_ABORT; } void @@ -2241,16 +2308,25 @@ static void Melee_UpdateView_fleetValue (MELEE_STATE *pMS, COUNT side) { + if (pMS->meleeStarted) + return; + LockMutex (GraphicsLock); - DrawTeamString (pMS, side, DTSHS_REPAIR, NULL); + DrawFleetValue (pMS, side, DTSHS_REPAIR); + // BUG: The fleet value is always drawn as deselected. UnlockMutex (GraphicsLock); } static void Melee_UpdateView_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index) { - MeleeShip ship = MeleeSetup_getShip (pMS->meleeSetup, side, index); + MeleeShip ship; + + if (pMS->meleeStarted) + return; + ship = MeleeSetup_getShip (pMS->meleeSetup, side, index); + LockMutex (GraphicsLock); if (ship == MELEE_NONE) { @@ -2266,6 +2342,9 @@ static void Melee_UpdateView_teamName (MELEE_STATE *pMS, COUNT side) { + if (pMS->meleeStarted) + return; + LockMutex (GraphicsLock); DrawTeamString (pMS, side, DTSHS_REPAIR, NULL); UnlockMutex (GraphicsLock); @@ -2273,10 +2352,11 @@ /////////////////////////////////////////////////////////////////////////// -// Melee_Change_xxx() functions are called when some value in the supermelee -// fleet setup screen has changed, eithed locally, or remotely. +// Melee_Change_xxx() functions are helper functions, called when some value +// in the supermelee fleet setup screen has changed, eithed because of a +// local change, or a remote change. -bool +static bool Melee_Change_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index, MeleeShip ship) { @@ -2300,16 +2380,11 @@ UnlockMutex (GraphicsLock); } -#ifdef NETPLAY - // Notify network connections of the change. - Netplay_NotifyAll_setShip (pMS, side, index); -#endif /* NETPLAY */ - return true; } // Pre: 'name' is '\0'-terminated -bool +static bool Melee_Change_teamName (MELEE_STATE *pMS, COUNT side, const char *name) { MeleeSetup *setup = pMS->meleeSetup; @@ -2329,37 +2404,93 @@ Melee_UpdateView_teamName (pMS, side); } + return true; +} + +/////////////////////////////////////////////////////////////////////////// + +// Melee_LocalChange_xxx() functions are called when some value in the +// supermelee fleet setup screen has changed because of a local action. +// The behavior of these functions (and the comments therein) follow the +// description in doc/devel/netplay/protocol. + +bool +Melee_LocalChange_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index, + MeleeShip ship) +{ + if (!Melee_Change_ship (pMS, side, index, ship)) + return false; + #ifdef NETPLAY - Netplay_NotifyAll_setTeamName (pMS, side); + { + MeleeSetup *setup = pMS->meleeSetup; + + MeleeShip sentShip = MeleeSetup_getSentShip (setup, side, index); + if (sentShip == MELEE_UNSET) + { + // State 1. + // Notify network connections of the change. + Netplay_NotifyAll_setShip (pMS, side, index); + MeleeSetup_setSentShip (setup, side, index, ship); + } + } #endif /* NETPLAY */ return true; } + +// Pre: 'name' is '\0'-terminated bool -Melee_Change_fleet (MELEE_STATE *pMS, size_t teamNr, const MeleeShip *fleet) +Melee_LocalChange_teamName (MELEE_STATE *pMS, COUNT side, const char *name) { - MeleeSetup *setup = pMS->meleeSetup; + if (!Melee_Change_teamName (pMS, side, name)) + return false; + +#ifdef NETPLAY + { + MeleeSetup *setup = pMS->meleeSetup; + + const char *sentName = MeleeSetup_getSentTeamName (setup, side); + if (sentName == NULL) + { + // State 1. + // Notify network connections of the change. + Netplay_NotifyAll_setTeamName (pMS, side); + MeleeSetup_setSentTeamName (setup, side, name); + } + } +#endif /* NETPLAY */ + + return true; +} + +bool +Melee_LocalChange_fleet (MELEE_STATE *pMS, size_t teamNr, + const MeleeShip *fleet) +{ FleetShipIndex slotI; bool changed = false; - for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) { - if (MeleeSetup_setShip (setup, teamNr, slotI, fleet[slotI])) + for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) + { + if (Melee_LocalChange_ship (pMS, teamNr, slotI, fleet[slotI])) changed = true; } return changed; } bool -Melee_Change_team (MELEE_STATE *pMS, size_t teamNr, const MeleeTeam *team) +Melee_LocalChange_team (MELEE_STATE *pMS, size_t teamNr, + const MeleeTeam *team) { - MeleeSetup *setup = pMS->meleeSetup; const MeleeShip *fleet = MeleeTeam_getFleet (team); + const char *name = MeleeTeam_getTeamName (team); bool changed = false; - if (Melee_Change_fleet (pMS, teamNr, fleet)) + if (Melee_LocalChange_fleet (pMS, teamNr, fleet)) changed = true; - if (MeleeSetup_setTeamName (setup, teamNr, MeleeTeam_getTeamName (team))) + if (Melee_LocalChange_teamName (pMS, teamNr, name)) changed = true; return changed; @@ -2367,8 +2498,40 @@ /////////////////////////////////////////////////////////////////////////// +// Send the entire team to the remote side. Used when the connection has +// just been established, or after the setup menu is reentered after battle. +void +Melee_bootstrapSyncTeam (MELEE_STATE *meleeState, size_t teamNr) +{ + MeleeSetup *setup = meleeState->meleeSetup; + FleetShipIndex slotI; + const char *teamName; + + // Send the current fleet. + Netplay_NotifyAll_setFleet(meleeState, teamNr); + + // Update the last sent fleet. + for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) + { + MeleeShip ship = MeleeSetup_getShip (setup, teamNr, slotI); + assert (MeleeSetup_getSentShip (setup, teamNr, slotI) == MELEE_UNSET); + MeleeSetup_setSentShip (setup, teamNr, slotI, ship); + } + + // Send the current team name. + Netplay_NotifyAll_setTeamName (meleeState, teamNr); + + // Update the last sent team name. + teamName = MeleeSetup_getTeamName (setup, teamNr); + MeleeSetup_setSentTeamName (setup, teamNr, teamName); +} + +/////////////////////////////////////////////////////////////////////////// + // Melee_RemoteChange_xxx() functions are called when some value in the // supermelee fleet setup screen has changed remotely. +// The behavior of these functions (and the comments therein) follow the +// description in doc/devel/netplay/protocol. #ifdef NETPLAY void @@ -2377,74 +2540,140 @@ { MeleeSetup *setup = pMS->meleeSetup; - MeleeShip currentShip = MeleeSetup_getShip (setup, side, index); + MeleeShip sentShip = MeleeSetup_getSentShip (setup, side, index); + MeleeShip currentShip; - if (ship == currentShip) + if (sentShip == MELEE_UNSET) { - // The remote side has confirmed what we want the value to be. - // If we had made the same local change before, then an update - // has already been sent. If not, then there is nothing to change. - // Either way, we do not need to send an update. - MeleeSetup_setConfirmedShip (setup, side, index, ship); - } else { - // The remote side wants to make a change. - // We accept the change when we don't have any changes of our own, - // or when we do have changes, but we "lose" the tie break. - // If we "win" the tie break, we have already sent an update to the - // remote side when our local change was made, so we do not need to - // send anything. The remote side still needs to confirm this local - // change, of which it will become aware shortly, when the already - // sent update message arrives. - MeleeShip confirmedShip = MeleeSetup_getConfirmedShip (setup, side, - index); - if (currentShip == confirmedShip || - NetConnection_getDiscriminant(conn)) + // State 1 + + // Change the ship locally. + Melee_Change_ship (pMS, side, index, ship); + + // Notify the remote side. + Netplay_NotifyAll_setShip (pMS, side, index); + + // A packet has now been received and sent. End of turn. + return; + } + + // A packet has been sent and received. End of turn. + MeleeSetup_setSentShip (setup, side, index, MELEE_UNSET); + + if (ship != sentShip) + { + // Rule 2c or 3d. The value which we sent is different from the value + // which the opponent sent. We need a tie-breaker to determine which + // value prevails. + if (NetConnection_getPlayerNr (conn) != side) { - MeleeSetup_setConfirmedShip (setup, side, index, ship); + // Rule 2c+ or 3d+ + // We win the tie-breaker. The value which we sent prevails. + } + else + { + // Rule 2c- or 3d-. + // We lose the tie-breaker. We adopt the remote value. Melee_Change_ship (pMS, side, index, ship); - // This will also cause a notification of the local - // change to be sent to the remote side, which will act - // as a confirmation. + return; } } + /* + else + { + // Rule 2b or 3c. The value which we sent is the value which + // the opponent sent. This confirms the value. + } + */ + + // Rule 2b, 2c+, 3c, or 3d+. The value which we sent is confirmed. + + currentShip = MeleeSetup_getShip (setup, side, index); + if (currentShip != sentShip) + { + // Rule 3c or 3d+. We had a local change which was yet + // unreported. + + // Notify the remote side and keep track of what we sent. + Netplay_NotifyAll_setShip (pMS, side, index); + MeleeSetup_setSentShip (setup, side, index, ship); + } } void -Melee_RemoteChange_teamName (MELEE_STATE *pMS, NetConnection *conn, COUNT side, - const char *name) +Melee_RemoteChange_teamName (MELEE_STATE *pMS, NetConnection *conn, + COUNT side, const char *newName) { MeleeSetup *setup = pMS->meleeSetup; - const char *currentName = MeleeSetup_getTeamName (setup, side); + const char *sentName = MeleeSetup_getSentTeamName (setup, side); + const char *currentName; - if (strcmp (name, currentName) == 0) + if (sentName == NULL) { - // The remote side has confirmed what we want the value to be. - // If we had made the same local change before, then an update - // has already been sent. If not, then there is nothing to change. - // Either way, we do not need to send an update. - MeleeSetup_setConfirmedTeamName (setup, side, name); - } else { - // The remote side wants to make a change. - // We accept the change when we don't have any changes of our own, - // or when we do have changes, but we "lose" the tie break. - // If we "win" the tie break, we have already sent an update to the - // remote side when our local change was made, so we do not need to - // send anything. The remote side still needs to confirm this local - // change, of which it will become aware shortly, when the already - // sent update message arrives. - const char *confirmedName = - MeleeSetup_getConfirmedTeamName (setup, side); - if (strcmp (currentName, confirmedName) == 0 || - NetConnection_getDiscriminant(conn)) + // State 1 + + // Change the team name locally. + Melee_Change_teamName (pMS, side, newName); + + // Notify the remote side. + Netplay_NotifyAll_setTeamName (pMS, side); + + // A packet has now been received and sent. End of turn. + // The sent team name is still unset, so we don't have to reset it. + return; + } + + if (strcmp (newName, sentName) == 0) + { + // Rule 2c or 3d. The value which we sent is different from the value + // which the opponent sent. We need a tie-breaker to determine which + // value prevails. + if (NetConnection_getPlayerNr (conn) != side) { - MeleeSetup_setConfirmedTeamName (setup, side, name); - Melee_Change_teamName (pMS, side, name); - // This will also cause a notification of the local - // change to be sent to the remote side, which will act - // as a confirmation. + // Rule 2c+ or 3d+ + // We win the tie-breaker. The value which we sent prevails. } + else + { + // Rule 2c- or 3d-. + // We lose the tie-breaker. We adopt the remote value. + Melee_Change_teamName (pMS, side, newName); + MeleeSetup_setSentTeamName (setup, side, NULL); + return; + } } + /* + else + { + // Rule 2b or 3c. The value which we sent is the value which + // the opponent sent. This confirms the value. + } + */ + + // Rule 2b, 2c+, 3c, or 3d+. The value which we sent is confirmed. + + currentName = MeleeSetup_getTeamName (setup, side); + if (strcmp (currentName, sentName) != 0) + { + // Rule 3c or 3d+. We had a local change which was yet + // unreported. + + // A packet has been sent and received, which ends the turn. + // We don't bother clearing the sent team name, as we're going + // to send a new packet immediately. + + // Notify the remote side and keep track of what we sent. + Netplay_NotifyAll_setTeamName (pMS, side); + + // Update the last sent message. + MeleeSetup_setSentTeamName (setup, side, newName); + } + else + { + // A packet has been sent and received. End of turn. + MeleeSetup_setSentTeamName (setup, side, NULL); + } } /////////////////////////////////////////////////////////////////////////// Modified: trunk/sc2/src/uqm/supermelee/melee.h =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.h 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/melee.h 2010-04-24 20:59:07 UTC (rev 3537) @@ -59,6 +59,7 @@ BOOLEAN (*InputFunc) (struct melee_state *pInputState); BOOLEAN Initialized; + BOOLEAN meleeStarted; MELEE_OPTIONS MeleeOption; COUNT side; COUNT row; @@ -108,14 +109,17 @@ void errorFeedback (NetConnection *conn); void closeFeedback (NetConnection *conn); -bool Melee_Change_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index, - MeleeShip ship); -bool Melee_Change_teamName (MELEE_STATE *pMS, COUNT side, const char *name); -bool Melee_Change_fleet (MELEE_STATE *pMS, size_t teamNr, +bool Melee_LocalChange_ship (MELEE_STATE *pMS, COUNT side, + FleetShipIndex index, MeleeShip ship); +bool Melee_LocalChange_teamName (MELEE_STATE *pMS, COUNT side, + const char *name); +bool Melee_LocalChange_fleet (MELEE_STATE *pMS, size_t teamNr, const MeleeShip *fleet); -bool Melee_Change_team (MELEE_STATE *pMS, size_t teamNr, +bool Melee_LocalChange_team (MELEE_STATE *pMS, size_t teamNr, const MeleeTeam *team); +void Melee_bootstrapSyncTeam (MELEE_STATE *pMS, size_t teamNr); + void Melee_RemoteChange_ship (MELEE_STATE *pMS, NetConnection *conn, COUNT side, FleetShipIndex index, MeleeShip ship); void Melee_RemoteChange_teamName (MELEE_STATE *pMS, NetConnection *conn, Modified: trunk/sc2/src/uqm/supermelee/meleesetup.c =================================================================== --- trunk/sc2/src/uqm/supermelee/meleesetup.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/meleesetup.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -34,6 +34,8 @@ for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) team->ships[slotI] = MELEE_NONE; + + team->name[0] = '\0'; } void @@ -158,7 +160,7 @@ // Returns true iff the state has actually changed. void -MeleeTeam_setName (MeleeTeam *team, const UNICODE *name) +MeleeTeam_setName (MeleeTeam *team, const char *name) { strncpy (team->name, name, sizeof team->name - 1); team->name[sizeof team->name - 1] = '\0'; @@ -196,6 +198,26 @@ /////////////////////////////////////////////////////////////////////////// +#ifdef NETPLAY +static void +MeleeSetup_initSentTeam (MeleeSetup *setup, size_t teamNr) +{ + MeleeTeam *team = &setup->sentTeams[teamNr]; + FleetShipIndex slotI; + + for (slotI = 0; slotI < MELEE_FLEET_SIZE; slotI++) + MeleeTeam_setShip (team, slotI, MELEE_UNSET); + + setup->haveSentTeamName[teamNr] = false; +#ifdef DEBUG + // The actual team name should be irrelevant if haveSentTeamName is + // set to false. In a debug build, we set it to invalid, so that + // it is more likely that it will be noticed if it is ever used. + MeleeTeam_setName (team, "<INVALID>"); +#endif /* DEBUG */ +} +#endif /* NETPLAY */ + MeleeSetup * MeleeSetup_new (void) { @@ -209,7 +231,7 @@ MeleeTeam_init (&result->teams[teamI]); result->fleetValue[teamI] = 0; #ifdef NETPLAY - MeleeTeam_init (&result->confirmedTeams[teamI]); + MeleeSetup_initSentTeam (result, teamI); #endif /* NETPLAY */ } return result; @@ -221,6 +243,17 @@ HFree (setup); } +#ifdef NETPLAY +void +MeleeSetup_resetSentTeams (MeleeSetup *setup) +{ + size_t teamI; + + for (teamI = 0; teamI < NUM_SIDES; teamI++) + MeleeSetup_initSentTeam (setup, teamI); +} +#endif /* NETPLAY */ + // Returns true iff the state has actually changed. bool MeleeSetup_setShip (MeleeSetup *setup, size_t teamNr, FleetShipIndex slotNr, @@ -259,10 +292,10 @@ // Returns true iff the state has actually changed. bool MeleeSetup_setTeamName (MeleeSetup *setup, size_t teamNr, - const UNICODE *name) + const char *name) { MeleeTeam *team = &setup->teams[teamNr]; - const UNICODE *oldName = MeleeTeam_getTeamName (team); + const char *oldName = MeleeTeam_getTeamName (team); if (strcmp (oldName, name) == 0) return false; @@ -271,6 +304,8 @@ return true; } +// NB. This function returns a pointer to a static buffer, which is +// overwritten by calls to MeleeSetup_setTeamName(). const char * MeleeSetup_getTeamName (const MeleeSetup *setup, size_t teamNr) { @@ -301,24 +336,31 @@ #ifdef NETPLAY MeleeShip -MeleeSetup_getConfirmedShip (const MeleeSetup *setup, size_t teamNr, +MeleeSetup_getSentShip (const MeleeSetup *setup, size_t teamNr, FleetShipIndex slotNr) { - return MeleeTeam_getShip (&setup->confirmedTeams[teamNr], slotNr); + return MeleeTeam_getShip (&setup->sentTeams[teamNr], slotNr); } +// Returns NULL if there is no team name set. This is not the same +// as when an empty (zero-length) team name is set. +// NB. This function returns a pointer to a static buffer, which is +// overwritten by calls to MeleeSetup_setSentTeamName(). const char * -MeleeSetup_getConfirmedTeamName (const MeleeSetup *setup, size_t teamNr) +MeleeSetup_getSentTeamName (const MeleeSetup *setup, size_t teamNr) { - return MeleeTeam_getTeamName (&setup->confirmedTeams[teamNr]); + if (!setup->haveSentTeamName[teamNr]) + return NULL; + + return MeleeTeam_getTeamName (&setup->sentTeams[teamNr]); } // Returns true iff the state has actually changed. bool -MeleeSetup_setConfirmedShip (MeleeSetup *setup, size_t teamNr, +MeleeSetup_setSentShip (MeleeSetup *setup, size_t teamNr, FleetShipIndex slotNr, MeleeShip ship) { - MeleeTeam *team = &setup->confirmedTeams[teamNr]; + MeleeTeam *team = &setup->sentTeams[teamNr]; MeleeShip oldShip = MeleeTeam_getShip (team, slotNr); if (ship == oldShip) @@ -329,28 +371,62 @@ } // Returns true iff the state has actually changed. +// 'name' can be NULL to indicate that no team name set. This is not the same +// as when an empty (zero-length) team name is set. bool -MeleeSetup_setConfirmedTeamName (MeleeSetup *setup, size_t teamNr, - const UNICODE *name) +MeleeSetup_setSentTeamName (MeleeSetup *setup, size_t teamNr, + const char *name) { - MeleeTeam *team = &setup->confirmedTeams[teamNr]; - const UNICODE *oldName = MeleeTeam_getTeamName (team); + bool haveSentName = setup->haveSentTeamName[teamNr]; - if (strcmp (oldName, name) == 0) - return false; + if (name == NULL) + { + if (!haveSentName) + { + // Had not sent a team name, and still haven't. + return false; + } - MeleeTeam_setName (team, name); +#ifdef DEBUG + { + // The actual team name should be irrelevant if haveSentTeamName + // is set to false. In a debug build, we set it to invalid, so + // that it is more likely that it will be noticed if it is ever + // used. + MeleeTeam *team = &setup->sentTeams[teamNr]; + MeleeTeam_setName (team, "<INVALID>"); + } +#endif + } + else + { + MeleeTeam *team; + + if (haveSentName) + { + // Have sent a team name. Check whether it has actually changed. + const char *oldName = MeleeTeam_getTeamName (team); + if (strcmp (oldName, name) == 0) + return false; // Team name has not changed. + } + + team = &setup->sentTeams[teamNr]; + MeleeTeam_setName (team, name); + } + + setup->haveSentTeamName[teamNr] = (name != NULL); + return true; } #if 0 bool -MeleeSetup_isTeamConfirmed (MeleeSetup *setup, size_t teamNr) +MeleeSetup_isTeamSent (MeleeSetup *setup, size_t teamNr) { MeleeTeam *localTeam = &setup->teams[teamNr]; - MeleeTeam *confirmedTeam = &setup->confirmedTeams[teamNr]; + MeleeTeam *sentTeam = &setup->sentTeams[teamNr]; - return MeleeTeam_isEqual (localTeam, confirmedTeam); + return MeleeTeam_isEqual (localTeam, sentTeam); } #endif Modified: trunk/sc2/src/uqm/supermelee/meleesetup.h =================================================================== --- trunk/sc2/src/uqm/supermelee/meleesetup.h 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/meleesetup.h 2010-04-24 20:59:07 UTC (rev 3537) @@ -36,47 +36,29 @@ struct MeleeTeam { MeleeShip ships[MELEE_FLEET_SIZE]; - UNICODE name[MAX_TEAM_CHARS + 1 + 24]; + char name[MAX_TEAM_CHARS + 1 + 24]; /* The +1 is for the terminating \0; the +24 is in case some * default name in starcon.txt is unknowingly mangled. */ + // XXX: SvdB: Why would it be mangled? Why don't we just reject + // it if it is? Is this so that we have some space + // for multibyte UTF-8 chars? }; #endif /* MELEETEAM_INTERNAL */ #ifdef MELEESETUP_INTERNAL -// When Netplay is enabled, we keep two copies of the teams: the team as we -// consider it to be locally, and last confirmed team. -// There are no separate change and confirmation messages; a confirmation -// message is a message reporting a change to the value which was specified -// by the remote side. -// When a local change is made, the current team is updated, and a message -// is sent to the other side. -// When we receive a message of a remote update: -// - if the current value is the same as the received value, we change -// the confirmed value to the current/received value -// - if the current value is different from the received value, and -// the current value is the same as the confirmed value, we change both -// the current value and the confirmed value to the received value, -// and sent a message to the remote side of our modification. -// - if the current value is different from the received value, and -// the current value is not the same as the confirmed value, our -// action depends on who "owns" the value: -// - if the change is to the remote fleet, we change the current and -// confirmed value to the received value, and send a message to the -// remote side of our modification (as above) -// - if the change is to the local fleet, we take no action. -// (In this situation, a local change has been made, and a message of -// this has already been sent to the other side, and a confirmation -// from the other side will arrive eventually.) -// XXX: put this in docs/netplay/protocols. -// XXX: this not only works for teams, but also for other properties. struct MeleeSetup { MeleeTeam teams[NUM_SIDES]; COUNT fleetValue[NUM_SIDES]; #ifdef NETPLAY - MeleeTeam confirmedTeams[NUM_SIDES]; - // The least team which both sides agreed upon. + MeleeTeam sentTeams[NUM_SIDES]; + // The last sent (parts of) teams. + // Used in the Update protocol. See doc/devel/netplay/protocol // XXX: this may actually be deallocated when the battle starts. + bool haveSentTeamName[NUM_SIDES]; + // Whether we have sent a team name this 'turn'. + // Used in the Update protocol. See doc/devel/netplay/protocol + // (also for the term 'turn'). #endif }; @@ -88,6 +70,9 @@ void MeleeTeam_uninit (MeleeTeam *team); MeleeTeam *MeleeTeam_new (void); void MeleeTeam_delete (MeleeTeam *team); +#ifdef NETPLAY +void MeleeSetup_resetSentTeams (MeleeSetup *setup); +#endif /* NETPLAY */ int MeleeTeam_serialize (const MeleeTeam *team, uio_Stream *stream); int MeleeTeam_deserialize (MeleeTeam *team, uio_Stream *stream); COUNT MeleeTeam_getValue (const MeleeTeam *team); @@ -96,23 +81,23 @@ MeleeShip ship); const MeleeShip *MeleeTeam_getFleet (const MeleeTeam *team); const char *MeleeTeam_getTeamName (const MeleeTeam *team); -void MeleeTeam_setName (MeleeTeam *team, const UNICODE *name); +void MeleeTeam_setName (MeleeTeam *team, const char *name); void MeleeTeam_copy (MeleeTeam *copy, const MeleeTeam *original); #if 0 bool MeleeTeam_isEqual (const MeleeTeam *team1, const MeleeTeam *team2); #endif #ifdef NETPLAY -MeleeShip MeleeSetup_getConfirmedShip (const MeleeSetup *setup, size_t teamNr, +MeleeShip MeleeSetup_getSentShip (const MeleeSetup *setup, size_t teamNr, FleetShipIndex slotNr); -const char *MeleeSetup_getConfirmedTeamName (const MeleeSetup *setup, +const char *MeleeSetup_getSentTeamName (const MeleeSetup *setup, size_t teamNr); -bool MeleeSetup_setConfirmedShip (MeleeSetup *setup, size_t teamNr, +bool MeleeSetup_setSentShip (MeleeSetup *setup, size_t teamNr, FleetShipIndex slotNr, MeleeShip ship); -bool MeleeSetup_setConfirmedTeamName (MeleeSetup *setup, size_t teamNr, - const UNICODE *name); +bool MeleeSetup_setSentTeamName (MeleeSetup *setup, size_t teamNr, + const char *name); #if 0 -bool MeleeSetup_isTeamConfirmed (MeleeSetup *setup, size_t teamNr); +bool MeleeSetup_isTeamSent (MeleeSetup *setup, size_t teamNr); #endif #endif /* NETPLAY */ @@ -127,7 +112,7 @@ const MeleeShip *fleet); const MeleeShip *MeleeSetup_getFleet (const MeleeSetup *setup, size_t teamNr); bool MeleeSetup_setTeamName (MeleeSetup *setup, size_t teamNr, - const UNICODE *name); + const char *name); const char *MeleeSetup_getTeamName (const MeleeSetup *setup, size_t teamNr); COUNT MeleeSetup_getFleetValue (const MeleeSetup *setup, size_t teamNr); @@ -142,7 +127,7 @@ void MeleeState_setFleet (MELEE_STATE *pMS, size_t teamNr, const MeleeShip *fleet); void MeleeState_setTeamName (MELEE_STATE *pMS, size_t teamNr, - const UNICODE *name); + const char *name); void MeleeState_setTeam (MELEE_STATE *pMS, size_t teamNr, const MeleeTeam *team); Modified: trunk/sc2/src/uqm/supermelee/meleeship.h =================================================================== --- trunk/sc2/src/uqm/supermelee/meleeship.h 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/meleeship.h 2010-04-24 20:59:07 UTC (rev 3537) @@ -30,7 +30,10 @@ MELEE_YEHAT, MELEE_ZOQFOTPIK, + MELEE_UNSET = ((BYTE) ~0) - 1, + // Used with the Update protocol, to register in the sentTeam MELEE_NONE = (BYTE) ~0 + // Empty fleet position. } MeleeShip; #define NUM_MELEE_SHIPS (MELEE_ZOQFOTPIK + 1) Modified: trunk/sc2/src/uqm/supermelee/netplay/nc_connect.ci =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/nc_connect.ci 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/netplay/nc_connect.ci 2010-04-24 20:59:07 UTC (rev 3537) @@ -181,8 +181,6 @@ // Ignore errors; it's not a big deal. In debug mode, a message // will already have been printed from the function itself. - conn->stateFlags.myTurn = true; - // The "server" may speak first. conn->stateFlags.discriminant = true; NetConnection_connected(conn); @@ -210,8 +208,6 @@ // Ignore errors; it's not a big deal. In debug mode, a message // will already have been printed from the function itself. - conn->stateFlags.myTurn = false; - // The "server" may speak first. conn->stateFlags.discriminant = false; NetConnection_connected(conn); Modified: trunk/sc2/src/uqm/supermelee/netplay/netconnection.c =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/netconnection.c 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/netplay/netconnection.c 2010-04-24 20:59:07 UTC (rev 3537) @@ -129,9 +129,6 @@ conn->stateData = NULL; conn->stateFlags.connected = false; conn->stateFlags.disconnected = false; - conn->stateFlags.myTurn = false; - conn->stateFlags.endingTurn = false; - conn->stateFlags.pendingTurnChange = false; conn->stateFlags.discriminant = false; conn->stateFlags.handshake.localOk = false; conn->stateFlags.handshake.remoteOk = false; @@ -350,11 +347,6 @@ return conn->stateFlags.connected; } -bool -NetConnection_isMyTurn(const NetConnection *conn) { - return conn->stateFlags.myTurn; -} - int NetConnection_getPlayerNr(const NetConnection *conn) { return conn->player; Modified: trunk/sc2/src/uqm/supermelee/netplay/netconnection.h =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/netconnection.h 2010-03-21 07:39:59 UTC (rev 3536) +++ trunk/sc2/src/uqm/supermelee/netplay/netconnection.h 2010-04-24 20:59:07 UTC (rev 3537) @@ -104,20 +104,11 @@ /* This NetConnection has been disconnected. This implies * !connected. It is only set if the NetConnection was once * connected, but is no longer. */ - bool myTurn; - /* This party is the only one who may send specific packets - * at the moment. */ - bool endingTurn; - /* Request to change the turn from/to the other party. */ - bool pendingTurnChange; - /* It is our turn and the other party wants our turn, - * but we're not ready to give it up just yet; we will first - * send our pending packets. */ bool discriminant; /* If it is true here, it is false on the remote side * of the same connection. It may be used to break ties. - * Unlike myTurn, this one is guaranteed not to change - * during a connection. Undefined while not connected. */ + * It is guaranteed not to change during a connection. Undefined + * while not connected. */ HandShakeFlags handshake; ReadyFlags ready; ResetFlags reset; @@ -204,7 +195,6 @@ void NetConnection_doErrorCallback(NetConnection *nd, int err); -bool NetConnection_isMyTurn... [truncated message content] |
From: <av...@us...> - 2010-05-22 18:27:28
|
Revision: 3538 http://sc2.svn.sourceforge.net/sc2/?rev=3538&view=rev Author: avolkov Date: 2010-05-22 18:27:21 +0000 (Sat, 22 May 2010) Log Message: ----------- Fixed uninited TEXT field in cargo display; bug #1092 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/planets/cargo.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-04-24 20:59:07 UTC (rev 3537) +++ trunk/sc2/ChangeLog 2010-05-22 18:27:21 UTC (rev 3538) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed misaligned cargo count (bug #1092) - Coredev - Fixed the network SuperMelee team configuration protocol - SvdB - Fixed fuel reserve bounds checks - SvdB - Fixed a crash when filling fuel tanks over 10 (bug #1082) - Alex Modified: trunk/sc2/src/uqm/planets/cargo.c =================================================================== --- trunk/sc2/src/uqm/planets/cargo.c 2010-04-24 20:59:07 UTC (rev 3537) +++ trunk/sc2/src/uqm/planets/cargo.c 2010-05-22 18:27:21 UTC (rev 3538) @@ -104,6 +104,7 @@ CARGO_SELECTED_BACK_COLOR : CARGO_BACK_COLOR); DrawFilledRectangle (&r); + t.align = ALIGN_RIGHT; t.pStr = buf; t.baseline.y = r.corner.y + TEXT_BASELINE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-05-22 19:15:02
|
Revision: 3539 http://sc2.svn.sourceforge.net/sc2/?rev=3539&view=rev Author: avolkov Date: 2010-05-22 19:14:57 +0000 (Sat, 22 May 2010) Log Message: ----------- Preserve character case when editing with joystick; bug #0180 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/getchar.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-05-22 18:27:21 UTC (rev 3538) +++ trunk/sc2/ChangeLog 2010-05-22 19:14:57 UTC (rev 3539) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Preserve character case when editing with joystick (bug #1080) - Alex - Fixed misaligned cargo count (bug #1092) - Coredev - Fixed the network SuperMelee team configuration protocol - SvdB - Fixed fuel reserve bounds checks - SvdB Modified: trunk/sc2/src/uqm/getchar.c =================================================================== --- trunk/sc2/src/uqm/getchar.c 2010-05-22 18:27:21 UTC (rev 3538) +++ trunk/sc2/src/uqm/getchar.c 2010-05-22 19:14:57 UTC (rev 3539) @@ -313,13 +313,22 @@ joy_char_t newch; joy_char_t cmpch; int i; + BOOLEAN curCharUpper; pTES->JoystickMode = TRUE; if (len) + { // changing an existing character ReadOneChar (&ch, pStr); + curCharUpper = !JoyCharIsLower (&ch, pTES); + } else + { // adding a new character ch = pTES->JoyAlpha[0]; + // new characters will have case determined by the + // currently selected register + curCharUpper = pTES->UpperRegister; + } newch = ch; JoyCharToUpper (&cmpch, &ch, pTES); @@ -347,7 +356,7 @@ { if (len) { // single char change - if (JoyCharIsLower (&newch, pTES)) + if (!curCharUpper) JoyCharToUpper (&newch, &newch, pTES); else JoyCharToLower (&newch, &newch, pTES); @@ -359,7 +368,7 @@ } else { // check register - if (pTES->UpperRegister) + if (curCharUpper) JoyCharToUpper (&newch, &newch, pTES); else JoyCharToLower (&newch, &newch, pTES); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-05-22 19:45:45
|
Revision: 3540 http://sc2.svn.sourceforge.net/sc2/?rev=3540&view=rev Author: avolkov Date: 2010-05-22 19:45:39 +0000 (Sat, 22 May 2010) Log Message: ----------- Do not match singular stars when given a prefix in star search; bug #1071 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/planets/pstarmap.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-05-22 19:14:57 UTC (rev 3539) +++ trunk/sc2/ChangeLog 2010-05-22 19:45:39 UTC (rev 3540) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Do not match singular stars when given a prefix in star search + (bug #1071) - Alex - Preserve character case when editing with joystick (bug #1080) - Alex - Fixed misaligned cargo count (bug #1092) - Coredev - Fixed the network SuperMelee team configuration protocol - SvdB Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2010-05-22 19:14:57 UTC (rev 3539) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2010-05-22 19:45:39 UTC (rev 3540) @@ -975,9 +975,13 @@ continue; } - if (!SDPtr->Prefix || WithinClust) - // singular star - prefix not checked - // or searching within clusters + if (pSS->Prefix && !SDPtr->Prefix) + // we were given a prefix but found a singular star; + // that is a no match + continue; + + if (WithinClust) + // searching within clusters; any prefix is a match break; if (!pSS->Prefix) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-06-01 18:44:51
|
Revision: 3543 http://sc2.svn.sourceforge.net/sc2/?rev=3543&view=rev Author: avolkov Date: 2010-06-01 18:44:44 +0000 (Tue, 01 Jun 2010) Log Message: ----------- Account for ship death in Supermelee early to keep the scores correct after a simultaneous destruction of last ships in each fleet; some ship selection refactoring; bug #437 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/encount.h trunk/sc2/src/uqm/init.c trunk/sc2/src/uqm/pickship.c trunk/sc2/src/uqm/supermelee/pickmele.c trunk/sc2/src/uqm/supermelee/pickmele.h trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/ChangeLog 2010-06-01 18:44:44 UTC (rev 3543) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Properly account for simultaneous destruction of last ships + in each fleet in Supermelee (bug #437) - Alex - Do not match singular stars when given a prefix in star search (bug #1071) - Alex - Preserve character case when editing with joystick (bug #1080) - Alex Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/encount.c 2010-06-01 18:44:44 UTC (rev 3543) @@ -89,6 +89,15 @@ return (TRUE); } +static QUEUE * +GetShipFragQueueForPlayer (COUNT playerNr) +{ + if (playerNr == RPG_PLAYER_NUM) + return &GLOBAL (built_ship_q); + else + return &GLOBAL (npc_built_ship_q); +} + // Called by comm code to intialize battle fleets during encounter void BuildBattle (COUNT which_player) @@ -106,10 +115,9 @@ return; } - if (which_player == RPG_PLAYER_NUM) - pQueue = &GLOBAL (built_ship_q); - else - { + if (which_player != RPG_PLAYER_NUM) + { // This function is called first for the NPC character + // and this is when a centerpiece is loaded switch (LOBYTE (GLOBAL (CurrentActivity))) { case IN_LAST_BATTLE: @@ -124,8 +132,8 @@ load_gravity_well (GET_GAME_STATE (BATTLE_PLANET)); break; } - pQueue = &GLOBAL (npc_built_ship_q); } + pQueue = GetShipFragQueueForPlayer (which_player); ReinitQueue (&race_q[which_player]); for (hStarShip = GetHeadLink (pQueue); @@ -181,6 +189,70 @@ } } +BOOLEAN +FleetIsInfinite (COUNT playerNr) +{ + QUEUE *pQueue; + HSHIPFRAG hShipFrag; + SHIP_FRAGMENT *FragPtr; + BOOLEAN ret; + + pQueue = GetShipFragQueueForPlayer (playerNr); + hShipFrag = GetHeadLink (pQueue); + if (!hShipFrag) + { // Ship queue is empty in SuperMelee or for RPG player w/o escorts + return FALSE; + } + + FragPtr = LockShipFrag (pQueue, hShipFrag); + ret = (FragPtr->crew_level == INFINITE_FLEET); + UnlockShipFrag (pQueue, hShipFrag); + + return ret; +} + +void +UpdateShipFragCrew (STARSHIP *StarShipPtr) +{ + QUEUE *frag_q; + HSHIPFRAG hShipFrag, hNextFrag; + SHIP_FRAGMENT *frag; + QUEUE *ship_q; + HSTARSHIP hStarShip, hNextShip; + STARSHIP *ship; + + frag_q = GetShipFragQueueForPlayer (StarShipPtr->playerNr); + ship_q = &race_q[StarShipPtr->playerNr]; + + // Find a SHIP_FRAGMENT that corresponds to the given STARSHIP + // The ships and fragments are in the same order in two queues + // XXX: It would probably be simpler to keep HSHIPFRAG in STARSHIP struct + for (hShipFrag = GetHeadLink (frag_q), hStarShip = GetHeadLink (ship_q); + hShipFrag != 0 && hStarShip != 0; + hShipFrag = hNextFrag, hStarShip = hNextShip) + { + ship = LockStarShip (ship_q, hStarShip); + hNextShip = _GetSuccLink (ship); + frag = LockShipFrag (frag_q, hShipFrag); + hNextFrag = _GetSuccLink (frag); + + if (ship == StarShipPtr) + { + assert (frag->crew_level != INFINITE_FLEET); + + // Record crew left after the battle */ + frag->crew_level = ship->crew_level; + + UnlockShipFrag (frag_q, hShipFrag); + UnlockStarShip (ship_q, hStarShip); + break; + } + + UnlockShipFrag (frag_q, hShipFrag); + UnlockStarShip (ship_q, hStarShip); + } +} + /* * Encountering an alien. * Draws the encounter screen, plays the red alert music, and Modified: trunk/sc2/src/uqm/encount.h =================================================================== --- trunk/sc2/src/uqm/encount.h 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/encount.h 2010-06-01 18:44:44 UTC (rev 3543) @@ -28,6 +28,7 @@ #include "libs/gfxlib.h" #include "planets/planets.h" #include "element.h" +#include "races.h" typedef HLINK HENCOUNTER; @@ -151,6 +152,8 @@ extern void BuildBattle (COUNT which_player); extern COUNT InitEncounter (void); extern COUNT UninitEncounter (void); +extern BOOLEAN FleetIsInfinite (COUNT playerNr); +extern void UpdateShipFragCrew (STARSHIP *); // XXX: in comm.h, temporary, until solsys generation code is redone extern COUNT InitCommunication (CONVERSATION which_comm); Modified: trunk/sc2/src/uqm/init.c =================================================================== --- trunk/sc2/src/uqm/init.c 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/init.c 2010-06-01 18:44:44 UTC (rev 3543) @@ -25,6 +25,7 @@ #include "pickship.h" #include "process.h" #include "globdata.h" +#include "encount.h" #include "hyper.h" #include "init.h" #include "port.h" @@ -268,7 +269,7 @@ UninitShips (void) { COUNT crew_retrieved; - SIZE i; + int i; HELEMENT hElement, hNextElement; STARSHIP *SPtr[NUM_PLAYERS]; @@ -325,20 +326,17 @@ GLOBAL (CurrentActivity) &= ~IN_BATTLE; - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) - { - } - else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER + if (LOBYTE (GLOBAL (CurrentActivity)) == IN_ENCOUNTER && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { - // XXX: This has no purpose for SuperMelee - // In full-game, the sole purpose of this is to record the crew - // left in the last ship standing. The crew left is first recorded - // into STARSHIP.crew_level just a few lines above here. + // Encounter battle in full game. + // Record the crew left in the last ship standing. The crew left + // is first recorded into STARSHIP.crew_level just a few lines + // above here. for (i = NUM_PLAYERS - 1; i >= 0; --i) { - if (SPtr[i]) - GetEncounterStarShip (SPtr[i], i); + if (SPtr[i] && !FleetIsInfinite (i)) + UpdateShipFragCrew (SPtr[i]); } } Modified: trunk/sc2/src/uqm/pickship.c =================================================================== --- trunk/sc2/src/uqm/pickship.c 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/pickship.c 2010-06-01 18:44:44 UTC (rev 3543) @@ -23,6 +23,7 @@ #include "controls.h" #include "menustat.h" #include "supermelee/pickmele.h" +#include "encount.h" #include "battle.h" #include "races.h" #include "resinst.h" @@ -290,7 +291,9 @@ if (hBattleShip) { if (hBattleShip == GetTailLink (&race_q[0])) - battle_counter[0] = 1; + { // Player chose SIS. There will be no more choices. + battle_counter[RPG_PLAYER_NUM] = 1; + } WaitForSoundEnd (0); } @@ -302,154 +305,89 @@ return (hBattleShip); } -static QUEUE * -GetShipQueueForSide (COUNT sideNr) -{ - if (sideNr == 0) - return &GLOBAL (built_ship_q); - else - return &GLOBAL (npc_built_ship_q); -} - // Get the next ship to use. HSTARSHIP GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player) { - HSTARSHIP hBattleShip; - if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) { - // Get the next ship from the battle group. - hBattleShip = GetHeadLink (&race_q[which_player]); + assert (which_player == RPG_PLAYER_NUM); + // SIS for the Hyperspace flight + return GetHeadLink (&race_q[which_player]); } else if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) { // Let the player chose their own ship. (May be a computer player). + HSTARSHIP hBattleShip; - if (!(GLOBAL (CurrentActivity) & IN_BATTLE)) - { - // XXX: This check is needed, because UninitShips() calls - // this function after the battle is over to record - // the crew left in the last ship standing. - hBattleShip = 0; + if (battle_counter[0] == 0 || battle_counter[1] == 0) + { // One side is out of ships. Game over. + return 0; } - else if (!MeleeShipDeath (LastStarShipPtr, which_player)) - hBattleShip = 0; - // Game over. - else - { - if (!GetNextMeleeStarShip (which_player, &hBattleShip)) - hBattleShip = 0; - } + + if (!GetNextMeleeStarShip (which_player, &hBattleShip)) + return 0; + + return hBattleShip; } else { // Full game. - HSHIPFRAG hStarShip; - SHIP_FRAGMENT *FragPtr; - - if (LastStarShipPtr == 0) - { - // First time picking a ship. - if (which_player == 0 && battle_counter[0] > 1) - { - // The player in a full game, still having a ship left. - hBattleShip = GetArmadaStarShip (); + if (which_player == RPG_PLAYER_NUM) + { // Human player in a full game. + if (LastStarShipPtr == 0 && battle_counter[which_player] == 1) + { // First time picking a ship and player has no escorts + // SIS is the last ship in queue (though there is only one) + return GetTailLink (&race_q[which_player]); } - else - { - hBattleShip = GetHeadLink (&race_q[which_player]); - if (which_player == 1) - { - // Select the next ship for the computer. - hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q)); - FragPtr = LockShipFrag (&GLOBAL (npc_built_ship_q), - hStarShip); - if (FragPtr->crew_level == INFINITE_FLEET) - { - // Infinite number of ships. - battle_counter[1]++; - } - UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip); + else if (battle_counter[which_player]) + { // Player still has ships left + return GetArmadaStarShip (); + } + else if (LastStarShipPtr != 0) + { // last ship was the flagship +#define RUN_AWAY_FUEL_COST (5 * FUEL_TANK_SCALE) + if (LastStarShipPtr->crew_level == 0) + { // Died in the line of duty + GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; } + else + { // Player ran away + if (GLOBAL_SIS (FuelOnBoard) > RUN_AWAY_FUEL_COST) + GLOBAL_SIS (FuelOnBoard) -= RUN_AWAY_FUEL_COST; + else + GLOBAL_SIS (FuelOnBoard) = 0; + } } + return 0; } else - { - QUEUE *pQueue; - HSHIPFRAG hNextShip; - - pQueue = GetShipQueueForSide (which_player); - - hBattleShip = GetHeadLink (&race_q[which_player]); - for (hStarShip = GetHeadLink (pQueue); - hStarShip != 0; hStarShip = hNextShip) + { // NPC player in a full game + if (FleetIsInfinite (which_player)) { - STARSHIP *SPtr; - - SPtr = LockStarShip (&race_q[which_player], hBattleShip); - hNextShip = _GetSuccLink (SPtr); - UnlockStarShip (&race_q[which_player], hBattleShip); - hBattleShip = hNextShip; - - FragPtr = LockShipFrag (pQueue, hStarShip); - if (SPtr == LastStarShipPtr) - { - if (FragPtr->crew_level != INFINITE_FLEET) - { - /* Record crew left after the battle */ - FragPtr->crew_level = SPtr->crew_level; - if (GLOBAL (CurrentActivity) & IN_BATTLE) - SPtr->SpeciesID = NO_ID; - // deactivates the ship - } - else /* if infinite ships */ - { - hBattleShip = GetTailLink (&race_q[which_player]); - /* XXX: Note that if Syreen had a homeworld you could - * fight, all Syreen ships there would be crewed to - * the maximum, instead of the normal level */ - SPtr->crew_level = FragPtr->max_crew; - SPtr->playerNr = which_player; - SPtr->captains_name_index = PickCaptainName (); - - battle_counter[1]++; - } - UnlockShipFrag (pQueue, hStarShip); - break; + if (LastStarShipPtr != 0) + { // The current STARSHIP is reused for the next one; + // update with new info + // XXX: Note that if Syreen had a homeworld you could + // fight, all Syreen ships there would be crewed to + // the maximum, instead of the normal level + LastStarShipPtr->crew_level = LastStarShipPtr->max_crew; + LastStarShipPtr->playerNr = which_player; + LastStarShipPtr->captains_name_index = PickCaptainName (); } - hNextShip = _GetSuccLink (FragPtr); - UnlockShipFrag (pQueue, hStarShip); + battle_counter[which_player]++; + + return GetHeadLink (&race_q[which_player]); } - if (which_player == 0) - { - // Player in a full game. - if (battle_counter[0]) - hBattleShip = GetArmadaStarShip (); - else /* last ship was flagship */ - { -#define RUN_AWAY_FUEL_COST (5 * FUEL_TANK_SCALE) - hBattleShip = 0; - if (LastStarShipPtr->crew_level == 0) - { - /* Died in the line of duty */ - GLOBAL_SIS (CrewEnlisted) = (COUNT)~0; - } - else - { - // Player ran away. - if (GLOBAL_SIS (FuelOnBoard) > RUN_AWAY_FUEL_COST) - GLOBAL_SIS (FuelOnBoard) -= RUN_AWAY_FUEL_COST; - else - GLOBAL_SIS (FuelOnBoard) = 0; - } - } - } + // Get the next ship for the computer + if (LastStarShipPtr != 0) + return _GetSuccLink (LastStarShipPtr); + + // Get the very first ship for the computer + return GetHeadLink (&race_q[which_player]); } } - - return (hBattleShip); } void Modified: trunk/sc2/src/uqm/supermelee/pickmele.c =================================================================== --- trunk/sc2/src/uqm/supermelee/pickmele.c 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/supermelee/pickmele.c 2010-06-01 18:44:44 UTC (rev 3543) @@ -682,24 +682,17 @@ LockMutex (GraphicsLock); } -BOOLEAN -MeleeShipDeath (STARSHIP *ship, COUNT which_player) { +void +MeleeShipDeath (STARSHIP *ship) +{ FRAME frame; // Deactivate fleet position. ship->SpeciesID = NO_ID; - frame = SetAbsFrameIndex (PickMeleeFrame, which_player); + frame = SetAbsFrameIndex (PickMeleeFrame, ship->playerNr); CrossOutShip (frame, ship->index); - UpdatePickMeleeFleetValue (frame, which_player); - - if (battle_counter[0] == 0 || battle_counter[1] == 0) - { - // One side is out of ships. Game over. - return FALSE; - } - - return TRUE; + UpdatePickMeleeFleetValue (frame, ship->playerNr); } // Post: the NetState for all players is NetState_interBattle Modified: trunk/sc2/src/uqm/supermelee/pickmele.h =================================================================== --- trunk/sc2/src/uqm/supermelee/pickmele.h 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/supermelee/pickmele.h 2010-06-01 18:44:44 UTC (rev 3543) @@ -24,7 +24,7 @@ #include "meleesetup.h" #include "libs/compiler.h" -BOOLEAN MeleeShipDeath (STARSHIP *ship, COUNT which_player); +void MeleeShipDeath (STARSHIP *); void BuildPickMeleeFrame (void); void DestroyPickMeleeFrame (void); void FillPickMeleeFrame (MeleeSetup *setup); Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2010-05-23 19:22:52 UTC (rev 3542) +++ trunk/sc2/src/uqm/tactrans.c 2010-06-01 18:44:44 UTC (rev 3543) @@ -27,6 +27,7 @@ #include "status.h" #include "battle.h" #include "init.h" +#include "supermelee/pickmele.h" #ifdef NETPLAY # include "supermelee/netplay/netmelee.h" # include "supermelee/netplay/netmisc.h" @@ -36,6 +37,7 @@ # include "supermelee/netplay/packetq.h" #endif #include "races.h" +#include "encount.h" #include "settings.h" #include "sounds.h" #include "libs/mathlib.h" @@ -279,7 +281,7 @@ if (DeadStarShipPtr->crew_level) { // We've just warped out. new_ship() will still be called - // a few times, to process the trace left behind (I assume). + // a few times, as for any "dead" ship. StopMusic (); // Even after much investigation, I could find no purpose for @@ -339,6 +341,8 @@ UnlockElement (hElement); } + // The ship will be "alive" for at least 2 more frames to make sure + // the elements it owns (set up for deletion above) expire first. DeadShipPtr->life_span = MusicStarted ? (ONE_SECOND * 3) / BATTLE_FRAME_RATE : 1; DeadShipPtr->death_func = new_ship; @@ -391,6 +395,13 @@ } #endif /* NETPLAY */ + if (!FleetIsInfinite (DeadStarShipPtr->playerNr)) + { // This may be a dead ship (crew_level == 0) or a warped out ship + UpdateShipFragCrew (DeadStarShipPtr); + // Deactivate the ship (cannot be selected) + DeadStarShipPtr->SpeciesID = NO_ID; + } + if (GetNextStarShip (DeadStarShipPtr, DeadStarShipPtr->playerNr)) { #ifdef NETPLAY @@ -574,6 +585,9 @@ PlaySound (SetAbsSoundIndex (GameSounds, SHIP_EXPLODES), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); } + + if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) + MeleeShipDeath (StarShipPtr); } #define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-06-02 18:26:48
|
Revision: 3545 http://sc2.svn.sourceforge.net/sc2/?rev=3545&view=rev Author: avolkov Date: 2010-06-02 18:26:41 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Reset input delay upon leaving Supermelee; bug #1022 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/supermelee/melee.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-06-02 18:21:21 UTC (rev 3544) +++ trunk/sc2/ChangeLog 2010-06-02 18:26:41 UTC (rev 3545) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Reset input delay upon leaving Supermelee (bug #1022) - Alex - Properly account for simultaneous destruction of last ships in each fleet in Supermelee (bug #437) - Alex - Do not match singular stars when given a prefix in star search Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2010-06-02 18:21:21 UTC (rev 3544) +++ trunk/sc2/src/uqm/supermelee/melee.c 2010-06-02 18:26:41 UTC (rev 3545) @@ -1453,6 +1453,9 @@ #ifdef NETPLAY closeAllConnections (); + // Clear the input delay in case we will go into the full game later. + // Must be done after the net connections are closed. + setupInputDelay (0); #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-06-02 20:59:39
|
Revision: 3546 http://sc2.svn.sourceforge.net/sc2/?rev=3546&view=rev Author: avolkov Date: 2010-06-02 20:59:33 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Use ditty-specific functions for playing and testing for (PLRPlaying() is not enough); fixes bug #1003 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqm/tactrans.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-06-02 18:26:41 UTC (rev 3545) +++ trunk/sc2/ChangeLog 2010-06-02 20:59:33 UTC (rev 3546) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Game no longer locks up after quickly escaping melee (bug #1003) - Alex - Reset input delay upon leaving Supermelee (bug #1022) - Alex - Properly account for simultaneous destruction of last ships in each fleet in Supermelee (bug #437) - Alex Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2010-06-02 18:26:41 UTC (rev 3545) +++ trunk/sc2/src/uqm/battle.c 2010-06-02 20:59:33 UTC (rev 3546) @@ -510,6 +510,7 @@ setBattleStateConnections (NULL); #endif /* NETPLAY */ + StopDitty (); StopMusic (); StopSound (); } Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2010-06-02 18:26:41 UTC (rev 3545) +++ trunk/sc2/src/uqm/tactrans.c 2010-06-02 20:59:33 UTC (rev 3546) @@ -43,6 +43,9 @@ #include "libs/mathlib.h" +static BOOLEAN dittyIsPlaying; + + BOOLEAN OpponentAlive (STARSHIP *TestStarShipPtr) { @@ -66,6 +69,31 @@ return TRUE; } +static void +PlayDitty (STARSHIP *ship) +{ + PlayMusic (ship->RaceDescPtr->ship_data.victory_ditty, FALSE, 3); + dittyIsPlaying = TRUE; +} + +void +StopDitty (void) +{ + if (dittyIsPlaying) + StopMusic (); + dittyIsPlaying = FALSE; +} + +static BOOLEAN +DittyPlaying (void) +{ + if (!dittyIsPlaying) + return FALSE; + + dittyIsPlaying = PLRPlaying ((MUSIC_REF)~0); + return dittyIsPlaying; +} + #ifdef NETPLAY static void readyToEnd2Callback (NetConnection *conn, void *arg) @@ -223,12 +251,12 @@ return true; #else /* !DEMO_MODE */ (void) side; - return !PLRPlaying ((MUSIC_REF)~0); + return !DittyPlaying (); #endif /* !DEMO_MODE */ #else /* defined (NETPLAY) */ int playerI; - if (PLRPlaying ((MUSIC_REF)~0)) + if (DittyPlaying ()) return false; // We can only handle one dead ship at a time. So 'deadSide' is set @@ -272,24 +300,15 @@ } else { + // Ship explosion has finished, or ship has just warped out + // if DeadStarShipPtr->crew_level != 0 BOOLEAN MusicStarted; HELEMENT hElement, hSuccElement; /* Record crew left after the battle */ DeadStarShipPtr->crew_level = DeadStarShipPtr->RaceDescPtr->ship_info.crew_level; - if (DeadStarShipPtr->crew_level) - { - // We've just warped out. new_ship() will still be called - // a few times, as for any "dead" ship. - StopMusic (); - // Even after much investigation, I could find no purpose for - // the next line, but with the crew management changes I need - // it not to be here. - SvdB - // DeadStarShipPtr->RaceDescPtr->ship_info.crew_level = 0; - } - MusicStarted = FALSE; // XXX: Set to 0 to be vaguely checksum-compatible with previous // Netplay builds which abused turn_wait to store the ship's side. @@ -333,8 +352,7 @@ { // StarShipPtr points to the remaining ship. MusicStarted = TRUE; - PlayMusic (StarShipPtr->RaceDescPtr-> - ship_data.victory_ditty, FALSE, 3); + PlayDitty (StarShipPtr); StarShipPtr->cur_status_flags &= ~PLAY_VICTORY_DITTY; } @@ -361,6 +379,7 @@ { BOOLEAN RestartMusic; + StopDitty (); StopMusic (); StopSound (); @@ -520,6 +539,7 @@ HELEMENT hElement, hNextElement; ELEMENT *ElementPtr; + StopDitty (); StopMusic (); GetElementStarShip (ShipPtr, &StarShipPtr); Modified: trunk/sc2/src/uqm/tactrans.h =================================================================== --- trunk/sc2/src/uqm/tactrans.h 2010-06-02 18:26:41 UTC (rev 3545) +++ trunk/sc2/src/uqm/tactrans.h 2010-06-02 20:59:33 UTC (rev 3546) @@ -37,6 +37,8 @@ extern void spawn_ion_trail (ELEMENT *ElementPtr); extern void flee_preprocess (ELEMENT *ElementPtr); +extern void StopDitty (void); + #endif /* _TACTRANS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-07-11 00:22:36
|
Revision: 3551 http://sc2.svn.sourceforge.net/sc2/?rev=3551&view=rev Author: avolkov Date: 2010-07-11 00:22:27 +0000 (Sun, 11 Jul 2010) Log Message: ----------- Fixed ship picking order after a simultaneous destruction: a dead winner (e.g. Shofixti) is kept alive longer than its dead opponent; in a tie, readyForBattleEnd() is called once per frame for the first ship found dead (currentDeadSide guard removed); fixes bugs #1087, #1088 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/battle.h trunk/sc2/src/uqm/tactrans.c trunk/sc2/src/uqm/tactrans.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-07-11 00:16:15 UTC (rev 3550) +++ trunk/sc2/ChangeLog 2010-07-11 00:22:27 UTC (rev 3551) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Fixed ship picking order after a simultaneous destruction, e.g. + Shofixti picks last after Glory device (bugs #1087, #1088) - Alex - Game no longer locks up after quickly escaping melee (bug #1003) - Alex - Reset input delay upon leaving Supermelee (bug #1022) - Alex - Properly account for simultaneous destruction of last ships Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2010-07-11 00:16:15 UTC (rev 3550) +++ trunk/sc2/src/uqm/battle.c 2010-07-11 00:22:27 UTC (rev 3551) @@ -57,12 +57,6 @@ #ifdef NETPLAY BattleFrameCounter battleFrameCount; // Used for synchronisation purposes during netplay. -COUNT currentDeadSide; - // When a ship has been destroyed, each side of a network - // connection waits until the other side is ready. - // When two ships die at the same time, this is handled for one - // ship after the other. This variable indicate for which player - // we're currently doing this. #endif static BOOLEAN @@ -447,7 +441,7 @@ initChecksumBuffers (); #endif /* NETPLAY_CHECKSUM */ battleFrameCount = 0; - currentDeadSide = (COUNT)~0; + ResetWinnerStarShip (); setBattleStateConnections (&bs); #endif /* NETPLAY */ Modified: trunk/sc2/src/uqm/battle.h =================================================================== --- trunk/sc2/src/uqm/battle.h 2010-07-11 00:16:15 UTC (rev 3550) +++ trunk/sc2/src/uqm/battle.h 2010-07-11 00:22:27 UTC (rev 3551) @@ -44,7 +44,6 @@ extern BattleFrameCounter battleFrameCount; #endif #ifdef NETPLAY -extern COUNT currentDeadSide; COUNT GetPlayerOrder (COUNT i); #else # define GetPlayerOrder(i) (i) Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2010-07-11 00:16:15 UTC (rev 3550) +++ trunk/sc2/src/uqm/tactrans.c 2010-07-11 00:22:27 UTC (rev 3551) @@ -46,6 +46,7 @@ static void cleanup_dead_ship (ELEMENT *ElementPtr); static BOOLEAN dittyIsPlaying; +static STARSHIP *winnerStarShip; BOOLEAN @@ -96,6 +97,12 @@ return dittyIsPlaying; } +void +ResetWinnerStarShip (void) +{ + winnerStarShip = NULL; +} + #ifdef NETPLAY static void readyToEnd2Callback (NetConnection *conn, void *arg) @@ -243,16 +250,14 @@ // Returns true iff this side is ready to end the battle. static inline bool -readyForBattleEnd (COUNT side) +readyForBattleEnd (void) { #ifndef NETPLAY #if DEMO_MODE // In Demo mode, the saved journal should be replayed with frame // accuracy. PLRPlaying () isn't consistent enough. - (void) side; return true; #else /* !DEMO_MODE */ - (void) side; return !DittyPlaying (); #endif /* !DEMO_MODE */ #else /* defined (NETPLAY) */ @@ -261,28 +266,11 @@ if (DittyPlaying ()) return false; - // We can only handle one dead ship at a time. So 'deadSide' is set - // to the side we're handling now. (COUNT)~0 means we're not handling - // any side yet. - if (currentDeadSide == (COUNT)~0) - { - // Not handling any side yet. - currentDeadSide = side; - } - else if (side != currentDeadSide) - { - // We're handing another side at the moment. - return false; - } - for (playerI = 0; playerI < NUM_PLAYERS; playerI++) if (!PlayerInput[playerI]->handlers->battleEndReady ( PlayerInput[playerI])) return false; - currentDeadSide = (COUNT)~0; - // Another side may be handled. - return true; #endif /* defined (NETPLAY) */ } @@ -358,10 +346,20 @@ UnlockElement (hElement); } +#define MIN_DITTY_FRAME_COUNT ((ONE_SECOND * 3) / BATTLE_FRAME_RATE) // The ship will be "alive" for at least 2 more frames to make sure // the elements it owns (set up for deletion above) expire first. - DeadShipPtr->life_span = - MusicStarted ? (ONE_SECOND * 3) / BATTLE_FRAME_RATE : 1; + // Ditty does NOT play in the following circumstances: + // * The winning ship dies before the loser finishes exploding + // * At the moment the losing ship dies, the winner has started + // the warp out sequence + DeadShipPtr->life_span = MusicStarted ? MIN_DITTY_FRAME_COUNT : 1; + if (DeadStarShipPtr == winnerStarShip) + { // This ship died but won the battle. We need to keep it alive + // longer than the dead opponent ship so that the winning player + // picks last. + DeadShipPtr->life_span = MIN_DITTY_FRAME_COUNT + 1; + } DeadShipPtr->death_func = new_ship; DeadShipPtr->preprocess_func = preprocess_dead_ship; DeadShipPtr->state_flags &= ~DISAPPEARING; @@ -373,6 +371,70 @@ } } +static void +setMinShipLifeSpan (ELEMENT *ship, COUNT life_span) +{ + if (ship->death_func == new_ship) + { // The ship has finished exploding or warping out, and now + // we can work with the remaining element + assert (ship->state_flags & FINITE_LIFE); + assert (!(ship->state_flags & DISAPPEARING)); + if (ship->life_span < life_span) + ship->life_span = life_span; + } +} + +static void +setMinStarShipLifeSpan (STARSHIP *starShip, COUNT life_span) +{ + ELEMENT *ship; + + LockElement (starShip->hShip, &ship); + setMinShipLifeSpan (ship, life_span); + UnlockElement (starShip->hShip); +} + +static void +checkOtherShipLifeSpan (ELEMENT *deadShip) +{ + STARSHIP *deadStarShip; + + GetElementStarShip (deadShip, &deadStarShip); + + if (winnerStarShip != NULL && deadStarShip != winnerStarShip + && winnerStarShip->RaceDescPtr->ship_info.crew_level == 0) + { // The opponent ship also died but won anyway (e.g. Glory device) + // We need to keep the opponent ship alive longer so that the + // winning player picks last. + setMinStarShipLifeSpan (winnerStarShip, deadShip->life_span + 1); + } + else if (winnerStarShip == NULL) + { // Both died at the same time, or the loser has already expired + HELEMENT hElement, hNextElement; + + // Find the other dead ship(s) and keep them alive for at least as + // long as this ship. + for (hElement = GetHeadElement (); hElement; hElement = hNextElement) + { + ELEMENT *element; + STARSHIP *starShip; + + LockElement (hElement, &element); + hNextElement = GetSuccElement (element); + GetElementStarShip (element, &starShip); + + if (starShip != NULL && element != deadShip + && starShip->RaceDescPtr->ship_info.crew_level == 0) + { // This is another dead ship + setMinShipLifeSpan (element, deadShip->life_span); + } + + UnlockElement (hElement); + } + } +} + +// This function is called when dead ship element's life_span reaches 0 void new_ship (ELEMENT *DeadShipPtr) { @@ -380,13 +442,25 @@ GetElementStarShip (DeadShipPtr, &DeadStarShipPtr); - if (!readyForBattleEnd (DeadStarShipPtr->playerNr)) + if (!readyForBattleEnd ()) { DeadShipPtr->state_flags &= ~DISAPPEARING; ++DeadShipPtr->life_span; + + // Keep the winner alive longer, or in a simultaneous destruction + // tie, keep the other dead ship alive so that readyForBattleEnd() + // is called for only one ship at a time. + // When a ship has been destroyed, each side of a network + // connection waits until the other side is ready. + // When two ships die at the same time, this is handled for one + // ship after the other. + checkOtherShipLifeSpan (DeadShipPtr); return; } + // Once a ship is being picked, we do not care about the winner anymore + winnerStarShip = NULL; + { BOOLEAN RestartMusic; @@ -563,7 +637,7 @@ battle_counter[StarShipPtr->playerNr]--; } - VictoriousStarShipPtr = 0; + VictoriousStarShipPtr = NULL; for (hElement = GetHeadElement (); hElement; hElement = hNextElement) { LockElement (hElement, &ElementPtr); @@ -574,9 +648,7 @@ { GetElementStarShip (ElementPtr, &VictoriousStarShipPtr); if (VictoriousStarShipPtr->RaceDescPtr->ship_info.crew_level == 0) - VictoriousStarShipPtr = 0; - else - VictoriousStarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY; + VictoriousStarShipPtr = NULL; UnlockElement (hElement); break; @@ -599,15 +671,17 @@ ZeroVelocityComponents (&ShipPtr->velocity); if (ShipPtr->crew_level) /* only happens for shofixti self-destruct */ { - PlaySound (SetAbsSoundIndex ( StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); DeltaCrew (ShipPtr, -(SIZE)ShipPtr->crew_level); - if (VictoriousStarShipPtr == 0) - StarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY; + if (VictoriousStarShipPtr == NULL) + { // No ships left alive after a Shofixti Glory device, + // thus Shofixti wins + VictoriousStarShipPtr = StarShipPtr; + } } else { @@ -617,6 +691,15 @@ CalcSoundPosition (ShipPtr), ShipPtr, GAME_SOUND_PRIORITY + 1); } + if (VictoriousStarShipPtr != NULL) + VictoriousStarShipPtr->cur_status_flags |= PLAY_VICTORY_DITTY; + + // The winner is set once per battle. If both ships die, this function is + // called twice, once for each ship. We need to preserve the winner + // determined on the first call. + if (winnerStarShip == NULL) + winnerStarShip = VictoriousStarShipPtr; + if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) MeleeShipDeath (StarShipPtr); } Modified: trunk/sc2/src/uqm/tactrans.h =================================================================== --- trunk/sc2/src/uqm/tactrans.h 2010-07-11 00:16:15 UTC (rev 3550) +++ trunk/sc2/src/uqm/tactrans.h 2010-07-11 00:22:27 UTC (rev 3551) @@ -38,6 +38,7 @@ extern void flee_preprocess (ELEMENT *ElementPtr); extern void StopDitty (void); +extern void ResetWinnerStarShip (void); #endif /* _TACTRANS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-02-12 21:29:17
|
Revision: 3552 http://sc2.svn.sourceforge.net/sc2/?rev=3552&view=rev Author: Meep-Eep Date: 2011-02-12 21:29:10 +0000 (Sat, 12 Feb 2011) Log Message: ----------- Fixed compilation with Netplay disabled (bug #1091), from Sze Howe Koh. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/supermelee/melee.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2010-07-11 00:22:27 UTC (rev 3551) +++ trunk/sc2/ChangeLog 2011-02-12 21:29:10 UTC (rev 3552) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed compilation with Netplay disabled (bug #1091), from Sze Howe Koh - Fixed ship picking order after a simultaneous destruction, e.g. Shofixti picks last after Glory device (bugs #1087, #1088) - Alex - Game no longer locks up after quickly escaping melee (bug #1003) - Alex Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2010-07-11 00:22:27 UTC (rev 3551) +++ trunk/sc2/src/uqm/supermelee/melee.c 2011-02-12 21:29:10 UTC (rev 3552) @@ -44,7 +44,7 @@ // for DrawShadowedBox() # include "../cnctdlg.h" // for MeleeConnectDialog() -#endif +#endif /* defined (NETPLAY) */ #include "../resinst.h" #include "../settings.h" #include "../setup.h" @@ -2501,6 +2501,8 @@ /////////////////////////////////////////////////////////////////////////// +#ifdef NETPLAY + // Send the entire team to the remote side. Used when the connection has // just been established, or after the setup menu is reentered after battle. void @@ -2536,7 +2538,6 @@ // The behavior of these functions (and the comments therein) follow the // description in doc/devel/netplay/protocol. -#ifdef NETPLAY void Melee_RemoteChange_ship (MELEE_STATE *pMS, NetConnection *conn, COUNT side, FleetShipIndex index, MeleeShip ship) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-02-13 04:37:24
|
Revision: 3553 http://sc2.svn.sourceforge.net/sc2/?rev=3553&view=rev Author: mcmartin Date: 2011-02-13 04:37:18 +0000 (Sun, 13 Feb 2011) Log Message: ----------- Update content version to 0.7. Update install scripts to match. Strip PPC support from Mac build, since this is no longer a configuration we can test. Fix some bugs in the build uqm install sequence on Mac. Modified Paths: -------------- trunk/sc2/build/unix/build.config trunk/sc2/build/unix/config_proginfo_build trunk/sc2/build/win32_install/uqm-installer.nsi trunk/sc2/content/version Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2011-02-12 21:29:10 UTC (rev 3552) +++ trunk/sc2/build/unix/build.config 2011-02-13 04:37:18 UTC (rev 3553) @@ -554,6 +554,7 @@ mkdirhier "$INSTROOT/MacOS" 0755 mkdirhier "$INSTROOT/Frameworks" 0755 mkdirhier "$INSTROOT/Resources/content/addons" 0755 + mkdirhier "$INSTROOT/Resources/content/packages" 0755 # Install misc. resources, icons, etc. echo "Installing miscellaneous resources..." >&2 Modified: trunk/sc2/build/unix/config_proginfo_build =================================================================== --- trunk/sc2/build/unix/config_proginfo_build 2011-02-12 21:29:10 UTC (rev 3552) +++ trunk/sc2/build/unix/config_proginfo_build 2011-02-13 04:37:18 UTC (rev 3553) @@ -62,9 +62,9 @@ } case "$HOST_SYSTEM" in Darwin) - EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C='-mmacosx-version-min=10.4 -arch ppc -arch i386' - EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC='-mmacosx-version-min=10.4 -arch ppc -arch i386' - EXTRA_PLATFORM_GCC_FLAGS_LINK='-mmacosx-version-min=10.4 -arch ppc -arch i386' + EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C='-mmacosx-version-min=10.4 -arch i386' + EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC='-mmacosx-version-min=10.4 -arch i386' + EXTRA_PLATFORM_GCC_FLAGS_LINK='-mmacosx-version-min=10.4 -arch i386' useGccBuildTools ;; WINSCW) Modified: trunk/sc2/build/win32_install/uqm-installer.nsi =================================================================== --- trunk/sc2/build/win32_install/uqm-installer.nsi 2011-02-12 21:29:10 UTC (rev 3552) +++ trunk/sc2/build/win32_install/uqm-installer.nsi 2011-02-13 04:37:18 UTC (rev 3553) @@ -7,7 +7,7 @@ ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "The Ur-Quan Masters" -!define PRODUCT_VERSION "0.6.2" +!define PRODUCT_VERSION "0.7.0" !define PRODUCT_WEB_SITE "http://sc2.sourceforge.net" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\uqm.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" Modified: trunk/sc2/content/version =================================================================== --- trunk/sc2/content/version 2011-02-12 21:29:10 UTC (rev 3552) +++ trunk/sc2/content/version 2011-02-13 04:37:18 UTC (rev 3553) @@ -1,3 +1,3 @@ -0.6.0 +0.7.0 $Date$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcm...@us...> - 2011-02-14 08:00:33
|
Revision: 3557 http://sc2.svn.sourceforge.net/sc2/?rev=3557&view=rev Author: mcmartin Date: 2011-02-14 08:00:27 +0000 (Mon, 14 Feb 2011) Log Message: ----------- Fix Win32 installer for UAC integration on Vista/7 and for the new download paths. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/build/win32_install/uqm-installer.nsi Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-02-13 18:05:57 UTC (rev 3556) +++ trunk/sc2/ChangeLog 2011-02-14 08:00:27 UTC (rev 3557) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Update download paths for the new SourceForge File Release system - Michael +- Fix UAC issues with installer for cleaner Vista/Win7 installs - Michael - Fixed compilation with Netplay disabled (bug #1091), from Sze Howe Koh - Fixed ship picking order after a simultaneous destruction, e.g. Shofixti picks last after Glory device (bugs #1087, #1088) - Alex Modified: trunk/sc2/build/win32_install/uqm-installer.nsi =================================================================== --- trunk/sc2/build/win32_install/uqm-installer.nsi 2011-02-13 18:05:57 UTC (rev 3556) +++ trunk/sc2/build/win32_install/uqm-installer.nsi 2011-02-14 08:00:27 UTC (rev 3557) @@ -26,6 +26,9 @@ !define MUI_HEADERIMAGE_BITMAP "ultron.bmp" !define MUI_HEADERIMAGE_RIGHT +; UAC support +RequestExecutionLevel admin + ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page @@ -234,7 +237,7 @@ GetTempFileName $DOWNLOADTARGET Delete $DOWNLOADTARGET CreateDirectory $DOWNLOADTARGET - NSISdl::download "http://$2.dl.sourceforge.net/sourceforge/sc2/$1" "$DOWNLOADTARGET\$1" + NSISdl::download "http://$2.dl.sourceforge.net/sourceforge/sc2/UQM/0.6.0/$1" "$DOWNLOADTARGET\$1" Pop $2 StrCmp $2 "success" DownloadSuccessful StrCmp $2 "cancel" DownloadCanceled This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-15 12:04:34
|
Revision: 3558 http://sc2.svn.sourceforge.net/sc2/?rev=3558&view=rev Author: avolkov Date: 2011-02-15 12:04:28 +0000 (Tue, 15 Feb 2011) Log Message: ----------- Change ReadResFile/WriteResFile interface to take size_t args; removes 64KB size limitation on key-value files; bug #1112 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/reslib.h trunk/sc2/src/libs/resource/filecntl.c trunk/sc2/src/libs/resource/getres.c trunk/sc2/src/libs/resource/loadres.c trunk/sc2/src/libs/resource/propfile.c trunk/sc2/src/libs/strings/getstr.c trunk/sc2/src/uqm/load.c trunk/sc2/src/uqm/save.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/ChangeLog 2011-02-15 12:04:28 UTC (rev 3558) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed the 64KB size limitation on key-value files (bug #1112) - Alex - Update download paths for the new SourceForge File Release system - Michael - Fix UAC issues with installer for cleaner Vista/Win7 installs - Michael - Fixed compilation with Netplay disabled (bug #1091), from Sze Howe Koh Modified: trunk/sc2/src/libs/reslib.h =================================================================== --- trunk/sc2/src/libs/reslib.h 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/reslib.h 2011-02-15 12:04:28 UTC (rev 3558) @@ -48,14 +48,14 @@ void *LoadResourceFromPath(const char *pathname, ResourceLoadFileFun fn); uio_Stream *res_OpenResFile (uio_DirHandle *dir, const char *filename, const char *mode); -int ReadResFile (void *lpBuf, COUNT size, COUNT count, uio_Stream *fp); -int WriteResFile (const void *lpBuf, COUNT size, COUNT count, uio_Stream *fp); +size_t ReadResFile (void *lpBuf, size_t size, size_t count, uio_Stream *fp); +size_t WriteResFile (const void *lpBuf, size_t size, size_t count, uio_Stream *fp); int GetResFileChar (uio_Stream *fp); int PutResFileChar (char ch, uio_Stream *fp); int PutResFileNewline (uio_Stream *fp); long SeekResFile (uio_Stream *fp, long offset, int whence); long TellResFile (uio_Stream *fp); -long LengthResFile (uio_Stream *fp); +size_t LengthResFile (uio_Stream *fp); BOOLEAN res_CloseResFile (uio_Stream *fp); BOOLEAN DeleteResFile (uio_DirHandle *dir, const char *filename); Modified: trunk/sc2/src/libs/resource/filecntl.c =================================================================== --- trunk/sc2/src/libs/resource/filecntl.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/resource/filecntl.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -60,8 +60,8 @@ return (uio_unlink (dir, filename) == 0); } -int -ReadResFile (void *lpBuf, COUNT size, COUNT count, uio_Stream *fp) +size_t +ReadResFile (void *lpBuf, size_t size, size_t count, uio_Stream *fp) { int retval; @@ -70,8 +70,8 @@ return (retval); } -int -WriteResFile (const void *lpBuf, COUNT size, COUNT count, uio_Stream *fp) +size_t +WriteResFile (const void *lpBuf, size_t size, size_t count, uio_Stream *fp) { int retval; @@ -131,7 +131,7 @@ return (retval); } -long +size_t LengthResFile (uio_Stream *fp) { struct stat sb; Modified: trunk/sc2/src/libs/resource/getres.c =================================================================== --- trunk/sc2/src/libs/resource/getres.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/resource/getres.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -43,7 +43,7 @@ LoadResourceFromPath (const char *path, ResourceLoadFileFun *loadFun) { uio_Stream *stream; - long dataLen; + unsigned long dataLen; void *resdata; stream = res_OpenResFile (contentDir, path, "rb"); Modified: trunk/sc2/src/libs/resource/loadres.c =================================================================== --- trunk/sc2/src/libs/resource/loadres.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/resource/loadres.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -17,56 +17,38 @@ */ #include "resintrn.h" -#include "libs/declib.h" #include "libs/memlib.h" +#include "libs/log.h" void * GetResourceData (uio_Stream *fp, DWORD length) { - BYTE *RDPtr; void *result; - DECODE_REF fh = 0; + DWORD compLen; - if (length == ~(DWORD)0) - length = LengthResFile (fp); - else if ((fh = copen (fp, FILE_STREAM, STREAM_READ))) - cfilelength (fh, &length); - else - length -= sizeof (DWORD); + // Resource data used to be prefixed by its length in package files. + // A valid length prefix indicated compressed data, and + // a length prefix ~0 meant uncompressed. + // Currently, .ct and .xlt files still carry a ~0 length prefix. + if (ReadResFile (&compLen, sizeof (compLen), 1, fp) != 1) + return NULL; + if (compLen != ~(DWORD)0) + { + log_add (log_Warning, "LZ-compressed binary data not supported"); + return NULL; + } + length -= sizeof (DWORD); result = AllocResourceData (length); - RDPtr = result; - if (RDPtr) - { - COUNT num_read; + if (!result) + return NULL; - do - { -#define READ_LENGTH 0x00007FFFL - num_read = length >= READ_LENGTH ? - (COUNT)READ_LENGTH : (COUNT)length; - if (fh) - { - if (cread (RDPtr, 1, num_read, fh) != num_read) - break; - } - else - { - if ((int)(ReadResFile (RDPtr, 1, num_read, fp)) != (int)num_read) - break; - } - RDPtr += num_read; - } while (length -= num_read); - - if (length > 0) - { - FreeResourceData (result); - result = NULL; - } + if (ReadResFile (result, 1, length, fp) != length) + { + FreeResourceData (result); + result = NULL; } - cclose (fh); - return result; } Modified: trunk/sc2/src/libs/resource/propfile.c =================================================================== --- trunk/sc2/src/libs/resource/propfile.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/resource/propfile.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -98,7 +98,7 @@ void PropFile_from_file (uio_Stream *f, PROPERTY_HANDLER handler, const char *prefix) { - long flen; + size_t flen; char *data; flen = LengthResFile (f); @@ -108,6 +108,8 @@ return; } + // We may end up with less bytes than we asked for due to the + // DOS->Unix newline conversion flen = ReadResFile (data, 1, flen, f); data[flen] = '\0'; Modified: trunk/sc2/src/libs/strings/getstr.c =================================================================== --- trunk/sc2/src/libs/strings/getstr.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/libs/strings/getstr.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -65,7 +65,7 @@ _GetConversationData (const char *path, RESOURCE_DATA *resdata) { uio_Stream *fp; - long dataLen; + unsigned long dataLen; void *result; int n, path_len, num_data_sets; DWORD opos, Modified: trunk/sc2/src/uqm/load.c =================================================================== --- trunk/sc2/src/uqm/load.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/uqm/load.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -107,7 +107,7 @@ return cread (ar, 1, count, fh) == count; } -static inline COUNT +static inline size_t read_8 (void *fp, BYTE *v) { BYTE t; @@ -116,7 +116,7 @@ return ReadResFile (v, 1, 1, fp); } -static inline COUNT +static inline size_t read_16 (void *fp, UWORD *v) { UWORD t; @@ -125,7 +125,7 @@ return ReadResFile (v, 2, 1, fp); } -static inline COUNT +static inline size_t read_32 (void *fp, DWORD *v) { DWORD t; @@ -134,7 +134,7 @@ return ReadResFile (v, 4, 1, fp); } -static inline COUNT +static inline size_t read_32s (void *fp, SDWORD *v) { DWORD t; @@ -147,28 +147,28 @@ return ret; } -static inline COUNT +static inline size_t read_ptr (void *fp) { DWORD t; return read_32 (fp, &t); /* ptrs are useless in saves */ } -static inline COUNT +static inline size_t read_a8 (void *fp, BYTE *ar, COUNT count) { assert (ar != NULL); return ReadResFile (ar, 1, count, fp) == count; } -static inline COUNT +static inline size_t read_str (void *fp, char *str, COUNT count) { // no type conversion needed for strings return read_a8 (fp, (BYTE *)str, count); } -static inline COUNT +static inline size_t read_a16 (void *fp, UWORD *ar, COUNT count) { assert (ar != NULL); Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2011-02-14 08:00:27 UTC (rev 3557) +++ trunk/sc2/src/uqm/save.c 2011-02-15 12:04:28 UTC (rev 3558) @@ -74,44 +74,44 @@ return cwrite (ar, 1, count, fh) == count; } -static inline COUNT +static inline size_t write_8 (void *fp, BYTE v) { return WriteResFile (&v, 1, 1, fp); } -static inline COUNT +static inline size_t write_16 (void *fp, UWORD v) { return WriteResFile (&v, 2, 1, fp); } -static inline COUNT +static inline size_t write_32 (void *fp, DWORD v) { return WriteResFile (&v, 4, 1, fp); } -static inline COUNT +static inline size_t write_ptr (void *fp) { return write_32 (fp, 0); /* ptrs are useless in saves */ } -static inline COUNT +static inline size_t write_a8 (void *fp, const BYTE *ar, COUNT count) { return WriteResFile (ar, 1, count, fp) == count; } -static inline COUNT +static inline size_t write_str (void *fp, const char *str, COUNT count) { // no type conversion needed for strings return write_a8 (fp, (const BYTE *)str, count); } -static inline COUNT +static inline size_t write_a16 (void *fp, const UWORD *ar, COUNT count) { for ( ; count > 0; --count, ++ar) @@ -838,8 +838,7 @@ success = SaveSummary (SummPtr, out_fp); // Then write the rest of the data. - if (success && WriteResFile (h, (COUNT)flen, 1, - out_fp) == 0) + if (success && WriteResFile (h, flen, 1, out_fp) != 1) success = FALSE; if (res_CloseResFile ((uio_Stream *)out_fp) == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-15 13:05:07
|
Revision: 3559 http://sc2.svn.sourceforge.net/sc2/?rev=3559&view=rev Author: avolkov Date: 2011-02-15 13:05:00 +0000 (Tue, 15 Feb 2011) Log Message: ----------- Fix melee.cfg loading: correct check for file size, calc fleet value after loading; bug #1099 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/supermelee/melee.c trunk/sc2/src/uqm/supermelee/meleesetup.c trunk/sc2/src/uqm/supermelee/meleesetup.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-02-15 12:04:28 UTC (rev 3558) +++ trunk/sc2/ChangeLog 2011-02-15 13:05:00 UTC (rev 3559) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed loading of melee.cfg (bug #1099) - Alex - Fixed the 64KB size limitation on key-value files (bug #1112) - Alex - Update download paths for the new SourceForge File Release system - Michael - Fix UAC issues with installer for cleaner Vista/Win7 installs - Michael Modified: trunk/sc2/src/uqm/supermelee/melee.c =================================================================== --- trunk/sc2/src/uqm/supermelee/melee.c 2011-02-15 12:04:28 UTC (rev 3558) +++ trunk/sc2/src/uqm/supermelee/melee.c 2011-02-15 13:05:00 UTC (rev 3559) @@ -2004,7 +2004,7 @@ if (uio_fstat(uio_streamHandle(stream), &sb) == -1) goto err; - if ((size_t) sb.st_size != (1 + MeleeTeam_size) * NUM_SIDES) + if ((size_t) sb.st_size != (1 + MeleeTeam_serialSize) * NUM_SIDES) goto err; } Modified: trunk/sc2/src/uqm/supermelee/meleesetup.c =================================================================== --- trunk/sc2/src/uqm/supermelee/meleesetup.c 2011-02-15 12:04:28 UTC (rev 3558) +++ trunk/sc2/src/uqm/supermelee/meleesetup.c 2011-02-15 13:05:00 UTC (rev 3559) @@ -25,7 +25,8 @@ /////////////////////////////////////////////////////////////////////////// // Temporary -const size_t MeleeTeam_size = sizeof (MeleeTeam); +const size_t MeleeTeam_serialSize = MELEE_FLEET_SIZE + + sizeof (((MeleeTeam*)0)->name); void MeleeTeam_init (MeleeTeam *team) @@ -323,7 +324,10 @@ uio_Stream *stream) { MeleeTeam *team = &setup->teams[teamNr]; - return MeleeTeam_deserialize (team, stream); + int ret = MeleeTeam_deserialize (team, stream); + if (ret == 0) + setup->fleetValue[teamNr] = MeleeTeam_getValue (team); + return ret; } int Modified: trunk/sc2/src/uqm/supermelee/meleesetup.h =================================================================== --- trunk/sc2/src/uqm/supermelee/meleesetup.h 2011-02-15 12:04:28 UTC (rev 3558) +++ trunk/sc2/src/uqm/supermelee/meleesetup.h 2011-02-15 13:05:00 UTC (rev 3559) @@ -64,7 +64,7 @@ #endif /* MELEESETUP_INTERNAL */ -extern const size_t MeleeTeam_size; +extern const size_t MeleeTeam_serialSize; void MeleeTeam_init (MeleeTeam *team); void MeleeTeam_uninit (MeleeTeam *team); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-02-21 14:41:27
|
Revision: 3570 http://sc2.svn.sourceforge.net/sc2/?rev=3570&view=rev Author: avolkov Date: 2011-02-21 14:41:18 +0000 (Mon, 21 Feb 2011) Log Message: ----------- Build fleet queues and name captains in the same exact order on both net sides; fixes bugs 1081 and 989 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/supermelee/pickmele.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-02-21 03:42:01 UTC (rev 3569) +++ trunk/sc2/ChangeLog 2011-02-21 14:41:18 UTC (rev 3570) @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Same captain names are used on both net sides (bug #989) - Alex +- Fixed sync loss in netplay games having duplicate ships (bug #1081) - Alex - Fixed loading of melee.cfg (bug #1099) - Alex - Fixed the 64KB size limitation on key-value files (bug #1112) - Alex - Update download paths for the new SourceForge File Release system - Michael Modified: trunk/sc2/src/uqm/supermelee/pickmele.c =================================================================== --- trunk/sc2/src/uqm/supermelee/pickmele.c 2011-02-21 03:42:01 UTC (rev 3569) +++ trunk/sc2/src/uqm/supermelee/pickmele.c 2011-02-21 14:41:18 UTC (rev 3570) @@ -507,20 +507,22 @@ void FillPickMeleeFrame (MeleeSetup *setup) { - COUNT sideI; + COUNT i; CONTEXT OldContext; OldContext = SetContext (OffScreenContext); - for (sideI = 0; sideI < NUM_SIDES; ++sideI) + for (i = 0; i < NUM_SIDES; ++i) { COUNT side; + COUNT sideI; RECT r; TEXT t; STAMP s; UNICODE buf[30]; FleetShipIndex index; + sideI = GetPlayerOrder (i); side = !sideI; s.frame = SetAbsFrameIndex (PickMeleeFrame, side); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-04-23 20:59:33
|
Revision: 3583 http://sc2.svn.sourceforge.net/sc2/?rev=3583&view=rev Author: avolkov Date: 2011-04-23 20:59:25 +0000 (Sat, 23 Apr 2011) Log Message: ----------- Energy and some bio generation code refactoring: generation funcs perform all action neccessary upon energy node pickup, Fwiffo hacks removed, duplicated code made into funcs; fixes bugs 1118/1028 Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/planets/generate/genand.c trunk/sc2/src/uqm/planets/generate/genburv.c trunk/sc2/src/uqm/planets/generate/gendefault.c trunk/sc2/src/uqm/planets/generate/gendefault.h trunk/sc2/src/uqm/planets/generate/gendru.c trunk/sc2/src/uqm/planets/generate/genilw.c trunk/sc2/src/uqm/planets/generate/genmyc.c trunk/sc2/src/uqm/planets/generate/genorz.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/planets/generate/genpku.c trunk/sc2/src/uqm/planets/generate/gensol.c trunk/sc2/src/uqm/planets/generate/genspa.c trunk/sc2/src/uqm/planets/generate/gensup.c trunk/sc2/src/uqm/planets/generate/genthrad.c trunk/sc2/src/uqm/planets/generate/genutw.c trunk/sc2/src/uqm/planets/generate/genvault.c trunk/sc2/src/uqm/planets/generate/genvux.c trunk/sc2/src/uqm/planets/generate/genwreck.c trunk/sc2/src/uqm/planets/generate/genyeh.c trunk/sc2/src/uqm/planets/generate/genzoq.c trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/lander.h trunk/sc2/src/uqm/planets/plandata.h trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/sundata.h trunk/sc2/src/uqm/planets/surface.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/ChangeLog 2011-04-23 20:59:25 UTC (rev 3583) @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Fixed Syreen Vault lander report infinite loop (bug #1118) - Alex - Same captain names are used on both net sides (bug #989) - Alex - Fixed sync loss in netplay games having duplicate ships (bug #1081) - Alex - Fixed loading of melee.cfg (bug #1099) - Alex Modified: trunk/sc2/src/uqm/planets/generate/genand.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genand.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genand.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -121,44 +121,30 @@ } static bool +onRuinPickedUp (SOLARSYS_STATE *solarSys, COUNT whichNode) +{ + PLANET_INFO *planetInfo = &solarSys->SysInfo.PlanetInfo; + + // Ruins previously visited are marked in the upper 16 bits + if (isNodeRetrieved (planetInfo, ENERGY_SCAN, whichNode + 16)) + return false; // already visited this ruin before, no report + + setNodeRetrieved (planetInfo, ENERGY_SCAN, whichNode + 16); + // We set the retrieved bit manually here and need to indicate + // the change to the solar system state functions + SET_GAME_STATE (PLANETARY_CHANGE, 1); + + return true; // give whatever report is next +} + +static bool GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { if (matchWorld (solarSys, world, 1, MATCH_PLANET)) { - COUNT i; - - GenerateRandomRuins (&solarSys->SysInfo, 0, whichNode); - - for (i = 0; i < 16; ++i) - { - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) - { - // Retrieval status is cleared to keep the node on the map - setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); - // Ruins previously visited are marked in the upper 16 bits - if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, - i + 16)) - { - SET_GAME_STATE (PLANETARY_CHANGE, 1); - - setNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, - i + 16); - if (solarSys->SysInfo.PlanetInfo.DiscoveryString) - { - UnbatchGraphics (); - DoDiscoveryReport (MenuSounds); - BatchGraphics (); - // Advance to the next report - solarSys->SysInfo.PlanetInfo.DiscoveryString = - SetRelStringTableIndex ( - solarSys->SysInfo.PlanetInfo.DiscoveryString, - 1); - } - } - } - } - + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, onRuinPickedUp); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genburv.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genburv.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genburv.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -17,6 +17,7 @@ */ #include "genall.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../globdata.h" @@ -139,11 +140,10 @@ GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { - DWORD old_rand; - if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } @@ -155,22 +155,17 @@ return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/gendefault.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -16,12 +16,15 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" +#include "../lander.h" #include "../../encount.h" #include "../../gamestr.h" #include "../../globdata.h" #include "../../grpinfo.h" #include "../../races.h" #include "../../state.h" +#include "../../sounds.h" #include "libs/mathlib.h" @@ -191,7 +194,100 @@ return true; } +bool +GenerateDefault_generateArtifact (SOLARSYS_STATE *solarSys, COUNT *whichNode) +{ + // Generate an energy node at a random location + GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, whichNode); + return true; +} +bool +GenerateDefault_generateRuins (SOLARSYS_STATE *solarSys, COUNT *whichNode) +{ + // Generate a standard spread of city ruins of a destroyed civilization + GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS, + 0, whichNode); + return true; +} + +bool +GenerateDefault_pickupRuins (SOLARSYS_STATE *solarSys, + PickupRuinCallback callback) +{ + PLANET_INFO *planetInfo = &solarSys->SysInfo.PlanetInfo; + COUNT i; + + for (i = 0; i < NUM_RACE_RUINS; ++i) + { + if (!isNodeRetrieved (planetInfo, ENERGY_SCAN, i)) + continue; + + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (planetInfo, ENERGY_SCAN, i); + + if (callback && !callback (solarSys, i)) + continue; // no lander report wanted + + // Some ruins have more than one lander report, like when + // you fish artifacts out of the ruins. + GenerateDefault_landerReportCycle (solarSys); + } + return true; +} + +static inline void +runLanderReport (void) +{ + UnbatchGraphics (); + DoDiscoveryReport (MenuSounds); + BatchGraphics (); +} + +bool +GenerateDefault_landerReport (SOLARSYS_STATE *solarSys) +{ + PLANET_INFO *planetInfo = &solarSys->SysInfo.PlanetInfo; + + if (!planetInfo->DiscoveryString) + return false; + + runLanderReport (); + + // XXX: A non-cycling report is given only once and has to be deleted + // in some circumstances (like the Syreen Vault). It does not + // hurt to simply delete it in all cases. Nothing should rely on + // the presence of DiscoveryString, but the Syreen Vault and the + // Mycon Egg Cases rely on its absence. + DestroyStringTable (ReleaseStringTable (planetInfo->DiscoveryString)); + planetInfo->DiscoveryString = 0; + + return true; +} + +bool +GenerateDefault_landerReportCycle (SOLARSYS_STATE *solarSys) +{ + PLANET_INFO *planetInfo = &solarSys->SysInfo.PlanetInfo; + + if (!planetInfo->DiscoveryString) + return false; + + runLanderReport (); + // Advance to the next report + planetInfo->DiscoveryString = SetRelStringTableIndex ( + planetInfo->DiscoveryString, 1); + + // If our discovery strings have cycled, we're done + if (GetStringTableIndex (planetInfo->DiscoveryString) == 0) + { + DestroyStringTable (ReleaseStringTable (planetInfo->DiscoveryString)); + planetInfo->DiscoveryString = 0; + } + + return true; +} + // NB. This function modifies the RNG state. static void GeneratePlanets (SOLARSYS_STATE *solarSys) Modified: trunk/sc2/src/uqm/planets/generate/gendefault.h =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-04-23 20:59:25 UTC (rev 3583) @@ -38,6 +38,17 @@ bool GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode); +// Ruin callback returns 'true' if a lander report should be given +typedef bool (*PickupRuinCallback)(SOLARSYS_STATE *solarSys, + COUNT whichNode); + +bool GenerateDefault_generateArtifact (SOLARSYS_STATE *, COUNT *whichNode); +bool GenerateDefault_generateRuins (SOLARSYS_STATE *, COUNT *whichNode); +bool GenerateDefault_pickupRuins (SOLARSYS_STATE *, PickupRuinCallback); +bool GenerateDefault_landerReport (SOLARSYS_STATE *); +bool GenerateDefault_landerReportCycle (SOLARSYS_STATE *); + + extern const GenerateFunctions generateDefaultFunctions; #endif /* GENDEFAULT_H */ Modified: trunk/sc2/src/uqm/planets/generate/gendru.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendru.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/gendru.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -19,7 +19,6 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" -#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -114,9 +113,11 @@ CaptureStringTable ( LoadStringTable (DRUUGE_RUINS_STRTAB)); if (GET_GAME_STATE (ROSY_SPHERE)) + { // Already picked up Rosy Sphere, skip the report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); + } } } @@ -126,34 +127,30 @@ } static bool -GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT *whichNode) +onRuinPickedUp (SOLARSYS_STATE *solarSys, COUNT whichNode) { - if (matchWorld (solarSys, world, 0, MATCH_PLANET)) - { - COUNT i; - COUNT type; + if (!GET_GAME_STATE (ROSY_SPHERE)) + { // Just picked up the Rosy Sphere from a ruin + SetLanderTakeoff (); - type = GET_GAME_STATE (ROSY_SPHERE) ? 1 : 0; - GenerateRandomRuins (&solarSys->SysInfo, type, whichNode); + SET_GAME_STATE (ROSY_SPHERE, 1); + SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1); + } - for (i = 0; i < 16; ++i) - { - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) - { - // Retrieval status is cleared to keep the node on the map - setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); + (void) solarSys; + (void) whichNode; - if (!GET_GAME_STATE (ROSY_SPHERE)) - { - SetLanderTakeoff (); + return true; // give whatever report is next +} - SET_GAME_STATE (ROSY_SPHERE, 1); - SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1); - } - } - } - +static bool +GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, + COUNT *whichNode) +{ + if (matchWorld (solarSys, world, 0, MATCH_PLANET)) + { + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, onRuinPickedUp); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genilw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genilw.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genilw.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -123,7 +123,8 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genmyc.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -17,6 +17,7 @@ */ #include "genall.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../build.h" @@ -185,8 +186,6 @@ GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { - DWORD old_rand; - if (CurStarDescPtr->Index == SUN_DEVICE_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { @@ -196,23 +195,18 @@ return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (SUN_DEVICE, 1); SET_GAME_STATE (SUN_DEVICE_ON_SHIP, 1); SET_GAME_STATE (MYCON_VISITS, 0); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } @@ -229,15 +223,8 @@ *whichNode = 0; return true; } - - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested + GenerateDefault_generateArtifact (solarSys, whichNode); if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { @@ -253,9 +240,11 @@ SET_GAME_STATE (EGG_CASE2_ON_SHIP, 1); break; } + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genorz.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genorz.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genorz.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -17,6 +17,7 @@ */ #include "genall.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../build.h" @@ -165,8 +166,6 @@ GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { - DWORD old_rand; - if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED && matchWorld (solarSys, world, 1, 2)) { @@ -176,29 +175,25 @@ return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (TAALO_PROTECTOR, 1); SET_GAME_STATE (TAALO_PROTECTOR_ON_SHIP, 1); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } if (CurStarDescPtr->Index == ORZ_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genpet.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpet.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genpet.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -160,7 +160,8 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genpku.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpku.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genpku.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -19,7 +19,6 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" -#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -105,9 +104,11 @@ solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (PKUNK_RUINS_STRTAB)); if (GET_GAME_STATE (CLEAR_SPINDLE)) + { // Already picked up the Clear Spindle, skip the report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); + } } } @@ -116,34 +117,30 @@ } static bool -GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT *whichNode) +onRuinPickedUp (SOLARSYS_STATE *solarSys, COUNT whichNode) { - if (matchWorld (solarSys, world, 0, MATCH_PLANET)) - { - COUNT i; - COUNT type; + if (!GET_GAME_STATE (CLEAR_SPINDLE)) + { // Just picked up the Clear Spindle from a ruin + SetLanderTakeoff (); - type = GET_GAME_STATE (CLEAR_SPINDLE) ? 1 : 0; - GenerateRandomRuins (&solarSys->SysInfo, type, whichNode); + SET_GAME_STATE (CLEAR_SPINDLE, 1); + SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1); + } - for (i = 0; i < 16; ++i) - { - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) - { - // Retrieval status is cleared to keep the node on the map - setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); + (void) solarSys; + (void) whichNode; - if (!GET_GAME_STATE (CLEAR_SPINDLE)) - { - SetLanderTakeoff (); + return true; // give whatever report is next +} - SET_GAME_STATE (CLEAR_SPINDLE, 1); - SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1); - } - } - } - +static bool +GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, + COUNT *whichNode) +{ + if (matchWorld (solarSys, world, 0, MATCH_PLANET)) + { + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, onRuinPickedUp); return true; } Modified: trunk/sc2/src/uqm/planets/generate/gensol.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensol.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/gensol.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -524,18 +524,23 @@ solarSys->SysInfo.PlanetInfo.CurPt.x = 20; solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT - 8; - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 2; *whichNode = 1; // only matters when count is requested if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) - { - SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1); + { // Ran into Fwiffo on Pluto // Retrieval status is cleared to keep the node on the map // while the lander is taking off. FOUND_PLUTO_SPATHI bit // will keep the node from showing up on subsequent visits. setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); + + #define FWIFFO_FRAGS 8 + if (!KillLanderCrewSeq (FWIFFO_FRAGS, ONE_SECOND / 20)) + return true; // lander probably died + + SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1); + + GenerateDefault_landerReport (solarSys); SetLanderTakeoff (); } @@ -553,8 +558,6 @@ solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH * 3 / 4; solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 1 / 4; - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; *whichNode = 1; // only matters when count is requested @@ -562,6 +565,9 @@ { SET_GAME_STATE (MOONBASE_DESTROYED, 1); SET_GAME_STATE (MOONBASE_ON_SHIP, 1); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } return true; Modified: trunk/sc2/src/uqm/planets/generate/genspa.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genspa.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genspa.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -18,6 +18,7 @@ #include "genall.h" #include "../lifeform.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../build.h" @@ -196,30 +197,23 @@ { if (matchWorld (solarSys, world, 0, 0)) { - DWORD old_rand; - if (GET_GAME_STATE (UMGAH_BROADCASTERS)) { // already picked up *whichNode = 0; return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (UMGAH_BROADCASTERS, 1); SET_GAME_STATE (UMGAH_BROADCASTERS_ON_SHIP, 1); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/gensup.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensup.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/gensup.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -19,7 +19,6 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" -#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -104,8 +103,8 @@ CaptureDrawable (LoadGraphic (RUINS_MASK_PMAP_ANIM)); solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (RUINS_STRTAB)); - if (!GET_GAME_STATE (ULTRON_CONDITION)) - { + if (GET_GAME_STATE (ULTRON_CONDITION)) + { // Already picked up the Ultron, skip the report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); @@ -119,33 +118,29 @@ } static bool -GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT *whichNode) +onRuinPickedUp (SOLARSYS_STATE *solarSys, COUNT whichNode) { - if (matchWorld (solarSys, world, 0, MATCH_PLANET)) - { - COUNT i; - COUNT type; + if (!GET_GAME_STATE (ULTRON_CONDITION)) + { // Just picked up the Ultron from a ruin + SetLanderTakeoff (); - type = GET_GAME_STATE (ULTRON_CONDITION) ? 1 : 0; - GenerateRandomRuins (&solarSys->SysInfo, type, whichNode); + SET_GAME_STATE (ULTRON_CONDITION, 1); + } - for (i = 0; i < 16; ++i) - { - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) - { - // Retrieval status is cleared to keep the node on the map - setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); + (void) solarSys; + (void) whichNode; - if (!GET_GAME_STATE (ULTRON_CONDITION)) - { - SetLanderTakeoff (); + return true; // give whatever report is next +} - SET_GAME_STATE (ULTRON_CONDITION, 1); - } - } - } - +static bool +GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, + COUNT *whichNode) +{ + if (matchWorld (solarSys, world, 0, MATCH_PLANET)) + { + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, onRuinPickedUp); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genthrad.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -17,6 +17,7 @@ */ #include "genall.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../build.h" @@ -158,12 +159,11 @@ GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { - DWORD old_rand; - if (CurStarDescPtr->Index == THRADD_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } @@ -176,24 +176,19 @@ return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (HELIX_VISITS, 0); SET_GAME_STATE (AQUA_HELIX, 1); SET_GAME_STATE (AQUA_HELIX_ON_SHIP, 1); SET_GAME_STATE (HELIX_UNPROTECTED, 1); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genutw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genutw.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genutw.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -17,6 +17,7 @@ */ #include "genall.h" +#include "../lander.h" #include "../planets.h" #include "../scan.h" #include "../../build.h" @@ -209,12 +210,11 @@ GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT *whichNode) { - DWORD old_rand; - if (CurStarDescPtr->Index == UTWIG_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } @@ -227,15 +227,8 @@ return true; } - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); + GenerateDefault_generateArtifact (solarSys, whichNode); - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; - - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (UTWIG_BOMB, 1); @@ -243,9 +236,11 @@ SET_GAME_STATE (DRUUGE_MANNER, 1); SET_GAME_STATE (DRUUGE_VISITS, 0); SET_GAME_STATE (DRUUGE_HOME_VISITS, 0); + + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genvault.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvault.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genvault.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -80,42 +80,40 @@ { if (matchWorld (solarSys, world, 0, 0)) { - DWORD old_rand; - - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); - - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (!GET_GAME_STATE (SHIP_VAULT_UNLOCKED)) - solarSys->SysInfo.PlanetInfo.CurType = 0; - else - solarSys->SysInfo.PlanetInfo.CurType = 1; + PLANET_INFO *planetInfo = &solarSys->SysInfo.PlanetInfo; - // This node is always present, even after it is "picked up". - *whichNode = 1; // only matters when count is requested + GenerateDefault_generateArtifact (solarSys, whichNode); - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) + if (isNodeRetrieved (planetInfo, ENERGY_SCAN, 0)) { // Retrieval status is cleared to keep the node on the map - setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); + setNodeNotRetrieved (planetInfo, ENERGY_SCAN, 0); - if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP)) + if (GET_GAME_STATE (SHIP_VAULT_UNLOCKED)) + { // Give the final report, "omg empty" and whatnot + GenerateDefault_landerReportCycle (solarSys); + } + else if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP)) { + GenerateDefault_landerReportCycle (solarSys); SetLanderTakeoff (); SET_GAME_STATE (SHIP_VAULT_UNLOCKED, 1); SET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP, 0); SET_GAME_STATE (SYREEN_HOME_VISITS, 0); } - else if (!GET_GAME_STATE (KNOW_SYREEN_VAULT)) + else { - SET_GAME_STATE (KNOW_SYREEN_VAULT, 1); - SET_GAME_STATE (SYREEN_HOME_VISITS, 0); + GenerateDefault_landerReport (solarSys); + + if (!GET_GAME_STATE (KNOW_SYREEN_VAULT)) + { + SET_GAME_STATE (KNOW_SYREEN_VAULT, 1); + SET_GAME_STATE (SYREEN_HOME_VISITS, 0); + } } } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genvux.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvux.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genvux.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -218,13 +218,14 @@ solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH / 3; solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 5 / 8; - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - solarSys->SysInfo.PlanetInfo.CurType = 0; *whichNode = 1; // only matters when count is requested if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { + GenerateDefault_landerReport (solarSys); + SetLanderTakeoff (); + SET_GAME_STATE (SHOFIXTI_MAIDENS, 1); SET_GAME_STATE (MAIDENS_ON_SHIP, 1); } @@ -235,7 +236,8 @@ if (CurStarDescPtr->Index == VUX_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } @@ -300,9 +302,7 @@ if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, BIOLOGICAL_SCAN, 0) && !GET_GAME_STATE (VUX_BEAST)) { // Picked up Zex' Beauty - UnbatchGraphics (); - DoDiscoveryReport (MenuSounds); - BatchGraphics (); + GenerateDefault_landerReport (solarSys); SetLanderTakeoff (); SET_GAME_STATE (VUX_BEAST, 1); Modified: trunk/sc2/src/uqm/planets/generate/genwreck.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genwreck.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genwreck.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -57,7 +57,7 @@ solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable (LoadStringTable (WRECK_STRTAB)); if (GET_GAME_STATE (PORTAL_KEY)) - { + { // Already picked it up, skip the first report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetAbsStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); @@ -74,26 +74,15 @@ { if (matchWorld (solarSys, world, 6, MATCH_PLANET)) { - DWORD old_rand; + GenerateDefault_generateArtifact (solarSys, whichNode); - old_rand = TFB_SeedRandom ( - solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN]); - - GenerateRandomLocation (&solarSys->SysInfo); - solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (!GET_GAME_STATE (PORTAL_KEY)) - solarSys->SysInfo.PlanetInfo.CurType = 0; - else - solarSys->SysInfo.PlanetInfo.CurType = 1; - - // This node is always present, even after it is "picked up". - *whichNode = 1; // only matters when count is requested - if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { // Retrieval status is cleared to keep the node on the map setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); + GenerateDefault_landerReportCycle (solarSys); + if (!GET_GAME_STATE (PORTAL_KEY)) { SetLanderTakeoff (); @@ -103,7 +92,6 @@ } } - TFB_SeedRandom (old_rand); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genyeh.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -113,7 +113,8 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } Modified: trunk/sc2/src/uqm/planets/generate/genzoq.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -143,7 +143,8 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - GenerateRandomRuins (&solarSys->SysInfo, 1, whichNode); + GenerateDefault_generateRuins (solarSys, whichNode); + GenerateDefault_pickupRuins (solarSys, NULL); return true; } Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/lander.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -745,39 +745,7 @@ } else if (scan == ENERGY_SCAN) { - if (ElementPtr->mass_points == 1) - { - #define FWIFFO_FRAGS 8 - DWORD TimeIn; - int i; - - /* Ran into Spathi on Pluto */ - TimeIn = GetTimeCounter (); - for (i = 0; i < FWIFFO_FRAGS && crew_left; ++i) - { - DeltaLanderCrew (-1, LANDER_INJURED); - SleepThreadUntil (TimeIn + ONE_SECOND / 20); - TimeIn = GetTimeCounter(); - } - } - - if (crew_left - && pSolarSysState->SysInfo.PlanetInfo.DiscoveryString - && CurStarDescPtr->Index != ANDROSYNTH_DEFINED) - { - UnbatchGraphics (); - DoDiscoveryReport (MenuSounds); - BatchGraphics (); - } - if (ElementPtr->mass_points == 0) - { - DestroyStringTable (ReleaseStringTable ( - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString - )); - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; - UnlockElement (hElement); - continue; - } + // noop; handled by generation funcs, see below } else if (scan == BIOLOGICAL_SCAN && ElementPtr->hit_points) { @@ -865,24 +833,11 @@ pSolarSysState->pOrbitalDesc, &allNodes, scan); - if (!isNodeRetrieved (&pSolarSysState->SysInfo.PlanetInfo, scan, + // Generation func above may reset the retrieved status bit + // to keep the node on the map + if (isNodeRetrieved (&pSolarSysState->SysInfo.PlanetInfo, scan, which_node)) { - /* If our discovery strings have cycled, we're done */ - if (GetStringTableIndex ( - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString) == 0) - { - if (DestroyStringTable (ReleaseStringTable ( - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString - ))) - pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0; - } - } - else - { - if (NumRetrieved && scan == ENERGY_SCAN) - pPSD->InTransit = TRUE; - SET_GAME_STATE (PLANETARY_CHANGE, 1); ElementPtr->state_flags |= DISAPPEARING; } @@ -1892,6 +1847,24 @@ planetSideDesc->InTransit = TRUE; } +// Returns whether the lander is still alive at the end of the sequence +bool +KillLanderCrewSeq (COUNT numKilled, DWORD period) +{ + TimeCount TimeOut; + COUNT i; + + TimeOut = GetTimeCounter (); + for (i = 0; i < numKilled && crew_left; ++i) + { + TimeOut += period; + DeltaLanderCrew (-1, LANDER_INJURED); + SleepThreadUntil (TimeOut); + } + + return crew_left > 0; +} + void PlanetSide (POINT planetLoc) { Modified: trunk/sc2/src/uqm/planets/lander.h =================================================================== --- trunk/sc2/src/uqm/planets/lander.h 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/lander.h 2011-04-23 20:59:25 UTC (rev 3583) @@ -67,6 +67,7 @@ extern void object_animation (ELEMENT *ElementPtr); extern void SetLanderTakeoff (void); +extern bool KillLanderCrewSeq (COUNT numKilled, DWORD period); // ELEMENT.playerNr constants enum Modified: trunk/sc2/src/uqm/planets/plandata.h =================================================================== --- trunk/sc2/src/uqm/planets/plandata.h 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/plandata.h 2011-04-23 20:59:25 UTC (rev 3583) @@ -293,9 +293,7 @@ // NUM_CREATURE_TYPES is an Evil One // NUM_CREATURE_TYPES + 1 is a Brainbox Bulldozer // NUM_CREATURE_TYPES + 2 is Zex' Beauty - // For energy: 0 - Liftoff on collision - // 1 - No liftoff on collision - // 2 - (special case) Fwiffo + // For energy: undefined STRING DiscoveryString; FONT LanderFont; Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/planets.h 2011-04-23 20:59:25 UTC (rev 3583) @@ -82,6 +82,8 @@ // XXX: -9 to match the original, but why? I have no idea #define PLANET_ORG_Y ((SCAN_SCREEN_HEIGHT - 9) / 2) +#define NUM_RACE_RUINS 16 + typedef struct planet_desc PLANET_DESC; typedef struct star_desc STAR_DESC; typedef struct planet_orbit PLANET_ORBIT; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/scan.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -1396,17 +1396,7 @@ NodeElementPtr->preprocess_func = object_animation; if (scan == ENERGY_SCAN) { - if (pSolarSysState->SysInfo.PlanetInfo.CurType == 1) - { - NodeElementPtr->mass_points = 0; - } - else if (pSolarSysState->SysInfo.PlanetInfo.CurType == 2) - { - // Special case: Fwiffo - NodeElementPtr->mass_points = 1; - } - else - NodeElementPtr->mass_points = MAX_SCROUNGED; + NodeElementPtr->mass_points = MAX_SCROUNGED; DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame = pSolarSysState->PlanetSideFrame[1]; } Modified: trunk/sc2/src/uqm/planets/sundata.h =================================================================== --- trunk/sc2/src/uqm/planets/sundata.h 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/sundata.h 2011-04-23 20:59:25 UTC (rev 3583) @@ -46,7 +46,6 @@ extern void GenerateRandomLocation (SYSTEM_INFO *); extern DWORD GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes, COUNT type, COUNT *whichNode); -extern DWORD GenerateRandomRuins (SYSTEM_INFO *, COUNT type, COUNT *whichNode); #define DWARF_ELEMENT_DENSITY 1 #define GIANT_ELEMENT_DENSITY 3 Modified: trunk/sc2/src/uqm/planets/surface.c =================================================================== --- trunk/sc2/src/uqm/planets/surface.c 2011-04-22 18:25:51 UTC (rev 3582) +++ trunk/sc2/src/uqm/planets/surface.c 2011-04-23 20:59:25 UTC (rev 3583) @@ -268,7 +268,9 @@ for (i = 0; i < numNodes; ++i) { GenerateRandomLocation (SysInfoPtr); + // CurType is irrelevant for energy nodes SysInfoPtr->PlanetInfo.CurType = type; + // CurDensity is irrelevant for energy and bio nodes SysInfoPtr->PlanetInfo.CurDensity = 0; if (i >= *whichNode) @@ -279,9 +281,3 @@ return (TFB_SeedRandom (old_rand)); } - -DWORD -GenerateRandomRuins (SYSTEM_INFO *SysInfoPtr, COUNT type, COUNT *whichNode) -{ - return GenerateRandomNodes (SysInfoPtr, ENERGY_SCAN, 16, type, whichNode); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |